diff options
Diffstat (limited to 'drivers/usb/dwc2')
-rw-r--r-- | drivers/usb/dwc2/core.h | 4 | ||||
-rw-r--r-- | drivers/usb/dwc2/gadget.c | 42 | ||||
-rw-r--r-- | drivers/usb/dwc2/params.c | 29 |
3 files changed, 25 insertions, 50 deletions
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index f66c94130cac..31749c79045f 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h | |||
@@ -537,6 +537,7 @@ struct dwc2_core_params { | |||
537 | * 2 - Internal DMA | 537 | * 2 - Internal DMA |
538 | * @power_optimized Are power optimizations enabled? | 538 | * @power_optimized Are power optimizations enabled? |
539 | * @num_dev_ep Number of device endpoints available | 539 | * @num_dev_ep Number of device endpoints available |
540 | * @num_dev_in_eps Number of device IN endpoints available | ||
540 | * @num_dev_perio_in_ep Number of device periodic IN endpoints | 541 | * @num_dev_perio_in_ep Number of device periodic IN endpoints |
541 | * available | 542 | * available |
542 | * @dev_token_q_depth Device Mode IN Token Sequence Learning Queue | 543 | * @dev_token_q_depth Device Mode IN Token Sequence Learning Queue |
@@ -565,6 +566,7 @@ struct dwc2_core_params { | |||
565 | * 2 - 8 or 16 bits | 566 | * 2 - 8 or 16 bits |
566 | * @snpsid: Value from SNPSID register | 567 | * @snpsid: Value from SNPSID register |
567 | * @dev_ep_dirs: Direction of device endpoints (GHWCFG1) | 568 | * @dev_ep_dirs: Direction of device endpoints (GHWCFG1) |
569 | * @g_tx_fifo_size[] Power-on values of TxFIFO sizes | ||
568 | */ | 570 | */ |
569 | struct dwc2_hw_params { | 571 | struct dwc2_hw_params { |
570 | unsigned op_mode:3; | 572 | unsigned op_mode:3; |
@@ -586,12 +588,14 @@ struct dwc2_hw_params { | |||
586 | unsigned fs_phy_type:2; | 588 | unsigned fs_phy_type:2; |
587 | unsigned i2c_enable:1; | 589 | unsigned i2c_enable:1; |
588 | unsigned num_dev_ep:4; | 590 | unsigned num_dev_ep:4; |
591 | unsigned num_dev_in_eps : 4; | ||
589 | unsigned num_dev_perio_in_ep:4; | 592 | unsigned num_dev_perio_in_ep:4; |
590 | unsigned total_fifo_size:16; | 593 | unsigned total_fifo_size:16; |
591 | unsigned power_optimized:1; | 594 | unsigned power_optimized:1; |
592 | unsigned utmi_phy_data_width:2; | 595 | unsigned utmi_phy_data_width:2; |
593 | u32 snpsid; | 596 | u32 snpsid; |
594 | u32 dev_ep_dirs; | 597 | u32 dev_ep_dirs; |
598 | u32 g_tx_fifo_size[MAX_EPS_CHANNELS]; | ||
595 | }; | 599 | }; |
596 | 600 | ||
597 | /* Size of control and EP0 buffers */ | 601 | /* Size of control and EP0 buffers */ |
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 88529d092503..e4c3ce0de5de 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c | |||
@@ -195,55 +195,18 @@ int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg) | |||
195 | { | 195 | { |
196 | if (hsotg->hw_params.en_multiple_tx_fifo) | 196 | if (hsotg->hw_params.en_multiple_tx_fifo) |
197 | /* In dedicated FIFO mode we need count of IN EPs */ | 197 | /* In dedicated FIFO mode we need count of IN EPs */ |
198 | return (dwc2_readl(hsotg->regs + GHWCFG4) & | 198 | return hsotg->hw_params.num_dev_in_eps; |
199 | GHWCFG4_NUM_IN_EPS_MASK) >> GHWCFG4_NUM_IN_EPS_SHIFT; | ||
200 | else | 199 | else |
201 | /* In shared FIFO mode we need count of Periodic IN EPs */ | 200 | /* In shared FIFO mode we need count of Periodic IN EPs */ |
202 | return hsotg->hw_params.num_dev_perio_in_ep; | 201 | return hsotg->hw_params.num_dev_perio_in_ep; |
203 | } | 202 | } |
204 | 203 | ||
205 | /** | 204 | /** |
206 | * dwc2_hsotg_ep_info_size - return Endpoint Info Control block size in DWORDs | ||
207 | */ | ||
208 | static int dwc2_hsotg_ep_info_size(struct dwc2_hsotg *hsotg) | ||
209 | { | ||
210 | int val = 0; | ||
211 | int i; | ||
212 | u32 ep_dirs; | ||
213 | |||
214 | /* | ||
215 | * Don't need additional space for ep info control registers in | ||
216 | * slave mode. | ||
217 | */ | ||
218 | if (!using_dma(hsotg)) { | ||
219 | dev_dbg(hsotg->dev, "Buffer DMA ep info size 0\n"); | ||
220 | return 0; | ||
221 | } | ||
222 | |||
223 | /* | ||
224 | * Buffer DMA mode - 1 location per endpoit | ||
225 | * Descriptor DMA mode - 4 locations per endpoint | ||
226 | */ | ||
227 | ep_dirs = hsotg->hw_params.dev_ep_dirs; | ||
228 | |||
229 | for (i = 0; i <= hsotg->hw_params.num_dev_ep; i++) { | ||
230 | val += ep_dirs & 3 ? 1 : 2; | ||
231 | ep_dirs >>= 2; | ||
232 | } | ||
233 | |||
234 | if (using_desc_dma(hsotg)) | ||
235 | val = val * 4; | ||
236 | |||
237 | return val; | ||
238 | } | ||
239 | |||
240 | /** | ||
241 | * dwc2_hsotg_tx_fifo_total_depth - return total FIFO depth available for | 205 | * dwc2_hsotg_tx_fifo_total_depth - return total FIFO depth available for |
242 | * device mode TX FIFOs | 206 | * device mode TX FIFOs |
243 | */ | 207 | */ |
244 | int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg) | 208 | int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg) |
245 | { | 209 | { |
246 | int ep_info_size; | ||
247 | int addr; | 210 | int addr; |
248 | int tx_addr_max; | 211 | int tx_addr_max; |
249 | u32 np_tx_fifo_size; | 212 | u32 np_tx_fifo_size; |
@@ -252,8 +215,7 @@ int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg) | |||
252 | hsotg->params.g_np_tx_fifo_size); | 215 | hsotg->params.g_np_tx_fifo_size); |
253 | 216 | ||
254 | /* Get Endpoint Info Control block size in DWORDs. */ | 217 | /* Get Endpoint Info Control block size in DWORDs. */ |
255 | ep_info_size = dwc2_hsotg_ep_info_size(hsotg); | 218 | tx_addr_max = hsotg->hw_params.total_fifo_size; |
256 | tx_addr_max = hsotg->hw_params.total_fifo_size - ep_info_size; | ||
257 | 219 | ||
258 | addr = hsotg->params.g_rx_fifo_size + np_tx_fifo_size; | 220 | addr = hsotg->params.g_rx_fifo_size + np_tx_fifo_size; |
259 | if (tx_addr_max <= addr) | 221 | if (tx_addr_max <= addr) |
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index ef73af6e03a9..03fd20f0b496 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c | |||
@@ -484,8 +484,7 @@ static void dwc2_check_param_tx_fifo_sizes(struct dwc2_hsotg *hsotg) | |||
484 | } | 484 | } |
485 | 485 | ||
486 | for (fifo = 1; fifo <= fifo_count; fifo++) { | 486 | for (fifo = 1; fifo <= fifo_count; fifo++) { |
487 | dptxfszn = (dwc2_readl(hsotg->regs + DPTXFSIZN(fifo)) & | 487 | dptxfszn = hsotg->hw_params.g_tx_fifo_size[fifo]; |
488 | FIFOSIZE_DEPTH_MASK) >> FIFOSIZE_DEPTH_SHIFT; | ||
489 | 488 | ||
490 | if (hsotg->params.g_tx_fifo_size[fifo] < min || | 489 | if (hsotg->params.g_tx_fifo_size[fifo] < min || |
491 | hsotg->params.g_tx_fifo_size[fifo] > dptxfszn) { | 490 | hsotg->params.g_tx_fifo_size[fifo] > dptxfszn) { |
@@ -609,6 +608,7 @@ static void dwc2_get_dev_hwparams(struct dwc2_hsotg *hsotg) | |||
609 | struct dwc2_hw_params *hw = &hsotg->hw_params; | 608 | struct dwc2_hw_params *hw = &hsotg->hw_params; |
610 | bool forced; | 609 | bool forced; |
611 | u32 gnptxfsiz; | 610 | u32 gnptxfsiz; |
611 | int fifo, fifo_count; | ||
612 | 612 | ||
613 | if (hsotg->dr_mode == USB_DR_MODE_HOST) | 613 | if (hsotg->dr_mode == USB_DR_MODE_HOST) |
614 | return; | 614 | return; |
@@ -617,6 +617,14 @@ static void dwc2_get_dev_hwparams(struct dwc2_hsotg *hsotg) | |||
617 | 617 | ||
618 | gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ); | 618 | gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ); |
619 | 619 | ||
620 | fifo_count = dwc2_hsotg_tx_fifo_count(hsotg); | ||
621 | |||
622 | for (fifo = 1; fifo <= fifo_count; fifo++) { | ||
623 | hw->g_tx_fifo_size[fifo] = | ||
624 | (dwc2_readl(hsotg->regs + DPTXFSIZN(fifo)) & | ||
625 | FIFOSIZE_DEPTH_MASK) >> FIFOSIZE_DEPTH_SHIFT; | ||
626 | } | ||
627 | |||
620 | if (forced) | 628 | if (forced) |
621 | dwc2_clear_force_mode(hsotg); | 629 | dwc2_clear_force_mode(hsotg); |
622 | 630 | ||
@@ -661,14 +669,6 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) | |||
661 | hwcfg4 = dwc2_readl(hsotg->regs + GHWCFG4); | 669 | hwcfg4 = dwc2_readl(hsotg->regs + GHWCFG4); |
662 | grxfsiz = dwc2_readl(hsotg->regs + GRXFSIZ); | 670 | grxfsiz = dwc2_readl(hsotg->regs + GRXFSIZ); |
663 | 671 | ||
664 | /* | ||
665 | * Host specific hardware parameters. Reading these parameters | ||
666 | * requires the controller to be in host mode. The mode will | ||
667 | * be forced, if necessary, to read these values. | ||
668 | */ | ||
669 | dwc2_get_host_hwparams(hsotg); | ||
670 | dwc2_get_dev_hwparams(hsotg); | ||
671 | |||
672 | /* hwcfg1 */ | 672 | /* hwcfg1 */ |
673 | hw->dev_ep_dirs = hwcfg1; | 673 | hw->dev_ep_dirs = hwcfg1; |
674 | 674 | ||
@@ -711,6 +711,8 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) | |||
711 | hw->en_multiple_tx_fifo = !!(hwcfg4 & GHWCFG4_DED_FIFO_EN); | 711 | hw->en_multiple_tx_fifo = !!(hwcfg4 & GHWCFG4_DED_FIFO_EN); |
712 | hw->num_dev_perio_in_ep = (hwcfg4 & GHWCFG4_NUM_DEV_PERIO_IN_EP_MASK) >> | 712 | hw->num_dev_perio_in_ep = (hwcfg4 & GHWCFG4_NUM_DEV_PERIO_IN_EP_MASK) >> |
713 | GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT; | 713 | GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT; |
714 | hw->num_dev_in_eps = (hwcfg4 & GHWCFG4_NUM_IN_EPS_MASK) >> | ||
715 | GHWCFG4_NUM_IN_EPS_SHIFT; | ||
714 | hw->dma_desc_enable = !!(hwcfg4 & GHWCFG4_DESC_DMA); | 716 | hw->dma_desc_enable = !!(hwcfg4 & GHWCFG4_DESC_DMA); |
715 | hw->power_optimized = !!(hwcfg4 & GHWCFG4_POWER_OPTIMIZ); | 717 | hw->power_optimized = !!(hwcfg4 & GHWCFG4_POWER_OPTIMIZ); |
716 | hw->utmi_phy_data_width = (hwcfg4 & GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK) >> | 718 | hw->utmi_phy_data_width = (hwcfg4 & GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK) >> |
@@ -719,6 +721,13 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) | |||
719 | /* fifo sizes */ | 721 | /* fifo sizes */ |
720 | hw->rx_fifo_size = (grxfsiz & GRXFSIZ_DEPTH_MASK) >> | 722 | hw->rx_fifo_size = (grxfsiz & GRXFSIZ_DEPTH_MASK) >> |
721 | GRXFSIZ_DEPTH_SHIFT; | 723 | GRXFSIZ_DEPTH_SHIFT; |
724 | /* | ||
725 | * Host specific hardware parameters. Reading these parameters | ||
726 | * requires the controller to be in host mode. The mode will | ||
727 | * be forced, if necessary, to read these values. | ||
728 | */ | ||
729 | dwc2_get_host_hwparams(hsotg); | ||
730 | dwc2_get_dev_hwparams(hsotg); | ||
722 | 731 | ||
723 | return 0; | 732 | return 0; |
724 | } | 733 | } |