From 550c116c702749dbb815eb45b23be45cebc2bddf Mon Sep 17 00:00:00 2001 From: ian Date: Sat, 7 Mar 2015 15:24:15 +0000 Subject: Move the uart_class definitions and fdt compat data into the individual uart implementations, and export them using the new linker-set mechanism. Differential Revision: https://reviews.freebsd.org/D1993 Submitted by: Michal Meloun --- sys/arm/at91/uart_bus_at91usart.c | 1 + sys/arm/at91/uart_cpu_at91usart.c | 1 + sys/arm/at91/uart_dev_at91usart.c | 12 ++++++++++++ sys/arm/freescale/vybrid/vf_uart.c | 9 ++++++++- sys/arm/samsung/exynos/exynos_uart.c | 9 ++++++++- sys/arm/samsung/s3c2xx0/uart_bus_s3c2410.c | 2 ++ sys/arm/samsung/s3c2xx0/uart_cpu_s3c2410.c | 4 ++-- sys/arm/xilinx/uart_dev_cdnc.c | 9 ++++++++- sys/dev/uart/uart.h | 10 ---------- sys/dev/uart/uart_bus_fdt.c | 31 ------------------------------ sys/dev/uart/uart_dev_imx.c | 15 ++++++++++++++- sys/dev/uart/uart_dev_lpc.c | 9 ++++++++- sys/dev/uart/uart_dev_msm.c | 9 ++++++++- sys/dev/uart/uart_dev_ns8250.c | 11 +++++++++++ sys/dev/uart/uart_dev_pl011.c | 9 ++++++++- sys/dev/uart/uart_dev_ti8250.c | 9 +++++++-- sys/dev/uart/uart_subr.c | 1 - 17 files changed, 98 insertions(+), 53 deletions(-) diff --git a/sys/arm/at91/uart_bus_at91usart.c b/sys/arm/at91/uart_bus_at91usart.c index 65829df..28182fa 100644 --- a/sys/arm/at91/uart_bus_at91usart.c +++ b/sys/arm/at91/uart_bus_at91usart.c @@ -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[] = { diff --git a/sys/arm/at91/uart_cpu_at91usart.c b/sys/arm/at91/uart_cpu_at91usart.c index 67a0a05..57c4a5a 100644 --- a/sys/arm/at91/uart_cpu_at91usart.c +++ b/sys/arm/at91/uart_cpu_at91usart.c @@ -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) diff --git a/sys/arm/at91/uart_dev_at91usart.c b/sys/arm/at91/uart_dev_at91usart.c index 470c7aa..cac5e6a 100644 --- a/sys/arm/at91/uart_dev_at91usart.c +++ b/sys/arm/at91/uart_dev_at91usart.c @@ -40,6 +40,9 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef FDT +#include +#endif #include #include #include @@ -865,3 +868,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 diff --git a/sys/arm/freescale/vybrid/vf_uart.c b/sys/arm/freescale/vybrid/vf_uart.c index d181432..da11871 100644 --- a/sys/arm/freescale/vybrid/vf_uart.c +++ b/sys/arm/freescale/vybrid/vf_uart.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #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) { diff --git a/sys/arm/samsung/exynos/exynos_uart.c b/sys/arm/samsung/exynos/exynos_uart.c index 0b3c7f7..9e33bcb 100644 --- a/sys/arm/samsung/exynos/exynos_uart.c +++ b/sys/arm/samsung/exynos/exynos_uart.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -372,7 +373,7 @@ exynos4210_bus_ioctl(struct uart_softc *sc, int request, intptr_t data) 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); diff --git a/sys/arm/samsung/s3c2xx0/uart_bus_s3c2410.c b/sys/arm/samsung/s3c2xx0/uart_bus_s3c2410.c index 2102d8b..882a546 100644 --- a/sys/arm/samsung/s3c2xx0/uart_bus_s3c2410.c +++ b/sys/arm/samsung/s3c2xx0/uart_bus_s3c2410.c @@ -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[] = { diff --git a/sys/arm/samsung/s3c2xx0/uart_cpu_s3c2410.c b/sys/arm/samsung/s3c2xx0/uart_cpu_s3c2410.c index 1beb12d..4be4b39 100644 --- a/sys/arm/samsung/s3c2xx0/uart_cpu_s3c2410.c +++ b/sys/arm/samsung/s3c2xx0/uart_cpu_s3c2410.c @@ -39,11 +39,11 @@ __FBSDID("$FreeBSD$"); #include +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; diff --git a/sys/arm/xilinx/uart_dev_cdnc.c b/sys/arm/xilinx/uart_dev_cdnc.c index 526c546..96092ba 100644 --- a/sys/arm/xilinx/uart_dev_cdnc.c +++ b/sys/arm/xilinx/uart_dev_cdnc.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include "uart_if.h" @@ -698,10 +699,16 @@ cdnc_uart_bus_ungrab(struct uart_softc *sc) 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); diff --git a/sys/dev/uart/uart.h b/sys/dev/uart/uart.h index 2a5f026..c40846b 100644 --- a/sys/dev/uart/uart.h +++ b/sys/dev/uart/uart.h @@ -64,22 +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 PC98 struct uart_class *uart_pc98_getdev(u_long port); diff --git a/sys/dev/uart/uart_bus_fdt.c b/sys/dev/uart/uart_bus_fdt.c index 9ef5152..3c68d95 100644 --- a/sys/dev/uart/uart_bus_fdt.c +++ b/sys/dev/uart/uart_bus_fdt.c @@ -63,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. */ -UART_FDT_CLASS_AND_DEVICE(compat_data); - static int uart_fdt_get_clock(phandle_t node, pcell_t *cell) { diff --git a/sys/dev/uart/uart_dev_imx.c b/sys/dev/uart/uart_dev_imx.c index 2f5fc06..9e34473 100644 --- a/sys/dev/uart/uart_dev_imx.c +++ b/sys/dev/uart/uart_dev_imx.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #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; \ diff --git a/sys/dev/uart/uart_dev_lpc.c b/sys/dev/uart/uart_dev_lpc.c index 08cebc9..992e890 100644 --- a/sys/dev/uart/uart_dev_lpc.c +++ b/sys/dev/uart/uart_dev_lpc.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -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; \ diff --git a/sys/dev/uart/uart_dev_msm.c b/sys/dev/uart/uart_dev_msm.c index 12dc8a7..114a415 100644 --- a/sys/dev/uart/uart_dev_msm.c +++ b/sys/dev/uart/uart_dev_msm.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -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); diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c index 89f7840..190ee29 100644 --- a/sys/dev/uart/uart_dev_ns8250.c +++ b/sys/dev/uart/uart_dev_ns8250.c @@ -45,6 +45,9 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef FDT +#include +#endif #include #include @@ -378,6 +381,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; \ diff --git a/sys/dev/uart/uart_dev_pl011.c b/sys/dev/uart/uart_dev_pl011.c index e8e23d5..8443adb 100644 --- a/sys/dev/uart/uart_dev_pl011.c +++ b/sys/dev/uart/uart_dev_pl011.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #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) { diff --git a/sys/dev/uart/uart_dev_ti8250.c b/sys/dev/uart/uart_dev_ti8250.c index 12d059a..daddbb7 100644 --- a/sys/dev/uart/uart_dev_ti8250.c +++ b/sys/dev/uart/uart_dev_ti8250.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -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); diff --git a/sys/dev/uart/uart_subr.c b/sys/dev/uart/uart_subr.c index 7a5df38..5516a6c 100644 --- a/sys/dev/uart/uart_subr.c +++ b/sys/dev/uart/uart_subr.c @@ -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 }; -- cgit v1.1