From owner-p4-projects@FreeBSD.ORG Wed Feb 23 07:06:11 2005 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5BD6216A4D0; Wed, 23 Feb 2005 07:06:11 +0000 (GMT) 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 077B216A4CE for ; Wed, 23 Feb 2005 07:06:11 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A612C43D1F for ; Wed, 23 Feb 2005 07:06:10 +0000 (GMT) (envelope-from jmg@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 j1N76AJN022001 for ; Wed, 23 Feb 2005 07:06:10 GMT (envelope-from jmg@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j1N76A7P021989 for perforce@freebsd.org; Wed, 23 Feb 2005 07:06:10 GMT (envelope-from jmg@freebsd.org) Date: Wed, 23 Feb 2005 07:06:10 GMT Message-Id: <200502230706.j1N76A7P021989@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jmg@freebsd.org using -f From: John-Mark Gurney To: Perforce Change Reviews Subject: PERFORCE change 71635 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Feb 2005 07:06:12 -0000 http://perforce.freebsd.org/chv.cgi?CH=71635 Change 71635 by jmg@jmg_carbon on 2005/02/23 07:05:27 fix up epclk to use the new resource system... the interrupt and timer resources are assigned via hints.. make attach return an int like it's suppose to, I guess we've been lucky... keep proper allocation of information when we setup the interrupt.. Affected files ... .. //depot/projects/arm/src/sys/arm/ep93xx/epclk.c#3 edit Differences ... ==== //depot/projects/arm/src/sys/arm/ep93xx/epclk.c#3 (text+ko) ==== @@ -69,7 +69,7 @@ #include static int epclk_probe(device_t); -static void epclk_attach(device_t); +static int epclk_attach(device_t); /* callback functions for intr_functions */ static void epclk_intr(void* arg); @@ -108,33 +108,52 @@ epclk_probe(device_t dev) { + if (device_get_unit(dev) != 0) + return ENXIO; + return 0; } struct epclk_softc { - bus_space_tag_t sc_iot; - bus_space_handle_t sc_ioh; - bus_space_handle_t sc_teoi_ioh; - device_t dev; + struct resource *sc_timerres; + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; + + struct resource *sc_irqres; + void *sc_irqcookie; + + bus_space_handle_t sc_teoi_ioh; + device_t dev; }; static struct epclk_softc *epclk; -static void +static int epclk_attach(device_t dev) { + int i; epclk = device_get_softc(dev); - epclk->sc_iot = &ep93xx_bs_tag; - epclk->sc_ioh = EP93XX_APB_VBASE; + + i = 0; + epclk->sc_timerres = bus_alloc_resource(dev, SYS_RES_MEMORY, &i, 0, ~0, + ~0, RF_ACTIVE); + + if (epclk->sc_timerres == NULL) + return ENXIO; + + epclk->sc_iot = rman_get_bustag(epclk->sc_timerres); + epclk->sc_ioh = rman_get_bushandle(epclk->sc_timerres); epclk->dev = dev; epclk->sc_teoi_ioh = EP93XX_APB_VBASE + EP93XX_APB_SYSCON + - EP93XX_SYSCON_TEOI; + EP93XX_SYSCON_TEOI; /* XXX - second memory res? */ /* clear and start the debug timer (Timer4) */ bus_space_write_4(epclk->sc_iot, epclk->sc_ioh, EP93XX_TIMERS_Timer4Enable, 0); bus_space_write_4(epclk->sc_iot, epclk->sc_ioh, EP93XX_TIMERS_Timer4Enable, 0x100); + + return 0; } static device_method_t epclk_methods[] = { @@ -161,7 +180,7 @@ { bus_space_write_4(epclk->sc_iot, epclk->sc_teoi_ioh, 0, 1); - hardclock((struct clockframe*) arg); + hardclock((struct clockframe *)arg); } @@ -173,9 +192,7 @@ void cpu_initclocks(void) { - struct resource *irq; - void *ihl; - int rid = 0; + int rid; stathz = profhz = 0; @@ -185,13 +202,15 @@ /* clear 64Hz interrupt status */ bus_space_write_4(epclk->sc_iot, epclk->sc_teoi_ioh, 0, 1); - irq = bus_alloc_resource(epclk->dev, SYS_RES_IRQ, &rid, 35, - 35, 1, RF_ACTIVE); - if (!irq) + rid = 0; + epclk->sc_irqres = bus_alloc_resource(epclk->dev, SYS_RES_IRQ, &rid, + 0, ~0, 1, RF_ACTIVE); + if (!epclk->sc_irqres) panic("Unable to setup the clock irq handler.\n"); else - bus_setup_intr(epclk->dev, irq, INTR_TYPE_CLK | INTR_FAST, - epclk_intr, NULL, &ihl); + bus_setup_intr(epclk->dev, epclk->sc_irqres, + INTR_TYPE_CLK | INTR_FAST, epclk_intr, NULL, + &epclk->sc_irqcookie); } /*