svn commit: r350836 - in stable/12/sys: arm/ti arm/ti/cpsw dev/ofw gnu/dts/arm

Emmanuel Vadot manu at FreeBSD.org
Sat Aug 10 13:50:17 UTC 2019


Author: manu
Date: Sat Aug 10 13:50:15 2019
New Revision: 350836
URL: https://svnweb.freebsd.org/changeset/base/350836

Log:
  MFC r350229-r350230, r350408, r350410, r350673-r350674
  
  r350229:
  arm: ti: Get the hwmods property from the parent node
  
  Since the Linux 5.0 dts the ti,hwmods property is on the parent
  ti.sysc node.
  
  r350230:
  arm: ti: Add a driver for ti,sysc bus
  
  ti,sysc is a simple-bus like driver.
  Add a driver for it so child nodes can attach.
  
  r350408:
  arm: ti: Get the hwmods property either from the node or the parent
  
  r350229 changed the code to lookup the ti,hwmods property in the parent
  as it's now like that in the DTS from >= Linux 5.0, allow the property
  to be also in the node itself so we can boot with an older DTB.
  
  Reported by:	"Dr. Rolf Jansen" <rj at obsigna.com>
  
  r350410:
  arm: ti: cpsw: Check the new slave node address
  
  Since DTS from >= Linux 5.0 the slave address are relative to the parent
  node address and aren't the full ones.
  Check both so the cpsw driver can find the phy id.
  
  r350673:
  arm: dts: am33xx: Fix the region for uart0
  
  The region for uart0 is declared to be 0x2000 in size but the parent
  node only declare 0x1000.
  As the parent only declare a size of 0x1000 in the ranges for it's children
  this cause the device to not be mappable.
  
  https://patchwork.kernel.org/patch/11056769/
  
  r350674:
  ofw: ofw_reg_to_paddr: Use a 256 static array for the cell
  
  Some hardware needs more than 32, bump this value.
  
  We cannot use the _alloc for of getencprop as this function is called
  too early in the boot before pmap is initialized and we only have
  2k of stack when cninit is called.
  
  Discussed with:     ian

Added:
  stable/12/sys/arm/ti/ti_sysc.c
     - copied unchanged from r350230, head/sys/arm/ti/ti_sysc.c
Modified:
  stable/12/sys/arm/ti/cpsw/if_cpsw.c
  stable/12/sys/arm/ti/files.ti
  stable/12/sys/arm/ti/ti_hwmods.c
  stable/12/sys/dev/ofw/ofw_subr.c
  stable/12/sys/gnu/dts/arm/am33xx-l4.dtsi
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/arm/ti/cpsw/if_cpsw.c
==============================================================================
--- stable/12/sys/arm/ti/cpsw/if_cpsw.c	Sat Aug 10 08:34:56 2019	(r350835)
+++ stable/12/sys/arm/ti/cpsw/if_cpsw.c	Sat Aug 10 13:50:15 2019	(r350836)
@@ -755,7 +755,9 @@ cpsw_get_fdt_data(struct cpsw_softc *sc, int port)
 			continue;
 		}
 		OF_prop_free(name);
