Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/usb/controller/ehci_mv.c
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
#include <dev/usb/usb_process.h> | #include <dev/usb/usb_process.h> | ||||
#include <dev/usb/usb_util.h> | #include <dev/usb/usb_util.h> | ||||
#include <dev/usb/usb_controller.h> | #include <dev/usb/usb_controller.h> | ||||
#include <dev/usb/usb_bus.h> | #include <dev/usb/usb_bus.h> | ||||
#include <dev/usb/controller/ehci.h> | #include <dev/usb/controller/ehci.h> | ||||
#include <dev/usb/controller/ehcireg.h> | #include <dev/usb/controller/ehcireg.h> | ||||
#if !defined(__aarch64__) | |||||
#include <arm/mv/mvreg.h> | #include <arm/mv/mvreg.h> | ||||
#endif | |||||
#include <arm/mv/mvvar.h> | #include <arm/mv/mvvar.h> | ||||
#define EHCI_VENDORID_MRVL 0x1286 | #define EHCI_VENDORID_MRVL 0x1286 | ||||
#define EHCI_HC_DEVSTR "Marvell Integrated USB 2.0 controller" | #define EHCI_HC_DEVSTR "Marvell Integrated USB 2.0 controller" | ||||
static device_attach_t mv_ehci_attach; | static device_attach_t mv_ehci_attach; | ||||
static device_detach_t mv_ehci_detach; | static device_detach_t mv_ehci_detach; | ||||
Show All 10 Lines | |||||
#define USB_BRIDGE_ERR_ADDR 0x21C | #define USB_BRIDGE_ERR_ADDR 0x21C | ||||
#define MV_USB_ADDR_DECODE_ERR (1 << 0) | #define MV_USB_ADDR_DECODE_ERR (1 << 0) | ||||
#define MV_USB_HOST_UNDERFLOW (1 << 1) | #define MV_USB_HOST_UNDERFLOW (1 << 1) | ||||
#define MV_USB_HOST_OVERFLOW (1 << 2) | #define MV_USB_HOST_OVERFLOW (1 << 2) | ||||
#define MV_USB_DEVICE_UNDERFLOW (1 << 3) | #define MV_USB_DEVICE_UNDERFLOW (1 << 3) | ||||
static struct ofw_compat_data compat_data[] = { | static struct ofw_compat_data compat_data[] = { | ||||
{"mrvl,usb-ehci", true}, | {"mrvl,usb-ehci", true}, | ||||
{"marvell,orion-ehci", true}, | {"marvell,orion-ehci", true}, | ||||
{"marvell,armada-3700-ehci", true}, | |||||
{NULL, false} | {NULL, false} | ||||
}; | }; | ||||
static void | static void | ||||
mv_ehci_post_reset(struct ehci_softc *ehci_softc) | mv_ehci_post_reset(struct ehci_softc *ehci_softc) | ||||
{ | { | ||||
uint32_t usbmode; | uint32_t usbmode; | ||||
/* Force HOST mode */ | /* Force HOST mode */ | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | mv_ehci_attach(device_t self) | ||||
*/ | */ | ||||
if (bus_space_subregion(sc->sc_io_tag, bsh, MV_USB_HOST_OFST, | if (bus_space_subregion(sc->sc_io_tag, bsh, MV_USB_HOST_OFST, | ||||
sc->sc_io_size, &sc->sc_io_hdl) != 0) | sc->sc_io_size, &sc->sc_io_hdl) != 0) | ||||
panic("%s: unable to subregion USB host registers", | panic("%s: unable to subregion USB host registers", | ||||
device_get_name(self)); | device_get_name(self)); | ||||
rid = 0; | rid = 0; | ||||
if (!ofw_bus_is_compatible(self, "marvell,orion-ehci")) { | if (!(ofw_bus_is_compatible(self, "marvell,orion-ehci") || | ||||
ofw_bus_is_compatible(self, "marvell,armada-3700-ehci"))) { | |||||
emaste: can we use `ofw_bus_search_compatible` here, as in D12258? | |||||
mwAuthorUnsubmitted Not Done Inline ActionsActually this code should be executed only for legacy devices using "mrvl,usb-ehci" compatible string, so ofw_bus_search_compatible is imo not sufficient. Would you like to invert the condition to: if ((ofw_bus_is_compatible(self, "mrvl,usb-ehci")) { or can we leave it as-is now? mw: Actually this code should be executed only for legacy devices using "mrvl,usb-ehci" compatible… | |||||
ianUnsubmitted Not Done Inline ActionsThe ocd_data field returned by ofw_bus_is_compatible() doesn't have to be just true/false. When you've got hardware that has a few small variations, you can use an enum with each compat string (see dev/sdhci/fsl_sdhci.c for an example). You could also do something like a set of bitmapped flags where different flag bits indicate different quirks. ian: The ocd_data field returned by ofw_bus_is_compatible() doesn't have to be just true/false. | |||||
irq_err = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid, | irq_err = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid, | ||||
RF_SHAREABLE | RF_ACTIVE); | RF_SHAREABLE | RF_ACTIVE); | ||||
if (irq_err == NULL) { | if (irq_err == NULL) { | ||||
device_printf(self, "Could not allocate error irq\n"); | device_printf(self, "Could not allocate error irq\n"); | ||||
mv_ehci_detach(self); | mv_ehci_detach(self); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
rid = 1; | rid = 1; | ||||
Show All 16 Lines | if (!sc->sc_bus.bdev) { | ||||
device_printf(self, "Could not add USB device\n"); | device_printf(self, "Could not add USB device\n"); | ||||
goto error; | goto error; | ||||
} | } | ||||
device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); | device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); | ||||
device_set_desc(sc->sc_bus.bdev, EHCI_HC_DEVSTR); | device_set_desc(sc->sc_bus.bdev, EHCI_HC_DEVSTR); | ||||
sprintf(sc->sc_vendor, "Marvell"); | sprintf(sc->sc_vendor, "Marvell"); | ||||
if (!ofw_bus_is_compatible(self, "marvell,orion-ehci")) { | if (!(ofw_bus_is_compatible(self, "marvell,orion-ehci") || | ||||
ofw_bus_is_compatible(self, "marvell,armada-3700-ehci"))) { | |||||
err = bus_setup_intr(self, irq_err, INTR_TYPE_BIO, | err = bus_setup_intr(self, irq_err, INTR_TYPE_BIO, | ||||
err_intr, NULL, sc, &ih_err); | err_intr, NULL, sc, &ih_err); | ||||
if (err) { | if (err) { | ||||
device_printf(self, "Could not setup error irq, %d\n", err); | device_printf(self, "Could not setup error irq, %d\n", err); | ||||
ih_err = NULL; | ih_err = NULL; | ||||
goto error; | goto error; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | |||||
static driver_t ehci_driver = { | static driver_t ehci_driver = { | ||||
"ehci", | "ehci", | ||||
ehci_methods, | ehci_methods, | ||||
sizeof(ehci_softc_t), | sizeof(ehci_softc_t), | ||||
}; | }; | ||||
static devclass_t ehci_devclass; | static devclass_t ehci_devclass; | ||||
DRIVER_MODULE(ehci, simplebus, ehci_driver, ehci_devclass, 0, 0); | DRIVER_MODULE(ehci_mv, simplebus, ehci_driver, ehci_devclass, 0, 0); | ||||
MODULE_DEPEND(ehci, usb, 1, 1, 1); | MODULE_DEPEND(ehci_mv, usb, 1, 1, 1); |
can we use ofw_bus_search_compatible here, as in D12258?