From: jsg Date: Sat, 6 Aug 2016 10:07:45 +0000 (+0000) Subject: Dynamically attach intc(4) using the FDT and switch omap/am335x X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7d7522cb95ae6c81b099766f3d94463592f2e0a8;p=openbsd Dynamically attach intc(4) using the FDT and switch omap/am335x drivers that use the FDT over to the FDT interrupt establish API. ok kettenis@ --- diff --git a/share/man/man4/man4.armv7/intc.4 b/share/man/man4/man4.armv7/intc.4 index cc90e8ef454..e94b01dcf8c 100644 --- a/share/man/man4/man4.armv7/intc.4 +++ b/share/man/man4/man4.armv7/intc.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: intc.4,v 1.2 2014/09/19 17:17:04 jmc Exp $ +.\" $OpenBSD: intc.4,v 1.3 2016/08/06 10:07:45 jsg Exp $ .\" Copyright (c) 2014 Raphael Graf .\" .\" Permission to use, copy, modify, and distribute this software for any @@ -13,14 +13,14 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: September 19 2014 $ +.Dd $Mdocdate: August 6 2016 $ .Dt INTC 4 armv7 .Os .Sh NAME .Nm intc .Nd Texas Instruments interrupt controller device .Sh SYNOPSIS -.Cd "intc* at omap?" +.Cd "intc* at fdt?" .Sh DESCRIPTION The .Nm diff --git a/share/man/man4/man4.armv7/omap.4 b/share/man/man4/man4.armv7/omap.4 index c0897da9541..735bc146159 100644 --- a/share/man/man4/man4.armv7/omap.4 +++ b/share/man/man4/man4.armv7/omap.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: omap.4,v 1.4 2016/06/26 10:04:18 jsg Exp $ +.\" $OpenBSD: omap.4,v 1.5 2016/08/06 10:07:45 jsg Exp $ .\" Copyright (c) 2014 Sylvestre Gallon .\" .\" Permission to use, copy, modify, and distribute this software for any @@ -13,7 +13,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 26 2016 $ +.Dd $Mdocdate: August 6 2016 $ .Dt OMAP 4 armv7 .Os .Sh NAME @@ -38,8 +38,6 @@ Texas Instruments dual mode timer device Texas Instruments enhanced DMA device .It Xr gptimer 4 Texas Instruments general purpose timer device -.It Xr intc 4 -Texas Instruments interrupt controller device .It Xr omgpio 4 omap3, omap4 and am335x GPIO controller .It Xr prcm 4 diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC index b8d069dd49d..d11f539442c 100644 --- a/sys/arch/armv7/conf/GENERIC +++ b/sys/arch/armv7/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.40 2016/08/06 09:50:55 jsg Exp $ +# $OpenBSD: GENERIC,v 1.41 2016/08/06 10:07:45 jsg Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -61,7 +61,7 @@ omap0 at mainbus? omapid* at omap? # OMAP on-chip devices -intc* at omap? # OMAP3 interrupt controller +intc* at fdt? # OMAP3 interrupt controller #edma* at omap? # OMAP3 dma controller prcm* at omap? # power/clock controller sitaracm* at omap? # sitara control module diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK index a97e95e2069..a46d11ee966 100644 --- a/sys/arch/armv7/conf/RAMDISK +++ b/sys/arch/armv7/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.37 2016/08/06 09:50:55 jsg Exp $ +# $OpenBSD: RAMDISK,v 1.38 2016/08/06 10:07:45 jsg Exp $ machine armv7 arm @@ -60,7 +60,7 @@ omap0 at mainbus? omapid* at omap? # OMAP on-chip devices -intc* at omap? # OMAP3 interrupt controller +intc* at fdt? # OMAP3 interrupt controller #edma* at omap? # OMAP3 dma controller prcm* at omap? # power/clock controller sitaracm* at omap? # sitara control module diff --git a/sys/arch/armv7/omap/files.omap b/sys/arch/armv7/omap/files.omap index 9567097aff2..a8326a87cf0 100644 --- a/sys/arch/armv7/omap/files.omap +++ b/sys/arch/armv7/omap/files.omap @@ -1,4 +1,4 @@ -# $OpenBSD: files.omap,v 1.13 2016/06/26 09:06:35 jsg Exp $ +# $OpenBSD: files.omap,v 1.14 2016/08/06 10:07:45 jsg Exp $ define omap {} device omap: omap @@ -39,7 +39,7 @@ attach edma at omap file arch/armv7/omap/edma.c edma device intc -attach intc at omap +attach intc at fdt file arch/armv7/omap/intc.c intc device gptimer diff --git a/sys/arch/armv7/omap/if_cpsw.c b/sys/arch/armv7/omap/if_cpsw.c index 5566e476103..38f8a3374aa 100644 --- a/sys/arch/armv7/omap/if_cpsw.c +++ b/sys/arch/armv7/omap/if_cpsw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cpsw.c,v 1.38 2016/07/27 11:45:02 patrick Exp $ */ +/* $OpenBSD: if_cpsw.c,v 1.39 2016/08/06 10:07:45 jsg Exp $ */ /* $NetBSD: if_cpsw.c,v 1.3 2013/04/17 14:36:34 bouyer Exp $ */ /* @@ -338,20 +338,12 @@ cpsw_attach(struct device *parent, struct device *self, void *aux) int error; int node; u_int i; - uint32_t intr[4]; uint32_t memsize; char name[32]; - if (faa->fa_nreg < 1 || (faa->fa_nintr != 4 && faa->fa_nintr != 12)) + if (faa->fa_nreg < 1) return; - for (i = 0; i < 4; i++) { - if (faa->fa_nintr == 4) - intr[i] = faa->fa_intr[i]; - else - intr[i] = faa->fa_intr[(3 * i) + 1]; - } - /* * fa_reg[0].size is size of CPSW_SS and CPSW_PORT * fa_reg[1].size is size of CPSW_WR @@ -378,14 +370,14 @@ cpsw_attach(struct device *parent, struct device *self, void *aux) memcpy(sc->sc_ac.ac_enaddr, sc->sc_port_config[0].enaddr, ETHER_ADDR_LEN); - sc->sc_rxthih = arm_intr_establish(intr[0], IPL_NET, cpsw_rxthintr, sc, - DEVNAME(sc)); - sc->sc_rxih = arm_intr_establish(intr[1], IPL_NET, cpsw_rxintr, sc, - DEVNAME(sc)); - sc->sc_txih = arm_intr_establish(intr[2], IPL_NET, cpsw_txintr, sc, - DEVNAME(sc)); - sc->sc_miscih = arm_intr_establish(intr[3], IPL_NET, cpsw_miscintr, sc, - DEVNAME(sc)); + sc->sc_rxthih = arm_intr_establish_fdt_idx(faa->fa_node, 0, IPL_NET, + cpsw_rxthintr, sc, DEVNAME(sc)); + sc->sc_rxih = arm_intr_establish_fdt_idx(faa->fa_node, 1, IPL_NET, + cpsw_rxintr, sc, DEVNAME(sc)); + sc->sc_txih = arm_intr_establish_fdt_idx(faa->fa_node, 2, IPL_NET, + cpsw_txintr, sc, DEVNAME(sc)); + sc->sc_miscih = arm_intr_establish_fdt_idx(faa->fa_node, 3, IPL_NET, + cpsw_miscintr, sc, DEVNAME(sc)); sc->sc_bst = faa->fa_iot; sc->sc_bdt = faa->fa_dmat; diff --git a/sys/arch/armv7/omap/intc.c b/sys/arch/armv7/omap/intc.c index fcb63c2951d..6fb563266d0 100644 --- a/sys/arch/armv7/omap/intc.c +++ b/sys/arch/armv7/omap/intc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intc.c,v 1.5 2016/07/17 00:28:46 jsg Exp $ */ +/* $OpenBSD: intc.c,v 1.6 2016/08/06 10:07:45 jsg Exp $ */ /* * Copyright (c) 2007,2009 Dale Rahn * @@ -21,9 +21,13 @@ #include #include #include + #include +#include + #include +#include #include #include "intc.h" @@ -92,19 +96,23 @@ volatile int softint_pending; struct intrq intc_handler[INTC_MAX_IRQ]; u_int32_t intc_smask[NIPL]; u_int32_t intc_imask[INTC_MAX_BANKS][NIPL]; +struct interrupt_controller intc_ic; bus_space_tag_t intc_iot; bus_space_handle_t intc_ioh; int intc_nirq; +int intc_match(struct device *, void *, void *); void intc_attach(struct device *, struct device *, void *); int intc_spllower(int new); int intc_splraise(int new); void intc_setipl(int new); void intc_calc_mask(void); +void *intc_intr_establish_fdt(void *, int *, int, int (*)(void *), + void *, char *); struct cfattach intc_ca = { - sizeof (struct device), NULL, intc_attach + sizeof (struct device), intc_match, intc_attach }; struct cfdriver intc_cd = { @@ -113,21 +121,25 @@ struct cfdriver intc_cd = { int intc_attached = 0; +int +intc_match(struct device *parent, void *match, void *aux) +{ + struct fdt_attach_args *faa = aux; + + return (OF_is_compatible(faa->fa_node, "ti,omap3-intc") || + OF_is_compatible(faa->fa_node, "ti,am33xx-intc")); +} + void -intc_attach(struct device *parent, struct device *self, void *args) +intc_attach(struct device *parent, struct device *self, void *aux) { - struct armv7_attach_args *aa = args; + struct fdt_attach_args *faa = aux; int i; u_int32_t rev; - void *node; - node = fdt_find_node("/"); - if (node == NULL) - panic("%s: could not get fdt root node", __func__); - - intc_iot = aa->aa_iot; - if (bus_space_map(intc_iot, aa->aa_dev->mem[0].addr, - aa->aa_dev->mem[0].size, 0, &intc_ioh)) + intc_iot = faa->fa_iot; + if (bus_space_map(intc_iot, faa->fa_reg[0].addr, + faa->fa_reg[0].size, 0, &intc_ioh)) panic("intc_attach: bus_space_map failed!"); rev = bus_space_read_4(intc_iot, intc_ioh, INTC_REVISION); @@ -145,7 +157,7 @@ intc_attach(struct device *parent, struct device *self, void *args) bus_space_write_4(intc_iot, intc_ioh, INTC_SYSCONFIG, INTC_SYSCONFIG_AUTOIDLE); - if (fdt_is_compatible(node, "ti,am33xx")) + if (OF_is_compatible(faa->fa_node, "ti,am33xx-intc")) intc_nirq = 128; else intc_nirq = 96; @@ -175,6 +187,10 @@ intc_attach(struct device *parent, struct device *self, void *args) intc_setipl(IPL_HIGH); /* XXX ??? */ enable_interrupts(PSR_I); + + intc_ic.ic_node = faa->fa_node; + intc_ic.ic_establish = intc_intr_establish_fdt; + arm_intr_register_fdt(&intc_ic); } void @@ -374,6 +390,13 @@ intc_intr_establish(int irqno, int level, int (*func)(void *), return (ih); } +void * +intc_intr_establish_fdt(void *cookie, int *cell, int level, + int (*func)(void *), void *arg, char *name) +{ + return intc_intr_establish(cell[0], level, func, arg, name); +} + void intc_intr_disestablish(void *cookie) { diff --git a/sys/arch/armv7/omap/omap.c b/sys/arch/armv7/omap/omap.c index 8a8f0895313..1fb7c975ee4 100644 --- a/sys/arch/armv7/omap/omap.c +++ b/sys/arch/armv7/omap/omap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: omap.c,v 1.16 2016/07/10 03:04:00 jsg Exp $ */ +/* $OpenBSD: omap.c,v 1.17 2016/08/06 10:07:45 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn * @@ -40,7 +40,6 @@ struct cfdriver omap_cd = { struct board_dev omap3_dev[] = { { "prcm", 0 }, - { "intc", 0 }, { "gptimer", 0 }, { "gptimer", 1 }, { "omgpio", 0 }, @@ -55,7 +54,6 @@ struct board_dev omap3_dev[] = { struct board_dev am33xx_dev[] = { { "prcm", 0 }, { "sitaracm", 0 }, - { "intc", 0 }, { "edma", 0 }, { "dmtimer", 0 }, { "dmtimer", 1 }, diff --git a/sys/arch/armv7/omap/omap_com.c b/sys/arch/armv7/omap/omap_com.c index 20a51b493fd..610c6097134 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.8 2016/07/27 11:45:02 patrick Exp $ */ +/* $OpenBSD: omap_com.c,v 1.9 2016/08/06 10:07:45 jsg Exp $ */ /* * Copyright 2003 Wasabi Systems, Inc. * All rights reserved. @@ -102,9 +102,8 @@ omapuart_attach(struct device *parent, struct device *self, void *aux) { struct com_softc *sc = (struct com_softc *)self; struct fdt_attach_args *faa = aux; - int irq; - if (faa->fa_nreg != 1 || (faa->fa_nintr != 1 && faa->fa_nintr != 3)) + if (faa->fa_nreg < 1) return; sc->sc_iot = &armv7_a4x_bs_tag; /* XXX: This sucks */ @@ -112,11 +111,6 @@ omapuart_attach(struct device *parent, struct device *self, void *aux) 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, faa->fa_reg[0].size, 0, &sc->sc_ioh)) { printf("%s: bus_space_map failed\n", __func__); @@ -127,7 +121,7 @@ omapuart_attach(struct device *parent, struct device *self, void *aux) com_attach_subr(sc); - (void)arm_intr_establish(irq, IPL_TTY, comintr, + (void)arm_intr_establish_fdt(faa->fa_node, IPL_TTY, comintr, sc, sc->sc_dev.dv_xname); } diff --git a/sys/arch/armv7/omap/ommmc.c b/sys/arch/armv7/omap/ommmc.c index bf0451cae88..05f9647adc1 100644 --- a/sys/arch/armv7/omap/ommmc.c +++ b/sys/arch/armv7/omap/ommmc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ommmc.c,v 1.27 2016/07/27 11:45:02 patrick Exp $ */ +/* $OpenBSD: ommmc.c,v 1.28 2016/08/06 10:07:45 jsg Exp $ */ /* * Copyright (c) 2009 Dale Rahn @@ -299,11 +299,11 @@ ommmc_attach(struct device *parent, struct device *self, void *aux) struct fdt_attach_args *faa = aux; struct sdmmcbus_attach_args saa; uint32_t caps; - uint32_t addr, size, irq; + uint32_t addr, size; int len, unit; char hwmods[128]; - if (faa->fa_nreg != 1 || (faa->fa_nintr != 1 && faa->fa_nintr != 3)) + if (faa->fa_nreg < 1) return; if (faa->fa_reg[0].size <= 0x100) @@ -317,11 +317,6 @@ ommmc_attach(struct device *parent, struct device *self, void *aux) size = faa->fa_reg[0].size; } - if (faa->fa_nintr == 1) - irq = faa->fa_intr[0]; - else - irq = faa->fa_intr[1]; - unit = 0; if ((len = OF_getprop(faa->fa_node, "ti,hwmods", hwmods, sizeof(hwmods))) == 5) { @@ -341,7 +336,7 @@ ommmc_attach(struct device *parent, struct device *self, void *aux) /* Enable ICLKEN, FCLKEN? */ prcm_enablemodule(PRCM_MMC0 + unit); - sc->sc_ih = arm_intr_establish(irq, IPL_SDMMC, + sc->sc_ih = arm_intr_establish_fdt(faa->fa_node, IPL_SDMMC, ommmc_intr, sc, DEVNAME(sc)); if (sc->sc_ih == NULL) { printf("%s: cannot map interrupt\n", DEVNAME(sc)); diff --git a/sys/arch/armv7/omap/ti_iic.c b/sys/arch/armv7/omap/ti_iic.c index 046a822aab3..c50bee2665d 100644 --- a/sys/arch/armv7/omap/ti_iic.c +++ b/sys/arch/armv7/omap/ti_iic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ti_iic.c,v 1.7 2016/07/27 11:45:02 patrick Exp $ */ +/* $OpenBSD: ti_iic.c,v 1.8 2016/08/06 10:07:45 jsg Exp $ */ /* $NetBSD: ti_iic.c,v 1.4 2013/04/25 13:04:27 rkujawa Exp $ */ /* @@ -165,19 +165,14 @@ ti_iic_attach(struct device *parent, struct device *self, void *aux) struct fdt_attach_args *faa = aux; struct i2cbus_attach_args iba; uint16_t rev; - int irq, unit, len; + int unit, len; char hwmods[128]; - if (faa->fa_nreg != 1 || (faa->fa_nintr != 1 && faa->fa_nintr != 3)) + if (faa->fa_nreg < 1) return; sc->sc_iot = faa->fa_iot; sc->sc_node = faa->fa_node; - - if (faa->fa_nintr == 1) - irq = faa->fa_intr[0]; - else - irq = faa->fa_intr[1]; unit = 0; if ((len = OF_getprop(faa->fa_node, "ti,hwmods", hwmods, @@ -197,7 +192,7 @@ ti_iic_attach(struct device *parent, struct device *self, void *aux) sitara_cm_pinctrlbyname(faa->fa_node, "default"); - sc->sc_ih = arm_intr_establish(irq, IPL_NET, + sc->sc_ih = arm_intr_establish_fdt(faa->fa_node, IPL_NET, ti_iic_intr, sc, DEVNAME(sc)); prcm_enablemodule(PRCM_I2C0 + unit);