diff options
author | Felipe Balbi <balbi@ti.com> | 2011-05-05 08:53:10 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-03-18 05:18:02 -0400 |
commit | 789451f6c698282d0745f265bde47173c9372867 (patch) | |
tree | 6ce8ccfe373fee12134fb3c97c1e93d8400ef802 /drivers/usb/dwc3 | |
parent | 5f71791947fcb1942df7d0df45520d420c2aee2b (diff) |
usb: dwc3: calculate the number of endpoints
hwparams2 holds the number of endpoints which
were selected during RTL generation, we can
use that on our driver.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc3')
-rw-r--r-- | drivers/usb/dwc3/core.c | 13 | ||||
-rw-r--r-- | drivers/usb/dwc3/core.h | 15 |
2 files changed, 28 insertions, 0 deletions
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index c6a46e0efe4f..66c05725daf3 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -260,6 +260,17 @@ static void dwc3_event_buffers_cleanup(struct dwc3 *dwc) | |||
260 | } | 260 | } |
261 | } | 261 | } |
262 | 262 | ||
263 | static void dwc3_core_num_eps(struct dwc3 *dwc) | ||
264 | { | ||
265 | struct dwc3_hwparams *parms = &dwc->hwparams; | ||
266 | |||
267 | dwc->num_in_eps = DWC3_NUM_IN_EPS(parms); | ||
268 | dwc->num_out_eps = DWC3_NUM_EPS(parms) - dwc->num_in_eps; | ||
269 | |||
270 | dev_vdbg(dwc->dev, "found %d IN and %d OUT endpoints\n", | ||
271 | dwc->num_in_eps, dwc->num_out_eps); | ||
272 | } | ||
273 | |||
263 | static void dwc3_cache_hwparams(struct dwc3 *dwc) | 274 | static void dwc3_cache_hwparams(struct dwc3 *dwc) |
264 | { | 275 | { |
265 | struct dwc3_hwparams *parms = &dwc->hwparams; | 276 | struct dwc3_hwparams *parms = &dwc->hwparams; |
@@ -336,6 +347,8 @@ static int dwc3_core_init(struct dwc3 *dwc) | |||
336 | if (dwc->revision < DWC3_REVISION_190A) | 347 | if (dwc->revision < DWC3_REVISION_190A) |
337 | reg |= DWC3_GCTL_U2RSTECN; | 348 | reg |= DWC3_GCTL_U2RSTECN; |
338 | 349 | ||
350 | dwc3_core_num_eps(dwc); | ||
351 | |||
339 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); | 352 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); |
340 | 353 | ||
341 | return 0; | 354 | return 0; |
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index ad2ffac71500..b42f71cb87dd 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -575,6 +575,14 @@ struct dwc3_hwparams { | |||
575 | /* HWPARAMS1 */ | 575 | /* HWPARAMS1 */ |
576 | #define DWC3_NUM_INT(n) (((n) & (0x3f << 15)) >> 15) | 576 | #define DWC3_NUM_INT(n) (((n) & (0x3f << 15)) >> 15) |
577 | 577 | ||
578 | /* HWPARAMS3 */ | ||
579 | #define DWC3_NUM_IN_EPS_MASK (0x1f << 18) | ||
580 | #define DWC3_NUM_EPS_MASK (0x3f << 12) | ||
581 | #define DWC3_NUM_EPS(p) (((p)->hwparams3 & \ | ||
582 | (DWC3_NUM_EPS_MASK)) >> 12) | ||
583 | #define DWC3_NUM_IN_EPS(p) (((p)->hwparams3 & \ | ||
584 | (DWC3_NUM_IN_EPS_MASK)) >> 18) | ||
585 | |||
578 | /* HWPARAMS7 */ | 586 | /* HWPARAMS7 */ |
579 | #define DWC3_RAM1_DEPTH(n) ((n) & 0xffff) | 587 | #define DWC3_RAM1_DEPTH(n) ((n) & 0xffff) |
580 | 588 | ||
@@ -641,6 +649,8 @@ struct dwc3_scratchpad_array { | |||
641 | * @u2pel: parameter from Set SEL request. | 649 | * @u2pel: parameter from Set SEL request. |
642 | * @u1sel: parameter from Set SEL request. | 650 | * @u1sel: parameter from Set SEL request. |
643 | * @u1pel: parameter from Set SEL request. | 651 | * @u1pel: parameter from Set SEL request. |
652 | * @num_out_eps: number of out endpoints | ||
653 | * @num_in_eps: number of in endpoints | ||
644 | * @ep0_next_event: hold the next expected event | 654 | * @ep0_next_event: hold the next expected event |
645 | * @ep0state: state of endpoint zero | 655 | * @ep0state: state of endpoint zero |
646 | * @link_state: link state | 656 | * @link_state: link state |
@@ -658,8 +668,10 @@ struct dwc3 { | |||
658 | dma_addr_t ep0_trb_addr; | 668 | dma_addr_t ep0_trb_addr; |
659 | dma_addr_t ep0_bounce_addr; | 669 | dma_addr_t ep0_bounce_addr; |
660 | struct dwc3_request ep0_usb_req; | 670 | struct dwc3_request ep0_usb_req; |
671 | |||
661 | /* device lock */ | 672 | /* device lock */ |
662 | spinlock_t lock; | 673 | spinlock_t lock; |
674 | |||
663 | struct device *dev; | 675 | struct device *dev; |
664 | 676 | ||
665 | struct platform_device *xhci; | 677 | struct platform_device *xhci; |
@@ -727,6 +739,9 @@ struct dwc3 { | |||
727 | 739 | ||
728 | u8 speed; | 740 | u8 speed; |
729 | 741 | ||
742 | u8 num_out_eps; | ||
743 | u8 num_in_eps; | ||
744 | |||
730 | void *mem; | 745 | void *mem; |
731 | 746 | ||
732 | struct dwc3_hwparams hwparams; | 747 | struct dwc3_hwparams hwparams; |