[PATCH 6/8] Add support for LPC32XX USB driver
Kevin Kirspel
kevin-kirspel at idexx.com
Fri Jan 27 05:32:24 UTC 2017
---
freebsd/sys/dev/usb/controller/ohci.h | 2 --
rtemsbsd/sys/dev/usb/controller/lpc_ohci.c | 19 ++++++++++++++++---
rtemsbsd/sys/dev/usb/usb_otg_transceiver.h | 1 +
3 files changed, 17 insertions(+), 5 deletions(-)
mode change 100644 => 100755 freebsd/sys/dev/usb/controller/ohci.h
mode change 100644 => 100755 rtemsbsd/sys/dev/usb/usb_otg_transceiver.h
diff --git a/freebsd/sys/dev/usb/controller/ohci.h b/freebsd/sys/dev/usb/controller/ohci.h
old mode 100644
new mode 100755
index d020d99..a650ce1
--- a/freebsd/sys/dev/usb/controller/ohci.h
+++ b/freebsd/sys/dev/usb/controller/ohci.h
@@ -234,9 +234,7 @@ typedef struct ohci_softc {
struct ohci_ed *sc_bulk_p_last;
struct ohci_ed *sc_isoc_p_last;
struct ohci_ed *sc_intr_p_last[OHCI_NO_EDS];
-#ifndef __rtems__
void *sc_intr_hdl;
-#endif /* __rtems__ */
device_t sc_dev;
bus_size_t sc_io_size;
bus_space_tag_t sc_io_tag;
diff --git a/rtemsbsd/sys/dev/usb/controller/lpc_ohci.c b/rtemsbsd/sys/dev/usb/controller/lpc_ohci.c
index 05c169a..4c6ef91 100755
--- a/rtemsbsd/sys/dev/usb/controller/lpc_ohci.c
+++ b/rtemsbsd/sys/dev/usb/controller/lpc_ohci.c
@@ -99,6 +99,7 @@ static void lpc_usb_host_clock_enable(device_t dev, struct ohci_softc *);
static void lpc_otg_status_and_control(device_t dev, struct ohci_softc *);
static rtems_interval lpc_usb_timeout_init(void);
static bool lpc_usb_timeout_not_expired(rtems_interval start);
+static void lpc_usb_delay(uint32_t ms);
static int lpc_otg_clk_ctrl(device_t dev, struct ohci_softc *sc, uint32_t otg_clk_ctrl);
static int lpc_otg_i2c_wait_for_receive_fifo_not_empty(struct ohci_softc *sc);
static int lpc_otg_i2c_wait_for_transaction_done(struct ohci_softc *sc);
@@ -192,6 +193,8 @@ lpc_ohci_attach(device_t dev)
if (eno != 0) {
goto fail;
}
+ //without the delay, _bsd_usbd_setup_device_desc: getting device descriptor at addr 2 failed, USB_ERR_IOERROR
+ lpc_usb_delay(10);
#endif /* BSP_USB_OTG_TRANSCEIVER_I2C_ADDR */
lpc_usb_host_clock_enable(dev, sc);
@@ -311,7 +314,17 @@ static bool lpc_usb_timeout_not_expired(rtems_interval start)
{
rtems_interval elapsed = rtems_clock_get_ticks_since_boot() - start;
- return elapsed < rtems_clock_get_ticks_per_second() / 10;
+ return elapsed < (rtems_clock_get_ticks_per_second() / 10);
+}
+
+static void lpc_usb_delay(uint32_t ms)
+{
+ rtems_interval end;
+
+ end = rtems_clock_get_ticks_since_boot() + RTEMS_MILLISECONDS_TO_TICKS(ms);
+ while (rtems_clock_get_ticks_since_boot() < end) {
+ /* Wait */
+ }
}
static int lpc_otg_clk_ctrl(device_t dev, struct ohci_softc *sc, uint32_t otg_clk_ctrl)
@@ -428,7 +441,7 @@ static int ohci_lpc_otg_transceiver_suspend(device_t dev, struct ohci_softc *sc)
}
static int
-ohci_lpc_resume(device_t dev)
+lpc_ohci_resume(device_t dev)
{
struct ohci_softc *sc = device_get_softc(dev);
int eno = 0;
@@ -475,7 +488,7 @@ static device_method_t lpc_ohci_methods[] = {
DEVMETHOD(device_attach, lpc_ohci_attach),
DEVMETHOD(device_detach, lpc_ohci_detach),
DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, ohci_lpc_resume),
+ DEVMETHOD(device_resume, lpc_ohci_resume),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
/* Bus interface */
diff --git a/rtemsbsd/sys/dev/usb/usb_otg_transceiver.h b/rtemsbsd/sys/dev/usb/usb_otg_transceiver.h
old mode 100644
new mode 100755
index 1e6b738..249d6a7
--- a/rtemsbsd/sys/dev/usb/usb_otg_transceiver.h
+++ b/rtemsbsd/sys/dev/usb/usb_otg_transceiver.h
@@ -88,6 +88,7 @@ struct usb_otg_transceiver {
uint16_t vendor_id;
uint16_t product_id;
uint8_t i2c_addr;
+ void* softc;
};
int usb_otg_transceiver_read(
--
1.9.1
More information about the devel
mailing list