diff options
author | imp <imp@FreeBSD.org> | 2012-07-10 04:17:49 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2012-07-10 04:17:49 +0000 |
commit | 06d108a4b9b6dfc32d9347085028a1d1c76ec75f (patch) | |
tree | 3a8f626a9f3fd210556c03ce787b6397d58cb2d4 /sys/arm/at91/at91.c | |
parent | af0280285fc0fa4162b42705fcdd4a09e9f9b842 (diff) | |
download | FreeBSD-src-06d108a4b9b6dfc32d9347085028a1d1c76ec75f.zip FreeBSD-src-06d108a4b9b6dfc32d9347085028a1d1c76ec75f.tar.gz |
Collapse all copies of at91_add_child into at91.c. They were
logically identical before today, and actually identical after today's
changes.
Diffstat (limited to 'sys/arm/at91/at91.c')
-rw-r--r-- | sys/arm/at91/at91.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/sys/arm/at91/at91.c b/sys/arm/at91/at91.c index 877b746..fc79da2 100644 --- a/sys/arm/at91/at91.c +++ b/sys/arm/at91/at91.c @@ -270,10 +270,12 @@ at91_attach(device_t dev) } - /* Our device list will be added automatically by the cpu device + /* + * Our device list will be added automatically by the cpu device * e.g. at91rm9200.c when it is identified. To ensure that the * CPU and PMC are attached first any other "identified" devices - * call BUS_ADD_CHILD(9) with an "order" of at least 2. */ + * call BUS_ADD_CHILD(9) with an "order" of at least 2. + */ bus_generic_probe(dev); bus_generic_attach(dev); @@ -471,6 +473,41 @@ at91_eoi(void *unused) IC_EOICR, 0); } +void +at91_add_child(device_t dev, int prio, const char *name, int unit, + bus_addr_t addr, bus_size_t size, int irq0, int irq1, int irq2) +{ + device_t kid; + struct at91_ivar *ivar; + + kid = device_add_child_ordered(dev, prio, name, unit); + if (kid == NULL) { + printf("Can't add child %s%d ordered\n", name, unit); + return; + } + ivar = malloc(sizeof(*ivar), M_DEVBUF, M_NOWAIT | M_ZERO); + if (ivar == NULL) { + device_delete_child(dev, kid); + printf("Can't add alloc ivar\n"); + return; + } + device_set_ivars(kid, ivar); + resource_list_init(&ivar->resources); + if (irq0 != -1) { + bus_set_resource(kid, SYS_RES_IRQ, 0, irq0, 1); + if (irq0 != AT91_IRQ_SYSTEM) + at91_pmc_clock_add(device_get_nameunit(kid), irq0, 0); + } + if (irq1 != 0) + bus_set_resource(kid, SYS_RES_IRQ, 1, irq1, 1); + if (irq2 != 0) + bus_set_resource(kid, SYS_RES_IRQ, 2, irq2, 1); + if (addr != 0 && addr < AT91_BASE) + addr += AT91_BASE; + if (addr != 0) + bus_set_resource(kid, SYS_RES_MEMORY, 0, addr, size); +} + static device_method_t at91_methods[] = { DEVMETHOD(device_probe, at91_probe), DEVMETHOD(device_attach, at91_attach), |