From e46fbb9e3d9e328957a5586b9814995430a3157d Mon Sep 17 00:00:00 2001 From: ranma Date: Mon, 28 Jun 2010 09:46:13 +0000 Subject: [PATCH] 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 --- firmware/export/config.h | 6 +- firmware/export/config/sansac200v2.h | 1 + firmware/export/config/sansaclip.h | 1 + firmware/export/config/sansae200v2.h | 1 + firmware/export/config/sansafuze.h | 1 + firmware/export/config/sansam200v4.h | 1 + firmware/target/arm/as3525/usb-drv-as3525.c | 87 +++++++++-------------------- firmware/target/arm/as3525/usb-drv-as3525.h | 1 - 8 files changed, 34 insertions(+), 65 deletions(-) diff --git a/firmware/export/config.h b/firmware/export/config.h index c06e5d110..29d68cd10 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 99cd0d2f2..5115e9191 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 ac26d7eec..e0f1e2bd4 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 cdcb3e73e..f8a66ee05 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 af866d85e..7b7cdb028 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 69582bbaf..c25a9046e 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 aa323a62a..88ebf671e 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 ee3b4fcd0..960b02303 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; -- 2.11.4.GIT