Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 May 2015 20:54:25 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r283327 - in stable/10/sys: arm/at91 arm/freescale/vybrid arm/samsung/exynos arm/samsung/s3c2xx0 arm/xilinx dev/uart
Message-ID:  <201505232054.t4NKsP7L086552@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Sat May 23 20:54:25 2015
New Revision: 283327
URL: https://svnweb.freebsd.org/changeset/base/283327

Log:
  MFC r279723, r279724:
  
    Define new linker set, UART_FDT_CLASS_AND_DEVICE, for registering full
    (class and device) FDT UART. Define second one, UART_FDT_CLASS, for UART
    class only.
  
    Move the uart_class definitions and fdt compat data into the individual
    uart implementations, and export them using the new linker-set mechanism.

Added:
  stable/10/sys/dev/uart/uart_cpu_fdt.h
     - copied unchanged from r279723, head/sys/dev/uart/uart_cpu_fdt.h
Modified:
  stable/10/sys/arm/at91/uart_bus_at91usart.c
  stable/10/sys/arm/at91/uart_cpu_at91usart.c
  stable/10/sys/arm/at91/uart_dev_at91usart.c
  stable/10/sys/arm/freescale/vybrid/vf_uart.c
  stable/10/sys/arm/samsung/exynos/exynos_uart.c
  stable/10/sys/arm/samsung/s3c2xx0/uart_bus_s3c2410.c
  stable/10/sys/arm/samsung/s3c2xx0/uart_cpu_s3c2410.c
  stable/10/sys/arm/xilinx/uart_dev_cdnc.c
  stable/10/sys/dev/uart/uart.h
  stable/10/sys/dev/uart/uart_bus_fdt.c
  stable/10/sys/dev/uart/uart_cpu_fdt.c
  stable/10/sys/dev/uart/uart_dev_imx.c
  stable/10/sys/dev/uart/uart_dev_lpc.c
  stable/10/sys/dev/uart/uart_dev_msm.c
  stable/10/sys/dev/uart/uart_dev_ns8250.c
  stable/10/sys/dev/uart/uart_dev_pl011.c
  stable/10/sys/dev/uart/uart_dev_ti8250.c
  stable/10/sys/dev/uart/uart_subr.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/arm/at91/uart_bus_at91usart.c
==============================================================================
--- stable/10/sys/arm/at91/uart_bus_at91usart.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/arm/at91/uart_bus_at91usart.c	Sat May 23 20:54:25 2015	(r283327)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
 
 #include "uart_if.h"
 
+extern struct uart_class at91_usart_class;
 static int usart_at91_probe(device_t dev);
 
 static device_method_t usart_at91_methods[] = {

Modified: stable/10/sys/arm/at91/uart_cpu_at91usart.c
==============================================================================
--- stable/10/sys/arm/at91/uart_cpu_at91usart.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/arm/at91/uart_cpu_at91usart.c	Sat May 23 20:54:25 2015	(r283327)
@@ -51,6 +51,7 @@ bus_space_tag_t uart_bus_space_io;
 bus_space_tag_t uart_bus_space_mem;
 
 extern struct bus_space at91_bs_tag;
+extern struct uart_class at91_usart_class;
 
 int
 uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2)

Modified: stable/10/sys/arm/at91/uart_dev_at91usart.c
==============================================================================
--- stable/10/sys/arm/at91/uart_dev_at91usart.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/arm/at91/uart_dev_at91usart.c	Sat May 23 20:54:25 2015	(r283327)
@@ -40,6 +40,9 @@ __FBSDID("$FreeBSD$");
 
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_cpu.h>
+#ifdef FDT
+#include <dev/uart/uart_cpu_fdt.h>
+#endif
 #include <dev/uart/uart_bus.h>
 #include <arm/at91/at91_usartreg.h>
 #include <arm/at91/at91_pdcreg.h>
@@ -866,3 +869,12 @@ struct uart_class at91_usart_class = {
 	.uc_ops = &at91_usart_ops,
 	.uc_range = 8
 };
+
+#ifdef FDT
+static struct ofw_compat_data compat_data[] = {
+	{"atmel,at91rm9200-usart",(uintptr_t)&at91_usart_class},
+	{"atmel,at91sam9260-usart",(uintptr_t)&at91_usart_class},
+	{NULL,			(uintptr_t)NULL},
+};
+UART_FDT_CLASS_AND_DEVICE(compat_data);
+#endif

