Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Apr 2018 23:39:04 +0000 (UTC)
From:      Oleksandr Tymoshenko <gonzo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r331897 - in stable/11/sys: arm/broadcom/bcm2835 boot/fdt/dts/arm dev/usb/net
Message-ID:  <201804022339.w32Nd4Ac078102@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gonzo
Date: Mon Apr  2 23:39:04 2018
New Revision: 331897
URL: https://svnweb.freebsd.org/changeset/base/331897

Log:
  MFC r314672, r315967, r324184, r325768
  
  r314672:
  [rpi] rpi3 should use the same cpufreq logic as rpi2, not rpi-b
  
  RPi3 cpufreq is more like that on RPi2. Setting arm frequency
  above min (say, "sysctl hw.cpufreq.arm_freq=600000001") turns on
  turbo mode, and the firmware automatically raises voltage, sets
  frequency to max 1200MHz, and throttle when overheat, etc.
  
  Swap if/else parts and use SOC_BCM2835 def so RPi3 can share the
  same cpufreq logic as RPi2, instead of falling to that for RPi.
  
  Submitted by:	Jia-Shiun Li <jiashiun@gmail.com>
  Differential Revision:	https://reviews.freebsd.org/D9640
  
  r315967:
  [rpi] Use compatibility string from upstream DTB for I2C controller
  
  FreeBSD uses upstream DTB for RPi3 build and compatibility string for
  i2c device is different there. Add this new string to compatibility data.
  
  Reported by:	Karl Denninger
  
  r324184 by ian:
  Allow Raspberry Pi platform and drivers to be configured with upstream DTBs.
  
   - Added more compatibility strings to drivers not yet converted
   - Added new RPI platform code compatibility string to match the ones used
     upstream
   - Adapted RPI and RPI2 DTS to match the new platform code compatibility
     string
  
  The goal is to use the upstream DTBs as a replacement for our custom one.
  This is now possible with these changes.
  
  Additionally, as the RPI firmware automatically chooses the right DTB for
  us, this would allow to have one common armv6 kernel for RPI0 and RPI1
  (BCM2835-based), and one common armv7 kernel for RPI2 v1.1 (BCM2836-based),
  and RPI2 v1.2 / RPI3 (BCM2837-based).
  
  Submitted by:	Sylvain Garrigues <sylgar@gmail.com>
  Differential Revision:	https://reviews.freebsd.org/D12360
  
  r325768 by manu:
  arm: rpi2: Fix cpufreq(4)
  
  Since r324184 the root node compatible for rpi2 is "brcm,bcm2836", add
  it to the compatible list of bcm2835_cpufreq.
  
  Tested On: RPI2 v1.1 RPI2 v1.2
  
  Reported by:	many on freebsd-arm@

Modified:
  stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
  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_rng.c
  stable/11/sys/boot/fdt/dts/arm/rpi2.dts
  stable/11/sys/dev/usb/net/if_smsc.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c	Mon Apr  2 23:37:25 2018	(r331896)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c	Mon Apr  2 23:39:04 2018	(r331897)
@@ -107,6 +107,7 @@ __FBSDID("$FreeBSD$");
 static struct ofw_compat_data compat_data[] = {
 	{"broadcom,bcm2835-bsc",	1},
 	{"brcm,bcm2708-i2c",		1},
+	{"brcm,bcm2835-i2c",		1},
 	{NULL,				0}
 };
 

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c	Mon Apr  2 23:37:25 2018	(r331896)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c	Mon Apr  2 23:39:04 2018	(r331897)
@@ -68,16 +68,16 @@ __FBSDID("$FreeBSD$");
 #define	HZ2MHZ(freq) ((freq) / (1000 * 1000))
 #define	MHZ2HZ(freq) ((freq) * (1000 * 1000))
 
-#ifdef SOC_BCM2836
-#define	OFFSET2MVOLT(val) (((val) / 1000))
-#define	MVOLT2OFFSET(val) (((val) * 1000))
-#define	DEFAULT_ARM_FREQUENCY	 600
-#define	DEFAULT_LOWEST_FREQ	 600
-#else
+#ifdef SOC_BCM2835
 #define	OFFSET2MVOLT(val) (1200 + ((val) * 25))
 #define	MVOLT2OFFSET(val) (((val) - 1200) / 25)
 #define	DEFAULT_ARM_FREQUENCY	 700
 #define	DEFAULT_LOWEST_FREQ	 300
+#else
+#define	OFFSET2MVOLT(val) (((val) / 1000))
+#define	MVOLT2OFFSET(val) (((val) * 1000))
+#define	DEFAULT_ARM_FREQUENCY	 600
+#define	DEFAULT_LOWEST_FREQ	 600
 #endif
 #define	DEFAULT_CORE_FREQUENCY	 250
 #define	DEFAULT_SDRAM_FREQUENCY	 400
@@ -128,6 +128,7 @@ static struct ofw_compat_data compat_data[] = {
 	{ "broadcom,bcm2835-vc",	1 },
 	{ "broadcom,bcm2708-vc",	1 },
 	{ "brcm,bcm2709",	1 },
+	{ "brcm,bcm2836",	1 },
 	{ NULL, 0 }
 };
 
