summaryrefslogtreecommitdiffstats
path: root/sys/dev/uart/uart_bus_fdt.c
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2013-12-13 19:01:50 +0000
committerian <ian@FreeBSD.org>2013-12-13 19:01:50 +0000
commit180cdddb9524b6e0bc4aeec1d5629683275af232 (patch)
tree69cb982d01bbedea55a6661792e48c21ea5d4c1a /sys/dev/uart/uart_bus_fdt.c
parentc34a10850035b2c2e84bc0629123bc614f41d490 (diff)
downloadFreeBSD-src-180cdddb9524b6e0bc4aeec1d5629683275af232.zip
FreeBSD-src-180cdddb9524b6e0bc4aeec1d5629683275af232.tar.gz
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.
Diffstat (limited to 'sys/dev/uart/uart_bus_fdt.c')
-rw-r--r--sys/dev/uart/uart_bus_fdt.c45
1 files changed, 30 insertions, 15 deletions
diff --git a/sys/dev/uart/uart_bus_fdt.c b/sys/dev/uart/uart_bus_fdt.c
index da84f26..cb2ce06 100644
--- a/sys/dev/uart/uart_bus_fdt.c
+++ b/sys/dev/uart/uart_bus_fdt.c
@@ -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)
OpenPOWER on IntegriCloud