Enable HID support, clean up usb-drv-as3525.c a bit, add a workaround for weird Linux...
authorranma <ranma@a1c6a512-1295-4272-9138-f99709370657>
Mon, 28 Jun 2010 09:46:13 +0000 (28 09:46 +0000)
committerranma <ranma@a1c6a512-1295-4272-9138-f99709370657>
Mon, 28 Jun 2010 09:46:13 +0000 (28 09:46 +0000)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27164 a1c6a512-1295-4272-9138-f99709370657

firmware/export/config.h
firmware/export/config/sansac200v2.h
firmware/export/config/sansaclip.h
firmware/export/config/sansae200v2.h
firmware/export/config/sansafuze.h
firmware/export/config/sansam200v4.h
firmware/target/arm/as3525/usb-drv-as3525.c
firmware/target/arm/as3525/usb-drv-as3525.h

index c06e5d1..29d68cd 100644 (file)
@@ -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
 
index 99cd0d2..5115e91 100644 (file)
 //#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
index ac26d7e..e0f1e2b 100644 (file)
 #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
index cdcb3e7..f8a66ee 100644 (file)
 #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
index af866d8..7b7cdb0 100644 (file)
 #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
index 69582bb..c25a904 100644 (file)
 #define USE_ROCKBOX_USB
 #define USB_VENDOR_ID 0x0781
 #define USB_PRODUCT_ID 0x7431
+#define HAVE_USB_HID_MOUSE
 
 #define CONFIG_LCD LCD_SSD1815
 
index aa323a6..88ebf67 100644 (file)
@@ -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;
index ee3b4fc..960b023 100644 (file)
@@ -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;