From owner-svn-src-head@freebsd.org Thu Sep 29 06:50:01 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 38F07C00B7D; Thu, 29 Sep 2016 06:50:01 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 16F95288; Thu, 29 Sep 2016 06:50:01 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8T6o0ge058992; Thu, 29 Sep 2016 06:50:00 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8T6o0fE058988; Thu, 29 Sep 2016 06:50:00 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201609290650.u8T6o0fE058988@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Thu, 29 Sep 2016 06:50:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306436 - in head/sys/arm: broadcom/bcm2835 conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Sep 2016 06:50:01 -0000 Author: manu Date: Thu Sep 29 06:49:59 2016 New Revision: 306436 URL: https://svnweb.freebsd.org/changeset/base/306436 Log: RPI-B: Add support for MULTIDELAY 100 cycles per us seems accurate enough, at least it's better than the 200 value that was used before. Reviewed by: andrew, imp Differential Revision: https://reviews.freebsd.org/D8062 Modified: head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c head/sys/arm/broadcom/bcm2835/bcm2835_systimer.c head/sys/arm/conf/RPI-B Modified: head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c Thu Sep 29 06:19:45 2016 (r306435) +++ head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c Thu Sep 29 06:49:59 2016 (r306436) @@ -129,7 +129,7 @@ static platform_method_t bcm2835_methods PLATFORMMETHOD_END, }; -FDT_PLATFORM_DEF(bcm2835, "bcm2835", 0, "raspberrypi,model-b", 0); +FDT_PLATFORM_DEF(bcm2835, "bcm2835", 0, "raspberrypi,model-b", 100); #endif #ifdef SOC_BCM2836 Modified: head/sys/arm/broadcom/bcm2835/bcm2835_systimer.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_systimer.c Thu Sep 29 06:19:45 2016 (r306435) +++ head/sys/arm/broadcom/bcm2835/bcm2835_systimer.c Thu Sep 29 06:49:59 2016 (r306436) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -101,6 +102,8 @@ static struct bcm_systimer_softc *bcm_sy static unsigned bcm_systimer_tc_get_timecount(struct timecounter *); +static delay_func bcm_systimer_delay; + static struct timecounter bcm_systimer_tc = { .tc_name = DEFAULT_TIMER_NAME, .tc_get_timecount = bcm_systimer_tc_get_timecount, @@ -113,6 +116,9 @@ static struct timecounter bcm_systimer_t static unsigned bcm_systimer_tc_get_timecount(struct timecounter *tc) { + if (bcm_systimer_sc == NULL) + return (0); + return bcm_systimer_tc_read_4(SYSTIMER_CLO); } @@ -147,7 +153,7 @@ restart: intr_restore(s); return (0); - } + } return (EINVAL); } @@ -167,7 +173,7 @@ bcm_systimer_intr(void *arg) struct systimer *st = (struct systimer *)arg; uint32_t cs; - cs = bcm_systimer_tc_read_4(SYSTIMER_CS); + cs = bcm_systimer_tc_read_4(SYSTIMER_CS); if ((cs & (1 << st->index)) == 0) return (FILTER_STRAY); @@ -254,6 +260,9 @@ bcm_systimer_attach(device_t dev) bcm_systimer_sc = sc; + if (device_get_unit(dev) == 0) + arm_set_delay(bcm_systimer_delay, sc); + bcm_systimer_tc.tc_frequency = DEFAULT_FREQUENCY; tc_init(&bcm_systimer_tc); @@ -276,19 +285,14 @@ static devclass_t bcm_systimer_devclass; DRIVER_MODULE(bcm_systimer, simplebus, bcm_systimer_driver, bcm_systimer_devclass, 0, 0); -void -DELAY(int usec) +static void +bcm_systimer_delay(int usec, void *arg) { + struct bcm_systimer_softc *sc; int32_t counts; uint32_t first, last; - if (bcm_systimer_sc == NULL) { - for (; usec > 0; usec--) - for (counts = 200; counts > 0; counts--) - /* Prevent gcc from optimizing out the loop */ - cpufunc_nullop(); - return; - } + sc = (struct bcm_systimer_softc *) arg; /* Get the number of times to count */ counts = usec * (bcm_systimer_tc.tc_frequency / 1000000) + 1; Modified: head/sys/arm/conf/RPI-B ============================================================================== --- head/sys/arm/conf/RPI-B Thu Sep 29 06:19:45 2016 (r306435) +++ head/sys/arm/conf/RPI-B Thu Sep 29 06:49:59 2016 (r306436) @@ -28,6 +28,7 @@ options INTRNG options SCHED_4BSD # 4BSD scheduler options PLATFORM +options MULTIDELAY # NFS root from boopt/dhcp #options BOOTP