Create the children devices for the SoC in atmelarm bus node, not in

the identify routine of the CPU.
This commit is contained in:
Warner Losh 2012-07-12 04:23:11 +00:00
parent 0fb8b6b070
commit 7f6eecf580
6 changed files with 26 additions and 83 deletions

View File

@ -242,6 +242,18 @@ at91_identify(driver_t *drv, device_t parent)
BUS_ADD_CHILD(parent, 0, "atmelarm", 0);
}
static void
at91_cpu_add_builtin_children(device_t dev, const struct cpu_devs *walker)
{
int i;
for (i = 1; walker->name; i++, walker++) {
at91_add_child(dev, i, walker->name, walker->unit,
walker->mem_base, walker->mem_len, walker->irq0,
walker->irq1, walker->irq2);
}
}
static int
at91_attach(device_t dev)
{
@ -294,12 +306,10 @@ at91_attach(device_t dev)
bus_space_write_4(sc->sc_st, sc->sc_aic_sh, IC_IDCR, 0xffffffff);
bus_space_write_4(sc->sc_st, sc->sc_aic_sh, IC_ICCR, 0xffffffff);
/*
* 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.
*/
/*
* Add this device's children...
*/
at91_cpu_add_builtin_children(dev, soc_info.soc_data->soc_children);
bus_generic_probe(dev);
bus_generic_attach(dev);

View File

@ -137,19 +137,6 @@ static const struct cpu_devs at91_devs[] =
{ 0, 0, 0, 0, 0 }
};
static void
at91_cpu_add_builtin_children(device_t dev)
{
int i;
const struct cpu_devs *walker;
for (i = 1, walker = at91_devs; walker->name; i++, walker++) {
at91_add_child(dev, i, walker->name, walker->unit,
walker->mem_base, walker->mem_len, walker->irq0,
walker->irq1, walker->irq2);
}
}
static uint32_t
at91_pll_outb(int freq)
{
@ -164,10 +151,8 @@ static void
at91_identify(driver_t *drv, device_t parent)
{
if (at91_cpu_is(AT91_T_RM9200)) {
if (at91_cpu_is(AT91_T_RM9200))
at91_add_child(parent, 0, "at91rm920", 0, 0, 0, -1, 0, 0);
at91_cpu_add_builtin_children(parent);
}
}
static int
@ -258,6 +243,7 @@ static struct at91_soc_data soc_data = {
.soc_delay = at91_st_delay,
.soc_reset = at91_st_cpu_reset,
.soc_irq_prio = at91_irq_prio,
.soc_children = at91_devs,
};
AT91_SOC(AT91_T_RM9200, &soc_data);

View File

@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
#include <arm/at91/at91_rstreg.h>
struct at91sam9_softc {
device_t dev;
bus_space_tag_t sc_st;
bus_space_handle_t sc_sh;
bus_space_handle_t sc_matrix_sh;
@ -129,19 +128,6 @@ static const struct cpu_devs at91_devs[] =
{ 0, 0, 0, 0, 0 }
};
static void
at91_cpu_add_builtin_children(device_t dev)
{
int i;
const struct cpu_devs *walker;
for (i = 1, walker = at91_devs; walker->name; i++, walker++) {
at91_add_child(dev, i, walker->name, walker->unit,
walker->mem_base, walker->mem_len, walker->irq0,
walker->irq1, walker->irq2);
}
}
static uint32_t
at91_pll_outa(int freq)
{
@ -163,10 +149,8 @@ static void
at91_identify(driver_t *drv, device_t parent)
{
if (soc_info.type == AT91_T_SAM9260) {
if (soc_info.type == AT91_T_SAM9260)
at91_add_child(parent, 0, "at91sam9260", 0, 0, 0, -1, 0, 0);
at91_cpu_add_builtin_children(parent);
}
}
static int
@ -187,7 +171,6 @@ at91_attach(device_t dev)
sc->sc_st = at91sc->sc_st;
sc->sc_sh = at91sc->sc_sh;
sc->dev = dev;
if (bus_space_subregion(sc->sc_st, sc->sc_sh,
AT91SAM9260_MATRIX_BASE, AT91SAM9260_MATRIX_SIZE,
@ -269,6 +252,7 @@ static struct at91_soc_data soc_data = {
.soc_delay = at91_pit_delay,
.soc_reset = at91_rst_cpu_reset,
.soc_irq_prio = at91_irq_prio,
.soc_children = at91_devs,
};
AT91_SOC(AT91_T_SAM9260, &soc_data);

View File

@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
#include <arm/at91/at91_rstreg.h>
struct at91sam9_softc {
device_t dev;
bus_space_tag_t sc_st;
bus_space_handle_t sc_sh;
bus_space_handle_t sc_matrix_sh;
@ -129,19 +128,6 @@ static const struct cpu_devs at91_devs[] =
{ 0, 0, 0, 0, 0 }
};
static void
at91_cpu_add_builtin_children(device_t dev)
{
int i;
const struct cpu_devs *walker;
for (i = 1, walker = at91_devs; walker->name; i++, walker++) {
at91_add_child(dev, i, walker->name, walker->unit,
walker->mem_base, walker->mem_len, walker->irq0,
walker->irq1, walker->irq2);
}
}
static uint32_t
at91_pll_outa(int freq)
{
@ -170,10 +156,8 @@ static void
at91_identify(driver_t *drv, device_t parent)
{
if (at91_cpu_is(AT91_T_SAM9G20)) {
if (at91_cpu_is(AT91_T_SAM9G20))
at91_add_child(parent, 0, "at91sam", 9, 0, 0, -1, 0, 0);
at91_cpu_add_builtin_children(parent);
}
}
static int
@ -194,7 +178,6 @@ at91_attach(device_t dev)
sc->sc_st = at91sc->sc_st;
sc->sc_sh = at91sc->sc_sh;
sc->dev = dev;
if (bus_space_subregion(sc->sc_st, sc->sc_sh,
AT91SAM9G20_MATRIX_BASE, AT91SAM9G20_MATRIX_SIZE,
@ -267,6 +250,7 @@ static struct at91_soc_data soc_data = {
.soc_delay = at91_pit_delay,
.soc_reset = at91_rst_cpu_reset,
.soc_irq_prio = at91_irq_prio,
.soc_childpren = at91_devs,
};
AT91_SOC(AT91_T_SAM9G20, &soc_data);

View File

@ -48,9 +48,7 @@ __FBSDID("$FreeBSD$");
#include <arm/at91/at91_rstreg.h>
struct at91sam9x25_softc {
device_t dev;
bus_space_tag_t sc_st;
bus_space_handle_t sc_sh;
int filler;
};
/*
@ -131,19 +129,6 @@ static const struct cpu_devs at91_devs[] =
{ 0, 0, 0, 0, 0 }
};
static void
at91_cpu_add_builtin_children(device_t dev)
{
int i;
const struct cpu_devs *walker;
for (i = 1, walker = at91_devs; walker->name; i++, walker++) {
at91_add_child(dev, i, walker->name, walker->unit,
walker->mem_base, walker->mem_len, walker->irq0,
walker->irq1, walker->irq2);
}
}
static uint32_t
at91_pll_outa(int freq)
{
@ -172,10 +157,8 @@ static void
at91_identify(driver_t *drv, device_t parent)
{
if (soc_info.type == AT91_T_SAM9X5 && soc_info.subtype == AT91_ST_SAM9X25) {
if (soc_info.type == AT91_T_SAM9X5 && soc_info.subtype == AT91_ST_SAM9X25)
at91_add_child(parent, 0, "at91sam9x25", 0, 0, 0, -1, 0, 0);
at91_cpu_add_builtin_children(parent);
}
}
static int
@ -190,12 +173,6 @@ static int
at91_attach(device_t dev)
{
struct at91_pmc_clock *clk;
struct at91sam9x25_softc *sc = device_get_softc(dev);
struct at91_softc *at91sc = device_get_softc(device_get_parent(dev));
sc->sc_st = at91sc->sc_st;
sc->sc_sh = at91sc->sc_sh;
sc->dev = dev;
/* Update USB device port clock info */
clk = at91_pmc_clock_ref("udpck");
@ -255,6 +232,7 @@ static struct at91_soc_data soc_data = {
.soc_delay = at91_pit_delay,
.soc_reset = at91_rst_cpu_reset,
.soc_irq_prio = at91_irq_prio,
.soc_childpren = at91_devs,
};
AT91_SOC_SUB(AT91_T_SAM9X5, AT91_ST_SAM9X25, &soc_data);

View File

@ -109,6 +109,7 @@ struct at91_soc_data {
DELAY_t soc_delay;
cpu_reset_t soc_reset;
const int *soc_irq_prio;
const struct cpu_devs *soc_children;
};
struct at91_soc_info {