PERFORCE change 128579 for review
Andrew Turner
andrew at FreeBSD.org
Sat Nov 3 13:08:00 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=128579
Change 128579 by andrew at andrew_hermies on 2007/11/03 20:07:24
Implement the bus_setup_intr and bus_alloc_resource functions
Add the timer to the children to probe for in the s3c2410 bus driver
Probe and attach the children of the s3c2410 bus
Fix the s3c24x0_timer driver to use the updated bus_setup_intr
Affected files ...
.. //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2410.c#6 edit
.. //depot/projects/arm/src/sys/arm/s3c2xx0/s3c24x0_clk.c#3 edit
.. //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2xx0var.h#3 edit
Differences ...
==== //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2410.c#6 (text+ko) ====
@@ -55,7 +55,7 @@
/* prototypes */
static int s3c2410_probe(device_t);
-static void s3c2410_attach(device_t);
+static int s3c2410_attach(device_t);
static void s3c2410_identify(driver_t *, device_t);
static struct resource *s3c2410_alloc_resource(device_t, device_t, int, int *,
@@ -64,7 +64,7 @@
static int s3c2410_activate_resource(device_t, device_t, int, int,
struct resource *);
static int s3c2410_setup_intr(device_t, device_t, struct resource *, int,
- driver_intr_t *, void *, void **);
+ driver_filter_t *, driver_intr_t *, void *, void **);
static device_method_t s3c2410_methods[] = {
DEVMETHOD(device_probe, s3c2410_probe),
@@ -85,11 +85,28 @@
DRIVER_MODULE(s3c2410, nexus, s3c2410_driver, s3c2410_devclass, 0, 0);
+struct s3c2xx0_softc *s3c2xx0_softc = NULL;
+
static int
s3c2410_setup_intr(device_t dev, device_t child,
- struct resource *ires, int flags, driver_intr_t *intr, void *arg,
- void **cookiep)
+ struct resource *ires, int flags, driver_filter_t *filt,
+ driver_intr_t *intr, void *arg, void **cookiep)
{
+ int saved_cpsr;
+
+ if (flags & INTR_TYPE_TTY)
+ rman_set_start(ires, 15);
+ else if (flags & INTR_TYPE_CLK) {
+ if (rman_get_start(ires) == 0)
+ rman_set_start(ires, 26);
+ else
+ rman_set_start(ires, 27);
+ }
+ saved_cpsr = SetCPSR(I32_bit, I32_bit);
+
+ SetCPSR(I32_bit, saved_cpsr & I32_bit);
+ BUS_SETUP_INTR(device_get_parent(dev), child, ires, flags, filt,
+ intr, arg, cookiep);
return (0);
}
@@ -97,7 +114,14 @@
s3c2410_alloc_resource(device_t bus, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
{
- return (NULL);
+ struct resource *res;
+
+ res = rman_reserve_resource(&s3c2xx0_softc->s3c2xx0_rman, *rid, *rid,
+ count, flags, child);
+ if (res != NULL)
+ rman_set_rid(res, *rid);
+
+ return (res);
}
void
@@ -120,9 +144,7 @@
return 0;
}
-struct s3c2xx0_softc *s3c2xx0_softc = NULL;
-
-void
+int
s3c2410_attach(device_t dev)
{
struct s3c24x0_softc *sc = device_get_softc(dev);
@@ -169,7 +191,19 @@
printf("\n");
#endif
- /* get busdma tag for the platform */
+ /*
+ * Attach children devices
+ */
+ s3c2xx0_softc->s3c2xx0_rman.rm_type = RMAN_ARRAY;
+ s3c2xx0_softc->s3c2xx0_rman.rm_descr = "S3C2410 IRQs";
+ if (rman_init(&s3c2xx0_softc->s3c2xx0_rman) != 0 ||
+ rman_manage_region(&s3c2xx0_softc->s3c2xx0_rman, 0, 32) != 0)
+ panic("s3c2410_attach: failed to set up rman");
+ device_add_child(dev, "timer", 0);
+ bus_generic_probe(dev);
+ bus_generic_attach(dev);
+
+ return (0);
}
/*
==== //depot/projects/arm/src/sys/arm/s3c2xx0/s3c24x0_clk.c#3 (text+ko) ====
@@ -194,7 +194,7 @@
panic("Unable to setup the clock irq handler.\n");
else
bus_setup_intr(dev, irq, INTR_TYPE_CLK | INTR_FAST,
- hardintr, NULL, &ihl);
+ hardintr, NULL, NULL, &ihl);
/* set prescaler1 */
reg = bus_space_read_4(iot, ioh, TIMER_TCFG0);
==== //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2xx0var.h#3 (text+ko) ====
@@ -36,6 +36,7 @@
#define _ARM_S3C2XX0VAR_H_
#include <machine/bus.h>
+#include <sys/rman.h>
struct s3c2xx0_softc {
device_t sc_dev;
@@ -54,6 +55,8 @@
int sc_fclk; /* CPU clock */
int sc_hclk; /* AHB bus clock */
int sc_pclk; /* peripheral clock */
+
+ struct rman s3c2xx0_rman;
};
typedef void *s3c2xx0_chipset_tag_t;
More information about the p4-projects
mailing list