Date: Thu, 17 Nov 2005 18:29:37 GMT From: Olivier Houchard <cognet@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 86881 for review Message-ID: <200511171829.jAHITbLw012588@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=86881 Change 86881 by cognet@cognet on 2005/11/17 18:29:03 Better interrupt stuff, it still lacks the PIO handling (yeek) Affected files ... .. //depot/projects/arm/src/sys/arm/at91/at91rm92.c#2 edit .. //depot/projects/arm/src/sys/arm/at91/at91rm92var.h#2 edit Differences ... ==== //depot/projects/arm/src/sys/arm/at91/at91rm92.c#2 (text+ko) ==== @@ -44,8 +44,6 @@ #include <arm/at91/at91rm92reg.h> #include <arm/at91/at91rm92var.h> -static int irqmask = 0; - static struct at91rm92_softc *at91rm92_softc; static int @@ -192,6 +190,7 @@ at91rm92_attach(device_t dev) { struct at91rm92_softc *sc = device_get_softc(dev); + int i; at91rm92_softc = sc; sc->sc_st = &at91rm92_bs_tag; @@ -200,16 +199,30 @@ sc->sc_irq_rman.rm_type = RMAN_ARRAY; sc->sc_irq_rman.rm_descr = "AT91RM92 IRQs"; if (bus_space_subregion(sc->sc_st, sc->sc_sh, AT91RM92_IC_BASE, - AT91RM92_IC_SIZE, &sc->sc_irq_sh) != 0) + AT91RM92_IC_SIZE, &sc->sc_sys_sh) != 0) panic("Enable to map IRQ registers"); if (rman_init(&sc->sc_irq_rman) != 0 || rman_manage_region(&sc->sc_irq_rman, 1, 31) != 0) panic("at91rm92_attach: failed to set up IRQ rman"); - /* Mask all interrupts. */ - bus_space_write_4(sc->sc_st, sc->sc_irq_sh, IC_IMR, 0); - /* Set the interrupt handler. */ - bus_space_write_4(sc->sc_st, sc->sc_irq_sh, IC_SPU, (uint32_t)irq_entry); + for (i = 0; i < 32; i++) { + bus_space_write_4(sc->sc_st, sc->sc_sys_sh, IC_SVR + + i * 4, i); + /* Priority. */ + /* XXX: Give better priorities to IRQs */ + bus_space_write_4(sc->sc_st, sc->sc_sys_sh, IC_SMR + i * 4, + 0); + if (i < 8) + bus_space_write_4(sc->sc_st, sc->sc_sys_sh, IC_EOICR, + 1); + + } + bus_space_write_4(sc->sc_st, sc->sc_sys_sh, IC_SPU, 32); + /* No debug. */ + bus_space_write_4(sc->sc_st, sc->sc_sys_sh, IC_DCR, 0); + /* Disable and clear all interrupts. */ + bus_space_write_4(sc->sc_st, sc->sc_sys_sh, IC_IDCR, 0xffffffff); + bus_space_write_4(sc->sc_st, sc->sc_sys_sh, IC_ICCR, 0xffffffff); device_add_child(dev, "at91rm92_timer", 0); bus_generic_probe(dev); bus_generic_attach(dev); @@ -243,8 +256,8 @@ BUS_SETUP_INTR(device_get_parent(dev), child, ires, flags, intr, arg, cookiep); - irqmask |= 1 << rman_get_start(ires); - bus_space_write_4(sc->sc_st, sc->sc_irq_sh, IC_IMR, irqmask); + bus_space_write_4(sc->sc_st, sc->sc_sys_sh, IC_IECR, + 1 << rman_get_start(ires)); return (0); } @@ -254,9 +267,8 @@ { struct at91rm92_softc *sc = device_get_softc(dev); - irqmask &= ~(1 << rman_get_start(res)); - bus_space_write_4(sc->sc_st, sc->sc_irq_sh, IC_IMR, irqmask); - + bus_space_write_4(sc->sc_st, sc->sc_sys_sh, IC_IDCR, + 1 << rman_get_start(res)); return (BUS_TEARDOWN_INTR(device_get_parent(dev), child, res, cookie)); } @@ -282,29 +294,36 @@ arm_mask_irq(uintptr_t nb) { - irqmask &= ~(1 << nb); bus_space_write_4(at91rm92_softc->sc_st, - at91rm92_softc->sc_irq_sh, IC_IMR, irqmask); + at91rm92_softc->sc_sys_sh, IC_IDCR, 1 << nb); } int arm_get_next_irq() { - int irq = bus_space_read_4(at91rm92_softc->sc_st, - at91rm92_softc->sc_irq_sh, IC_IPR); - irq &= irqmask; - return (ffs(irq) - 1); + int status; + int irq; + + irq = bus_space_read_4(at91rm92_softc->sc_st, + at91rm92_softc->sc_sys_sh, IC_IVR); + status = bus_space_read_4(at91rm92_softc->sc_st, + at91rm92_softc->sc_sys_sh, IC_ISR); + if (status == 0) { + bus_space_write_4(at91rm92_softc->sc_st, + at91rm92_softc->sc_sys_sh, IC_EOICR, 1); + return (-1); + } + return (irq); } void arm_unmask_irq(uintptr_t nb) { - irqmask |= 1 << nb; bus_space_write_4(at91rm92_softc->sc_st, - at91rm92_softc->sc_irq_sh, IC_IMR, irqmask); + at91rm92_softc->sc_sys_sh, IC_IECR, 1 << nb); } ==== //depot/projects/arm/src/sys/arm/at91/at91rm92var.h#2 (text+ko) ==== @@ -33,7 +33,7 @@ device_t dev; bus_space_tag_t sc_st; bus_space_handle_t sc_sh; - bus_space_handle_t sc_irq_sh; + bus_space_handle_t sc_sys_sh; struct rman sc_irq_rman; };
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200511171829.jAHITbLw012588>