aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2011-10-10 12:38:10 -0400
committerFelipe Balbi <balbi@ti.com>2011-12-12 04:44:45 -0500
commitdd39c358dff41394f20b623fc68be857b6d702ad (patch)
tree138976e023ddff4bfaaed93de6bf9e2e8da02efa
parent7bb4fdc602c6cc763185d88f58ed75c84eb32158 (diff)
USB: ci13xxx_udc: handle controllers with less than 16 EPs
The ci13xxx_udc driver checks the number of endpoints in the udc controller, however some routines expect that the hardware has 16 bidirectional endpoints. This patch improves the driver to work on controllers with less than 16 endpoints like the udc controller found on freescale's mx23 and mx28. Tested-by: Pavankumar Kondeti <pkondeti@codeaurora.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.c16
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.h2
2 files changed, 15 insertions, 3 deletions
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
index 9db7e7667c2b..8956a2448b33 100644
--- a/drivers/usb/gadget/ci13xxx_udc.c
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -182,6 +182,16 @@ static inline int hw_ep_bit(int num, int dir)
182 return num + (dir ? 16 : 0); 182 return num + (dir ? 16 : 0);
183} 183}
184 184
185static int ep_to_bit(int n)
186{
187 int fill = 16 - hw_ep_max / 2;
188
189 if (n >= hw_ep_max / 2)
190 n += fill;
191
192 return n;
193}
194
185/** 195/**
186 * hw_aread: reads from register bitfield 196 * hw_aread: reads from register bitfield
187 * @addr: address relative to bus map 197 * @addr: address relative to bus map
@@ -440,12 +450,13 @@ static int hw_ep_get_halt(int num, int dir)
440/** 450/**
441 * hw_test_and_clear_setup_status: test & clear setup status (execute without 451 * hw_test_and_clear_setup_status: test & clear setup status (execute without
442 * interruption) 452 * interruption)
443 * @n: bit number (endpoint) 453 * @n: endpoint number
444 * 454 *
445 * This function returns setup status 455 * This function returns setup status
446 */ 456 */
447static int hw_test_and_clear_setup_status(int n) 457static int hw_test_and_clear_setup_status(int n)
448{ 458{
459 n = ep_to_bit(n);
449 return hw_ctest_and_clear(CAP_ENDPTSETUPSTAT, BIT(n)); 460 return hw_ctest_and_clear(CAP_ENDPTSETUPSTAT, BIT(n));
450} 461}
451 462
@@ -641,12 +652,13 @@ static int hw_register_write(u16 addr, u32 data)
641/** 652/**
642 * hw_test_and_clear_complete: test & clear complete status (execute without 653 * hw_test_and_clear_complete: test & clear complete status (execute without
643 * interruption) 654 * interruption)
644 * @n: bit number (endpoint) 655 * @n: endpoint number
645 * 656 *
646 * This function returns complete status 657 * This function returns complete status
647 */ 658 */
648static int hw_test_and_clear_complete(int n) 659static int hw_test_and_clear_complete(int n)
649{ 660{
661 n = ep_to_bit(n);
650 return hw_ctest_and_clear(CAP_ENDPTCOMPLETE, BIT(n)); 662 return hw_ctest_and_clear(CAP_ENDPTCOMPLETE, BIT(n));
651} 663}
652 664
diff --git a/drivers/usb/gadget/ci13xxx_udc.h b/drivers/usb/gadget/ci13xxx_udc.h
index 23707775cb43..f4871e1fac59 100644
--- a/drivers/usb/gadget/ci13xxx_udc.h
+++ b/drivers/usb/gadget/ci13xxx_udc.h
@@ -127,7 +127,7 @@ struct ci13xxx {
127 struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */ 127 struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */
128 u32 ep0_dir; /* ep0 direction */ 128 u32 ep0_dir; /* ep0 direction */
129#define ep0out ci13xxx_ep[0] 129#define ep0out ci13xxx_ep[0]
130#define ep0in ci13xxx_ep[16] 130#define ep0in ci13xxx_ep[hw_ep_max / 2]
131 u8 remote_wakeup; /* Is remote wakeup feature 131 u8 remote_wakeup; /* Is remote wakeup feature
132 enabled by the host? */ 132 enabled by the host? */
133 u8 suspended; /* suspended by the host */ 133 u8 suspended; /* suspended by the host */