From owner-p4-projects@FreeBSD.ORG Wed Jun 29 02:15:22 2011 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 30AD21065774; Wed, 29 Jun 2011 02:15:21 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B2AD106566C for ; Wed, 29 Jun 2011 02:15:21 +0000 (UTC) (envelope-from jceel@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 397928FC16 for ; Wed, 29 Jun 2011 02:15:21 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id p5T2FL47000446 for ; Wed, 29 Jun 2011 02:15:21 GMT (envelope-from jceel@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id p5T2FLPY000443 for perforce@freebsd.org; Wed, 29 Jun 2011 02:15:21 GMT (envelope-from jceel@freebsd.org) Date: Wed, 29 Jun 2011 02:15:21 GMT Message-Id: <201106290215.p5T2FLPY000443@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jceel@freebsd.org using -f From: Jakub Wojciech Klama To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 195493 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2011 02:15:22 -0000 http://p4web.freebsd.org/@@195493?ac=10 Change 195493 by jceel@jceel_cyclone on 2011/06/29 02:15:12 First version of USB OHCI host controller driver (broken). Affected files ... .. //depot/projects/soc2011/jceel_lpc/sys/arm/conf/EA3250#4 edit .. //depot/projects/soc2011/jceel_lpc/sys/arm/lpc/files.lpc#3 edit .. //depot/projects/soc2011/jceel_lpc/sys/arm/lpc/lpc_ohci.c#2 edit .. //depot/projects/soc2011/jceel_lpc/sys/boot/fdt/dts/ea3250.dts#3 edit Differences ... ==== //depot/projects/soc2011/jceel_lpc/sys/arm/conf/EA3250#4 (text+ko) ==== @@ -73,6 +73,15 @@ device bpf device lpe +# USB +options USB_DEBUG +device usb +device ohci +device umass +device scbus +device pass +device da + # Flattened Device Tree options FDT options FDT_DTB_STATIC ==== //depot/projects/soc2011/jceel_lpc/sys/arm/lpc/files.lpc#3 (text+ko) ==== @@ -10,5 +10,6 @@ arm/lpc/lpc_timer.c standard arm/lpc/lpc_rtc.c standard arm/lpc/if_lpe.c optional lpe +arm/lpc/lpc_ohci.c optional ohci dev/uart/uart_dev_ns8250.c optional uart kern/kern_clocksource.c standard ==== //depot/projects/soc2011/jceel_lpc/sys/arm/lpc/lpc_ohci.c#2 (text+ko) ==== @@ -27,15 +27,136 @@ #include __FBSDID("$FreeBSD$"); +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + + + static int lpc_ohci_probe(device_t dev); static int lpc_ohci_attach(device_t dev); +static int lpc_ohci_detach(device_t dev); +static int +lpc_ohci_probe(device_t dev) +{ + if (!ofw_bus_is_compatible(dev, "lpc,usb-ohci")) + return (ENXIO); + + device_set_desc(dev, "LPC32x0 USB OHCI controller"); + return (BUS_PROBE_DEFAULT); +} + +static int +lpc_ohci_attach(device_t dev) +{ + struct ohci_softc *sc = device_get_softc(dev); + int err; + int rid; + + sc->sc_bus.parent = dev; + sc->sc_bus.devices = sc->sc_devices; + sc->sc_bus.devices_max = OHCI_MAX_DEVICES; + + if (usb_bus_mem_alloc_all(&sc->sc_bus, USB_GET_DMA_TAG(dev), + &ohci_iterate_hw_softc)) + return (ENOMEM); + + rid = 0; + sc->sc_io_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); + if (!sc->sc_io_res) { + device_printf(dev, "cannot map register space\n"); + goto fail; + } + + sc->sc_io_tag = rman_get_bustag(sc->sc_io_res); + sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res); + sc->sc_io_size = rman_get_size(sc->sc_io_res); + + rid = 0; + sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); + if (sc->sc_irq_res == NULL) { + device_printf(dev, "cannot allocate interrupt\n"); + goto fail; + } + + sc->sc_bus.bdev = device_add_child(dev, "usbus", -1); + if (!(sc->sc_bus.bdev)) + goto fail; + + device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); + strlcpy(sc->sc_vendor, "NXP", sizeof(sc->sc_vendor)); + + err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, + NULL , (void *)ohci_interrupt, sc, &sc->sc_intr_hdl); + if (err) { + sc->sc_intr_hdl = NULL; + goto fail; + } + + bus_space_write_4(sc->sc_io_tag, sc->sc_io_hdl, + OHCI_CONTROL, 0); + + err = ohci_init(sc); + if (err) + goto fail; + + err = device_probe_and_attach(sc->sc_bus.bdev); + if (err) + goto fail; + + return (0); + +fail: + /* XXX */ + return (ENXIO); +} + +static int +lpc_ohci_detach(device_t dev) +{ + return (0); +} + + static device_method_t lpc_ohci_methods[] = { /* Device interface */ DEVMETHOD(device_probe, lpc_ohci_probe), DEVMETHOD(device_attach, lpc_ohci_attach), DEVMETHOD(device_detach, lpc_ohci_detach), - DEVMETHOD(device_shutdown, lpc_ohci_shutdown), + DEVMETHOD(device_shutdown, bus_generic_shutdown), /* Bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), ==== //depot/projects/soc2011/jceel_lpc/sys/boot/fdt/dts/ea3250.dts#3 (text+ko) ==== @@ -173,6 +173,13 @@ #size-cells = <1>; compatible = "simple-bus"; ranges = <0x0 0x30000000 0x10000000>; + + usb@1020000 { + compatible = "lpc,usb-ohci", "usb-ohci"; + reg = <0x1020000 0x20000>; + interrupts = <59>; + interrupt-parent = <&PIC>; + }; lpe@1060000 { compatible = "lpc,ethernet";