From owner-svn-src-all@FreeBSD.ORG Sat Nov 2 20:14:40 2013 Return-Path: Delivered-To: svn-src-all@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 ESMTP id C871CFA8; Sat, 2 Nov 2013 20:14:40 +0000 (UTC) (envelope-from ian@FreeBSD.org) 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 B57F926C3; Sat, 2 Nov 2013 20:14:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rA2KEeLX027428; Sat, 2 Nov 2013 20:14:40 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rA2KEeRu027425; Sat, 2 Nov 2013 20:14:40 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201311022014.rA2KEeRu027425@svn.freebsd.org> From: Ian Lepore Date: Sat, 2 Nov 2013 20:14:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r257556 - head/sys/dev/uart X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Nov 2013 20:14:41 -0000 Author: ian Date: Sat Nov 2 20:14:39 2013 New Revision: 257556 URL: http://svnweb.freebsd.org/changeset/base/257556 Log: Arrange for uart_cpu_fdt's probe() routine to use the same table of compat strings as uart_bus_fdt's probe(). The bus code uses ofw_bus_search_compatible() and that's not an option in cpu (console) code -- it runs way before the ofw routines are usable. So the console probe has its own loop to search the table, but now at least there's only one table to be maintained when new devices are added. Modified: head/sys/dev/uart/uart.h head/sys/dev/uart/uart_bus_fdt.c head/sys/dev/uart/uart_cpu_fdt.c Modified: head/sys/dev/uart/uart.h ============================================================================== --- head/sys/dev/uart/uart.h Sat Nov 2 20:12:19 2013 (r257555) +++ head/sys/dev/uart/uart.h Sat Nov 2 20:14:39 2013 (r257556) @@ -76,6 +76,11 @@ extern struct uart_class uart_pl011_clas extern struct uart_class uart_cdnc_class __attribute__((weak)); extern struct uart_class uart_ti8250_class __attribute__((weak)); +#ifdef FDT +struct ofw_compat_data; +extern const struct ofw_compat_data *uart_fdt_compat_data; +#endif + #ifdef PC98 struct uart_class *uart_pc98_getdev(u_long port); #endif Modified: head/sys/dev/uart/uart_bus_fdt.c ============================================================================== --- head/sys/dev/uart/uart_bus_fdt.c Sat Nov 2 20:12:19 2013 (r257555) +++ head/sys/dev/uart/uart_bus_fdt.c Sat Nov 2 20:14:39 2013 (r257556) @@ -30,6 +30,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_platform.h" + #include #include #include @@ -85,6 +87,9 @@ static struct ofw_compat_data compat_dat {NULL, (uintptr_t)NULL}, }; +/* Export the compat_data table for use by the uart_cpu_fdt.c probe routine. */ +const struct ofw_compat_data *uart_fdt_compat_data = compat_data; + static int uart_fdt_get_clock(phandle_t node, pcell_t *cell) { Modified: head/sys/dev/uart/uart_cpu_fdt.c ============================================================================== --- head/sys/dev/uart/uart_cpu_fdt.c Sat Nov 2 20:12:19 2013 (r257555) +++ head/sys/dev/uart/uart_cpu_fdt.c Sat Nov 2 20:14:39 2013 (r257556) @@ -30,6 +30,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_platform.h" + #include #include #include @@ -118,6 +120,7 @@ uart_cpu_getdev(int devtype, struct uart const char *propnames[] = {"stdout-path", "linux,stdout-path", "stdout", "stdin-path", "stdin", NULL}; const char **name; + const struct ofw_compat_data *cd; struct uart_class *class; phandle_t node, chosen; pcell_t shift, br, rclk; @@ -166,22 +169,13 @@ uart_cpu_getdev(int devtype, struct uart /* * Finalize configuration. */ - if (fdt_is_compatible(node, "fsl,imx-uart")) - class = &uart_imx_class; - else if (fdt_is_compatible(node, "quicc")) - class = &uart_quicc_class; - else if (fdt_is_compatible(node, "lpc")) - class = &uart_lpc_class; - else if (fdt_is_compatible(node, "arm,pl011")) - class = &uart_pl011_class; - else if (fdt_is_compatible(node, "exynos")) - class = &uart_s3c2410_class; - else if (fdt_is_compatible(node, "cadence,uart")) - class = &uart_cdnc_class; - else if (fdt_is_compatible(node, "ti,ns16550")) - class = &uart_ti8250_class; - else if (fdt_is_compatible(node, "ns16550")) - class = &uart_ns8250_class; + for (cd = uart_fdt_compat_data; cd->ocd_str != NULL; ++cd) { + if (fdt_is_compatible(node, cd->ocd_str)) + break; + } + if (cd->ocd_str == NULL) + return (ENXIO); + class = (struct uart_class *)cd->ocd_data; di->bas.chan = 0; di->bas.regshft = (u_int)shift;