Modified: stable/10/sys/arm/freescale/vybrid/vf_uart.c
==============================================================================
--- stable/10/sys/arm/freescale/vybrid/vf_uart.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/arm/freescale/vybrid/vf_uart.c	Sat May 23 20:54:25 2015	(r283327)
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_cpu.h>
+#include <dev/uart/uart_cpu_fdt.h>
 #include <dev/uart/uart_bus.h>
 
 #include "uart_if.h"
@@ -270,7 +271,7 @@ static kobj_method_t vf_uart_methods[] =
 	{ 0, 0 }
 };
 
-struct uart_class uart_vybrid_class = {
+static struct uart_class uart_vybrid_class = {
 	"vybrid",
 	vf_uart_methods,
 	sizeof(struct vf_uart_softc),
@@ -279,6 +280,12 @@ struct uart_class uart_vybrid_class = {
 	.uc_rclk = 24000000 /* TODO: get value from CCM */
 };
 
+static struct ofw_compat_data compat_data[] = {
+	{"fsl,mvf600-uart",	(uintptr_t)&uart_vybrid_class},
+	{NULL,			(uintptr_t)NULL},
+};
+UART_FDT_CLASS_AND_DEVICE(compat_data);
+
 static int
 vf_uart_bus_attach(struct uart_softc *sc)
 {

Modified: stable/10/sys/arm/samsung/exynos/exynos_uart.c
==============================================================================
--- stable/10/sys/arm/samsung/exynos/exynos_uart.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/arm/samsung/exynos/exynos_uart.c	Sat May 23 20:54:25 2015	(r283327)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_cpu.h>
+#include <dev/uart/uart_cpu_fdt.h>
 #include <dev/uart/uart_bus.h>
 
 #include <arm/samsung/exynos/exynos_uart.h>
@@ -372,7 +373,7 @@ exynos4210_bus_ioctl(struct uart_softc *
 	return (EINVAL);
 }
 
-struct uart_class uart_exynos4210_class = {
+static struct uart_class uart_exynos4210_class = {
 	"exynos4210 class",
 	exynos4210_methods,
 	1,
@@ -380,3 +381,9 @@ struct uart_class uart_exynos4210_class 
 	.uc_range = 8,
 	.uc_rclk = 0,
 };
+
+static struct ofw_compat_data compat_data[] = {
+	{"exynos",		(uintptr_t)&uart_exynos4210_class},
+	{NULL,			(uintptr_t)NULL},
+};
+UART_FDT_CLASS_AND_DEVICE(compat_data);

Modified: stable/10/sys/arm/samsung/s3c2xx0/uart_bus_s3c2410.c
==============================================================================
--- stable/10/sys/arm/samsung/s3c2xx0/uart_bus_s3c2410.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/arm/samsung/s3c2xx0/uart_bus_s3c2410.c	Sat May 23 20:54:25 2015	(r283327)
@@ -19,6 +19,8 @@ __FBSDID("$FreeBSD$");
 
 #include "uart_if.h"
 
+extern struct uart_class uart_s3c2410_class;
+
 static int uart_s3c2410_probe(device_t dev);
 
 static device_method_t uart_s3c2410_methods[] = {

Modified: stable/10/sys/arm/samsung/s3c2xx0/uart_cpu_s3c2410.c
==============================================================================
--- stable/10/sys/arm/samsung/s3c2xx0/uart_cpu_s3c2410.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/arm/samsung/s3c2xx0/uart_cpu_s3c2410.c	Sat May 23 20:54:25 2015	(r283327)
@@ -39,11 +39,11 @@ __FBSDID("$FreeBSD$");
 
 #include <arm/samsung/s3c2xx0/s3c2xx0var.h>
 
+extern struct uart_class uart_s3c2410_class;
+
 bus_space_tag_t uart_bus_space_io;
 bus_space_tag_t uart_bus_space_mem;
 
-extern struct uart_ops uart_s3c2410_ops;
-
 vm_offset_t s3c2410_uart_vaddr;
 unsigned int s3c2410_pclk;
 

Modified: stable/10/sys/arm/xilinx/uart_dev_cdnc.c
==============================================================================
--- stable/10/sys/arm/xilinx/uart_dev_cdnc.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/arm/xilinx/uart_dev_cdnc.c	Sat May 23 20:54:25 2015	(r283327)
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
 
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_cpu.h>
+#include <dev/uart/uart_cpu_fdt.h>
 #include <dev/uart/uart_bus.h>
 
 #include "uart_if.h"
@@ -700,10 +701,16 @@ cdnc_uart_bus_ungrab(struct uart_softc *
 	    CDNC_UART_INT_DMSI);
 }
 
-struct uart_class uart_cdnc_class = {
+static struct uart_class uart_cdnc_class = {
 	"cdnc_uart",
 	cdnc_uart_bus_methods,
 	sizeof(struct uart_softc),
 	.uc_ops = &cdnc_uart_ops,
 	.uc_range = 8
 };
+
+static struct ofw_compat_data compat_data[] = {
+	{"cadence,uart",	(uintptr_t)&uart_cdnc_class},
+	{NULL,			(uintptr_t)NULL},
+};
+UART_FDT_CLASS_AND_DEVICE(compat_data);

Modified: stable/10/sys/dev/uart/uart.h
==============================================================================
--- stable/10/sys/dev/uart/uart.h	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/dev/uart/uart.h	Sat May 23 20:54:25 2015	(r283327)
@@ -64,26 +64,12 @@ struct uart_bas {
  */
 struct uart_class;
 
-extern struct uart_class uart_imx_class __attribute__((weak));
-extern struct uart_class uart_msm_class __attribute__((weak));
 extern struct uart_class uart_ns8250_class __attribute__((weak));
 extern struct uart_class uart_quicc_class __attribute__((weak));
 extern struct uart_class uart_s3c2410_class __attribute__((weak));
 extern struct uart_class uart_sab82532_class __attribute__((weak));
 extern struct uart_class uart_sbbc_class __attribute__((weak));
 extern struct uart_class uart_z8530_class __attribute__((weak));
-extern struct uart_class uart_lpc_class __attribute__((weak));
-extern struct uart_class uart_pl011_class __attribute__((weak));
-extern struct uart_class uart_cdnc_class __attribute__((weak));
-extern struct uart_class uart_ti8250_class __attribute__((weak));
-extern struct uart_class uart_vybrid_class __attribute__((weak));
-extern struct uart_class at91_usart_class __attribute__((weak));
-extern struct uart_class uart_exynos4210_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);

Modified: stable/10/sys/dev/uart/uart_bus_fdt.c
==============================================================================
--- stable/10/sys/dev/uart/uart_bus_fdt.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/dev/uart/uart_bus_fdt.c	Sat May 23 20:54:25 2015	(r283327)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_bus.h>
 #include <dev/uart/uart_cpu.h>
+#include <dev/uart/uart_cpu_fdt.h>
 
 static int uart_fdt_probe(device_t);
 
@@ -62,37 +63,6 @@ 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},
-	{"atmel,at91rm9200-usart",(uintptr_t)&at91_usart_class},
-	{"atmel,at91sam9260-usart",(uintptr_t)&at91_usart_class},
-	{"cadence,uart",	(uintptr_t)&uart_cdnc_class},
-	{"exynos",		(uintptr_t)&uart_exynos4210_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},
-	{"fsl,mvf600-uart",	(uintptr_t)&uart_vybrid_class},
-	{"lpc,uart",		(uintptr_t)&uart_lpc_class},
-	{"qcom,msm-uartdm",	(uintptr_t)&uart_msm_class},
-	{"ti,ns16550",		(uintptr_t)&uart_ti8250_class},
-	{"ns16550",		(uintptr_t)&uart_ns8250_class},
-	{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)
 {
@@ -127,6 +97,20 @@ uart_fdt_get_shift(phandle_t node, pcell
 	return (0);
 }
 
+static uintptr_t
+uart_fdt_find_device(device_t dev)
+{
+	struct ofw_compat_data **cd;
+	const struct ofw_compat_data *ocd;
+
+	SET_FOREACH(cd, uart_fdt_class_and_device_set) {
+		ocd = ofw_bus_search_compatible(dev, *cd);
+		if (ocd->ocd_data != 0)
+			return (ocd->ocd_data);
+	}
+	return (0);
+}
+
 static int
 uart_fdt_probe(device_t dev)
 {
@@ -134,19 +118,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_status_okay(dev))
 		return (ENXIO);
 
-	cd = ofw_bus_search_compatible(dev, compat_data);
-	if (cd->ocd_data == (uintptr_t)NULL)
+	sc->sc_class = (struct uart_class *)uart_fdt_find_device(dev);
+	if (sc->sc_class == 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)

Modified: stable/10/sys/dev/uart/uart_cpu_fdt.c
==============================================================================
--- stable/10/sys/dev/uart/uart_cpu_fdt.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/dev/uart/uart_cpu_fdt.c	Sat May 23 20:54:25 2015	(r283327)
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_bus.h>
 #include <dev/uart/uart_cpu.h>
+#include <dev/uart/uart_cpu_fdt.h>
 
 /*
  * UART console routines.
@@ -115,13 +116,46 @@ phandle_chosen_propdev(phandle_t chosen,
 	return (0);
 }
 
+static const struct ofw_compat_data *
+uart_fdt_find_compatible(phandle_t node, const struct ofw_compat_data *cd)
+{
+	const struct ofw_compat_data *ocd;
+
+	for (ocd = cd; ocd->ocd_str != NULL; ocd++) {
+		if (fdt_is_compatible(node, ocd->ocd_str))
+			return (ocd);
+	}
+	return (NULL);
+}
+
+static uintptr_t
+uart_fdt_find_by_node(phandle_t node, int class_list)
+{
+	struct ofw_compat_data **cd;
+	const struct ofw_compat_data *ocd;
+
+	if (class_list) {
+		SET_FOREACH(cd, uart_fdt_class_set) {
+			ocd = uart_fdt_find_compatible(node, *cd);
+			if ((ocd != NULL) && (ocd->ocd_data != 0))
+				return (ocd->ocd_data);
+		}
+	} else {
+		SET_FOREACH(cd, uart_fdt_class_and_device_set) {
+			ocd = uart_fdt_find_compatible(node, *cd);
+			if ((ocd != NULL) && (ocd->ocd_data != 0))
+				return (ocd->ocd_data);
+		}
+	}
+	return (0);
+}
+
 int
 uart_cpu_getdev(int devtype, struct uart_devinfo *di)
 {
 	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;
@@ -160,24 +194,32 @@ uart_cpu_getdev(int devtype, struct uart
 	 * Retrieve serial attributes.
 	 */
 	uart_fdt_get_shift(node, &shift);
-
 	if (OF_getprop(node, "current-speed", &br, sizeof(br)) <= 0)
 		br = 0;
-	br = fdt32_to_cpu(br);
+	else
+		br = fdt32_to_cpu(br);
 
-	if ((err = uart_fdt_get_clock(node, &rclk)) != 0)
-		return (err);
 	/*
-	 * Finalize configuration.
+	 * Check old style of UART definition first. Unfortunately, the common
+	 * FDT processing is not possible if we have clock, power domains and
+	 * pinmux stuff.
 	 */
-	for (cd = uart_fdt_compat_data; cd->ocd_str != NULL; ++cd) {
-		if (fdt_is_compatible(node, cd->ocd_str))
-			break;
+	class = (struct uart_class *)uart_fdt_find_by_node(node, 0);
+	if (class != NULL) {
+		if ((err = uart_fdt_get_clock(node, &rclk)) != 0)
+			return (err);
+	} else {
+		/* Check class only linker set */
+		class =
+		    (struct uart_class *)uart_fdt_find_by_node(node, 1);
+		if (class == NULL)
+			return (ENXIO);
+		rclk = 0;
 	}
-	if (cd->ocd_str == NULL)
-		return (ENXIO);
-	class = (struct uart_class *)cd->ocd_data;
 
+	/*
+	 * Finalize configuration.
+	 */
 	di->bas.chan = 0;
 	di->bas.regshft = (u_int)shift;
 	di->baudrate = br;

Copied: stable/10/sys/dev/uart/uart_cpu_fdt.h (from r279723, head/sys/dev/uart/uart_cpu_fdt.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/sys/dev/uart/uart_cpu_fdt.h	Sat May 23 20:54:25 2015	(r283327, copy of r279723, head/sys/dev/uart/uart_cpu_fdt.h)
@@ -0,0 +1,54 @@
+/*-
+ * Copyright 2015 Michal Meloun
+ * All rights reserved.
+ *
+ * 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$
+ */
+
+#ifndef _DEV_UART_CPU_FDT_H_
+#define _DEV_UART_CPU_FDT_H_
+
+#include <sys/linker_set.h>
+
+#include <dev/ofw/ofw_bus_subr.h>
+
+/*
+ * If your UART driver implements only uart_class and uses uart_cpu_fdt.c
+ * for device instantiation, then use UART_FDT_CLASS_AND_DEVICE for its
+ * declaration
+ */
+SET_DECLARE(uart_fdt_class_and_device_set, struct ofw_compat_data );
+#define UART_FDT_CLASS_AND_DEVICE(data)				\
+	DATA_SET(uart_fdt_class_and_device_set, data)
+
+/*
+ * If your UART driver implements uart_class and custom device layer,
+ * then use UART_FDT_CLASS for its declaration
+ */
+SET_DECLARE(uart_fdt_class_set, struct ofw_compat_data );
+#define UART_FDT_CLASS(data)				\
+	DATA_SET(uart_fdt_class_set, data)
+
+
+#endif /* _DEV_UART_CPU_FDT_H_ */

Modified: stable/10/sys/dev/uart/uart_dev_imx.c
==============================================================================
--- stable/10/sys/dev/uart/uart_dev_imx.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/dev/uart/uart_dev_imx.c	Sat May 23 20:54:25 2015	(r283327)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_cpu.h>
+#include <dev/uart/uart_cpu_fdt.h>
 #include <dev/uart/uart_bus.h>
 #include <dev/uart/uart_dev_imx.h>
 #include "uart_if.h"
@@ -291,7 +292,7 @@ static kobj_method_t imx_uart_methods[] 
 	{ 0, 0 }
 };
 
-struct uart_class uart_imx_class = {
+static struct uart_class uart_imx_class = {
 	"imx",
 	imx_uart_methods,
 	sizeof(struct imx_uart_softc),
@@ -300,6 +301,18 @@ struct uart_class uart_imx_class = {
 	.uc_rclk = 24000000 /* TODO: get value from CCM */
 };
 
+static struct ofw_compat_data compat_data[] = {
+	{"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},
+	{NULL,			(uintptr_t)NULL},
+};
+UART_FDT_CLASS_AND_DEVICE(compat_data);
+
 #define	SIGCHG(c, i, s, d)				\
 	if (c) {					\
 		i |= (i & s) ? s : s | d;		\

Modified: stable/10/sys/dev/uart/uart_dev_lpc.c
==============================================================================
--- stable/10/sys/dev/uart/uart_dev_lpc.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/dev/uart/uart_dev_lpc.c	Sat May 23 20:54:25 2015	(r283327)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_cpu.h>
+#include <dev/uart/uart_cpu_fdt.h>
 #include <dev/uart/uart_bus.h>
 
 #include <dev/ic/ns16550.h>
@@ -421,7 +422,7 @@ static kobj_method_t lpc_ns8250_methods[
 	{ 0, 0 }
 };
 
-struct uart_class uart_lpc_class = {
+static struct uart_class uart_lpc_class = {
 	"lpc_ns8250",
 	lpc_ns8250_methods,
 	sizeof(struct lpc_ns8250_softc),
@@ -430,6 +431,12 @@ struct uart_class uart_lpc_class = {
 	.uc_rclk = DEFAULT_RCLK
 };
 
+static struct ofw_compat_data compat_data[] = {
+	{"lpc,uart",		(uintptr_t)&uart_lpc_class},
+	{NULL,			(uintptr_t)NULL},
+};
+UART_FDT_CLASS_AND_DEVICE(compat_data);
+
 #define	SIGCHG(c, i, s, d)				\
 	if (c) {					\
 		i |= (i & s) ? s : s | d;		\

Modified: stable/10/sys/dev/uart/uart_dev_msm.c
==============================================================================
--- stable/10/sys/dev/uart/uart_dev_msm.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/dev/uart/uart_dev_msm.c	Sat May 23 20:54:25 2015	(r283327)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_cpu.h>
+#include <dev/uart/uart_cpu_fdt.h>
 #include <dev/uart/uart_bus.h>
 #include <dev/uart/uart_dev_msm.h>
 
@@ -558,7 +559,7 @@ msm_bus_ungrab(struct uart_softc *sc)
 	uart_unlock(sc->sc_hwmtx);
 }
 
-struct uart_class uart_msm_class = {
+static struct uart_class uart_msm_class = {
 	"msm",
 	msm_methods,
 	sizeof(struct msm_uart_softc),
@@ -566,3 +567,9 @@ struct uart_class uart_msm_class = {
 	.uc_range = 8,
 	.uc_rclk = DEF_CLK,
 };
+
+static struct ofw_compat_data compat_data[] = {
+	{"qcom,msm-uartdm",	(uintptr_t)&uart_msm_class},
+	{NULL,			(uintptr_t)NULL},
+};
+UART_FDT_CLASS_AND_DEVICE(compat_data);

Modified: stable/10/sys/dev/uart/uart_dev_ns8250.c
==============================================================================
--- stable/10/sys/dev/uart/uart_dev_ns8250.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/dev/uart/uart_dev_ns8250.c	Sat May 23 20:54:25 2015	(r283327)
@@ -45,6 +45,9 @@ __FBSDID("$FreeBSD$");
 
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_cpu.h>
+#ifdef FDT
+#include <dev/uart/uart_cpu_fdt.h>
+#endif
 #include <dev/uart/uart_bus.h>
 #include <dev/uart/uart_dev_ns8250.h>
 
@@ -379,6 +382,14 @@ struct uart_class uart_ns8250_class = {
 	.uc_rclk = DEFAULT_RCLK
 };
 
+#ifdef FDT
+static struct ofw_compat_data compat_data[] = {
+	{"ns16550",		(uintptr_t)&uart_ns8250_class},
+	{NULL,			(uintptr_t)NULL},
+};
+UART_FDT_CLASS_AND_DEVICE(compat_data);
+#endif
+
 #define	SIGCHG(c, i, s, d)				\
 	if (c) {					\
 		i |= (i & s) ? s : s | d;		\

Modified: stable/10/sys/dev/uart/uart_dev_pl011.c
==============================================================================
--- stable/10/sys/dev/uart/uart_dev_pl011.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/dev/uart/uart_dev_pl011.c	Sat May 23 20:54:25 2015	(r283327)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
 
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_cpu.h>
+#include <dev/uart/uart_cpu_fdt.h>
 #include <dev/uart/uart_bus.h>
 #include "uart_if.h"
 
@@ -266,7 +267,7 @@ static kobj_method_t uart_pl011_methods[
 	{ 0, 0 }
 };
 
-struct uart_class uart_pl011_class = {
+static struct uart_class uart_pl011_class = {
 	"uart_pl011",
 	uart_pl011_methods,
 	sizeof(struct uart_pl011_softc),
@@ -275,6 +276,12 @@ struct uart_class uart_pl011_class = {
 	.uc_rclk = 0
 };
 
+static struct ofw_compat_data compat_data[] = {
+	{"arm,pl011",		(uintptr_t)&uart_pl011_class},
+	{NULL,			(uintptr_t)NULL},
+};
+UART_FDT_CLASS_AND_DEVICE(compat_data);
+
 static int
 uart_pl011_bus_attach(struct uart_softc *sc)
 {

Modified: stable/10/sys/dev/uart/uart_dev_ti8250.c
==============================================================================
--- stable/10/sys/dev/uart/uart_dev_ti8250.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/dev/uart/uart_dev_ti8250.c	Sat May 23 20:54:25 2015	(r283327)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_cpu.h>
+#include <dev/uart/uart_cpu_fdt.h>
 #include <dev/uart/uart_bus.h>
 #include <dev/uart/uart_dev_ns8250.h>
 
@@ -130,7 +131,7 @@ static kobj_method_t ti8250_methods[] = 
 	KOBJMETHOD_END
 };
 
-struct uart_class uart_ti8250_class = {
+static struct uart_class uart_ti8250_class = {
 	"ti8250",
 	ti8250_methods,
 	sizeof(struct ti8250_softc),
@@ -138,4 +139,8 @@ struct uart_class uart_ti8250_class = {
 	.uc_range = 0x88,
 	.uc_rclk = 48000000
 };
-
+static struct ofw_compat_data compat_data[] = {
+	{"ti,ns16550",		(uintptr_t)&uart_ti8250_class},
+	{NULL,			(uintptr_t)NULL},
+};
+UART_FDT_CLASS_AND_DEVICE(compat_data);

Modified: stable/10/sys/dev/uart/uart_subr.c
==============================================================================
--- stable/10/sys/dev/uart/uart_subr.c	Sat May 23 20:53:19 2015	(r283326)
+++ stable/10/sys/dev/uart/uart_subr.c	Sat May 23 20:54:25 2015	(r283327)
@@ -53,7 +53,6 @@ static struct uart_class *uart_classes[]
 	&uart_sab82532_class,
 	&uart_z8530_class,
 #if defined(__arm__)
-	&uart_lpc_class,
 	&uart_s3c2410_class,
 #endif
 };



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505232054.t4NKsP7L086552>