43#include <sys/stdint.h>
44#include <sys/stddef.h>
49#include <sys/kernel.h>
51#include <sys/module.h>
54#include <sys/condvar.h>
55#include <sys/sysctl.h>
57#include <sys/unistd.h>
58#include <sys/callout.h>
59#include <sys/malloc.h>
62#include <dev/ofw/ofw_bus.h>
63#include <dev/ofw/ofw_bus_subr.h>
78#if !defined(__aarch64__)
79#include <arm/mv/mvreg.h>
81#include <arm/mv/mvvar.h>
83#define EHCI_VENDORID_MRVL 0x1286
84#define EHCI_HC_DEVSTR "Marvell Integrated USB 2.0 controller"
95#define MV_USB_HOST_OFST 0x0100
97#define USB_BRIDGE_INTR_CAUSE 0x210
98#define USB_BRIDGE_INTR_MASK 0x214
99#define USB_BRIDGE_ERR_ADDR 0x21C
101#define MV_USB_ADDR_DECODE_ERR (1 << 0)
102#define MV_USB_HOST_UNDERFLOW (1 << 1)
103#define MV_USB_HOST_OVERFLOW (1 << 2)
104#define MV_USB_DEVICE_UNDERFLOW (1 << 3)
126 usbmode &= ~EHCI_UM_CM;
135 if (!ofw_bus_status_okay(self))
138 if (!ofw_bus_search_compatible(self,
compat_data)->ocd_data)
143 return (BUS_PROBE_DEFAULT);
151 bus_space_handle_t bsh;
161 hwtype = ofw_bus_search_compatible(self,
compat_data)->ocd_data;
163 device_printf(self,
"Wrong HW type flag detected\n");
174 sc->
sc_io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &
rid, RF_ACTIVE);
176 device_printf(self,
"Could not map memory\n");
191 panic(
"%s: unable to subregion USB host registers",
192 device_get_name(self));
196 irq_err = bus_alloc_resource_any(self, SYS_RES_IRQ, &
rid,
197 RF_SHAREABLE | RF_ACTIVE);
199 device_printf(self,
"Could not allocate error irq\n");
211 sc->
sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &
rid,
212 RF_SHAREABLE | RF_ACTIVE);
214 device_printf(self,
"Could not allocate irq\n");
218 sc->
sc_bus.
bdev = device_add_child(self,
"usbus", -1);
220 device_printf(self,
"Could not add USB device\n");
229 err = bus_setup_intr(self,
irq_err, INTR_TYPE_BIO,
232 device_printf(self,
"Could not setup error irq, %d\n", err);
242 err = bus_setup_intr(self, sc->
sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
245 device_printf(self,
"Could not setup irq, %d\n", err);
261 device_printf(self,
"5.24 GL USB-2 workaround enabled\n");
268 err = device_probe_and_attach(sc->
sc_bus.
bdev);
271 device_printf(self,
"USB init failed err=%d\n", err);
288 device_delete_children(self);
306 device_printf(self,
"Could not tear down irq, %d\n",
314 device_printf(self,
"Could not tear down irq, %d\n",
319 bus_release_resource(self, SYS_RES_IRQ, 0,
irq_err);
323 bus_release_resource(self, SYS_RES_IRQ, 1, sc->
sc_irq_res);
327 bus_release_resource(self, SYS_RES_MEMORY, 0,
344 printf(
"USB error: ");
349 printf(
"address decoding error (addr=%#x)\n",
addr);
352 printf(
"host underflow\n");
354 printf(
"host overflow\n");
356 printf(
"device underflow\n");
359 printf(
"unknown cause (cause=%#x)\n", cause);
363 return (FILTER_HANDLED);
371 DEVMETHOD(device_suspend, bus_generic_suspend),
372 DEVMETHOD(device_resume, bus_generic_resume),
373 DEVMETHOD(device_shutdown, bus_generic_shutdown),
void ehci_interrupt(ehci_softc_t *sc)
void ehci_detach(ehci_softc_t *sc)
usb_error_t ehci_init(ehci_softc_t *sc)
uint16_t ehci_get_port_speed_portsc(struct ehci_softc *sc, uint16_t index)
struct ehci_softc ehci_softc_t
#define EHCI_SCFLG_NORESTERM
#define EOWRITE4(sc, a, x)
usb_bus_mem_cb_t ehci_iterate_hw_softc
#define EWRITE4(sc, a, x)
#define USB_BRIDGE_INTR_MASK
#define USB_BRIDGE_INTR_CAUSE
#define USB_BRIDGE_ERR_ADDR
static int mv_ehci_probe(device_t self)
static struct resource * irq_err
#define MV_USB_ADDR_DECODE_ERR
static device_detach_t mv_ehci_detach
DRIVER_MODULE(ehci_mv, simplebus, ehci_driver, ehci_devclass, 0, 0)
#define MV_USB_HOST_UNDERFLOW
static devclass_t ehci_devclass
static struct ofw_compat_data compat_data[]
MODULE_DEPEND(ehci_mv, usb, 1, 1, 1)
#define MV_USB_DEVICE_UNDERFLOW
static device_method_t ehci_methods[]
static void mv_ehci_post_reset(struct ehci_softc *ehci_softc)
static device_attach_t mv_ehci_attach
static int err_intr(void *arg)
#define MV_USB_HOST_OVERFLOW
static driver_t ehci_driver
#define EHCI_USBMODE_NOLPM
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
void(* sc_vendor_post_reset)(struct ehci_softc *sc)
bus_space_tag_t sc_io_tag
uint16_t(* sc_vendor_get_port_speed)(struct ehci_softc *sc, uint16_t index)
struct usb_device ** devices
#define USB_GET_DMA_TAG(dev)
void usb_bus_mem_free_all(struct usb_bus *bus, usb_bus_mem_cb_t *cb)
uint8_t usb_bus_mem_alloc_all(struct usb_bus *bus, bus_dma_tag_t dmat, usb_bus_mem_cb_t *cb)