aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc2/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/dwc2/core.c')
-rw-r--r--drivers/usb/dwc2/core.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 11d8ae9aead1..1b6612c2cdda 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -104,7 +104,7 @@ static int dwc2_restore_global_registers(struct dwc2_hsotg *hsotg)
104 gr = &hsotg->gr_backup; 104 gr = &hsotg->gr_backup;
105 if (!gr->valid) { 105 if (!gr->valid) {
106 dev_err(hsotg->dev, "%s: no global registers to restore\n", 106 dev_err(hsotg->dev, "%s: no global registers to restore\n",
107 __func__); 107 __func__);
108 return -EINVAL; 108 return -EINVAL;
109 } 109 }
110 gr->valid = false; 110 gr->valid = false;
@@ -155,21 +155,21 @@ int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, bool restore)
155 ret = dwc2_restore_global_registers(hsotg); 155 ret = dwc2_restore_global_registers(hsotg);
156 if (ret) { 156 if (ret) {
157 dev_err(hsotg->dev, "%s: failed to restore registers\n", 157 dev_err(hsotg->dev, "%s: failed to restore registers\n",
158 __func__); 158 __func__);
159 return ret; 159 return ret;
160 } 160 }
161 if (dwc2_is_host_mode(hsotg)) { 161 if (dwc2_is_host_mode(hsotg)) {
162 ret = dwc2_restore_host_registers(hsotg); 162 ret = dwc2_restore_host_registers(hsotg);
163 if (ret) { 163 if (ret) {
164 dev_err(hsotg->dev, "%s: failed to restore host registers\n", 164 dev_err(hsotg->dev, "%s: failed to restore host registers\n",
165 __func__); 165 __func__);
166 return ret; 166 return ret;
167 } 167 }
168 } else { 168 } else {
169 ret = dwc2_restore_device_registers(hsotg); 169 ret = dwc2_restore_device_registers(hsotg);
170 if (ret) { 170 if (ret) {
171 dev_err(hsotg->dev, "%s: failed to restore device registers\n", 171 dev_err(hsotg->dev, "%s: failed to restore device registers\n",
172 __func__); 172 __func__);
173 return ret; 173 return ret;
174 } 174 }
175 } 175 }
@@ -195,7 +195,7 @@ int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg)
195 ret = dwc2_backup_global_registers(hsotg); 195 ret = dwc2_backup_global_registers(hsotg);
196 if (ret) { 196 if (ret) {
197 dev_err(hsotg->dev, "%s: failed to backup global registers\n", 197 dev_err(hsotg->dev, "%s: failed to backup global registers\n",
198 __func__); 198 __func__);
199 return ret; 199 return ret;
200 } 200 }
201 201
@@ -203,14 +203,14 @@ int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg)
203 ret = dwc2_backup_host_registers(hsotg); 203 ret = dwc2_backup_host_registers(hsotg);
204 if (ret) { 204 if (ret) {
205 dev_err(hsotg->dev, "%s: failed to backup host registers\n", 205 dev_err(hsotg->dev, "%s: failed to backup host registers\n",
206 __func__); 206 __func__);
207 return ret; 207 return ret;
208 } 208 }
209 } else { 209 } else {
210 ret = dwc2_backup_device_registers(hsotg); 210 ret = dwc2_backup_device_registers(hsotg);
211 if (ret) { 211 if (ret) {
212 dev_err(hsotg->dev, "%s: failed to backup device registers\n", 212 dev_err(hsotg->dev, "%s: failed to backup device registers\n",
213 __func__); 213 __func__);
214 return ret; 214 return ret;
215 } 215 }
216 } 216 }
@@ -313,7 +313,7 @@ static bool dwc2_iddig_filter_enabled(struct dwc2_hsotg *hsotg)
313 * Do core a soft reset of the core. Be careful with this because it 313 * Do core a soft reset of the core. Be careful with this because it
314 * resets all the internal state machines of the core. 314 * resets all the internal state machines of the core.
315 */ 315 */
316int dwc2_core_reset(struct dwc2_hsotg *hsotg) 316int dwc2_core_reset(struct dwc2_hsotg *hsotg, bool skip_wait)
317{ 317{
318 u32 greset; 318 u32 greset;
319 int count = 0; 319 int count = 0;
@@ -369,7 +369,7 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg)
369 } 369 }
370 } while (!(greset & GRSTCTL_AHBIDLE)); 370 } while (!(greset & GRSTCTL_AHBIDLE));
371 371
372 if (wait_for_host_mode) 372 if (wait_for_host_mode && !skip_wait)
373 dwc2_wait_for_mode(hsotg, true); 373 dwc2_wait_for_mode(hsotg, true);
374 374
375 return 0; 375 return 0;
@@ -455,7 +455,7 @@ void dwc2_clear_force_mode(struct dwc2_hsotg *hsotg)
455 dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG); 455 dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG);
456 456
457 if (dwc2_iddig_filter_enabled(hsotg)) 457 if (dwc2_iddig_filter_enabled(hsotg))
458 usleep_range(100000, 110000); 458 msleep(100);
459} 459}
460 460
461/* 461/*
@@ -500,7 +500,7 @@ int dwc2_core_reset_and_force_dr_mode(struct dwc2_hsotg *hsotg)
500{ 500{
501 int retval; 501 int retval;
502 502
503 retval = dwc2_core_reset(hsotg); 503 retval = dwc2_core_reset(hsotg, false);
504 if (retval) 504 if (retval)
505 return retval; 505 return retval;
506 506
@@ -541,7 +541,7 @@ void dwc2_dump_host_registers(struct dwc2_hsotg *hsotg)
541 addr = hsotg->regs + HAINTMSK; 541 addr = hsotg->regs + HAINTMSK;
542 dev_dbg(hsotg->dev, "HAINTMSK @0x%08lX : 0x%08X\n", 542 dev_dbg(hsotg->dev, "HAINTMSK @0x%08lX : 0x%08X\n",
543 (unsigned long)addr, dwc2_readl(addr)); 543 (unsigned long)addr, dwc2_readl(addr));
544 if (hsotg->params.dma_desc_enable > 0) { 544 if (hsotg->params.dma_desc_enable) {
545 addr = hsotg->regs + HFLBADDR; 545 addr = hsotg->regs + HFLBADDR;
546 dev_dbg(hsotg->dev, "HFLBADDR @0x%08lX : 0x%08X\n", 546 dev_dbg(hsotg->dev, "HFLBADDR @0x%08lX : 0x%08X\n",
547 (unsigned long)addr, dwc2_readl(addr)); 547 (unsigned long)addr, dwc2_readl(addr));
@@ -571,7 +571,7 @@ void dwc2_dump_host_registers(struct dwc2_hsotg *hsotg)
571 addr = hsotg->regs + HCDMA(i); 571 addr = hsotg->regs + HCDMA(i);
572 dev_dbg(hsotg->dev, "HCDMA @0x%08lX : 0x%08X\n", 572 dev_dbg(hsotg->dev, "HCDMA @0x%08lX : 0x%08X\n",
573 (unsigned long)addr, dwc2_readl(addr)); 573 (unsigned long)addr, dwc2_readl(addr));
574 if (hsotg->params.dma_desc_enable > 0) { 574 if (hsotg->params.dma_desc_enable) {
575 addr = hsotg->regs + HCDMAB(i); 575 addr = hsotg->regs + HCDMAB(i);
576 dev_dbg(hsotg->dev, "HCDMAB @0x%08lX : 0x%08X\n", 576 dev_dbg(hsotg->dev, "HCDMAB @0x%08lX : 0x%08X\n",
577 (unsigned long)addr, dwc2_readl(addr)); 577 (unsigned long)addr, dwc2_readl(addr));
@@ -751,11 +751,6 @@ bool dwc2_force_mode_if_needed(struct dwc2_hsotg *hsotg, bool host)
751 return dwc2_force_mode(hsotg, host); 751 return dwc2_force_mode(hsotg, host);
752} 752}
753 753
754u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg)
755{
756 return hsotg->params.otg_ver == 1 ? 0x0200 : 0x0103;
757}
758
759bool dwc2_is_controller_alive(struct dwc2_hsotg *hsotg) 754bool dwc2_is_controller_alive(struct dwc2_hsotg *hsotg)
760{ 755{
761 if (dwc2_readl(hsotg->regs + GSNPSID) == 0xffffffff) 756 if (dwc2_readl(hsotg->regs + GSNPSID) == 0xffffffff)
@@ -793,7 +788,7 @@ void dwc2_disable_global_interrupts(struct dwc2_hsotg *hsotg)
793} 788}
794 789
795/* Returns the controller's GHWCFG2.OTG_MODE. */ 790/* Returns the controller's GHWCFG2.OTG_MODE. */
796unsigned dwc2_op_mode(struct dwc2_hsotg *hsotg) 791unsigned int dwc2_op_mode(struct dwc2_hsotg *hsotg)
797{ 792{
798 u32 ghwcfg2 = dwc2_readl(hsotg->regs + GHWCFG2); 793 u32 ghwcfg2 = dwc2_readl(hsotg->regs + GHWCFG2);
799 794
@@ -804,7 +799,7 @@ unsigned dwc2_op_mode(struct dwc2_hsotg *hsotg)
804/* Returns true if the controller is capable of DRD. */ 799/* Returns true if the controller is capable of DRD. */
805bool dwc2_hw_is_otg(struct dwc2_hsotg *hsotg) 800bool dwc2_hw_is_otg(struct dwc2_hsotg *hsotg)
806{ 801{
807 unsigned op_mode = dwc2_op_mode(hsotg); 802 unsigned int op_mode = dwc2_op_mode(hsotg);
808 803
809 return (op_mode == GHWCFG2_OP_MODE_HNP_SRP_CAPABLE) || 804 return (op_mode == GHWCFG2_OP_MODE_HNP_SRP_CAPABLE) ||
810 (op_mode == GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE) || 805 (op_mode == GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE) ||
@@ -814,7 +809,7 @@ bool dwc2_hw_is_otg(struct dwc2_hsotg *hsotg)
814/* Returns true if the controller is host-only. */ 809/* Returns true if the controller is host-only. */
815bool dwc2_hw_is_host(struct dwc2_hsotg *hsotg) 810bool dwc2_hw_is_host(struct dwc2_hsotg *hsotg)
816{ 811{
817 unsigned op_mode = dwc2_op_mode(hsotg); 812 unsigned int op_mode = dwc2_op_mode(hsotg);
818 813
819 return (op_mode == GHWCFG2_OP_MODE_SRP_CAPABLE_HOST) || 814 return (op_mode == GHWCFG2_OP_MODE_SRP_CAPABLE_HOST) ||
820 (op_mode == GHWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST); 815 (op_mode == GHWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST);
@@ -823,7 +818,7 @@ bool dwc2_hw_is_host(struct dwc2_hsotg *hsotg)
823/* Returns true if the controller is device-only. */ 818/* Returns true if the controller is device-only. */
824bool dwc2_hw_is_device(struct dwc2_hsotg *hsotg) 819bool dwc2_hw_is_device(struct dwc2_hsotg *hsotg)
825{ 820{
826 unsigned op_mode = dwc2_op_mode(hsotg); 821 unsigned int op_mode = dwc2_op_mode(hsotg);
827 822
828 return (op_mode == GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE) || 823 return (op_mode == GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE) ||
829 (op_mode == GHWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE); 824 (op_mode == GHWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE);