Beispiel #1
0
static 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 != AT91SAM9260_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 < AT91SAM9260_BASE) 
		addr += AT91SAM9260_BASE;
	if (addr != 0)
		bus_set_resource(kid, SYS_RES_MEMORY, 0, addr, size);
}
Beispiel #2
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);
    /*
     * Special case for on-board devices. These have their address
     * defined relative to AT91_PA_BASE in all the register files we
     * have. We could change this, but that's a lot of effort which
     * will be obsoleted when FDT arrives.
     */
    if (addr != 0 && addr < 0x10000000 && addr >= 0x0f000000)
        addr += AT91_PA_BASE;
    if (addr != 0)
        bus_set_resource(kid, SYS_RES_MEMORY, 0, addr, size);
}