From a41b6ebba9765b38ea9e6b9737c6f7d056ad29c9 Mon Sep 17 00:00:00 2001 From: kettenis Date: Sat, 20 Aug 2016 15:44:04 +0000 Subject: [PATCH] Replace bcmmuart(4) with com(4). ok patrick@ --- sys/arch/armv7/armv7/platform.c | 4 +- sys/arch/armv7/broadcom/bcm2835_muart.c | 112 ------------------------ sys/arch/armv7/conf/GENERIC | 3 +- sys/arch/armv7/conf/RAMDISK | 3 +- sys/arch/armv7/dev/com_fdt.c | 33 ++++--- 5 files changed, 24 insertions(+), 131 deletions(-) delete mode 100644 sys/arch/armv7/broadcom/bcm2835_muart.c diff --git a/sys/arch/armv7/armv7/platform.c b/sys/arch/armv7/armv7/platform.c index d37f283954b..4d81d41c792 100644 --- a/sys/arch/armv7/armv7/platform.c +++ b/sys/arch/armv7/armv7/platform.c @@ -1,4 +1,4 @@ -/* $OpenBSD: platform.c,v 1.12 2016/08/17 13:05:02 patrick Exp $ */ +/* $OpenBSD: platform.c,v 1.13 2016/08/20 15:44:04 kettenis Exp $ */ /* * Copyright (c) 2014 Patrick Wildt * @@ -40,7 +40,6 @@ void exuart_init_cons(void); void imxuart_init_cons(void); void com_fdt_init_cons(void); void pl011_init_cons(void); -void bcmmuart_init_cons(void); struct armv7_platform *imx_platform_match(void); struct armv7_platform *omap_platform_match(void); @@ -107,7 +106,6 @@ platform_init_cons(void) imxuart_init_cons(); com_fdt_init_cons(); pl011_init_cons(); - bcmmuart_init_cons(); } void diff --git a/sys/arch/armv7/broadcom/bcm2835_muart.c b/sys/arch/armv7/broadcom/bcm2835_muart.c deleted file mode 100644 index 8e7e31c563e..00000000000 --- a/sys/arch/armv7/broadcom/bcm2835_muart.c +++ /dev/null @@ -1,112 +0,0 @@ -/* $OpenBSD: bcm2835_muart.c,v 1.1 2016/08/07 17:46:36 kettenis Exp $ */ -/* - * Copyright (c) 2016 Patrick Wildt - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include -#include - -int bcmmuart_match(struct device *, void *, void *); -void bcmmuart_attach(struct device *, struct device *, void *); - -void bcmmuart_init_cons(void); - -struct cfdriver bcmmuart_cd = { - NULL, "bcmmuart", DV_DULL -}; - -struct cfattach bcmmuart_ca = { - sizeof (struct com_softc), bcmmuart_match, bcmmuart_attach, -}; - -int -bcmmuart_match(struct device *parent, void *self, void *aux) -{ - struct fdt_attach_args *faa = aux; - - if (OF_is_compatible(faa->fa_node, "brcm,bcm2835-aux-uart")) - return 1; - - return 0; -} - -void -bcmmuart_attach(struct device *parent, struct device *self, void *aux) -{ - struct com_softc *sc = (struct com_softc *)self; - struct fdt_attach_args *faa = aux; - - if (faa->fa_nreg < 1) - return; - - sc->sc_frequency = 500000000; - sc->sc_uarttype = COM_UART_16550; - - if (faa->fa_reg[0].addr == comconsaddr + 0x3f000000) { - sc->sc_iobase = comconsaddr; - sc->sc_iot = comconsiot; - sc->sc_ioh = comconsioh; - } else { - sc->sc_iot = faa->fa_iot; /* XXX */ - sc->sc_iobase = faa->fa_reg[0].addr; - if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, - faa->fa_reg[0].size, 0, &sc->sc_ioh)) { - printf("%s: bus_space_map failed\n", __func__); - return; - } - } - - com_attach_subr(sc); - - arm_intr_establish_fdt(faa->fa_node, IPL_TTY, comintr, sc, - sc->sc_dev.dv_xname); - - extern struct cfdriver com_cd; - com_cd.cd_devs = bcmmuart_cd.cd_devs; - com_cd.cd_ndevs = bcmmuart_cd.cd_ndevs; -} - -extern int comcnspeed; -extern int comcnmode; - -void -bcmmuart_init_cons(void) -{ - struct fdt_reg reg; - void *node; - - if ((node = fdt_find_cons("brcm,bcm2835-aux-uart")) == NULL) - return; - if (fdt_get_reg(node, 0, ®)) - return; - - comcnattach(&armv7_a4x_bs_tag, reg.addr, comcnspeed, 500000000, - comcnmode); -} diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC index bf8ea065674..905846cba49 100644 --- a/sys/arch/armv7/conf/GENERIC +++ b/sys/arch/armv7/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.49 2016/08/20 13:24:38 patrick Exp $ +# $OpenBSD: GENERIC,v 1.50 2016/08/20 15:44:04 kettenis Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -128,7 +128,6 @@ exuart* at exynos? # Raspberry Pi 2/3 bcmintc* at fdt? -bcmmuart* at fdt? dwctwo* at fdt? usb* at dwctwo? diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK index 6cd45df61b2..38a0d0f2d58 100644 --- a/sys/arch/armv7/conf/RAMDISK +++ b/sys/arch/armv7/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.45 2016/08/20 13:24:38 patrick Exp $ +# $OpenBSD: RAMDISK,v 1.46 2016/08/20 15:44:04 kettenis Exp $ machine armv7 arm @@ -126,7 +126,6 @@ exuart* at exynos? # Raspberry Pi 2/3 bcmintc* at fdt? -bcmmuart* at fdt? dwctwo* at fdt? usb* at dwctwo? diff --git a/sys/arch/armv7/dev/com_fdt.c b/sys/arch/armv7/dev/com_fdt.c index 3dbb46dbb06..2058c226a9b 100644 --- a/sys/arch/armv7/dev/com_fdt.c +++ b/sys/arch/armv7/dev/com_fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com_fdt.c,v 1.7 2016/08/20 10:41:54 kettenis Exp $ */ +/* $OpenBSD: com_fdt.c,v 1.8 2016/08/20 15:44:04 kettenis Exp $ */ /* * Copyright (c) 2016 Patrick Wildt * @@ -71,16 +71,17 @@ com_fdt_init_cons(void) struct fdt_reg reg; void *node; - if ((node = fdt_find_cons("ti,omap3-uart")) == NULL && - (node = fdt_find_cons("ti,omap4-uart")) == NULL && - (node = fdt_find_cons("snps,dw-apb-uart")) == NULL) + if ((node = fdt_find_cons("brcm,bcm2835-aux-uart")) == NULL && + (node = fdt_find_cons("snps,dw-apb-uart")) == NULL && + (node = fdt_find_cons("ti,omap3-uart")) == NULL && + (node = fdt_find_cons("ti,omap4-uart")) == NULL) return; if (fdt_get_reg(node, 0, ®)) return; /* * Figuring out the clock frequency is rather complicated as - * om many SoCs this requires traversing a fair amount of the + * on many SoCs this requires traversing a fair amount of the * clock tree. Instead we rely on the firmware to set up the * console for us and bypass the cominit() call that * comcnattach() does by doing the minimal setup here. @@ -100,9 +101,10 @@ com_fdt_match(struct device *parent, void *match, void *aux) { struct fdt_attach_args *faa = aux; - return (OF_is_compatible(faa->fa_node, "ti,omap3-uart") || - OF_is_compatible(faa->fa_node, "ti,omap4-uart") || - OF_is_compatible(faa->fa_node, "snps,dw-apb-uart")); + return (OF_is_compatible(faa->fa_node, "brcm,bcm2835-aux-uart") || + OF_is_compatible(faa->fa_node, "snps,dw-apb-uart") || + OF_is_compatible(faa->fa_node, "ti,omap3-uart") || + OF_is_compatible(faa->fa_node, "ti,omap4-uart")); } void @@ -126,12 +128,19 @@ com_fdt_attach(struct device *parent, struct device *self, void *aux) sc->sc.sc_iot = &sc->sc_iot; sc->sc.sc_iobase = faa->fa_reg[0].addr; - sc->sc.sc_frequency = 48000000; - sc->sc.sc_uarttype = COM_UART_TI16750; + sc->sc.sc_uarttype = COM_UART_16550; + sc->sc.sc_frequency = COM_FREQ; - if (OF_is_compatible(faa->fa_node, "snps,dw-apb-uart")) { - sc->sc.sc_uarttype = COM_UART_16550; + if (OF_is_compatible(faa->fa_node, "snps,dw-apb-uart")) intr = com_fdt_intr_designware; + + if (OF_is_compatible(faa->fa_node, "brcm,bcm2835-aux-uart")) + sc->sc.sc_frequency = 500000000; + + if (OF_is_compatible(faa->fa_node, "ti,omap3-uart") || + OF_is_compatible(faa->fa_node, "ti,omap4-uart")) { + sc->sc.sc_uarttype = COM_UART_TI16750; + sc->sc.sc_frequency = 48000000; } if ((node = OF_finddevice("/")) != 0 && -- 2.20.1