From owner-p4-projects@FreeBSD.ORG Tue Oct 24 07:09:09 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D553516A40F; Tue, 24 Oct 2006 07:09:08 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9496F16A403 for ; Tue, 24 Oct 2006 07:09:08 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4C9FF43D4C for ; Tue, 24 Oct 2006 07:09:08 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k9O798Sm097718 for ; Tue, 24 Oct 2006 07:09:08 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k9O7977w097670 for perforce@freebsd.org; Tue, 24 Oct 2006 07:09:07 GMT (envelope-from imp@freebsd.org) Date: Tue, 24 Oct 2006 07:09:07 GMT Message-Id: <200610240709.k9O7977w097670@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 108332 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Oct 2006 07:09:09 -0000 http://perforce.freebsd.org/chv.cgi?CH=108332 Change 108332 by imp@imp_lighthouse on 2006/10/24 07:08:52 Do something, even if it is wrong, wrt obio Affected files ... .. //depot/projects/arm/src/sys/arm/at91/at91.c#22 edit .. //depot/projects/arm/src/sys/arm/at91/at91var.h#5 edit Differences ... ==== //depot/projects/arm/src/sys/arm/at91/at91.c#22 (text+ko) ==== @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -171,7 +172,7 @@ static int at91_probe(device_t dev) { - device_set_desc(dev, "AT91RM9200 device bus"); + device_set_desc(dev, "AT91 device bus"); return (0); } @@ -216,7 +217,7 @@ return; } device_set_ivars(kid, ivar); - resource_list_init(&ivar->resources); + resource_list_init(&ivar->obio.resources); if (irq0 != -1) bus_set_resource(kid, SYS_RES_IRQ, 0, irq0, 1); if (irq1 != 0) @@ -403,28 +404,29 @@ int i; at91_softc = sc; + sc->obio.sc_bt = &at91_bs_tag; sc->sc_st = &at91_bs_tag; sc->sc_sh = AT91RM92_BASE; - sc->dev = dev; + sc->obio.dev = dev; if (bus_space_subregion(sc->sc_st, sc->sc_sh, AT91RM92_SYS_BASE, AT91RM92_SYS_SIZE, &sc->sc_sys_sh) != 0) panic("Enable to map IRQ registers"); - sc->sc_irq_rman.rm_type = RMAN_ARRAY; - sc->sc_irq_rman.rm_descr = "AT91RM92 IRQs"; - sc->sc_mem_rman.rm_type = RMAN_ARRAY; - sc->sc_mem_rman.rm_descr = "AT91RM92 Memory"; + sc->obio.sc_irq_rman.rm_type = RMAN_ARRAY; + sc->obio.sc_irq_rman.rm_descr = "AT91RM92 IRQs"; + sc->obio.sc_mem_rman.rm_type = RMAN_ARRAY; + sc->obio.sc_mem_rman.rm_descr = "AT91RM92 Memory"; #if 0 sc->sc_usbmem_rman.rm_type = RMAN_ARRAY; sc->sc_usbmem_rman.rm_descr = "AT91RM92 USB Memory-mapped regs"; #endif - if (rman_init(&sc->sc_irq_rman) != 0 || - rman_manage_region(&sc->sc_irq_rman, 1, 31) != 0) + if (rman_init(&sc->obio.sc_irq_rman) != 0 || + rman_manage_region(&sc->obio.sc_irq_rman, 1, 31) != 0) panic("at91_attach: failed to set up IRQ rman"); - if (rman_init(&sc->sc_mem_rman) != 0 || - rman_manage_region(&sc->sc_mem_rman, 0xdff00000ul, + if (rman_init(&sc->obio.sc_mem_rman) != 0 || + rman_manage_region(&sc->obio.sc_mem_rman, 0xdff00000ul, 0xdffffffful) != 0) panic("at91_attach: failed to set up memory rman"); - if (rman_manage_region(&sc->sc_mem_rman, AT91RM92_OHCI_BASE, + if (rman_manage_region(&sc->obio.sc_mem_rman, AT91RM92_OHCI_BASE, AT91RM92_OHCI_BASE + AT91RM92_OHCI_SIZE - 1) != 0) panic("at91_attach: failed to set up ohci memory"); @@ -463,84 +465,6 @@ return (0); } -static struct resource * -at91_alloc_resource(device_t dev, device_t child, int type, int *rid, - u_long start, u_long end, u_long count, u_int flags) -{ - struct at91_softc *sc = device_get_softc(dev); - struct resource_list_entry *rle; - struct at91_ivar *ivar = device_get_ivars(child); - struct resource_list *rl = &ivar->resources; - - if (device_get_parent(child) != dev) - return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child, - type, rid, start, end, count, flags)); - - rle = resource_list_find(rl, type, *rid); - if (rle == NULL) - return (NULL); - if (rle->res) - panic("Resource rid %d type %d already in use", *rid, type); - if (start == 0UL && end == ~0UL) { - start = rle->start; - count = ulmax(count, rle->count); - end = ulmax(rle->end, start + count - 1); - } - switch (type) - { - case SYS_RES_IRQ: - rle->res = rman_reserve_resource(&sc->sc_irq_rman, - start, end, count, flags, child); - break; - case SYS_RES_MEMORY: -#if 0 - if (start >= 0x00300000 && start <= 0x003fffff) - rle->res = rman_reserve_resource(&sc->sc_usbmem_rman, - start, end, count, flags, child); - else -#endif - rle->res = rman_reserve_resource(&sc->sc_mem_rman, - start, end, count, flags, child); - rman_set_bustag(rle->res, &at91_bs_tag); - rman_set_bushandle(rle->res, start); - break; - } - if (rle->res) { - rle->start = rman_get_start(rle->res); - rle->end = rman_get_end(rle->res); - rle->count = count; - rman_set_rid(rle->res, *rid); - } - return (rle->res); -} - -static struct resource_list * -at91_get_resource_list(device_t dev, device_t child) -{ - struct at91_ivar *ivar; - - ivar = device_get_ivars(child); - return (&(ivar->resources)); -} - -static int -at91_release_resource(device_t dev, device_t child, int type, - int rid, struct resource *r) -{ - struct resource_list *rl; - struct resource_list_entry *rle; - - rl = at91_get_resource_list(dev, child); - if (rl == NULL) - return (EINVAL); - rle = resource_list_find(rl, type, rid); - if (rle == NULL) - return (EINVAL); - rman_release_resource(r); - rle->res = NULL; - return (0); -} - static int at91_setup_intr(device_t dev, device_t child, struct resource *ires, int flags, driver_intr_t *intr, void *arg, @@ -568,48 +492,6 @@ return (BUS_TEARDOWN_INTR(device_get_parent(dev), child, res, cookie)); } -static int -at91_activate_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ -#if 0 - u_long p; - int error; - - if (type == SYS_RES_MEMORY) { - error = bus_space_map(rman_get_bustag(r), - rman_get_bushandle(r), rman_get_size(r), 0, &p); - if (error) - return (error); - rman_set_bushandle(r, p); - } -#endif - return (rman_activate_resource(r)); -} - -static int -at91_print_child(device_t dev, device_t child) -{ - struct at91_ivar *ivars; - struct resource_list *rl; - int retval = 0; - - ivars = device_get_ivars(child); - rl = &ivars->resources; - - retval += bus_print_child_header(dev, child); - - retval += resource_list_print_type(rl, "port", SYS_RES_IOPORT, "%#lx"); - retval += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx"); - retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld"); - if (device_get_flags(dev)) - retval += printf(" flags %#x", device_get_flags(dev)); - - retval += bus_print_child_footer(dev, child); - - return (retval); -} - void arm_mask_irq(uintptr_t nb) { @@ -654,16 +536,16 @@ DEVMETHOD(device_attach, at91_attach), DEVMETHOD(device_identify, at91_identify), - DEVMETHOD(bus_alloc_resource, at91_alloc_resource), + DEVMETHOD(bus_alloc_resource, obio_alloc_resource), DEVMETHOD(bus_setup_intr, at91_setup_intr), DEVMETHOD(bus_teardown_intr, at91_teardown_intr), - DEVMETHOD(bus_activate_resource, at91_activate_resource), + DEVMETHOD(bus_activate_resource, obio_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_get_resource_list,at91_get_resource_list), + DEVMETHOD(bus_get_resource_list,obio_get_resource_list), DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), - DEVMETHOD(bus_release_resource, at91_release_resource), - DEVMETHOD(bus_print_child, at91_print_child), + DEVMETHOD(bus_release_resource, obio_release_resource), + DEVMETHOD(bus_print_child, obio_print_child), {0, 0}, }; ==== //depot/projects/arm/src/sys/arm/at91/at91var.h#5 (text+ko) ==== @@ -28,18 +28,17 @@ #define _AT91VAR_H_ #include +#include struct at91_softc { - device_t dev; + struct obio_softc obio; bus_space_tag_t sc_st; bus_space_handle_t sc_sh; bus_space_handle_t sc_sys_sh; - struct rman sc_irq_rman; - struct rman sc_mem_rman; }; struct at91_ivar { - struct resource_list resources; + struct obio_ivar obio; };