From owner-svn-src-stable@FreeBSD.ORG Fri Dec 13 19:01:51 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0145CD4A; Fri, 13 Dec 2013 19:01:51 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D5CC4129B; Fri, 13 Dec 2013 19:01:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBDJ1orv077706; Fri, 13 Dec 2013 19:01:50 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBDJ1osG077705; Fri, 13 Dec 2013 19:01:50 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201312131901.rBDJ1osG077705@svn.freebsd.org> From: Ian Lepore Date: Fri, 13 Dec 2013 19:01:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r259323 - stable/10/sys/dev/uart X-SVN-Group: stable-10 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.17 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: Fri, 13 Dec 2013 19:01:51 -0000 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)