From: patrick Date: Mon, 15 Aug 2016 13:42:49 +0000 (+0000) Subject: Move the com(4) fdt attachment driver to a more generic location and X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=769dc45f036fe9b4ccdf01cc98d827bce805246f;p=openbsd Move the com(4) fdt attachment driver to a more generic location and rename it to fit the typical scheme of such an attachment driver. ok kettenis@ jsg@ --- diff --git a/sys/arch/armv7/armv7/platform.c b/sys/arch/armv7/armv7/platform.c index aa2bafa1d86..80ce5f1ad87 100644 --- a/sys/arch/armv7/armv7/platform.c +++ b/sys/arch/armv7/armv7/platform.c @@ -1,4 +1,4 @@ -/* $OpenBSD: platform.c,v 1.10 2016/08/10 06:51:57 kettenis Exp $ */ +/* $OpenBSD: platform.c,v 1.11 2016/08/15 13:42:49 patrick Exp $ */ /* * Copyright (c) 2014 Patrick Wildt * @@ -38,7 +38,7 @@ void agtimer_init(void); void exuart_init_cons(void); void imxuart_init_cons(void); -void omapuart_init_cons(void); +void com_fdt_init_cons(void); void sxiuart_init_cons(void); void pl011_init_cons(void); void bcmmuart_init_cons(void); @@ -106,7 +106,7 @@ platform_init_cons(void) } exuart_init_cons(); imxuart_init_cons(); - omapuart_init_cons(); + com_fdt_init_cons(); sxiuart_init_cons(); pl011_init_cons(); bcmmuart_init_cons(); diff --git a/sys/arch/armv7/conf/files.armv7 b/sys/arch/armv7/conf/files.armv7 index c427ccf6176..60a9e2bb68e 100644 --- a/sys/arch/armv7/conf/files.armv7 +++ b/sys/arch/armv7/conf/files.armv7 @@ -1,4 +1,4 @@ -# $OpenBSD: files.armv7,v 1.23 2016/08/13 10:58:45 kettenis Exp $ +# $OpenBSD: files.armv7,v 1.24 2016/08/15 13:42:49 patrick Exp $ maxpartitions 16 maxusers 2 8 64 @@ -71,3 +71,7 @@ include "arch/armv7/sunxi/files.sunxi" include "arch/armv7/exynos/files.exynos" include "arch/armv7/vexpress/files.vexpress" include "arch/armv7/broadcom/files.broadcom" + +# Console related stuff +attach com at fdt with com_fdt +file arch/armv7/dev/com_fdt.c com_fdt diff --git a/sys/arch/armv7/dev/com_fdt.c b/sys/arch/armv7/dev/com_fdt.c new file mode 100644 index 00000000000..9e83c243779 --- /dev/null +++ b/sys/arch/armv7/dev/com_fdt.c @@ -0,0 +1,153 @@ +/* $OpenBSD: com_fdt.c,v 1.1 2016/08/15 13:42:49 patrick Exp $ */ +/* + * Copyright 2003 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Steve C. Woodford for Wasabi Systems, Inc. + * + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed for the NetBSD Project by + * Wasabi Systems, Inc. + * 4. The name of Wasabi Systems, Inc. may not be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC + * 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. + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +/* pick up armv7_a4x_bs_tag */ +#include + +#include +#include + +#include +#include +#include + +#define com_isr 8 +#define ISR_RECV (ISR_RXPL | ISR_XMODE | ISR_RCVEIR) + +int com_fdt_match(struct device *, void *, void *); +void com_fdt_attach(struct device *, struct device *, void *); +int com_fdt_activate(struct device *, int); + +extern int comcnspeed; +extern int comcnmode; + +struct cfattach com_fdt_ca = { + sizeof (struct com_softc), com_fdt_match, com_fdt_attach, NULL, + com_fdt_activate +}; + +void +com_fdt_init_cons(void) +{ + struct fdt_reg reg; + void *node; + + if ((node = fdt_find_cons("ti,omap3-uart")) == NULL) + if ((node = fdt_find_cons("ti,omap4-uart")) == NULL) + return; + if (fdt_get_reg(node, 0, ®)) + return; + + comcnattach(&armv7_a4x_bs_tag, reg.addr, comcnspeed, 48000000, + comcnmode); + comdefaultrate = comcnspeed; +} + +int +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")); +} + +void +com_fdt_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_iot = &armv7_a4x_bs_tag; /* XXX: This sucks */ + sc->sc_iobase = faa->fa_reg[0].addr; + sc->sc_frequency = 48000000; + sc->sc_uarttype = COM_UART_TI16750; + + if (bus_space_map(sc->sc_iot, sc->sc_iobase, + faa->fa_reg[0].size, 0, &sc->sc_ioh)) { + printf("%s: bus_space_map failed\n", __func__); + return; + } + + pinctrl_byname(faa->fa_node, "default"); + + com_attach_subr(sc); + + (void)arm_intr_establish_fdt(faa->fa_node, IPL_TTY, comintr, + sc, sc->sc_dev.dv_xname); +} + +int +com_fdt_activate(struct device *self, int act) +{ + struct com_softc *sc = (struct com_softc *)self; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh = sc->sc_ioh; + struct tty *tp = sc->sc_tty; + + switch (act) { + case DVACT_SUSPEND: + break; + case DVACT_RESUME: + if (sc->enabled) { + sc->sc_initialize = 1; + comparam(tp, &tp->t_termios); + bus_space_write_1(iot, ioh, com_ier, sc->sc_ier); + + if (ISSET(sc->sc_hwflags, COM_HW_SIR)) { + bus_space_write_1(iot, ioh, com_isr, + ISR_RECV); + } + } + break; + } + return 0; +} diff --git a/sys/arch/armv7/omap/files.omap b/sys/arch/armv7/omap/files.omap index 295d9ead933..976733b6852 100644 --- a/sys/arch/armv7/omap/files.omap +++ b/sys/arch/armv7/omap/files.omap @@ -1,4 +1,4 @@ -# $OpenBSD: files.omap,v 1.16 2016/08/11 04:33:06 jsg Exp $ +# $OpenBSD: files.omap,v 1.17 2016/08/15 13:42:49 patrick Exp $ define omap {} device omap: omap @@ -65,10 +65,6 @@ device omehci: usbus attach omehci at fdt file arch/armv7/omap/omehci.c omehci -# NS16550 compatible serial ports -attach com at fdt with com_omap -file arch/armv7/omap/omap_com.c com_omap - device omusbtll attach omusbtll at omap file arch/armv7/omap/omusbtll.c omusbtll diff --git a/sys/arch/armv7/omap/omap_com.c b/sys/arch/armv7/omap/omap_com.c deleted file mode 100644 index 4b80887e737..00000000000 --- a/sys/arch/armv7/omap/omap_com.c +++ /dev/null @@ -1,153 +0,0 @@ -/* $OpenBSD: omap_com.c,v 1.10 2016/08/12 03:22:41 jsg Exp $ */ -/* - * Copyright 2003 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Steve C. Woodford for Wasabi Systems, Inc. - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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. - */ - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -/* pick up armv7_a4x_bs_tag */ -#include - -#include -#include - -#include -#include -#include - -#define com_isr 8 -#define ISR_RECV (ISR_RXPL | ISR_XMODE | ISR_RCVEIR) - -int omapuart_match(struct device *, void *, void *); -void omapuart_attach(struct device *, struct device *, void *); -int omapuart_activate(struct device *, int); - -extern int comcnspeed; -extern int comcnmode; - -struct cfattach com_omap_ca = { - sizeof (struct com_softc), omapuart_match, omapuart_attach, NULL, - omapuart_activate -}; - -void -omapuart_init_cons(void) -{ - struct fdt_reg reg; - void *node; - - if ((node = fdt_find_cons("ti,omap3-uart")) == NULL) - if ((node = fdt_find_cons("ti,omap4-uart")) == NULL) - return; - if (fdt_get_reg(node, 0, ®)) - return; - - comcnattach(&armv7_a4x_bs_tag, reg.addr, comcnspeed, 48000000, - comcnmode); - comdefaultrate = comcnspeed; -} - -int -omapuart_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")); -} - -void -omapuart_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_iot = &armv7_a4x_bs_tag; /* XXX: This sucks */ - sc->sc_iobase = faa->fa_reg[0].addr; - sc->sc_frequency = 48000000; - sc->sc_uarttype = COM_UART_TI16750; - - if (bus_space_map(sc->sc_iot, sc->sc_iobase, - faa->fa_reg[0].size, 0, &sc->sc_ioh)) { - printf("%s: bus_space_map failed\n", __func__); - return; - } - - pinctrl_byname(faa->fa_node, "default"); - - com_attach_subr(sc); - - (void)arm_intr_establish_fdt(faa->fa_node, IPL_TTY, comintr, - sc, sc->sc_dev.dv_xname); -} - -int -omapuart_activate(struct device *self, int act) -{ - struct com_softc *sc = (struct com_softc *)self; - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - struct tty *tp = sc->sc_tty; - - switch (act) { - case DVACT_SUSPEND: - break; - case DVACT_RESUME: - if (sc->enabled) { - sc->sc_initialize = 1; - comparam(tp, &tp->t_termios); - bus_space_write_1(iot, ioh, com_ier, sc->sc_ier); - - if (ISSET(sc->sc_hwflags, COM_HW_SIR)) { - bus_space_write_1(iot, ioh, com_isr, - ISR_RECV); - } - } - break; - } - return 0; -}