PERFORCE change 71635 for review
John-Mark Gurney
jmg at FreeBSD.org
Tue Feb 22 23:06:12 PST 2005
http://perforce.freebsd.org/chv.cgi?CH=71635
Change 71635 by jmg at 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 <arm/ep93xx/ep93xxvar.h>
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);
}
/*
More information about the p4-projects
mailing list