-		if (mdio_child_addr != slave_mdio_addr[port])
+
+		if (mdio_child_addr != slave_mdio_addr[port] &&
+		    mdio_child_addr != (slave_mdio_addr[port] & 0xFFF))
 			continue;
 
 		if (fdt_get_phyaddr(child, NULL, &phy, NULL) != 0){

Modified: stable/12/sys/arm/ti/files.ti
==============================================================================
--- stable/12/sys/arm/ti/files.ti	Sat Aug 10 08:34:56 2019	(r350835)
+++ stable/12/sys/arm/ti/files.ti	Sat Aug 10 13:50:15 2019	(r350836)
@@ -16,6 +16,7 @@ arm/ti/ti_gpio_if.m				optional	gpio
 arm/ti/ti_i2c.c					optional	ti_i2c
 arm/ti/ti_sdhci.c	 			optional	sdhci
 arm/ti/ti_spi.c		 			optional	ti_spi
+arm/ti/ti_sysc.c	 			standard
 
 dev/uart/uart_dev_ti8250.c			optional	uart
 dev/uart/uart_dev_ns8250.c			optional	uart

Modified: stable/12/sys/arm/ti/ti_hwmods.c
==============================================================================
--- stable/12/sys/arm/ti/ti_hwmods.c	Sat Aug 10 08:34:56 2019	(r350835)
+++ stable/12/sys/arm/ti/ti_hwmods.c	Sat Aug 10 13:50:15 2019	(r350836)
@@ -97,6 +97,16 @@ struct hwmod ti_hwmods[] = {
 	{NULL,		0}
 };
 
+static inline int
+ti_get_hwmods_prop(phandle_t node, void **name)
+{
+	int len;
+
+	if ((len = OF_getprop_alloc(node, "ti,hwmods", name)) > 0)
+		return (len);
+	return (OF_getprop_alloc(OF_parent(node), "ti,hwmods", name));
+}
+
 clk_ident_t
 ti_hwmods_get_clock(device_t dev)
 {
@@ -110,7 +120,7 @@ ti_hwmods_get_clock(device_t dev)
 	if ((node = ofw_bus_get_node(dev)) == 0)
 		return (INVALID_CLK_IDENT);
 
-	if ((len = OF_getprop_alloc(node, "ti,hwmods", (void**)&name)) <= 0)
+	if ((len = ti_get_hwmods_prop(node, (void **)&name)) <= 0)
 		return (INVALID_CLK_IDENT);
 
 	buf = name;
@@ -148,7 +158,7 @@ int ti_hwmods_contains(device_t dev, const char *hwmod
 	if ((node = ofw_bus_get_node(dev)) == 0)
 		return (0);
 
-	if ((len = OF_getprop_alloc(node, "ti,hwmods", (void**)&name)) <= 0)
+	if ((len = ti_get_hwmods_prop(node, (void **)&name)) <= 0)
 		return (0);
 
 	buf = name;
@@ -182,7 +192,7 @@ ti_hwmods_get_unit(device_t dev, const char *hwmod)
 	if ((node = ofw_bus_get_node(dev)) == 0)
 		return (0);
 
-	if ((len = OF_getprop_alloc(node, "ti,hwmods", (void**)&name)) <= 0)
+	if ((len = ti_get_hwmods_prop(node, (void **)&name)) <= 0)
 		return (0);
 
 	buf = name;

Copied: stable/12/sys/arm/ti/ti_sysc.c (from r350230, head/sys/arm/ti/ti_sysc.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/12/sys/arm/ti/ti_sysc.c	Sat Aug 10 13:50:15 2019	(r350836, copy of r350230, head/sys/arm/ti/ti_sysc.c)
@@ -0,0 +1,125 @@
+/*-
+ * Copyright (c) 2019 Emmanuel Vadot <manu at FreeBSD.org>
+ *
+ * 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 ``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 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$
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/fbio.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/rman.h>
+#include <sys/resource.h>
+#include <machine/bus.h>
+#include <vm/vm.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_kern.h>
+#include <vm/pmap.h>
+
+#include <dev/fdt/simplebus.h>
+
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+static struct ofw_compat_data compat_data[] = {
+	{ "ti,sysc",	1 },
+	{ NULL,				0 }
+};
+
+struct ti_sysc_softc {
+	struct simplebus_softc	sc;
+	device_t		dev;
+};
+
+static int ti_sysc_probe(device_t dev);
+static int ti_sysc_attach(device_t dev);
+static int ti_sysc_detach(device_t dev);
+
+static int
+ti_sysc_probe(device_t dev)
+{
+	if (!ofw_bus_status_okay(dev))
+		return (ENXIO);
+
+	if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
+		return (ENXIO);
+
+	device_set_desc(dev, "TI SYSC Interconnect");
+	return (BUS_PROBE_DEFAULT);
+}
+
+static int
+ti_sysc_attach(device_t dev)
+{
+	struct ti_sysc_softc *sc;
+	device_t cdev;
+	phandle_t node, child;
+
+	sc = device_get_softc(dev);
+	sc->dev = dev;
+	node = ofw_bus_get_node(dev);
+
+	simplebus_init(dev, node);
+	if (simplebus_fill_ranges(node, &sc->sc) < 0) {
+		device_printf(dev, "could not get ranges\n");
+		return (ENXIO);
+	}
+
+	for (child = OF_child(node); child > 0; child = OF_peer(child)) {
+		cdev = simplebus_add_device(dev, child, 0, NULL, -1, NULL);
+		if (cdev != NULL)
+			device_probe_and_attach(cdev);
+	}
+
+	return (bus_generic_attach(dev));
+}
+
+static int
+ti_sysc_detach(device_t dev)
+{
+
+	return (EBUSY);
+}
+
+static device_method_t ti_sysc_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe,		ti_sysc_probe),
+	DEVMETHOD(device_attach,	ti_sysc_attach),
+	DEVMETHOD(device_detach,	ti_sysc_detach),
+
+	DEVMETHOD_END
+};
+
+DEFINE_CLASS_1(ti_sysc, ti_sysc_driver, ti_sysc_methods,
+    sizeof(struct ti_sysc_softc), simplebus_driver);
+
+static devclass_t ti_sysc_devclass;
+
+EARLY_DRIVER_MODULE(ti_sysc, simplebus, ti_sysc_driver,
+ti_sysc_devclass, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_FIRST);

Modified: stable/12/sys/dev/ofw/ofw_subr.c
==============================================================================
--- stable/12/sys/dev/ofw/ofw_subr.c	Sat Aug 10 08:34:56 2019	(r350835)
+++ stable/12/sys/dev/ofw/ofw_subr.c	Sat Aug 10 13:50:15 2019	(r350836)
@@ -79,7 +79,8 @@ int
 ofw_reg_to_paddr(phandle_t dev, int regno, bus_addr_t *paddr,
     bus_size_t *psize, pcell_t *ppci_hi)
 {
-	pcell_t cell[32], pci_hi;
+	static pcell_t cell[256];
+	pcell_t pci_hi;
 	uint64_t addr, raddr, baddr;
 	uint64_t size, rsize;
 	uint32_t c, nbridge, naddr, nsize;

Modified: stable/12/sys/gnu/dts/arm/am33xx-l4.dtsi
==============================================================================
--- stable/12/sys/gnu/dts/arm/am33xx-l4.dtsi	Sat Aug 10 08:34:56 2019	(r350835)
+++ stable/12/sys/gnu/dts/arm/am33xx-l4.dtsi	Sat Aug 10 13:50:15 2019	(r350836)
@@ -185,7 +185,7 @@
 			uart0: serial at 0 {
 				compatible = "ti,am3352-uart", "ti,omap3-uart";
 				clock-frequency = <48000000>;
-				reg = <0x0 0x2000>;
+				reg = <0x0 0x1000>;
 				interrupts = <72>;
 				status = "disabled";
 				dmas = <&edma 26 0>, <&edma 27 0>;


More information about the svn-src-all mailing list