summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorTobias Diedrich <ranma+coreboot@tdiedrich.de>2010-06-28 09:46:13 +0000
committerTobias Diedrich <ranma+coreboot@tdiedrich.de>2010-06-28 09:46:13 +0000
commit31cf6d501338964538978f79be9a078deebdafdd (patch)
tree56ce91cccdc09adb33283f216e80c225d2a5a1ee /firmware
parentdf238bcaf5aa178cbbe96dae993ef054ddfb982c (diff)
downloadrockbox-31cf6d501338964538978f79be9a078deebdafdd.tar.gz
rockbox-31cf6d501338964538978f79be9a078deebdafdd.tar.bz2
rockbox-31cf6d501338964538978f79be9a078deebdafdd.zip
Enable HID support, clean up usb-drv-as3525.c a bit, add a workaround for weird Linux behaviour (don't have Windows to test with), we don't need to set up USB_PHY_EPx_INFO (OF doesn't bother either).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27164 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/config.h6
-rw-r--r--firmware/export/config/sansac200v2.h1
-rw-r--r--firmware/export/config/sansaclip.h1
-rw-r--r--firmware/export/config/sansae200v2.h1
-rw-r--r--firmware/export/config/sansafuze.h1
-rw-r--r--firmware/export/config/sansam200v4.h1
-rw-r--r--firmware/target/arm/as3525/usb-drv-as3525.c87
-rw-r--r--firmware/target/arm/as3525/usb-drv-as3525.h1
8 files changed, 34 insertions, 65 deletions
diff --git a/firmware/export/config.h b/firmware/export/config.h
index c06e5d110a..29d68cd100 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -907,7 +907,8 @@ Lyre prototype 1 */
#define USB_HAS_BULK
#elif (CONFIG_USBOTG == USBOTG_ARC) || \
(CONFIG_USBOTG == USBOTG_JZ4740) || \
- (CONFIG_USBOTG == USBOTG_M66591)
+ (CONFIG_USBOTG == USBOTG_M66591) || \
+ (CONFIG_USBOTG == USBOTG_AS3525)
#define USB_HAS_BULK
#define USB_HAS_INTERRUPT
#elif defined(CPU_TCC780X) || defined(CPU_TCC77X)
@@ -917,7 +918,8 @@ Lyre prototype 1 */
//#define USB_HAS_INTERRUPT -- seems to be broken
#endif /* CONFIG_USBOTG */
-#if CONFIG_USBOTG == USBOTG_ARC
+#if (CONFIG_USBOTG == USBOTG_ARC) || \
+ (CONFIG_USBOTG == USBOTG_AS3525)
#define USB_HAS_ISOCHRONOUS
#endif
diff --git a/firmware/export/config/sansac200v2.h b/firmware/export/config/sansac200v2.h
index 99cd0d2f2f..5115e91915 100644
--- a/firmware/export/config/sansac200v2.h
+++ b/firmware/export/config/sansac200v2.h
@@ -178,6 +178,7 @@
//#define USB_ENABLE_SERIAL
#define USB_VENDOR_ID 0x0781
#define USB_PRODUCT_ID 0x7452
+#define HAVE_USB_HID_MOUSE
/* Define this if you have adjustable CPU frequency */
#define HAVE_ADJUSTABLE_CPU_FREQ
diff --git a/firmware/export/config/sansaclip.h b/firmware/export/config/sansaclip.h
index ac26d7eec4..e0f1e2bd4e 100644
--- a/firmware/export/config/sansaclip.h
+++ b/firmware/export/config/sansaclip.h
@@ -172,6 +172,7 @@
#define USE_ROCKBOX_USB
#define USB_VENDOR_ID 0x0781
#define USB_PRODUCT_ID 0x7433
+#define HAVE_USB_HID_MOUSE
/* Define this if you have adjustable CPU frequency */
#define HAVE_ADJUSTABLE_CPU_FREQ
diff --git a/firmware/export/config/sansae200v2.h b/firmware/export/config/sansae200v2.h
index cdcb3e73e5..f8a66ee05e 100644
--- a/firmware/export/config/sansae200v2.h
+++ b/firmware/export/config/sansae200v2.h
@@ -191,6 +191,7 @@
#define USE_ROCKBOX_USB
#define USB_VENDOR_ID 0x0781
#define USB_PRODUCT_ID 0x7423
+#define HAVE_USB_HID_MOUSE
/* Define this if you have adjustable CPU frequency */
#define HAVE_ADJUSTABLE_CPU_FREQ
diff --git a/firmware/export/config/sansafuze.h b/firmware/export/config/sansafuze.h
index af866d85e1..7b7cdb0284 100644
--- a/firmware/export/config/sansafuze.h
+++ b/firmware/export/config/sansafuze.h
@@ -194,6 +194,7 @@
#define USE_ROCKBOX_USB
#define USB_VENDOR_ID 0x0781
#define USB_PRODUCT_ID 0x74c1
+#define HAVE_USB_HID_MOUSE
/* Define this if you have adjustable CPU frequency */
#define HAVE_ADJUSTABLE_CPU_FREQ
diff --git a/firmware/export/config/sansam200v4.h b/firmware/export/config/sansam200v4.h
index 69582bbafb..c25a9046ee 100644
--- a/firmware/export/config/sansam200v4.h
+++ b/firmware/export/config/sansam200v4.h
@@ -140,6 +140,7 @@
#define USE_ROCKBOX_USB
#define USB_VENDOR_ID 0x0781
#define USB_PRODUCT_ID 0x7431
+#define HAVE_USB_HID_MOUSE
#define CONFIG_LCD LCD_SSD1815
diff --git a/firmware/target/arm/as3525/usb-drv-as3525.c b/firmware/target/arm/as3525/usb-drv-as3525.c
index aa323a62ae..88ebf671ec 100644
--- a/firmware/target/arm/as3525/usb-drv-as3525.c
+++ b/firmware/target/arm/as3525/usb-drv-as3525.c
@@ -417,7 +417,6 @@ int usb_drv_recv(int ep, void *ptr, int len)
endpoints[ep][1].state |= EP_STATE_BUSY;
endpoints[ep][1].len = len;
endpoints[ep][1].rc = -1;
- endpoints[ep][1].timeout = current_tick + HZ;
/* remove data buffer from cache */
invalidate_dcache_range(ptr, len);
@@ -437,10 +436,9 @@ int usb_drv_recv(int ep, void *ptr, int len)
/* Make sure receive DMA is on */
if (!(USB_DEV_CTRL & USB_DEV_CTRL_RDE)){
- logf("enabling receive DMA\n");
USB_DEV_CTRL |= USB_DEV_CTRL_RDE;
if (!(USB_DEV_CTRL & USB_DEV_CTRL_RDE))
- logf("failed to enable!\n");
+ logf("failed to enable RDE!\n");
}
USB_OEP_CTRL(ep) |= USB_EP_CTRL_CNAK; /* Go! */
@@ -487,7 +485,15 @@ void ep_send(int ep, void *ptr, int len)
endpoints[ep][0].state |= EP_STATE_BUSY;
endpoints[ep][0].len = len;
endpoints[ep][0].rc = -1;
- endpoints[ep][0].timeout = current_tick + HZ;
+
+ /*
+ * I'm seeing a problem where Linux sends two SETUP requests,
+ * but fails to read the response from the first one.
+ * We then have the response we wanted to send still in our fifo,
+ * so flush the fifo before sending on the control endpoint.
+ */
+ if (ep == 0)
+ USB_IEP_CTRL(ep) |= USB_EP_CTRL_FLUSH;
/* Make sure data is committed to memory */
clean_dcache_range(ptr, len);
@@ -525,8 +531,8 @@ int usb_drv_send(int ep, void *ptr, int len)
}
ep_send(ep, ptr, len);
- while (endpoints[ep][0].state & EP_STATE_BUSY)
- wakeup_wait(&endpoints[ep][0].complete, TIMEOUT_BLOCK);
+ if (wakeup_wait(&endpoints[ep][0].complete, HZ) == OBJ_WAIT_TIMEDOUT)
+ logf("send timed out!\n");
return endpoints[ep][0].rc;
}
@@ -647,17 +653,6 @@ static void handle_out_ep(int ep)
logf("ep%d OUT, status %x\n", ep, ep_sts);
panicf("ep%d OUT 0x%x", ep, ep_sts);
}
-
-#if 0
- /* HW automatically disables RDE, re-enable it */
- /* THEORY: Because we only set up one DMA buffer... */
- USB_DEV_CTRL |= USB_DEV_CTRL_RDE;
-#endif
-
- if (!(USB_DEV_CTRL & USB_DEV_CTRL_RDE)){
- logf("receive DMA is disabled!\n");
- //USB_DEV_CTRL |= USB_DEV_CTRL_RDE;
- }
}
/*
@@ -678,8 +673,6 @@ static void usb_tick(void)
{
static int rde_timer = 0;
static int rde_fails = 0;
- struct usb_endpoint *eps = &endpoints[0][0];
- int i;
if (usb_enum_timeout != -1) {
/*
@@ -689,42 +682,24 @@ static void usb_tick(void)
usb_remove_int();
}
- for (i=0; i<2*USB_NUM_EPS; i++) {
- if (!(eps[i].state & EP_STATE_BUSY) ||
- !TIME_AFTER(current_tick, endpoints[i]))
- continue;
-
- /* recv or send timed out */
- if (eps[i].state & EP_STATE_ASYNC) {
- eps[i].rc = -1;
- wakeup_signal(&eps[i].complete);
- } else {
- usb_core_transfer_complete(i/2, i&1 ? USB_DIR_OUT : USB_DIR_IN,
- -1, 0);
- }
- eps[i].state &= ~(EP_STATE_BUSY|EP_STATE_ASYNC);
- }
-
if (USB_DEV_CTRL & USB_DEV_CTRL_RDE)
return;
- if (!(USB_DEV_STS & USB_DEV_STS_RXF_EMPTY)) {
- if (rde_timer == 0)
- logf("usb_tick: fifo got filled\n");
+ if (!(USB_DEV_STS & USB_DEV_STS_RXF_EMPTY))
rde_timer++;
- }
- if (rde_timer > 2) {
- logf("usb_tick: re-enabling RDE\n");
- USB_DEV_CTRL |= USB_DEV_CTRL_RDE;
- rde_timer = 0;
- if (USB_DEV_CTRL & USB_DEV_CTRL_RDE) {
- rde_fails = 0;
- } else {
- rde_fails++;
- if (rde_fails > 3)
- panicf("usb_tick: failed to set RDE");
- }
+ if (rde_timer < 2)
+ return;
+
+ logf("usb_tick: re-enabling RDE\n");
+ USB_DEV_CTRL |= USB_DEV_CTRL_RDE;
+ rde_timer = 0;
+ if (USB_DEV_CTRL & USB_DEV_CTRL_RDE) {
+ rde_fails = 0;
+ } else {
+ rde_fails++;
+ if (rde_fails > 3)
+ panicf("usb_tick: failed to set RDE");
}
}
@@ -806,18 +781,6 @@ void INT_USB(void)
if (spd == USB_DEV_STS_SPD_FS) logf("fs\n");
if (spd == USB_DEV_STS_SPD_LS) logf("ls\n");
- USB_PHY_EP0_INFO = 0x00200000 |
- USB_CSR_DIR_OUT |
- USB_CSR_TYPE_CTL;
- USB_PHY_EP1_INFO = 0x00200000 |
- USB_CSR_DIR_IN |
- USB_CSR_TYPE_CTL;
- USB_PHY_EP2_INFO = 0x00200001 |
- USB_CSR_DIR_IN |
- USB_CSR_TYPE_BULK;
- USB_PHY_EP3_INFO = 0x00200001 |
- USB_CSR_DIR_IN |
- USB_CSR_TYPE_BULK;
USB_DEV_CTRL |= USB_DEV_CTRL_APCSR_DONE;
USB_IEP_CTRL(0) |= USB_EP_CTRL_ACT;
USB_OEP_CTRL(0) |= USB_EP_CTRL_ACT;
diff --git a/firmware/target/arm/as3525/usb-drv-as3525.h b/firmware/target/arm/as3525/usb-drv-as3525.h
index ee3b4fcd03..960b023039 100644
--- a/firmware/target/arm/as3525/usb-drv-as3525.h
+++ b/firmware/target/arm/as3525/usb-drv-as3525.h
@@ -308,7 +308,6 @@ struct usb_dev_setup_buf {
struct usb_endpoint
{
unsigned int len;
- unsigned int timeout;
volatile unsigned int state;
int rc;
struct wakeup complete;