svn commit: r259323 - stable/10/sys/dev/uart

Ian Lepore ian at FreeBSD.org
Fri Dec 13 19:01:51 UTC 2013


Author: ian
Date: Fri Dec 13 19:01:50 2013
New Revision: 259323
URL: http://svnweb.freebsd.org/changeset/base/259323

Log:
  MFC r257480:
  
    Convert the if/else list of compatible devices to the table-driven
    ofw_bus_search_compatible() routine.  In addition to converting existing
    strings to table entries, also add compat strings for the whole imx family.

Modified:
  stable/10/sys/dev/uart/uart_bus_fdt.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/uart/uart_bus_fdt.c
==============================================================================
--- stable/10/sys/dev/uart/uart_bus_fdt.c	Fri Dec 13 18:26:22 2013	(r259322)
+++ stable/10/sys/dev/uart/uart_bus_fdt.c	Fri Dec 13 19:01:50 2013	(r259323)
@@ -61,6 +61,30 @@ static driver_t uart_fdt_driver = {
 	sizeof(struct uart_softc),
 };
 
+/*
+ * Compatible devices.  Keep this sorted in most- to least-specific order first,
+ * alphabetical second.  That is, "zwie,ns16550" should appear before "ns16550"
+ * on the theory that the zwie driver knows how to make better use of the
+ * hardware than the generic driver.  Likewise with chips within a family, the
+ * highest-numbers / most recent models should probably appear earlier.
+ */
+static struct ofw_compat_data compat_data[] = {
+	{"arm,pl011",		(uintptr_t)&uart_pl011_class},
+	{"cadence,uart",	(uintptr_t)&uart_cdnc_class},
+	{"exynos",		(uintptr_t)&uart_s3c2410_class},
+	{"fsl,imx6q-uart",	(uintptr_t)&uart_imx_class},
+	{"fsl,imx53-uart",	(uintptr_t)&uart_imx_class},
+	{"fsl,imx51-uart",	(uintptr_t)&uart_imx_class},
+	{"fsl,imx31-uart",	(uintptr_t)&uart_imx_class},
+	{"fsl,imx27-uart",	(uintptr_t)&uart_imx_class},
+	{"fsl,imx25-uart",	(uintptr_t)&uart_imx_class},
+	{"fsl,imx21-uart",	(uintptr_t)&uart_imx_class},
+	{"lpc,uart",		(uintptr_t)&uart_lpc_class},
+	{"ti,ns16550",		(uintptr_t)&uart_ti8250_class},
+	{"ns16550",		(uintptr_t)&uart_ns8250_class},
+	{NULL,			(uintptr_t)NULL},
+};
+
 static int
 uart_fdt_get_clock(phandle_t node, pcell_t *cell)
 {
@@ -99,25 +123,16 @@ uart_fdt_probe(device_t dev)
 	phandle_t node;
 	pcell_t clock, shift;
 	int err;
+	const struct ofw_compat_data * cd;
 
 	sc = device_get_softc(dev);
-	if (ofw_bus_is_compatible(dev, "lpc,uart"))
-		sc->sc_class = &uart_lpc_class;
-	else if (ofw_bus_is_compatible(dev, "fsl,imx-uart"))
-		sc->sc_class = &uart_imx_class;
-	else if (ofw_bus_is_compatible(dev, "arm,pl011"))
-		sc->sc_class = &uart_pl011_class;
-	else if (ofw_bus_is_compatible(dev, "exynos"))
-		sc->sc_class = &uart_s3c2410_class;
-	else if (ofw_bus_is_compatible(dev, "cadence,uart"))
-		sc->sc_class = &uart_cdnc_class;
-	else if (ofw_bus_is_compatible(dev, "ti,ns16550"))
-		sc->sc_class = &uart_ti8250_class;
-	else if (ofw_bus_is_compatible(dev, "ns16550"))
-		sc->sc_class = &uart_ns8250_class;
-	else
+
+	cd = ofw_bus_search_compatible(dev, compat_data);
+	if (cd->ocd_data == (uintptr_t)NULL)
 		return (ENXIO);
 
+	sc->sc_class = (struct uart_class *)cd->ocd_data;
+
 	node = ofw_bus_get_node(dev);
 
 	if ((err = uart_fdt_get_clock(node, &clock)) != 0)


More information about the svn-src-stable-10 mailing list