@@ -1546,7 +1547,20 @@ bcm2835_cpufreq_make_freq_list(device_t dev, struct cf
 		if (min_freq > cpufreq_lowest_freq)
 			min_freq = cpufreq_lowest_freq;
 
-#ifdef SOC_BCM2836
+#ifdef SOC_BCM2835
+	/* from freq to min_freq */
+	for (idx = 0; idx < *count && freq >= min_freq; idx++) {
+		if (freq > sc->arm_min_freq)
+			volts = sc->max_voltage_core;
+		else
+			volts = sc->min_voltage_core;
+		sets[idx].freq = freq;
+		sets[idx].volts = volts;
+		sets[idx].lat = TRANSITION_LATENCY;
+		sets[idx].dev = dev;
+		freq -= MHZSTEP;
+	}
+#else
 	/* XXX RPi2 have only 900/600MHz */
 	idx = 0;
 	volts = sc->min_voltage_core;
@@ -1561,19 +1575,6 @@ bcm2835_cpufreq_make_freq_list(device_t dev, struct cf
 		sets[idx].lat = TRANSITION_LATENCY;
 		sets[idx].dev = dev;
 		idx++;
-	}
-#else
-	/* from freq to min_freq */
-	for (idx = 0; idx < *count && freq >= min_freq; idx++) {
-		if (freq > sc->arm_min_freq)
-			volts = sc->max_voltage_core;
-		else
-			volts = sc->min_voltage_core;
-		sets[idx].freq = freq;
-		sets[idx].volts = volts;
-		sets[idx].lat = TRANSITION_LATENCY;
-		sets[idx].dev = dev;
-		freq -= MHZSTEP;
 	}
 #endif
 	*count = idx;

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_machdep.c	Mon Apr  2 23:37:25 2018	(r331896)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_machdep.c	Mon Apr  2 23:39:04 2018	(r331897)
@@ -132,7 +132,8 @@ static platform_method_t bcm2835_methods[] = {
 
 	PLATFORMMETHOD_END,
 };
-FDT_PLATFORM_DEF(bcm2835, "bcm2835", 0, "raspberrypi,model-b", 100);
+FDT_PLATFORM_DEF2(bcm2835, bcm2835_legacy, "bcm2835 (legacy)", 0, "raspberrypi,model-b", 100);
+FDT_PLATFORM_DEF2(bcm2835, bcm2835, "bcm2835", 0, "brcm,bcm2835", 100);
 #endif
 
 #ifdef SOC_BCM2836
@@ -149,5 +150,6 @@ static platform_method_t bcm2836_methods[] = {
 
 	PLATFORMMETHOD_END,
 };
-FDT_PLATFORM_DEF(bcm2836, "bcm2836", 0, "brcm,bcm2709", 100);
+FDT_PLATFORM_DEF2(bcm2836, bcm2836_legacy, "bcm2836 (legacy)", 0, "brcm,bcm2709", 100);
+FDT_PLATFORM_DEF2(bcm2836, bcm2836, "bcm2836", 0, "brcm,bcm2836", 100);
 #endif

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_rng.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_rng.c	Mon Apr  2 23:37:25 2018	(r331896)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_rng.c	Mon Apr  2 23:39:04 2018	(r331897)
@@ -109,6 +109,12 @@ struct bcm2835_rng_softc {
 	long			sc_underrun;
 };
 
+static struct ofw_compat_data compat_data[] = {
+	{"broadcom,bcm2835-rng",	1},
+	{"brcm,bcm2835-rng",		1},
+	{NULL,				0}
+};
+
 static __inline void
 bcm2835_rng_stat_inc_underrun(struct bcm2835_rng_softc *sc)
 {
@@ -364,7 +370,7 @@ bcm2835_rng_probe(device_t dev)
 	if (!ofw_bus_status_okay(dev))
 		return (ENXIO);
 
-	if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-rng"))
+	if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
 		return (ENXIO);
 
 	device_set_desc(dev, "Broadcom BCM2835 RNG");

Modified: stable/11/sys/boot/fdt/dts/arm/rpi2.dts
==============================================================================
--- stable/11/sys/boot/fdt/dts/arm/rpi2.dts	Mon Apr  2 23:37:25 2018	(r331896)
+++ stable/11/sys/boot/fdt/dts/arm/rpi2.dts	Mon Apr  2 23:39:04 2018	(r331897)
@@ -30,7 +30,7 @@
 
 / {
 	model = "Raspberry Pi 2 Model B";
-	compatible = "brcm,bcm2709";
+	compatible = "brcm,bcm2836";
 
 	memreserve = <0x08000000 0x08000000>;	/* Set by VideoCore */
 

Modified: stable/11/sys/dev/usb/net/if_smsc.c
==============================================================================
--- stable/11/sys/dev/usb/net/if_smsc.c	Mon Apr  2 23:37:25 2018	(r331896)
+++ stable/11/sys/dev/usb/net/if_smsc.c	Mon Apr  2 23:39:04 2018	(r331897)
@@ -1568,8 +1568,9 @@ smsc_fdt_find_eth_node(phandle_t start)
 
 	/* Traverse through entire tree to find usb ethernet nodes. */
 	for (node = OF_child(start); node != 0; node = OF_peer(node)) {
-		if (ofw_bus_node_is_compatible(node, "net,ethernet") &&
-		    ofw_bus_node_is_compatible(node, "usb,device"))
+		if ((ofw_bus_node_is_compatible(node, "net,ethernet") &&
+		    ofw_bus_node_is_compatible(node, "usb,device")) ||
+		    ofw_bus_node_is_compatible(node, "usb424,ec00"))
 			return (node);
 		child = smsc_fdt_find_eth_node(node);
 		if (child != -1)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201804022339.w32Nd4Ac078102>