36#include <sys/kernel.h>
37#include <sys/module.h>
41#include <sys/lockmgr.h>
42#include <sys/condvar.h>
45#include <dev/ofw/ofw_bus.h>
46#include <dev/ofw/ofw_bus_subr.h>
59#include <machine/bus.h>
60#include <machine/clock.h>
61#include <machine/resource.h>
63#include <powerpc/include/tlb.h>
65#include "opt_platform.h"
80 DEVMETHOD(device_suspend, bus_generic_suspend),
81 DEVMETHOD(device_resume, bus_generic_resume),
82 DEVMETHOD(device_shutdown, bus_generic_shutdown),
85 DEVMETHOD(bus_print_child, bus_generic_print_child),
104#define FSL_EHCI_REG_OFF 0x100
105#define FSL_EHCI_REG_SIZE 0x300
132#define SNOOP_RANGE_2GB 0x1E
150#define PORT_POWER_MASK 0x00001000
166enable_usb(device_t dev, bus_space_tag_t iot, bus_space_handle_t ioh)
175 node = ofw_bus_get_node(
dev);
177 (OF_getprop_alloc(node,
"phy_type", (
void **)&phy_type) > 0)) {
178 if (strncasecmp(phy_type,
"utmi", strlen(
"utmi")) == 0)
180 OF_prop_free(phy_type);
182 bus_space_write_4(iot, ioh,
CONTROL, tmp);
216 if (!ofw_bus_status_okay(
dev))
219 if (((ofw_bus_is_compatible(
dev,
"fsl-usb2-dr")) == 0) &&
220 ((ofw_bus_is_compatible(
dev,
"fsl-usb2-mph")) == 0))
223 device_set_desc(
dev,
"Freescale integrated EHCI controller");
225 return (BUS_PROBE_DEFAULT);
234 bus_space_handle_t ioh;
237 sc = device_get_softc(self);
250 sc->
sc_io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &
rid,
256 "Detach of the driver failed with error %d\n",
275 "Detach of the driver failed with error %d\n",
285 sc->
sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &
rid,
291 "Detach of the driver failed with error %d\n",
298 err = bus_setup_intr(self, sc->
sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
301 device_printf(self,
"Could not setup irq, %d\n", err);
306 "Detach of the driver failed with error %d\n",
313 sc->
sc_bus.
bdev = device_add_child(self,
"usbus", -1);
315 device_printf(self,
"Could not add USB device\n");
319 "Detach of the driver failed with error %d\n",
332 device_printf(self,
"Could not reset the controller\n");
336 "Detach of the driver failed with error %d\n",
359 err = device_probe_and_attach(sc->
sc_bus.
bdev);
363 device_printf(self,
"USB init failed err=%d\n", err);
367 "Detach of the driver failed with error %d\n",
383 sc = device_get_softc(self);
389 sc->
sc_flags &= ~EHCI_SCFLG_DONEINIT;
399 device_printf(self,
"Could not tear down irq, %d\n",
412 device_delete_children(self);
415 bus_release_resource(self, SYS_RES_IRQ, 0, sc->
sc_irq_res);
420 bus_release_resource(self, SYS_RES_MEMORY, 0, sc->
sc_io_res);
void ehci_interrupt(ehci_softc_t *sc)
void ehci_detach(ehci_softc_t *sc)
usb_error_t ehci_reset(ehci_softc_t *sc)
usb_error_t ehci_init(ehci_softc_t *sc)
#define EHCI_SCFLG_DONEINIT
#define EHCI_SCFLG_DONTRESET
#define EHCI_SCFLG_NORESTERM
usb_bus_mem_cb_t ehci_iterate_hw_softc
static void set_snooping(bus_space_tag_t iot, bus_space_handle_t ioh)
static void set_32b_prefetch(bus_space_tag_t iot, bus_space_handle_t ioh)
static int fsl_ehci_attach(device_t self)
static int fsl_ehci_probe(device_t self)
MODULE_DEPEND(ehci, usb, 1, 1, 1)
static void clear_port_power(ehci_softc_t *sc)
static void set_to_host_mode(ehci_softc_t *sc)
static int fsl_ehci_detach(device_t self)
static devclass_t ehci_devclass
DRIVER_MODULE(ehci, simplebus, ehci_driver, ehci_devclass, 0, 0)
static void enable_usb(device_t dev, bus_space_tag_t iot, bus_space_handle_t ioh)
static device_method_t ehci_methods[]
#define FSL_EHCI_REG_SIZE
static driver_t ehci_driver
struct usb_device * sc_devices[EHCI_MAX_DEVICES]
struct resource * sc_irq_res
bus_space_handle_t sc_io_hdl
struct resource * sc_io_res
bus_space_tag_t sc_io_tag
struct usb_device ** devices
#define USB_GET_DMA_TAG(dev)
uint8_t usb_bus_mem_alloc_all(struct usb_bus *bus, bus_dma_tag_t dmat, usb_bus_mem_cb_t *cb)