summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-09-08 06:13:07 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-09-08 06:13:07 +0000
commitca0e95ad08263d4dc7e121074eaa07dab6c07507 (patch)
tree2e5aff5de5e930da6d656442ff265e2406362348 /firmware
parentf1adafc05a12600e27c9366e2dd7033949e61c57 (diff)
downloadrockbox-ca0e95ad08263d4dc7e121074eaa07dab6c07507.tar.gz
rockbox-ca0e95ad08263d4dc7e121074eaa07dab6c07507.tar.bz2
rockbox-ca0e95ad08263d4dc7e121074eaa07dab6c07507.zip
USB AMSv2: use tables for usb_drv_port_speed() and usb_drv_mps_by_type()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28044 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/as3525/usb-drv-as3525v2.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/firmware/target/arm/as3525/usb-drv-as3525v2.c b/firmware/target/arm/as3525/usb-drv-as3525v2.c
index 335c3144fe..d87ccb5f87 100644
--- a/firmware/target/arm/as3525/usb-drv-as3525v2.c
+++ b/firmware/target/arm/as3525/usb-drv-as3525v2.c
@@ -640,34 +640,31 @@ void INT_USB(void)
int usb_drv_port_speed(void)
{
- switch(extract(DSTS, enumspd))
- {
- case DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ:
- return 1;
- case DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ:
- case DSTS_ENUMSPD_FS_PHY_48MHZ:
- return 0;
- break;
- case DSTS_ENUMSPD_LS_PHY_6MHZ:
- panicf("usb-drv: LS is not supported");
- return 0;
- default:
- panicf("usb-drv: wtf is this speed ?");
- return 0;
- }
+ static const uint8_t speed[4] = {
+ [DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ] = 1,
+ [DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ] = 0,
+ [DSTS_ENUMSPD_FS_PHY_48MHZ] = 0,
+ [DSTS_ENUMSPD_LS_PHY_6MHZ] = 0,
+ };
+
+ unsigned enumspd = extract(DSTS, enumspd);
+
+ if(enumspd == DSTS_ENUMSPD_LS_PHY_6MHZ)
+ panicf("usb-drv: LS is not supported");
+
+ return speed[enumspd & 3];
}
static unsigned long usb_drv_mps_by_type(int type)
{
- bool hs = usb_drv_port_speed();
- switch(type)
- {
- case USB_ENDPOINT_XFER_CONTROL: return 64;
- case USB_ENDPOINT_XFER_BULK: return hs ? 512 : 64;
- case USB_ENDPOINT_XFER_INT: return hs ? 1024 : 64;
- case USB_ENDPOINT_XFER_ISOC: return hs ? 1024 : 1023;
- default: return 0;
- }
+ static const uint16_t mps[4][2] = {
+ /* type fs hs */
+ [USB_ENDPOINT_XFER_CONTROL] = { 64, 64 },
+ [USB_ENDPOINT_XFER_ISOC] = { 1023, 1024 },
+ [USB_ENDPOINT_XFER_BULK] = { 64, 512 },
+ [USB_ENDPOINT_XFER_INT] = { 64, 1024 },
+ };
+ return mps[type & 3][usb_drv_port_speed() & 1];
}
int usb_drv_request_endpoint(int type, int dir)