summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/dev/usb/controller/saf1761_otg.c
diff options
context:
space:
mode:
Diffstat (limited to 'freebsd/sys/dev/usb/controller/saf1761_otg.c')
-rw-r--r--freebsd/sys/dev/usb/controller/saf1761_otg.c54
1 files changed, 52 insertions, 2 deletions
diff --git a/freebsd/sys/dev/usb/controller/saf1761_otg.c b/freebsd/sys/dev/usb/controller/saf1761_otg.c
index 3ce693b4..f9d28a63 100644
--- a/freebsd/sys/dev/usb/controller/saf1761_otg.c
+++ b/freebsd/sys/dev/usb/controller/saf1761_otg.c
@@ -44,14 +44,14 @@
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
-#include <rtems/bsd/sys/param.h>
+#include <sys/param.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
-#include <rtems/bsd/sys/lock.h>
+#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/sysctl.h>
@@ -82,6 +82,13 @@
#include <dev/usb/controller/saf1761_otg.h>
#include <dev/usb/controller/saf1761_otg_reg.h>
+#ifdef __rtems__
+#include <rtems.h>
+#include <bsp.h>
+#ifdef LIBBSP_ARM_ATSAM_BSP_H
+#include <bsp/pin-config.h>
+#endif /* LIBBSP_ARM_ATSAM_BSP_H */
+#endif /* __rtems__ */
#define SAF1761_OTG_BUS2SC(bus) \
((struct saf1761_otg_softc *)(((uint8_t *)(bus)) - \
@@ -518,7 +525,29 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t
DPRINTFN(5, "STATUS=0x%08x\n", status);
if (status & SOTG_PTD_DW3_ACTIVE) {
+#ifndef __rtems__
goto busy;
+#else /* __rtems__ */
+ temp = saf1761_peek_host_status_le_4(sc,
+ pdt_addr + SOTG_PTD_DW0);
+ if (temp & SOTG_PTD_DW0_VALID) {
+ goto busy;
+ } else {
+ status = saf1761_peek_host_status_le_4(sc,
+ pdt_addr + SOTG_PTD_DW3);
+
+ /* check if still active */
+ if (status & SOTG_PTD_DW3_ACTIVE) {
+ saf1761_host_channel_free(sc, td);
+ goto retry;
+ } else if (status & SOTG_PTD_DW3_HALTED) {
+ if (!(status & SOTG_PTD_DW3_ERRORS))
+ td->error_stall = 1;
+ td->error_any = 1;
+ goto complete;
+ }
+ }
+#endif /* __rtems__ */
} else if (status & SOTG_PTD_DW3_HALTED) {
if (!(status & SOTG_PTD_DW3_ERRORS))
td->error_stall = 1;
@@ -562,6 +591,9 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t
}
saf1761_host_channel_free(sc, td);
}
+#ifdef __rtems__
+retry:
+#endif /* __rtems__ */
if (saf1761_host_channel_alloc(sc, td))
goto busy;
@@ -1591,6 +1623,10 @@ saf1761_otg_filter_interrupt(void *arg)
(void) SAF1761_READ_LE_4(sc, SOTG_INT_PTD_DONE_PTD);
(void) SAF1761_READ_LE_4(sc, SOTG_ISO_PTD_DONE_PTD);
+#ifdef __rtems__
+ DPRINTFN(9, "HCINTERRUPT=0x%08x DCINTERRUPT=0x%08x\n", hcstat, status);
+
+#endif /* __rtems__ */
if (status & SOTG_DCINTERRUPT_IEPSOF) {
if ((sc->sc_host_async_busy_map[1] | sc->sc_host_async_busy_map[0] |
sc->sc_host_intr_busy_map[1] | sc->sc_host_intr_busy_map[0] |
@@ -1623,6 +1659,15 @@ saf1761_otg_filter_interrupt(void *arg)
USB_BUS_SPIN_UNLOCK(&sc->sc_bus);
+#ifdef __rtems__
+#ifdef LIBBSP_ARM_ATSAM_BSP_H
+ const Pio *saf_irq_pio = PIOC;
+ /* The PIOC is used only by the SAF1761. So we can just reset the status
+ * without any further handling. */
+ (void) saf_irq_pio->PIO_ISR;
+#endif /* LIBBSP_ARM_ATSAM_BSP_H */
+
+#endif /* __rtems__ */
return (retval);
}
@@ -2448,10 +2493,15 @@ saf1761_otg_init(struct saf1761_otg_softc *sc)
*/
SAF1761_WRITE_LE_4(sc, SOTG_CTRL_SET_CLR,
SOTG_CTRL_CLR(0xFFFF));
+#ifdef __rtems__
+ SAF1761_WRITE_LE_4(sc, SOTG_CTRL_SET_CLR,
+ SOTG_CTRL_SET(SOTG_CTRL_SEL_CP_EXT | SOTG_CTRL_VBUS_DRV));
+#else /* __rtems__ */
SAF1761_WRITE_LE_4(sc, SOTG_CTRL_SET_CLR,
SOTG_CTRL_SET(SOTG_CTRL_SW_SEL_HC_DC |
SOTG_CTRL_BDIS_ACON_EN | SOTG_CTRL_SEL_CP_EXT |
SOTG_CTRL_VBUS_DRV));
+#endif /* __rtems__ */
/* disable device address */
SAF1761_WRITE_LE_4(sc, SOTG_ADDRESS, 0);