From owner-svn-src-stable@freebsd.org Mon Apr 2 23:30:23 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8FC42F6CDD4; Mon, 2 Apr 2018 23:30:22 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5E66D7874F; Mon, 2 Apr 2018 23:30:22 +0000 (UTC) (envelope-from gonzo@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 54A331C4E4; Mon, 2 Apr 2018 23:30:22 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w32NUMvI068098; Mon, 2 Apr 2018 23:30:22 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w32NULVa068091; Mon, 2 Apr 2018 23:30:21 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201804022330.w32NULVa068091@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Mon, 2 Apr 2018 23:30:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r331894 - in stable/11/sys/arm: broadcom/bcm2835 conf X-SVN-Group: stable-11 X-SVN-Commit-Author: gonzo X-SVN-Commit-Paths: in stable/11/sys/arm: broadcom/bcm2835 conf X-SVN-Commit-Revision: 331894 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 23:30:23 -0000 Author: gonzo Date: Mon Apr 2 23:30:21 2018 New Revision: 331894 URL: https://svnweb.freebsd.org/changeset/base/331894 Log: MFC r306436-r306437, r306489, r306491 r306436 by manu: 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 r306437 by manu: RPI2: Add support for PLATFORM_SMP so we can later add it to GENERIC. Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D8063 r306489 by manu: bcm2835_cpufreq: Only attach driver if we correcly match on the machine compatible string. r306491 by manu: RPI2: Add support for MULTIDELAY, this is needed for inclusion into GENERIC. Added: stable/11/sys/arm/broadcom/bcm2835/bcm2836_mp.h - copied unchanged from r306437, head/sys/arm/broadcom/bcm2835/bcm2836_mp.h Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c stable/11/sys/arm/broadcom/bcm2835/bcm2835_machdep.c stable/11/sys/arm/broadcom/bcm2835/bcm2835_systimer.c stable/11/sys/arm/broadcom/bcm2835/bcm2836_mp.c stable/11/sys/arm/conf/RPI-B stable/11/sys/arm/conf/RPI2 Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c Mon Apr 2 23:19:07 2018 (r331893) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c Mon Apr 2 23:30:21 2018 (r331894) @@ -44,6 +44,11 @@ __FBSDID("$FreeBSD$"); #include #include +#include + +#include +#include + #include #include #include @@ -119,6 +124,13 @@ struct bcm2835_cpufreq_softc { struct intr_config_hook init_hook; }; +static struct ofw_compat_data compat_data[] = { + { "broadcom,bcm2835-vc", 1 }, + { "broadcom,bcm2708-vc", 1 }, + { "brcm,bcm2709", 1 }, + { NULL, 0 } +}; + static int cpufreq_verbose = 0; TUNABLE_INT("hw.bcm2835.cpufreq.verbose", &cpufreq_verbose); static int cpufreq_lowest_freq = DEFAULT_LOWEST_FREQ; @@ -1244,6 +1256,16 @@ bcm2835_cpufreq_init(void *arg) static void bcm2835_cpufreq_identify(driver_t *driver, device_t parent) { + const struct ofw_compat_data *compat; + phandle_t root; + + root = OF_finddevice("/"); + for (compat = compat_data; compat->ocd_str != NULL; compat++) + if (fdt_is_compatible(root, compat->ocd_str)) + break; + + if (compat->ocd_data == 0) + return; DPRINTF("driver=%p, parent=%p\n", driver, parent); if (device_find_child(parent, "bcm2835_cpufreq", -1) != NULL) Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_machdep.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_machdep.c Mon Apr 2 23:19:07 2018 (r331893) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_machdep.c Mon Apr 2 23:30:21 2018 (r331894) @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "platform_if.h" @@ -131,7 +132,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 @@ -141,7 +142,12 @@ static platform_method_t bcm2836_methods[] = { PLATFORMMETHOD(platform_late_init, bcm2835_late_init), PLATFORMMETHOD(platform_cpu_reset, bcm2835_cpu_reset), +#ifdef SMP + PLATFORMMETHOD(platform_mp_start_ap, bcm2836_mp_start_ap), + PLATFORMMETHOD(platform_mp_setmaxid, bcm2836_mp_setmaxid), +#endif + PLATFORMMETHOD_END, }; -FDT_PLATFORM_DEF(bcm2836, "bcm2836", 0, "brcm,bcm2709", 0); +FDT_PLATFORM_DEF(bcm2836, "bcm2836", 0, "brcm,bcm2709", 100); #endif Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_systimer.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_systimer.c Mon Apr 2 23:19:07 2018 (r331893) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_systimer.c Mon Apr 2 23:30:21 2018 (r331894) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -101,6 +102,8 @@ static struct bcm_systimer_softc *bcm_systimer_sc = NU 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_tc = { 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: stable/11/sys/arm/broadcom/bcm2835/bcm2836_mp.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2836_mp.c Mon Apr 2 23:19:07 2018 (r331893) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2836_mp.c Mon Apr 2 23:30:21 2018 (r331894) @@ -45,7 +45,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include + #ifdef DEBUG #define DPRINTF(fmt, ...) do { \ printf("%s:%u: ", __func__, __LINE__); \ @@ -77,7 +80,7 @@ static bus_space_handle_t bs_periph; bus_space_write_4(fdtbus_bs_tag, bs_periph, (addr), (val)) void -platform_mp_setmaxid(void) +bcm2836_mp_setmaxid(platform_t plat) { DPRINTF("platform_mp_setmaxid\n"); @@ -90,7 +93,7 @@ platform_mp_setmaxid(void) } void -platform_mp_start_ap(void) +bcm2836_mp_start_ap(platform_t plat) { uint32_t val; int i, retry; Copied: stable/11/sys/arm/broadcom/bcm2835/bcm2836_mp.h (from r306437, head/sys/arm/broadcom/bcm2835/bcm2836_mp.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2836_mp.h Mon Apr 2 23:30:21 2018 (r331894, copy of r306437, head/sys/arm/broadcom/bcm2835/bcm2836_mp.h) @@ -0,0 +1,38 @@ +/*- + * Copyright (C) 2016 Emmanuel Vadot + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _BCM2836_MP_H_ +#define _BCM2836_MP_H_ + +void bcm2836_mp_setmaxid(platform_t plat); +void bcm2836_mp_start_ap(platform_t plat); + +#endif /* _BCM2836_MP_H_ */ Modified: stable/11/sys/arm/conf/RPI-B ============================================================================== --- stable/11/sys/arm/conf/RPI-B Mon Apr 2 23:19:07 2018 (r331893) +++ stable/11/sys/arm/conf/RPI-B Mon Apr 2 23:30:21 2018 (r331894) @@ -28,6 +28,7 @@ options INTRNG options SCHED_4BSD # 4BSD scheduler options PLATFORM +options MULTIDELAY # NFS root from boopt/dhcp #options BOOTP Modified: stable/11/sys/arm/conf/RPI2 ============================================================================== --- stable/11/sys/arm/conf/RPI2 Mon Apr 2 23:19:07 2018 (r331893) +++ stable/11/sys/arm/conf/RPI2 Mon Apr 2 23:30:21 2018 (r331894) @@ -29,6 +29,8 @@ options INTRNG options SCHED_ULE # ULE scheduler options SMP # Enable multiple cores options PLATFORM +options PLATFORM_SMP +options MULTIDELAY # NFS root from boopt/dhcp #options BOOTP