From owner-p4-projects@FreeBSD.ORG Thu Nov 17 18:29:48 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 80A0216A424; Thu, 17 Nov 2005 18:29:47 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 276DF16A41F for ; Thu, 17 Nov 2005 18:29:47 +0000 (GMT) (envelope-from cognet@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5423E43D70 for ; Thu, 17 Nov 2005 18:29:37 +0000 (GMT) (envelope-from cognet@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id jAHITbVS012591 for ; Thu, 17 Nov 2005 18:29:37 GMT (envelope-from cognet@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id jAHITbLw012588 for perforce@freebsd.org; Thu, 17 Nov 2005 18:29:37 GMT (envelope-from cognet@freebsd.org) Date: Thu, 17 Nov 2005 18:29:37 GMT Message-Id: <200511171829.jAHITbLw012588@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to cognet@freebsd.org using -f From: Olivier Houchard To: Perforce Change Reviews Cc: Subject: PERFORCE change 86881 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Nov 2005 18:29:48 -0000 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 #include -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; };