From 67fceb1ed80b1388f6181f05ce55e2889ab60e71 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Sun, 19 Jun 2016 14:27:36 +0000 Subject: dynamically attach omap uart with fdt --- sys/arch/armv7/conf/GENERIC | 4 ++-- sys/arch/armv7/conf/RAMDISK | 4 ++-- sys/arch/armv7/omap/files.omap | 4 ++-- sys/arch/armv7/omap/omap.c | 6 +----- sys/arch/armv7/omap/omap_com.c | 34 +++++++++++++++++++++++++++------- 5 files changed, 34 insertions(+), 18 deletions(-) (limited to 'sys/arch/armv7') diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC index 6c535e12ea7..7fb791b975d 100644 --- a/sys/arch/armv7/conf/GENERIC +++ b/sys/arch/armv7/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.22 2016/06/18 05:59:26 jsg Exp $ +# $OpenBSD: GENERIC,v 1.23 2016/06/19 14:27:35 jsg Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -73,7 +73,7 @@ gptimer* at omap? # general purpose timers dmtimer* at omap? # am335x dual mode timers omusbtll* at omap? cpsw* at omap? -com* at omap? # onboard uarts +com* at fdt? # onboard uarts ommmc* at fdt? # SD/MMC card controller sdmmc* at ommmc? # SD/MMC bus diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK index aaab98e8f61..6ed438c009d 100644 --- a/sys/arch/armv7/conf/RAMDISK +++ b/sys/arch/armv7/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.19 2016/06/18 05:59:26 jsg Exp $ +# $OpenBSD: RAMDISK,v 1.20 2016/06/19 14:27:35 jsg Exp $ machine armv7 arm @@ -72,7 +72,7 @@ gptimer* at omap? # general purpose timers dmtimer* at omap? # am335x dual mode timers omusbtll* at omap? cpsw* at omap? -com* at omap? # onboard uarts +com* at fdt? # onboard uarts ommmc* at fdt? # SD/MMC card controller sdmmc* at ommmc? # SD/MMC bus diff --git a/sys/arch/armv7/omap/files.omap b/sys/arch/armv7/omap/files.omap index 712aedf40f4..092b27e67b5 100644 --- a/sys/arch/armv7/omap/files.omap +++ b/sys/arch/armv7/omap/files.omap @@ -1,4 +1,4 @@ -# $OpenBSD: files.omap,v 1.9 2016/06/18 05:59:26 jsg Exp $ +# $OpenBSD: files.omap,v 1.10 2016/06/19 14:27:35 jsg Exp $ define omap {} device omap: omap @@ -65,7 +65,7 @@ attach ehci at omap with omehci file arch/armv7/omap/omehci.c omehci # NS16550 compatible serial ports -attach com at omap with com_omap +attach com at fdt with com_omap file arch/armv7/omap/omap_com.c com_omap device omusbtll diff --git a/sys/arch/armv7/omap/omap.c b/sys/arch/armv7/omap/omap.c index 30690dba403..67d407f60b7 100644 --- a/sys/arch/armv7/omap/omap.c +++ b/sys/arch/armv7/omap/omap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: omap.c,v 1.11 2016/06/18 05:59:26 jsg Exp $ */ +/* $OpenBSD: omap.c,v 1.12 2016/06/19 14:27:35 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn * @@ -48,7 +48,6 @@ struct board_dev beagleboard_devs[] = { { "omgpio", 3 }, { "omgpio", 4 }, { "omgpio", 5 }, - { "com", 2 }, /* UART3 */ { NULL, 0 } }; @@ -67,7 +66,6 @@ struct board_dev beaglebone_devs[] = { { "tiiic", 0 }, { "tiiic", 1 }, { "tiiic", 2 }, - { "com", 0 }, /* UART0 */ { "cpsw", 0 }, { NULL, 0 } }; @@ -84,7 +82,6 @@ struct board_dev overo_devs[] = { { "omgpio", 3 }, { "omgpio", 4 }, { "omgpio", 5 }, - { "com", 2 }, /* UART3 */ { NULL, 0 } }; @@ -98,7 +95,6 @@ struct board_dev pandaboard_devs[] = { { "omgpio", 3 }, { "omgpio", 4 }, { "omgpio", 5 }, - { "com", 2 }, /* UART3 */ { "ehci", 0 }, { NULL, 0 } }; diff --git a/sys/arch/armv7/omap/omap_com.c b/sys/arch/armv7/omap/omap_com.c index a7ee6ba427f..05aafdc2dde 100644 --- a/sys/arch/armv7/omap/omap_com.c +++ b/sys/arch/armv7/omap/omap_com.c @@ -1,4 +1,4 @@ -/* $OpenBSD: omap_com.c,v 1.3 2016/06/08 15:27:05 jsg Exp $ */ +/* $OpenBSD: omap_com.c,v 1.4 2016/06/19 14:27:35 jsg Exp $ */ /* * Copyright 2003 Wasabi Systems, Inc. * All rights reserved. @@ -41,6 +41,7 @@ #include #include +#include #include #include @@ -52,10 +53,12 @@ #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); @@ -63,7 +66,7 @@ extern int comcnspeed; extern int comcnmode; struct cfattach com_omap_ca = { - sizeof (struct com_softc), NULL, omapuart_attach, NULL, + sizeof (struct com_softc), omapuart_match, omapuart_attach, NULL, omapuart_activate }; @@ -83,26 +86,43 @@ omapuart_init_cons(void) 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"); +} + void omapuart_attach(struct device *parent, struct device *self, void *aux) { struct com_softc *sc = (struct com_softc *)self; - struct armv7_attach_args *aa = aux; + struct fdt_attach_args *faa = aux; + int irq; + + if (faa->fa_nreg != 2 || (faa->fa_nintr != 1 && faa->fa_nintr != 3)) + return; - sc->sc_iot = &armv7_a4x_bs_tag; /* XXX: This sucks */ - sc->sc_iobase = aa->aa_dev->mem[0].addr; + sc->sc_iot = &armv7_a4x_bs_tag; /* XXX: This sucks */ + sc->sc_iobase = faa->fa_reg[0]; sc->sc_frequency = 48000000; sc->sc_uarttype = COM_UART_TI16750; + if (faa->fa_nintr == 1) + irq = faa->fa_intr[0]; + else + irq = faa->fa_intr[1]; + if (bus_space_map(sc->sc_iot, sc->sc_iobase, - aa->aa_dev->mem[0].size, 0, &sc->sc_ioh)) { + faa->fa_reg[1], 0, &sc->sc_ioh)) { printf("%s: bus_space_map failed\n", __func__); return; } com_attach_subr(sc); - (void)arm_intr_establish(aa->aa_dev->irq[0], IPL_TTY, comintr, + (void)arm_intr_establish(irq, IPL_TTY, comintr, sc, sc->sc_dev.dv_xname); } -- cgit v1.2.3