• Home
  • Raw
  • Download

Lines Matching refs:dwc

47 static int dwc3_get_dr_mode(struct dwc3 *dwc)  in dwc3_get_dr_mode()  argument
50 struct device *dev = dwc->dev; in dwc3_get_dr_mode()
53 if (dwc->dr_mode == USB_DR_MODE_UNKNOWN) in dwc3_get_dr_mode()
54 dwc->dr_mode = USB_DR_MODE_OTG; in dwc3_get_dr_mode()
56 mode = dwc->dr_mode; in dwc3_get_dr_mode()
57 hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0); in dwc3_get_dr_mode()
89 !device_property_read_bool(dwc->dev, "usb-role-switch")) && in dwc3_get_dr_mode()
94 if (mode != dwc->dr_mode) { in dwc3_get_dr_mode()
99 dwc->dr_mode = mode; in dwc3_get_dr_mode()
105 void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode) in dwc3_set_prtcap() argument
109 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in dwc3_set_prtcap()
112 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in dwc3_set_prtcap()
114 dwc->current_dr_role = mode; in dwc3_set_prtcap()
119 struct dwc3 *dwc = work_to_dwc(work); in __dwc3_set_mode() local
125 mutex_lock(&dwc->mutex); in __dwc3_set_mode()
126 spin_lock_irqsave(&dwc->lock, flags); in __dwc3_set_mode()
127 desired_dr_role = dwc->desired_dr_role; in __dwc3_set_mode()
128 spin_unlock_irqrestore(&dwc->lock, flags); in __dwc3_set_mode()
130 pm_runtime_get_sync(dwc->dev); in __dwc3_set_mode()
132 if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_OTG) in __dwc3_set_mode()
133 dwc3_otg_update(dwc, 0); in __dwc3_set_mode()
138 if (desired_dr_role == dwc->current_dr_role) in __dwc3_set_mode()
141 if (desired_dr_role == DWC3_GCTL_PRTCAP_OTG && dwc->edev) in __dwc3_set_mode()
144 switch (dwc->current_dr_role) { in __dwc3_set_mode()
146 dwc3_host_exit(dwc); in __dwc3_set_mode()
149 dwc3_gadget_exit(dwc); in __dwc3_set_mode()
150 dwc3_event_buffers_cleanup(dwc); in __dwc3_set_mode()
153 dwc3_otg_exit(dwc); in __dwc3_set_mode()
154 spin_lock_irqsave(&dwc->lock, flags); in __dwc3_set_mode()
155 dwc->desired_otg_role = DWC3_OTG_ROLE_IDLE; in __dwc3_set_mode()
156 spin_unlock_irqrestore(&dwc->lock, flags); in __dwc3_set_mode()
157 dwc3_otg_update(dwc, 1); in __dwc3_set_mode()
167 if (dwc->current_dr_role && ((DWC3_IP_IS(DWC3) || in __dwc3_set_mode()
170 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in __dwc3_set_mode()
172 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in __dwc3_set_mode()
182 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in __dwc3_set_mode()
184 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in __dwc3_set_mode()
187 spin_lock_irqsave(&dwc->lock, flags); in __dwc3_set_mode()
189 dwc3_set_prtcap(dwc, desired_dr_role); in __dwc3_set_mode()
191 spin_unlock_irqrestore(&dwc->lock, flags); in __dwc3_set_mode()
195 ret = dwc3_host_init(dwc); in __dwc3_set_mode()
197 dev_err(dwc->dev, "failed to initialize host\n"); in __dwc3_set_mode()
199 if (dwc->usb2_phy) in __dwc3_set_mode()
200 otg_set_vbus(dwc->usb2_phy->otg, true); in __dwc3_set_mode()
201 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST); in __dwc3_set_mode()
202 phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST); in __dwc3_set_mode()
203 if (dwc->dis_split_quirk) { in __dwc3_set_mode()
204 reg = dwc3_readl(dwc->regs, DWC3_GUCTL3); in __dwc3_set_mode()
206 dwc3_writel(dwc->regs, DWC3_GUCTL3, reg); in __dwc3_set_mode()
211 dwc3_core_soft_reset(dwc); in __dwc3_set_mode()
213 dwc3_event_buffers_setup(dwc); in __dwc3_set_mode()
215 if (dwc->usb2_phy) in __dwc3_set_mode()
216 otg_set_vbus(dwc->usb2_phy->otg, false); in __dwc3_set_mode()
217 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_DEVICE); in __dwc3_set_mode()
218 phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_DEVICE); in __dwc3_set_mode()
220 ret = dwc3_gadget_init(dwc); in __dwc3_set_mode()
222 dev_err(dwc->dev, "failed to initialize peripheral\n"); in __dwc3_set_mode()
225 dwc3_otg_init(dwc); in __dwc3_set_mode()
226 dwc3_otg_update(dwc, 0); in __dwc3_set_mode()
233 pm_runtime_mark_last_busy(dwc->dev); in __dwc3_set_mode()
234 pm_runtime_put_autosuspend(dwc->dev); in __dwc3_set_mode()
235 mutex_unlock(&dwc->mutex); in __dwc3_set_mode()
238 void dwc3_set_mode(struct dwc3 *dwc, u32 mode) in dwc3_set_mode() argument
242 if (dwc->dr_mode != USB_DR_MODE_OTG) in dwc3_set_mode()
245 spin_lock_irqsave(&dwc->lock, flags); in dwc3_set_mode()
246 dwc->desired_dr_role = mode; in dwc3_set_mode()
247 spin_unlock_irqrestore(&dwc->lock, flags); in dwc3_set_mode()
249 queue_work(system_freezable_wq, &dwc->drd_work); in dwc3_set_mode()
254 struct dwc3 *dwc = dep->dwc; in dwc3_core_fifo_space() local
257 dwc3_writel(dwc->regs, DWC3_GDBGFIFOSPACE, in dwc3_core_fifo_space()
261 reg = dwc3_readl(dwc->regs, DWC3_GDBGFIFOSPACE); in dwc3_core_fifo_space()
270 int dwc3_core_soft_reset(struct dwc3 *dwc) in dwc3_core_soft_reset() argument
280 if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST) in dwc3_core_soft_reset()
283 reg = dwc3_readl(dwc->regs, DWC3_DCTL); in dwc3_core_soft_reset()
286 dwc3_gadget_dctl_write_safe(dwc, reg); in dwc3_core_soft_reset()
298 reg = dwc3_readl(dwc->regs, DWC3_DCTL); in dwc3_core_soft_reset()
308 dev_warn(dwc->dev, "DWC3 controller soft reset failed.\n"); in dwc3_core_soft_reset()
327 static void dwc3_frame_length_adjustment(struct dwc3 *dwc) in dwc3_frame_length_adjustment() argument
335 if (dwc->fladj == 0) in dwc3_frame_length_adjustment()
338 reg = dwc3_readl(dwc->regs, DWC3_GFLADJ); in dwc3_frame_length_adjustment()
340 if (dft != dwc->fladj) { in dwc3_frame_length_adjustment()
342 reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | dwc->fladj; in dwc3_frame_length_adjustment()
343 dwc3_writel(dwc->regs, DWC3_GFLADJ, reg); in dwc3_frame_length_adjustment()
352 static void dwc3_free_one_event_buffer(struct dwc3 *dwc, in dwc3_free_one_event_buffer() argument
355 dma_free_coherent(dwc->sysdev, evt->length, evt->buf, evt->dma); in dwc3_free_one_event_buffer()
366 static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc, in dwc3_alloc_one_event_buffer() argument
371 evt = devm_kzalloc(dwc->dev, sizeof(*evt), GFP_KERNEL); in dwc3_alloc_one_event_buffer()
375 evt->dwc = dwc; in dwc3_alloc_one_event_buffer()
377 evt->cache = devm_kzalloc(dwc->dev, length, GFP_KERNEL); in dwc3_alloc_one_event_buffer()
381 evt->buf = dma_alloc_coherent(dwc->sysdev, length, in dwc3_alloc_one_event_buffer()
393 static void dwc3_free_event_buffers(struct dwc3 *dwc) in dwc3_free_event_buffers() argument
397 evt = dwc->ev_buf; in dwc3_free_event_buffers()
399 dwc3_free_one_event_buffer(dwc, evt); in dwc3_free_event_buffers()
410 static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) in dwc3_alloc_event_buffers() argument
414 evt = dwc3_alloc_one_event_buffer(dwc, length); in dwc3_alloc_event_buffers()
416 dev_err(dwc->dev, "can't allocate event buffer\n"); in dwc3_alloc_event_buffers()
419 dwc->ev_buf = evt; in dwc3_alloc_event_buffers()
430 int dwc3_event_buffers_setup(struct dwc3 *dwc) in dwc3_event_buffers_setup() argument
434 evt = dwc->ev_buf; in dwc3_event_buffers_setup()
436 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0), in dwc3_event_buffers_setup()
438 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0), in dwc3_event_buffers_setup()
440 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), in dwc3_event_buffers_setup()
442 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); in dwc3_event_buffers_setup()
447 void dwc3_event_buffers_cleanup(struct dwc3 *dwc) in dwc3_event_buffers_cleanup() argument
451 evt = dwc->ev_buf; in dwc3_event_buffers_cleanup()
455 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0), 0); in dwc3_event_buffers_cleanup()
456 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0), 0); in dwc3_event_buffers_cleanup()
457 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), DWC3_GEVNTSIZ_INTMASK in dwc3_event_buffers_cleanup()
459 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); in dwc3_event_buffers_cleanup()
462 static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc) in dwc3_alloc_scratch_buffers() argument
464 if (!dwc->has_hibernation) in dwc3_alloc_scratch_buffers()
467 if (!dwc->nr_scratch) in dwc3_alloc_scratch_buffers()
470 dwc->scratchbuf = kmalloc_array(dwc->nr_scratch, in dwc3_alloc_scratch_buffers()
472 if (!dwc->scratchbuf) in dwc3_alloc_scratch_buffers()
478 static int dwc3_setup_scratch_buffers(struct dwc3 *dwc) in dwc3_setup_scratch_buffers() argument
484 if (!dwc->has_hibernation) in dwc3_setup_scratch_buffers()
487 if (!dwc->nr_scratch) in dwc3_setup_scratch_buffers()
491 if (!WARN_ON(dwc->scratchbuf)) in dwc3_setup_scratch_buffers()
494 scratch_addr = dma_map_single(dwc->sysdev, dwc->scratchbuf, in dwc3_setup_scratch_buffers()
495 dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE, in dwc3_setup_scratch_buffers()
497 if (dma_mapping_error(dwc->sysdev, scratch_addr)) { in dwc3_setup_scratch_buffers()
498 dev_err(dwc->sysdev, "failed to map scratch buffer\n"); in dwc3_setup_scratch_buffers()
503 dwc->scratch_addr = scratch_addr; in dwc3_setup_scratch_buffers()
507 ret = dwc3_send_gadget_generic_command(dwc, in dwc3_setup_scratch_buffers()
514 ret = dwc3_send_gadget_generic_command(dwc, in dwc3_setup_scratch_buffers()
522 dma_unmap_single(dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch * in dwc3_setup_scratch_buffers()
529 static void dwc3_free_scratch_buffers(struct dwc3 *dwc) in dwc3_free_scratch_buffers() argument
531 if (!dwc->has_hibernation) in dwc3_free_scratch_buffers()
534 if (!dwc->nr_scratch) in dwc3_free_scratch_buffers()
538 if (!WARN_ON(dwc->scratchbuf)) in dwc3_free_scratch_buffers()
541 dma_unmap_single(dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch * in dwc3_free_scratch_buffers()
543 kfree(dwc->scratchbuf); in dwc3_free_scratch_buffers()
546 static void dwc3_core_num_eps(struct dwc3 *dwc) in dwc3_core_num_eps() argument
548 struct dwc3_hwparams *parms = &dwc->hwparams; in dwc3_core_num_eps()
550 dwc->num_eps = DWC3_NUM_EPS(parms); in dwc3_core_num_eps()
553 static void dwc3_cache_hwparams(struct dwc3 *dwc) in dwc3_cache_hwparams() argument
555 struct dwc3_hwparams *parms = &dwc->hwparams; in dwc3_cache_hwparams()
557 parms->hwparams0 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS0); in dwc3_cache_hwparams()
558 parms->hwparams1 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS1); in dwc3_cache_hwparams()
559 parms->hwparams2 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS2); in dwc3_cache_hwparams()
560 parms->hwparams3 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS3); in dwc3_cache_hwparams()
561 parms->hwparams4 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS4); in dwc3_cache_hwparams()
562 parms->hwparams5 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS5); in dwc3_cache_hwparams()
563 parms->hwparams6 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS6); in dwc3_cache_hwparams()
564 parms->hwparams7 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS7); in dwc3_cache_hwparams()
565 parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8); in dwc3_cache_hwparams()
568 parms->hwparams9 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS9); in dwc3_cache_hwparams()
571 static int dwc3_core_ulpi_init(struct dwc3 *dwc) in dwc3_core_ulpi_init() argument
576 intf = DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3); in dwc3_core_ulpi_init()
580 dwc->hsphy_interface && in dwc3_core_ulpi_init()
581 !strncmp(dwc->hsphy_interface, "ulpi", 4))) in dwc3_core_ulpi_init()
582 ret = dwc3_ulpi_init(dwc); in dwc3_core_ulpi_init()
595 static int dwc3_phy_setup(struct dwc3 *dwc) in dwc3_phy_setup() argument
600 hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0); in dwc3_phy_setup()
602 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); in dwc3_phy_setup()
627 if (dwc->u2ss_inp3_quirk) in dwc3_phy_setup()
630 if (dwc->dis_rxdet_inp3_quirk) in dwc3_phy_setup()
633 if (dwc->req_p1p2p3_quirk) in dwc3_phy_setup()
636 if (dwc->del_p1p2p3_quirk) in dwc3_phy_setup()
639 if (dwc->del_phy_power_chg_quirk) in dwc3_phy_setup()
642 if (dwc->lfps_filter_quirk) in dwc3_phy_setup()
645 if (dwc->rx_detect_poll_quirk) in dwc3_phy_setup()
648 if (dwc->tx_de_emphasis_quirk) in dwc3_phy_setup()
649 reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis); in dwc3_phy_setup()
651 if (dwc->dis_u3_susphy_quirk) in dwc3_phy_setup()
654 if (dwc->dis_del_phy_power_chg_quirk) in dwc3_phy_setup()
657 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); in dwc3_phy_setup()
659 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_phy_setup()
662 switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) { in dwc3_phy_setup()
664 if (dwc->hsphy_interface && in dwc3_phy_setup()
665 !strncmp(dwc->hsphy_interface, "utmi", 4)) { in dwc3_phy_setup()
668 } else if (dwc->hsphy_interface && in dwc3_phy_setup()
669 !strncmp(dwc->hsphy_interface, "ulpi", 4)) { in dwc3_phy_setup()
671 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_phy_setup()
683 switch (dwc->hsphy_mode) { in dwc3_phy_setup()
717 if (dwc->dis_u2_susphy_quirk) in dwc3_phy_setup()
720 if (dwc->dis_enblslpm_quirk) in dwc3_phy_setup()
725 if (dwc->dis_u2_freeclk_exists_quirk) in dwc3_phy_setup()
728 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_phy_setup()
733 static void dwc3_core_exit(struct dwc3 *dwc) in dwc3_core_exit() argument
735 dwc3_event_buffers_cleanup(dwc); in dwc3_core_exit()
737 usb_phy_set_suspend(dwc->usb2_phy, 1); in dwc3_core_exit()
738 usb_phy_set_suspend(dwc->usb3_phy, 1); in dwc3_core_exit()
739 phy_power_off(dwc->usb2_generic_phy); in dwc3_core_exit()
740 phy_power_off(dwc->usb3_generic_phy); in dwc3_core_exit()
742 usb_phy_shutdown(dwc->usb2_phy); in dwc3_core_exit()
743 usb_phy_shutdown(dwc->usb3_phy); in dwc3_core_exit()
744 phy_exit(dwc->usb2_generic_phy); in dwc3_core_exit()
745 phy_exit(dwc->usb3_generic_phy); in dwc3_core_exit()
747 clk_bulk_disable_unprepare(dwc->num_clks, dwc->clks); in dwc3_core_exit()
748 reset_control_assert(dwc->reset); in dwc3_core_exit()
751 static bool dwc3_core_is_valid(struct dwc3 *dwc) in dwc3_core_is_valid() argument
755 reg = dwc3_readl(dwc->regs, DWC3_GSNPSID); in dwc3_core_is_valid()
756 dwc->ip = DWC3_GSNPS_ID(reg); in dwc3_core_is_valid()
760 dwc->revision = reg; in dwc3_core_is_valid()
762 dwc->revision = dwc3_readl(dwc->regs, DWC3_VER_NUMBER); in dwc3_core_is_valid()
763 dwc->version_type = dwc3_readl(dwc->regs, DWC3_VER_TYPE); in dwc3_core_is_valid()
771 static void dwc3_core_setup_global_control(struct dwc3 *dwc) in dwc3_core_setup_global_control() argument
773 u32 hwparams4 = dwc->hwparams.hwparams4; in dwc3_core_setup_global_control()
776 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in dwc3_core_setup_global_control()
779 switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) { in dwc3_core_setup_global_control()
793 if ((dwc->dr_mode == USB_DR_MODE_HOST || in dwc3_core_setup_global_control()
794 dwc->dr_mode == USB_DR_MODE_OTG) && in dwc3_core_setup_global_control()
802 dwc->nr_scratch = DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4); in dwc3_core_setup_global_control()
816 if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) { in dwc3_core_setup_global_control()
817 dev_info(dwc->dev, "Running with FPGA optimizations\n"); in dwc3_core_setup_global_control()
818 dwc->is_fpga = true; in dwc3_core_setup_global_control()
821 WARN_ONCE(dwc->disable_scramble_quirk && !dwc->is_fpga, in dwc3_core_setup_global_control()
824 if (dwc->disable_scramble_quirk && dwc->is_fpga) in dwc3_core_setup_global_control()
829 if (dwc->u2exit_lfps_quirk) in dwc3_core_setup_global_control()
841 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in dwc3_core_setup_global_control()
844 static int dwc3_core_get_phy(struct dwc3 *dwc);
845 static int dwc3_core_ulpi_init(struct dwc3 *dwc);
848 static void dwc3_set_incr_burst_type(struct dwc3 *dwc) in dwc3_set_incr_burst_type() argument
850 struct device *dev = dwc->dev; in dwc3_set_incr_burst_type()
861 cfg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0); in dwc3_set_incr_burst_type()
938 dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, cfg); in dwc3_set_incr_burst_type()
941 static void dwc3_set_power_down_clk_scale(struct dwc3 *dwc) in dwc3_set_power_down_clk_scale() argument
943 struct device *dev = dwc->dev; in dwc3_set_power_down_clk_scale()
949 if (dwc->num_clks == 0) in dwc3_set_power_down_clk_scale()
970 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in dwc3_set_power_down_clk_scale()
975 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in dwc3_set_power_down_clk_scale()
985 static int dwc3_core_init(struct dwc3 *dwc) in dwc3_core_init() argument
991 hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0); in dwc3_core_init()
997 dwc3_writel(dwc->regs, DWC3_GUID, LINUX_VERSION_CODE); in dwc3_core_init()
999 ret = dwc3_phy_setup(dwc); in dwc3_core_init()
1003 if (!dwc->ulpi_ready) { in dwc3_core_init()
1004 ret = dwc3_core_ulpi_init(dwc); in dwc3_core_init()
1007 dwc3_core_soft_reset(dwc); in dwc3_core_init()
1012 dwc->ulpi_ready = true; in dwc3_core_init()
1015 if (!dwc->phys_ready) { in dwc3_core_init()
1016 ret = dwc3_core_get_phy(dwc); in dwc3_core_init()
1019 dwc->phys_ready = true; in dwc3_core_init()
1022 usb_phy_init(dwc->usb2_phy); in dwc3_core_init()
1023 usb_phy_init(dwc->usb3_phy); in dwc3_core_init()
1024 ret = phy_init(dwc->usb2_generic_phy); in dwc3_core_init()
1028 ret = phy_init(dwc->usb3_generic_phy); in dwc3_core_init()
1030 phy_exit(dwc->usb2_generic_phy); in dwc3_core_init()
1034 ret = dwc3_core_soft_reset(dwc); in dwc3_core_init()
1040 if (!dwc->dis_u3_susphy_quirk) { in dwc3_core_init()
1041 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); in dwc3_core_init()
1043 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); in dwc3_core_init()
1046 if (!dwc->dis_u2_susphy_quirk) { in dwc3_core_init()
1047 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_core_init()
1049 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_core_init()
1053 dwc3_core_setup_global_control(dwc); in dwc3_core_init()
1054 dwc3_core_num_eps(dwc); in dwc3_core_init()
1056 ret = dwc3_setup_scratch_buffers(dwc); in dwc3_core_init()
1061 dwc3_set_power_down_clk_scale(dwc); in dwc3_core_init()
1064 dwc3_frame_length_adjustment(dwc); in dwc3_core_init()
1066 dwc3_set_incr_burst_type(dwc); in dwc3_core_init()
1068 usb_phy_set_suspend(dwc->usb2_phy, 0); in dwc3_core_init()
1069 usb_phy_set_suspend(dwc->usb3_phy, 0); in dwc3_core_init()
1070 ret = phy_power_on(dwc->usb2_generic_phy); in dwc3_core_init()
1074 ret = phy_power_on(dwc->usb3_generic_phy); in dwc3_core_init()
1078 ret = dwc3_event_buffers_setup(dwc); in dwc3_core_init()
1080 dev_err(dwc->dev, "failed to setup event buffers\n"); in dwc3_core_init()
1090 reg = dwc3_readl(dwc->regs, DWC3_GUCTL2); in dwc3_core_init()
1092 dwc3_writel(dwc->regs, DWC3_GUCTL2, reg); in dwc3_core_init()
1096 reg = dwc3_readl(dwc->regs, DWC3_GUCTL1); in dwc3_core_init()
1114 if (dwc->dis_tx_ipgap_linecheck_quirk) in dwc3_core_init()
1117 if (dwc->parkmode_disable_ss_quirk) in dwc3_core_init()
1120 dwc3_writel(dwc->regs, DWC3_GUCTL1, reg); in dwc3_core_init()
1127 if (!DWC3_IP_IS(DWC3) && dwc->dr_mode == USB_DR_MODE_HOST) { in dwc3_core_init()
1128 u8 rx_thr_num = dwc->rx_thr_num_pkt_prd; in dwc3_core_init()
1129 u8 rx_maxburst = dwc->rx_max_burst_prd; in dwc3_core_init()
1130 u8 tx_thr_num = dwc->tx_thr_num_pkt_prd; in dwc3_core_init()
1131 u8 tx_maxburst = dwc->tx_max_burst_prd; in dwc3_core_init()
1134 reg = dwc3_readl(dwc->regs, DWC3_GRXTHRCFG); in dwc3_core_init()
1143 dwc3_writel(dwc->regs, DWC3_GRXTHRCFG, reg); in dwc3_core_init()
1147 reg = dwc3_readl(dwc->regs, DWC3_GTXTHRCFG); in dwc3_core_init()
1156 dwc3_writel(dwc->regs, DWC3_GTXTHRCFG, reg); in dwc3_core_init()
1166 dwc->maximum_speed == USB_SPEED_SUPER) { in dwc3_core_init()
1167 reg = dwc3_readl(dwc->regs, DWC3_LLUCTL); in dwc3_core_init()
1169 dwc3_writel(dwc->regs, DWC3_LLUCTL, reg); in dwc3_core_init()
1175 phy_power_off(dwc->usb3_generic_phy); in dwc3_core_init()
1178 phy_power_off(dwc->usb2_generic_phy); in dwc3_core_init()
1181 usb_phy_set_suspend(dwc->usb2_phy, 1); in dwc3_core_init()
1182 usb_phy_set_suspend(dwc->usb3_phy, 1); in dwc3_core_init()
1185 usb_phy_shutdown(dwc->usb2_phy); in dwc3_core_init()
1186 usb_phy_shutdown(dwc->usb3_phy); in dwc3_core_init()
1187 phy_exit(dwc->usb2_generic_phy); in dwc3_core_init()
1188 phy_exit(dwc->usb3_generic_phy); in dwc3_core_init()
1191 dwc3_ulpi_exit(dwc); in dwc3_core_init()
1197 static int dwc3_core_get_phy(struct dwc3 *dwc) in dwc3_core_get_phy() argument
1199 struct device *dev = dwc->dev; in dwc3_core_get_phy()
1204 dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); in dwc3_core_get_phy()
1205 dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1); in dwc3_core_get_phy()
1207 dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); in dwc3_core_get_phy()
1208 dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); in dwc3_core_get_phy()
1211 if (IS_ERR(dwc->usb2_phy)) { in dwc3_core_get_phy()
1212 ret = PTR_ERR(dwc->usb2_phy); in dwc3_core_get_phy()
1214 dwc->usb2_phy = NULL; in dwc3_core_get_phy()
1220 if (IS_ERR(dwc->usb3_phy)) { in dwc3_core_get_phy()
1221 ret = PTR_ERR(dwc->usb3_phy); in dwc3_core_get_phy()
1223 dwc->usb3_phy = NULL; in dwc3_core_get_phy()
1229 dwc->usb2_generic_phy = devm_phy_get(dev, "usb2-phy"); in dwc3_core_get_phy()
1230 if (IS_ERR(dwc->usb2_generic_phy)) { in dwc3_core_get_phy()
1231 ret = PTR_ERR(dwc->usb2_generic_phy); in dwc3_core_get_phy()
1233 dwc->usb2_generic_phy = NULL; in dwc3_core_get_phy()
1239 dwc->usb3_generic_phy = devm_phy_get(dev, "usb3-phy"); in dwc3_core_get_phy()
1240 if (IS_ERR(dwc->usb3_generic_phy)) { in dwc3_core_get_phy()
1241 ret = PTR_ERR(dwc->usb3_generic_phy); in dwc3_core_get_phy()
1243 dwc->usb3_generic_phy = NULL; in dwc3_core_get_phy()
1252 static int dwc3_core_init_mode(struct dwc3 *dwc) in dwc3_core_init_mode() argument
1254 struct device *dev = dwc->dev; in dwc3_core_init_mode()
1257 switch (dwc->dr_mode) { in dwc3_core_init_mode()
1259 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE); in dwc3_core_init_mode()
1261 if (dwc->usb2_phy) in dwc3_core_init_mode()
1262 otg_set_vbus(dwc->usb2_phy->otg, false); in dwc3_core_init_mode()
1263 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_DEVICE); in dwc3_core_init_mode()
1264 phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_DEVICE); in dwc3_core_init_mode()
1266 ret = dwc3_gadget_init(dwc); in dwc3_core_init_mode()
1271 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST); in dwc3_core_init_mode()
1273 if (dwc->usb2_phy) in dwc3_core_init_mode()
1274 otg_set_vbus(dwc->usb2_phy->otg, true); in dwc3_core_init_mode()
1275 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST); in dwc3_core_init_mode()
1276 phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST); in dwc3_core_init_mode()
1278 ret = dwc3_host_init(dwc); in dwc3_core_init_mode()
1283 INIT_WORK(&dwc->drd_work, __dwc3_set_mode); in dwc3_core_init_mode()
1284 ret = dwc3_drd_init(dwc); in dwc3_core_init_mode()
1289 dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode); in dwc3_core_init_mode()
1296 static void dwc3_core_exit_mode(struct dwc3 *dwc) in dwc3_core_exit_mode() argument
1298 switch (dwc->dr_mode) { in dwc3_core_exit_mode()
1300 dwc3_gadget_exit(dwc); in dwc3_core_exit_mode()
1303 dwc3_host_exit(dwc); in dwc3_core_exit_mode()
1306 dwc3_drd_exit(dwc); in dwc3_core_exit_mode()
1314 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE); in dwc3_core_exit_mode()
1317 static void dwc3_get_properties(struct dwc3 *dwc) in dwc3_get_properties() argument
1319 struct device *dev = dwc->dev; in dwc3_get_properties()
1350 dwc->maximum_speed = usb_get_maximum_speed(dev); in dwc3_get_properties()
1351 dwc->max_ssp_rate = usb_get_maximum_ssp_rate(dev); in dwc3_get_properties()
1352 dwc->dr_mode = usb_get_dr_mode(dev); in dwc3_get_properties()
1353 dwc->hsphy_mode = of_usb_get_phy_mode(dev->of_node); in dwc3_get_properties()
1355 dwc->sysdev_is_parent = device_property_read_bool(dev, in dwc3_get_properties()
1357 if (dwc->sysdev_is_parent) in dwc3_get_properties()
1358 dwc->sysdev = dwc->dev->parent; in dwc3_get_properties()
1360 dwc->sysdev = dwc->dev; in dwc3_get_properties()
1364 dwc->usb_psy = power_supply_get_by_name(usb_psy_name); in dwc3_get_properties()
1365 if (!dwc->usb_psy) in dwc3_get_properties()
1369 dwc->has_lpm_erratum = device_property_read_bool(dev, in dwc3_get_properties()
1373 dwc->is_utmi_l1_suspend = device_property_read_bool(dev, in dwc3_get_properties()
1377 dwc->dis_start_transfer_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1379 dwc->usb3_lpm_capable = device_property_read_bool(dev, in dwc3_get_properties()
1381 dwc->usb2_lpm_disable = device_property_read_bool(dev, in dwc3_get_properties()
1383 dwc->usb2_gadget_lpm_disable = device_property_read_bool(dev, in dwc3_get_properties()
1393 dwc->do_fifo_resize = device_property_read_bool(dev, in dwc3_get_properties()
1395 if (dwc->do_fifo_resize) in dwc3_get_properties()
1399 dwc->disable_scramble_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1401 dwc->u2exit_lfps_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1403 dwc->u2ss_inp3_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1405 dwc->req_p1p2p3_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1407 dwc->del_p1p2p3_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1409 dwc->del_phy_power_chg_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1411 dwc->lfps_filter_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1413 dwc->rx_detect_poll_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1415 dwc->dis_u3_susphy_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1417 dwc->dis_u2_susphy_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1419 dwc->dis_enblslpm_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1421 dwc->dis_u1_entry_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1423 dwc->dis_u2_entry_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1425 dwc->dis_rxdet_inp3_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1427 dwc->dis_u2_freeclk_exists_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1429 dwc->dis_del_phy_power_chg_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1431 dwc->dis_tx_ipgap_linecheck_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1433 dwc->parkmode_disable_ss_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1436 dwc->tx_de_emphasis_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1441 &dwc->hsphy_interface); in dwc3_get_properties()
1443 &dwc->fladj); in dwc3_get_properties()
1445 dwc->dis_metastability_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1448 dwc->dis_split_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1451 dwc->lpm_nyet_threshold = lpm_nyet_threshold; in dwc3_get_properties()
1452 dwc->tx_de_emphasis = tx_de_emphasis; in dwc3_get_properties()
1454 dwc->hird_threshold = hird_threshold; in dwc3_get_properties()
1456 dwc->rx_thr_num_pkt_prd = rx_thr_num_pkt_prd; in dwc3_get_properties()
1457 dwc->rx_max_burst_prd = rx_max_burst_prd; in dwc3_get_properties()
1459 dwc->tx_thr_num_pkt_prd = tx_thr_num_pkt_prd; in dwc3_get_properties()
1460 dwc->tx_max_burst_prd = tx_max_burst_prd; in dwc3_get_properties()
1462 dwc->imod_interval = 0; in dwc3_get_properties()
1464 dwc->tx_fifo_resize_max_num = tx_fifo_resize_max_num; in dwc3_get_properties()
1468 bool dwc3_has_imod(struct dwc3 *dwc) in dwc3_has_imod() argument
1475 static void dwc3_check_params(struct dwc3 *dwc) in dwc3_check_params() argument
1477 struct device *dev = dwc->dev; in dwc3_check_params()
1479 DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3); in dwc3_check_params()
1482 if (dwc->imod_interval && !dwc3_has_imod(dwc)) { in dwc3_check_params()
1483 dev_warn(dwc->dev, "Interrupt moderation not supported\n"); in dwc3_check_params()
1484 dwc->imod_interval = 0; in dwc3_check_params()
1494 if (!dwc->imod_interval && in dwc3_check_params()
1496 dwc->imod_interval = 1; in dwc3_check_params()
1499 switch (dwc->maximum_speed) { in dwc3_check_params()
1516 dwc->maximum_speed); in dwc3_check_params()
1521 dwc->maximum_speed = USB_SPEED_SUPER_PLUS; in dwc3_check_params()
1525 dwc->maximum_speed = USB_SPEED_SUPER_PLUS; in dwc3_check_params()
1527 dwc->maximum_speed = USB_SPEED_SUPER; in dwc3_check_params()
1530 dwc->maximum_speed = USB_SPEED_HIGH; in dwc3_check_params()
1533 dwc->maximum_speed = USB_SPEED_SUPER; in dwc3_check_params()
1546 if (dwc->maximum_speed == USB_SPEED_SUPER_PLUS) { in dwc3_check_params()
1547 switch (dwc->max_ssp_rate) { in dwc3_check_params()
1562 dwc->max_ssp_rate = USB_SSP_GEN_2x2; in dwc3_check_params()
1564 dwc->max_ssp_rate = USB_SSP_GEN_2x1; in dwc3_check_params()
1568 dwc->max_ssp_rate = USB_SSP_GEN_1x2; in dwc3_check_params()
1580 struct dwc3 *dwc; in dwc3_probe() local
1591 dwc = &vdwc->dwc; in dwc3_probe()
1592 dwc->dev = dev; in dwc3_probe()
1600 dwc->xhci_resources[0].start = res->start; in dwc3_probe()
1601 dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + in dwc3_probe()
1603 dwc->xhci_resources[0].flags = res->flags; in dwc3_probe()
1604 dwc->xhci_resources[0].name = res->name; in dwc3_probe()
1617 dwc->regs = regs; in dwc3_probe()
1618 dwc->regs_size = resource_size(&dwc_res); in dwc3_probe()
1620 dwc3_get_properties(dwc); in dwc3_probe()
1622 dwc->reset = devm_reset_control_array_get_optional_shared(dev); in dwc3_probe()
1623 if (IS_ERR(dwc->reset)) in dwc3_probe()
1624 return PTR_ERR(dwc->reset); in dwc3_probe()
1627 ret = devm_clk_bulk_get_all(dev, &dwc->clks); in dwc3_probe()
1635 dwc->num_clks = 0; in dwc3_probe()
1637 dwc->num_clks = ret; in dwc3_probe()
1641 ret = reset_control_deassert(dwc->reset); in dwc3_probe()
1645 ret = clk_bulk_prepare_enable(dwc->num_clks, dwc->clks); in dwc3_probe()
1649 if (!dwc3_core_is_valid(dwc)) { in dwc3_probe()
1650 dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n"); in dwc3_probe()
1655 platform_set_drvdata(pdev, dwc); in dwc3_probe()
1656 dwc3_cache_hwparams(dwc); in dwc3_probe()
1658 if (!dwc->sysdev_is_parent && in dwc3_probe()
1659 DWC3_GHWPARAMS0_AWIDTH(dwc->hwparams.hwparams0) == 64) { in dwc3_probe()
1660 ret = dma_set_mask_and_coherent(dwc->sysdev, DMA_BIT_MASK(64)); in dwc3_probe()
1665 spin_lock_init(&dwc->lock); in dwc3_probe()
1666 mutex_init(&dwc->mutex); in dwc3_probe()
1676 ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); in dwc3_probe()
1678 dev_err(dwc->dev, "failed to allocate event buffers\n"); in dwc3_probe()
1683 ret = dwc3_get_dr_mode(dwc); in dwc3_probe()
1687 ret = dwc3_alloc_scratch_buffers(dwc); in dwc3_probe()
1691 ret = dwc3_core_init(dwc); in dwc3_probe()
1697 dwc3_check_params(dwc); in dwc3_probe()
1698 dwc3_debugfs_init(dwc); in dwc3_probe()
1700 ret = dwc3_core_init_mode(dwc); in dwc3_probe()
1711 dwc3_debugfs_exit(dwc); in dwc3_probe()
1712 dwc3_event_buffers_cleanup(dwc); in dwc3_probe()
1714 usb_phy_set_suspend(dwc->usb2_phy, 1); in dwc3_probe()
1715 usb_phy_set_suspend(dwc->usb3_phy, 1); in dwc3_probe()
1716 phy_power_off(dwc->usb2_generic_phy); in dwc3_probe()
1717 phy_power_off(dwc->usb3_generic_phy); in dwc3_probe()
1719 usb_phy_shutdown(dwc->usb2_phy); in dwc3_probe()
1720 usb_phy_shutdown(dwc->usb3_phy); in dwc3_probe()
1721 phy_exit(dwc->usb2_generic_phy); in dwc3_probe()
1722 phy_exit(dwc->usb3_generic_phy); in dwc3_probe()
1724 dwc3_ulpi_exit(dwc); in dwc3_probe()
1727 dwc3_free_scratch_buffers(dwc); in dwc3_probe()
1730 dwc3_free_event_buffers(dwc); in dwc3_probe()
1738 clk_bulk_disable_unprepare(dwc->num_clks, dwc->clks); in dwc3_probe()
1740 reset_control_assert(dwc->reset); in dwc3_probe()
1742 if (dwc->usb_psy) in dwc3_probe()
1743 power_supply_put(dwc->usb_psy); in dwc3_probe()
1750 struct dwc3 *dwc = platform_get_drvdata(pdev); in dwc3_remove() local
1754 dwc3_core_exit_mode(dwc); in dwc3_remove()
1755 dwc3_debugfs_exit(dwc); in dwc3_remove()
1757 dwc3_core_exit(dwc); in dwc3_remove()
1758 dwc3_ulpi_exit(dwc); in dwc3_remove()
1770 dwc3_free_event_buffers(dwc); in dwc3_remove()
1771 dwc3_free_scratch_buffers(dwc); in dwc3_remove()
1773 if (dwc->usb_psy) in dwc3_remove()
1774 power_supply_put(dwc->usb_psy); in dwc3_remove()
1780 static int dwc3_core_init_for_resume(struct dwc3 *dwc) in dwc3_core_init_for_resume() argument
1784 ret = reset_control_deassert(dwc->reset); in dwc3_core_init_for_resume()
1788 ret = clk_bulk_prepare_enable(dwc->num_clks, dwc->clks); in dwc3_core_init_for_resume()
1792 ret = dwc3_core_init(dwc); in dwc3_core_init_for_resume()
1799 clk_bulk_disable_unprepare(dwc->num_clks, dwc->clks); in dwc3_core_init_for_resume()
1801 reset_control_assert(dwc->reset); in dwc3_core_init_for_resume()
1806 static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg) in dwc3_suspend_common() argument
1811 switch (dwc->current_dr_role) { in dwc3_suspend_common()
1813 if (pm_runtime_suspended(dwc->dev)) in dwc3_suspend_common()
1815 dwc3_gadget_suspend(dwc); in dwc3_suspend_common()
1816 synchronize_irq(dwc->irq_gadget); in dwc3_suspend_common()
1817 dwc3_core_exit(dwc); in dwc3_suspend_common()
1821 dwc3_core_exit(dwc); in dwc3_suspend_common()
1826 if (dwc->dis_u2_susphy_quirk || in dwc3_suspend_common()
1827 dwc->dis_enblslpm_quirk) { in dwc3_suspend_common()
1828 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_suspend_common()
1831 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_suspend_common()
1837 phy_pm_runtime_put_sync(dwc->usb2_generic_phy); in dwc3_suspend_common()
1838 phy_pm_runtime_put_sync(dwc->usb3_generic_phy); in dwc3_suspend_common()
1845 if (dwc->current_otg_role == DWC3_OTG_ROLE_DEVICE) { in dwc3_suspend_common()
1846 spin_lock_irqsave(&dwc->lock, flags); in dwc3_suspend_common()
1847 dwc3_gadget_suspend(dwc); in dwc3_suspend_common()
1848 spin_unlock_irqrestore(&dwc->lock, flags); in dwc3_suspend_common()
1849 synchronize_irq(dwc->irq_gadget); in dwc3_suspend_common()
1852 dwc3_otg_exit(dwc); in dwc3_suspend_common()
1853 dwc3_core_exit(dwc); in dwc3_suspend_common()
1863 static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg) in dwc3_resume_common() argument
1869 switch (dwc->current_dr_role) { in dwc3_resume_common()
1871 ret = dwc3_core_init_for_resume(dwc); in dwc3_resume_common()
1875 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE); in dwc3_resume_common()
1876 dwc3_gadget_resume(dwc); in dwc3_resume_common()
1880 ret = dwc3_core_init_for_resume(dwc); in dwc3_resume_common()
1883 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST); in dwc3_resume_common()
1887 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_resume_common()
1888 if (dwc->dis_u2_susphy_quirk) in dwc3_resume_common()
1891 if (dwc->dis_enblslpm_quirk) in dwc3_resume_common()
1894 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_resume_common()
1896 phy_pm_runtime_get_sync(dwc->usb2_generic_phy); in dwc3_resume_common()
1897 phy_pm_runtime_get_sync(dwc->usb3_generic_phy); in dwc3_resume_common()
1904 ret = dwc3_core_init_for_resume(dwc); in dwc3_resume_common()
1908 dwc3_set_prtcap(dwc, dwc->current_dr_role); in dwc3_resume_common()
1910 dwc3_otg_init(dwc); in dwc3_resume_common()
1911 if (dwc->current_otg_role == DWC3_OTG_ROLE_HOST) { in dwc3_resume_common()
1912 dwc3_otg_host_init(dwc); in dwc3_resume_common()
1913 } else if (dwc->current_otg_role == DWC3_OTG_ROLE_DEVICE) { in dwc3_resume_common()
1914 spin_lock_irqsave(&dwc->lock, flags); in dwc3_resume_common()
1915 dwc3_gadget_resume(dwc); in dwc3_resume_common()
1916 spin_unlock_irqrestore(&dwc->lock, flags); in dwc3_resume_common()
1928 static int dwc3_runtime_checks(struct dwc3 *dwc) in dwc3_runtime_checks() argument
1930 switch (dwc->current_dr_role) { in dwc3_runtime_checks()
1932 if (dwc->connected) in dwc3_runtime_checks()
1946 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_runtime_suspend() local
1949 if (dwc3_runtime_checks(dwc)) in dwc3_runtime_suspend()
1952 ret = dwc3_suspend_common(dwc, PMSG_AUTO_SUSPEND); in dwc3_runtime_suspend()
1963 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_runtime_resume() local
1968 ret = dwc3_resume_common(dwc, PMSG_AUTO_RESUME); in dwc3_runtime_resume()
1972 switch (dwc->current_dr_role) { in dwc3_runtime_resume()
1974 dwc3_gadget_process_pending_events(dwc); in dwc3_runtime_resume()
1989 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_runtime_idle() local
1991 switch (dwc->current_dr_role) { in dwc3_runtime_idle()
1993 if (dwc3_runtime_checks(dwc)) in dwc3_runtime_idle()
2012 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_suspend() local
2015 ret = dwc3_suspend_common(dwc, PMSG_SUSPEND); in dwc3_suspend()
2026 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_resume() local
2031 ret = dwc3_resume_common(dwc, PMSG_RESUME); in dwc3_resume()
2044 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_complete() local
2047 if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST && in dwc3_complete()
2048 dwc->dis_split_quirk) { in dwc3_complete()
2049 reg = dwc3_readl(dwc->regs, DWC3_GUCTL3); in dwc3_complete()
2051 dwc3_writel(dwc->regs, DWC3_GUCTL3, reg); in dwc3_complete()