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()
117 static int dwc3_core_soft_reset(struct dwc3 *dwc);
121 struct dwc3 *dwc = work_to_dwc(work); in __dwc3_set_mode() local
126 mutex_lock(&dwc->mutex); in __dwc3_set_mode()
128 pm_runtime_get_sync(dwc->dev); in __dwc3_set_mode()
130 if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_OTG) in __dwc3_set_mode()
131 dwc3_otg_update(dwc, 0); in __dwc3_set_mode()
133 if (!dwc->desired_dr_role) in __dwc3_set_mode()
136 if (dwc->desired_dr_role == dwc->current_dr_role) in __dwc3_set_mode()
139 if (dwc->desired_dr_role == DWC3_GCTL_PRTCAP_OTG && dwc->edev) in __dwc3_set_mode()
142 switch (dwc->current_dr_role) { in __dwc3_set_mode()
144 dwc3_host_exit(dwc); in __dwc3_set_mode()
147 dwc3_gadget_exit(dwc); in __dwc3_set_mode()
148 dwc3_event_buffers_cleanup(dwc); in __dwc3_set_mode()
151 dwc3_otg_exit(dwc); in __dwc3_set_mode()
152 spin_lock_irqsave(&dwc->lock, flags); in __dwc3_set_mode()
153 dwc->desired_otg_role = DWC3_OTG_ROLE_IDLE; in __dwc3_set_mode()
154 spin_unlock_irqrestore(&dwc->lock, flags); in __dwc3_set_mode()
155 dwc3_otg_update(dwc, 1); in __dwc3_set_mode()
162 if (dwc->desired_dr_role != DWC3_GCTL_PRTCAP_OTG) { in __dwc3_set_mode()
163 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in __dwc3_set_mode()
165 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in __dwc3_set_mode()
175 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in __dwc3_set_mode()
177 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in __dwc3_set_mode()
180 spin_lock_irqsave(&dwc->lock, flags); in __dwc3_set_mode()
182 dwc3_set_prtcap(dwc, dwc->desired_dr_role); in __dwc3_set_mode()
184 spin_unlock_irqrestore(&dwc->lock, flags); in __dwc3_set_mode()
186 switch (dwc->desired_dr_role) { in __dwc3_set_mode()
188 ret = dwc3_host_init(dwc); in __dwc3_set_mode()
190 dev_err(dwc->dev, "failed to initialize host\n"); in __dwc3_set_mode()
192 if (dwc->usb2_phy) in __dwc3_set_mode()
193 otg_set_vbus(dwc->usb2_phy->otg, true); in __dwc3_set_mode()
194 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST); in __dwc3_set_mode()
195 phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST); in __dwc3_set_mode()
196 if (dwc->dis_split_quirk) { in __dwc3_set_mode()
197 reg = dwc3_readl(dwc->regs, DWC3_GUCTL3); in __dwc3_set_mode()
199 dwc3_writel(dwc->regs, DWC3_GUCTL3, reg); in __dwc3_set_mode()
204 dwc3_core_soft_reset(dwc); in __dwc3_set_mode()
206 dwc3_event_buffers_setup(dwc); in __dwc3_set_mode()
208 if (dwc->usb2_phy) in __dwc3_set_mode()
209 otg_set_vbus(dwc->usb2_phy->otg, false); in __dwc3_set_mode()
210 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_DEVICE); in __dwc3_set_mode()
211 phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_DEVICE); in __dwc3_set_mode()
213 ret = dwc3_gadget_init(dwc); in __dwc3_set_mode()
215 dev_err(dwc->dev, "failed to initialize peripheral\n"); in __dwc3_set_mode()
218 dwc3_otg_init(dwc); in __dwc3_set_mode()
219 dwc3_otg_update(dwc, 0); in __dwc3_set_mode()
226 pm_runtime_mark_last_busy(dwc->dev); in __dwc3_set_mode()
227 pm_runtime_put_autosuspend(dwc->dev); in __dwc3_set_mode()
228 mutex_unlock(&dwc->mutex); in __dwc3_set_mode()
231 void dwc3_set_mode(struct dwc3 *dwc, u32 mode) in dwc3_set_mode() argument
235 if (dwc->dr_mode != USB_DR_MODE_OTG) in dwc3_set_mode()
238 spin_lock_irqsave(&dwc->lock, flags); in dwc3_set_mode()
239 dwc->desired_dr_role = mode; in dwc3_set_mode()
240 spin_unlock_irqrestore(&dwc->lock, flags); in dwc3_set_mode()
242 queue_work(system_freezable_wq, &dwc->drd_work); in dwc3_set_mode()
247 struct dwc3 *dwc = dep->dwc; in dwc3_core_fifo_space() local
250 dwc3_writel(dwc->regs, DWC3_GDBGFIFOSPACE, in dwc3_core_fifo_space()
254 reg = dwc3_readl(dwc->regs, DWC3_GDBGFIFOSPACE); in dwc3_core_fifo_space()
263 static int dwc3_core_soft_reset(struct dwc3 *dwc) in dwc3_core_soft_reset() argument
273 if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST) in dwc3_core_soft_reset()
276 reg = dwc3_readl(dwc->regs, DWC3_DCTL); in dwc3_core_soft_reset()
278 dwc3_writel(dwc->regs, DWC3_DCTL, reg); in dwc3_core_soft_reset()
290 reg = dwc3_readl(dwc->regs, DWC3_DCTL); in dwc3_core_soft_reset()
318 static void dwc3_frame_length_adjustment(struct dwc3 *dwc) in dwc3_frame_length_adjustment() argument
326 if (dwc->fladj == 0) in dwc3_frame_length_adjustment()
329 reg = dwc3_readl(dwc->regs, DWC3_GFLADJ); in dwc3_frame_length_adjustment()
331 if (dft != dwc->fladj) { in dwc3_frame_length_adjustment()
333 reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | dwc->fladj; in dwc3_frame_length_adjustment()
334 dwc3_writel(dwc->regs, DWC3_GFLADJ, reg); in dwc3_frame_length_adjustment()
343 static void dwc3_free_one_event_buffer(struct dwc3 *dwc, in dwc3_free_one_event_buffer() argument
346 dma_free_coherent(dwc->sysdev, evt->length, evt->buf, evt->dma); in dwc3_free_one_event_buffer()
357 static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc, in dwc3_alloc_one_event_buffer() argument
362 evt = devm_kzalloc(dwc->dev, sizeof(*evt), GFP_KERNEL); in dwc3_alloc_one_event_buffer()
366 evt->dwc = dwc; in dwc3_alloc_one_event_buffer()
368 evt->cache = devm_kzalloc(dwc->dev, length, GFP_KERNEL); in dwc3_alloc_one_event_buffer()
372 evt->buf = dma_alloc_coherent(dwc->sysdev, length, in dwc3_alloc_one_event_buffer()
384 static void dwc3_free_event_buffers(struct dwc3 *dwc) in dwc3_free_event_buffers() argument
388 evt = dwc->ev_buf; in dwc3_free_event_buffers()
390 dwc3_free_one_event_buffer(dwc, evt); in dwc3_free_event_buffers()
401 static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) in dwc3_alloc_event_buffers() argument
405 evt = dwc3_alloc_one_event_buffer(dwc, length); in dwc3_alloc_event_buffers()
407 dev_err(dwc->dev, "can't allocate event buffer\n"); in dwc3_alloc_event_buffers()
410 dwc->ev_buf = evt; in dwc3_alloc_event_buffers()
421 int dwc3_event_buffers_setup(struct dwc3 *dwc) in dwc3_event_buffers_setup() argument
425 evt = dwc->ev_buf; in dwc3_event_buffers_setup()
427 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0), in dwc3_event_buffers_setup()
429 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0), in dwc3_event_buffers_setup()
431 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), in dwc3_event_buffers_setup()
433 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); in dwc3_event_buffers_setup()
438 void dwc3_event_buffers_cleanup(struct dwc3 *dwc) in dwc3_event_buffers_cleanup() argument
442 evt = dwc->ev_buf; in dwc3_event_buffers_cleanup()
446 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0), 0); in dwc3_event_buffers_cleanup()
447 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0), 0); in dwc3_event_buffers_cleanup()
448 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), DWC3_GEVNTSIZ_INTMASK in dwc3_event_buffers_cleanup()
450 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); in dwc3_event_buffers_cleanup()
453 static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc) in dwc3_alloc_scratch_buffers() argument
455 if (!dwc->has_hibernation) in dwc3_alloc_scratch_buffers()
458 if (!dwc->nr_scratch) in dwc3_alloc_scratch_buffers()
461 dwc->scratchbuf = kmalloc_array(dwc->nr_scratch, in dwc3_alloc_scratch_buffers()
463 if (!dwc->scratchbuf) in dwc3_alloc_scratch_buffers()
469 static int dwc3_setup_scratch_buffers(struct dwc3 *dwc) in dwc3_setup_scratch_buffers() argument
475 if (!dwc->has_hibernation) in dwc3_setup_scratch_buffers()
478 if (!dwc->nr_scratch) in dwc3_setup_scratch_buffers()
482 if (!WARN_ON(dwc->scratchbuf)) in dwc3_setup_scratch_buffers()
485 scratch_addr = dma_map_single(dwc->sysdev, dwc->scratchbuf, in dwc3_setup_scratch_buffers()
486 dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE, in dwc3_setup_scratch_buffers()
488 if (dma_mapping_error(dwc->sysdev, scratch_addr)) { in dwc3_setup_scratch_buffers()
489 dev_err(dwc->sysdev, "failed to map scratch buffer\n"); in dwc3_setup_scratch_buffers()
494 dwc->scratch_addr = scratch_addr; in dwc3_setup_scratch_buffers()
498 ret = dwc3_send_gadget_generic_command(dwc, in dwc3_setup_scratch_buffers()
505 ret = dwc3_send_gadget_generic_command(dwc, in dwc3_setup_scratch_buffers()
513 dma_unmap_single(dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch * in dwc3_setup_scratch_buffers()
520 static void dwc3_free_scratch_buffers(struct dwc3 *dwc) in dwc3_free_scratch_buffers() argument
522 if (!dwc->has_hibernation) in dwc3_free_scratch_buffers()
525 if (!dwc->nr_scratch) in dwc3_free_scratch_buffers()
529 if (!WARN_ON(dwc->scratchbuf)) in dwc3_free_scratch_buffers()
532 dma_unmap_single(dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch * in dwc3_free_scratch_buffers()
534 kfree(dwc->scratchbuf); in dwc3_free_scratch_buffers()
537 static void dwc3_core_num_eps(struct dwc3 *dwc) in dwc3_core_num_eps() argument
539 struct dwc3_hwparams *parms = &dwc->hwparams; in dwc3_core_num_eps()
541 dwc->num_eps = DWC3_NUM_EPS(parms); in dwc3_core_num_eps()
544 static void dwc3_cache_hwparams(struct dwc3 *dwc) in dwc3_cache_hwparams() argument
546 struct dwc3_hwparams *parms = &dwc->hwparams; in dwc3_cache_hwparams()
548 parms->hwparams0 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS0); in dwc3_cache_hwparams()
549 parms->hwparams1 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS1); in dwc3_cache_hwparams()
550 parms->hwparams2 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS2); in dwc3_cache_hwparams()
551 parms->hwparams3 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS3); in dwc3_cache_hwparams()
552 parms->hwparams4 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS4); in dwc3_cache_hwparams()
553 parms->hwparams5 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS5); in dwc3_cache_hwparams()
554 parms->hwparams6 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS6); in dwc3_cache_hwparams()
555 parms->hwparams7 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS7); in dwc3_cache_hwparams()
556 parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8); in dwc3_cache_hwparams()
559 parms->hwparams9 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS9); in dwc3_cache_hwparams()
562 static int dwc3_core_ulpi_init(struct dwc3 *dwc) in dwc3_core_ulpi_init() argument
567 intf = DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3); in dwc3_core_ulpi_init()
571 dwc->hsphy_interface && in dwc3_core_ulpi_init()
572 !strncmp(dwc->hsphy_interface, "ulpi", 4))) in dwc3_core_ulpi_init()
573 ret = dwc3_ulpi_init(dwc); in dwc3_core_ulpi_init()
586 static int dwc3_phy_setup(struct dwc3 *dwc) in dwc3_phy_setup() argument
591 hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0); in dwc3_phy_setup()
593 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); in dwc3_phy_setup()
618 if (dwc->u2ss_inp3_quirk) in dwc3_phy_setup()
621 if (dwc->dis_rxdet_inp3_quirk) in dwc3_phy_setup()
624 if (dwc->req_p1p2p3_quirk) in dwc3_phy_setup()
627 if (dwc->del_p1p2p3_quirk) in dwc3_phy_setup()
630 if (dwc->del_phy_power_chg_quirk) in dwc3_phy_setup()
633 if (dwc->lfps_filter_quirk) in dwc3_phy_setup()
636 if (dwc->rx_detect_poll_quirk) in dwc3_phy_setup()
639 if (dwc->tx_de_emphasis_quirk) in dwc3_phy_setup()
640 reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis); in dwc3_phy_setup()
642 if (dwc->dis_u3_susphy_quirk) in dwc3_phy_setup()
645 if (dwc->dis_del_phy_power_chg_quirk) in dwc3_phy_setup()
648 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); in dwc3_phy_setup()
650 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_phy_setup()
653 switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) { in dwc3_phy_setup()
655 if (dwc->hsphy_interface && in dwc3_phy_setup()
656 !strncmp(dwc->hsphy_interface, "utmi", 4)) { in dwc3_phy_setup()
659 } else if (dwc->hsphy_interface && in dwc3_phy_setup()
660 !strncmp(dwc->hsphy_interface, "ulpi", 4)) { in dwc3_phy_setup()
662 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_phy_setup()
674 switch (dwc->hsphy_mode) { in dwc3_phy_setup()
708 if (dwc->dis_u2_susphy_quirk) in dwc3_phy_setup()
711 if (dwc->dis_enblslpm_quirk) in dwc3_phy_setup()
716 if (dwc->dis_u2_freeclk_exists_quirk) in dwc3_phy_setup()
719 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_phy_setup()
724 static void dwc3_core_exit(struct dwc3 *dwc) in dwc3_core_exit() argument
726 dwc3_event_buffers_cleanup(dwc); in dwc3_core_exit()
728 usb_phy_shutdown(dwc->usb2_phy); in dwc3_core_exit()
729 usb_phy_shutdown(dwc->usb3_phy); in dwc3_core_exit()
730 phy_exit(dwc->usb2_generic_phy); in dwc3_core_exit()
731 phy_exit(dwc->usb3_generic_phy); in dwc3_core_exit()
733 usb_phy_set_suspend(dwc->usb2_phy, 1); in dwc3_core_exit()
734 usb_phy_set_suspend(dwc->usb3_phy, 1); in dwc3_core_exit()
735 phy_power_off(dwc->usb2_generic_phy); in dwc3_core_exit()
736 phy_power_off(dwc->usb3_generic_phy); in dwc3_core_exit()
737 clk_bulk_disable_unprepare(dwc->num_clks, dwc->clks); in dwc3_core_exit()
738 reset_control_assert(dwc->reset); in dwc3_core_exit()
741 static bool dwc3_core_is_valid(struct dwc3 *dwc) in dwc3_core_is_valid() argument
745 reg = dwc3_readl(dwc->regs, DWC3_GSNPSID); in dwc3_core_is_valid()
746 dwc->ip = DWC3_GSNPS_ID(reg); in dwc3_core_is_valid()
750 dwc->revision = reg; in dwc3_core_is_valid()
752 dwc->revision = dwc3_readl(dwc->regs, DWC3_VER_NUMBER); in dwc3_core_is_valid()
753 dwc->version_type = dwc3_readl(dwc->regs, DWC3_VER_TYPE); in dwc3_core_is_valid()
761 static void dwc3_core_setup_global_control(struct dwc3 *dwc) in dwc3_core_setup_global_control() argument
763 u32 hwparams4 = dwc->hwparams.hwparams4; in dwc3_core_setup_global_control()
766 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in dwc3_core_setup_global_control()
769 switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) { in dwc3_core_setup_global_control()
783 if ((dwc->dr_mode == USB_DR_MODE_HOST || in dwc3_core_setup_global_control()
784 dwc->dr_mode == USB_DR_MODE_OTG) && in dwc3_core_setup_global_control()
792 dwc->nr_scratch = DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4); in dwc3_core_setup_global_control()
806 if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) { in dwc3_core_setup_global_control()
807 dev_info(dwc->dev, "Running with FPGA optimizations\n"); in dwc3_core_setup_global_control()
808 dwc->is_fpga = true; in dwc3_core_setup_global_control()
811 WARN_ONCE(dwc->disable_scramble_quirk && !dwc->is_fpga, in dwc3_core_setup_global_control()
814 if (dwc->disable_scramble_quirk && dwc->is_fpga) in dwc3_core_setup_global_control()
819 if (dwc->u2exit_lfps_quirk) in dwc3_core_setup_global_control()
831 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in dwc3_core_setup_global_control()
834 static int dwc3_core_get_phy(struct dwc3 *dwc);
835 static int dwc3_core_ulpi_init(struct dwc3 *dwc);
838 static void dwc3_set_incr_burst_type(struct dwc3 *dwc) in dwc3_set_incr_burst_type() argument
840 struct device *dev = dwc->dev; in dwc3_set_incr_burst_type()
851 cfg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0); in dwc3_set_incr_burst_type()
928 dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, cfg); in dwc3_set_incr_burst_type()
937 static int dwc3_core_init(struct dwc3 *dwc) in dwc3_core_init() argument
943 hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0); in dwc3_core_init()
949 dwc3_writel(dwc->regs, DWC3_GUID, LINUX_VERSION_CODE); in dwc3_core_init()
951 ret = dwc3_phy_setup(dwc); in dwc3_core_init()
955 if (!dwc->ulpi_ready) { in dwc3_core_init()
956 ret = dwc3_core_ulpi_init(dwc); in dwc3_core_init()
959 dwc->ulpi_ready = true; in dwc3_core_init()
962 if (!dwc->phys_ready) { in dwc3_core_init()
963 ret = dwc3_core_get_phy(dwc); in dwc3_core_init()
966 dwc->phys_ready = true; in dwc3_core_init()
969 usb_phy_init(dwc->usb2_phy); in dwc3_core_init()
970 usb_phy_init(dwc->usb3_phy); in dwc3_core_init()
971 ret = phy_init(dwc->usb2_generic_phy); in dwc3_core_init()
975 ret = phy_init(dwc->usb3_generic_phy); in dwc3_core_init()
977 phy_exit(dwc->usb2_generic_phy); in dwc3_core_init()
981 ret = dwc3_core_soft_reset(dwc); in dwc3_core_init()
987 if (!dwc->dis_u3_susphy_quirk) { in dwc3_core_init()
988 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); in dwc3_core_init()
990 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); in dwc3_core_init()
993 if (!dwc->dis_u2_susphy_quirk) { in dwc3_core_init()
994 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_core_init()
996 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_core_init()
1000 dwc3_core_setup_global_control(dwc); in dwc3_core_init()
1001 dwc3_core_num_eps(dwc); in dwc3_core_init()
1003 ret = dwc3_setup_scratch_buffers(dwc); in dwc3_core_init()
1008 dwc3_frame_length_adjustment(dwc); in dwc3_core_init()
1010 dwc3_set_incr_burst_type(dwc); in dwc3_core_init()
1012 usb_phy_set_suspend(dwc->usb2_phy, 0); in dwc3_core_init()
1013 usb_phy_set_suspend(dwc->usb3_phy, 0); in dwc3_core_init()
1014 ret = phy_power_on(dwc->usb2_generic_phy); in dwc3_core_init()
1018 ret = phy_power_on(dwc->usb3_generic_phy); in dwc3_core_init()
1022 ret = dwc3_event_buffers_setup(dwc); in dwc3_core_init()
1024 dev_err(dwc->dev, "failed to setup event buffers\n"); in dwc3_core_init()
1034 reg = dwc3_readl(dwc->regs, DWC3_GUCTL2); in dwc3_core_init()
1036 dwc3_writel(dwc->regs, DWC3_GUCTL2, reg); in dwc3_core_init()
1040 reg = dwc3_readl(dwc->regs, DWC3_GUCTL1); in dwc3_core_init()
1058 if (dwc->dis_tx_ipgap_linecheck_quirk) in dwc3_core_init()
1061 if (dwc->parkmode_disable_ss_quirk) in dwc3_core_init()
1064 dwc3_writel(dwc->regs, DWC3_GUCTL1, reg); in dwc3_core_init()
1067 if (dwc->dr_mode == USB_DR_MODE_HOST || in dwc3_core_init()
1068 dwc->dr_mode == USB_DR_MODE_OTG) { in dwc3_core_init()
1069 reg = dwc3_readl(dwc->regs, DWC3_GUCTL); in dwc3_core_init()
1080 dwc3_writel(dwc->regs, DWC3_GUCTL, reg); in dwc3_core_init()
1087 if (!DWC3_IP_IS(DWC3) && dwc->dr_mode == USB_DR_MODE_HOST) { in dwc3_core_init()
1088 u8 rx_thr_num = dwc->rx_thr_num_pkt_prd; in dwc3_core_init()
1089 u8 rx_maxburst = dwc->rx_max_burst_prd; in dwc3_core_init()
1090 u8 tx_thr_num = dwc->tx_thr_num_pkt_prd; in dwc3_core_init()
1091 u8 tx_maxburst = dwc->tx_max_burst_prd; in dwc3_core_init()
1094 reg = dwc3_readl(dwc->regs, DWC3_GRXTHRCFG); in dwc3_core_init()
1103 dwc3_writel(dwc->regs, DWC3_GRXTHRCFG, reg); in dwc3_core_init()
1107 reg = dwc3_readl(dwc->regs, DWC3_GTXTHRCFG); in dwc3_core_init()
1116 dwc3_writel(dwc->regs, DWC3_GTXTHRCFG, reg); in dwc3_core_init()
1123 phy_power_off(dwc->usb3_generic_phy); in dwc3_core_init()
1126 phy_power_off(dwc->usb2_generic_phy); in dwc3_core_init()
1129 usb_phy_set_suspend(dwc->usb2_phy, 1); in dwc3_core_init()
1130 usb_phy_set_suspend(dwc->usb3_phy, 1); in dwc3_core_init()
1133 usb_phy_shutdown(dwc->usb2_phy); in dwc3_core_init()
1134 usb_phy_shutdown(dwc->usb3_phy); in dwc3_core_init()
1135 phy_exit(dwc->usb2_generic_phy); in dwc3_core_init()
1136 phy_exit(dwc->usb3_generic_phy); in dwc3_core_init()
1139 dwc3_ulpi_exit(dwc); in dwc3_core_init()
1145 static int dwc3_core_get_phy(struct dwc3 *dwc) in dwc3_core_get_phy() argument
1147 struct device *dev = dwc->dev; in dwc3_core_get_phy()
1152 dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); in dwc3_core_get_phy()
1153 dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1); in dwc3_core_get_phy()
1155 dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); in dwc3_core_get_phy()
1156 dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); in dwc3_core_get_phy()
1159 if (IS_ERR(dwc->usb2_phy)) { in dwc3_core_get_phy()
1160 ret = PTR_ERR(dwc->usb2_phy); in dwc3_core_get_phy()
1162 dwc->usb2_phy = NULL; in dwc3_core_get_phy()
1168 if (IS_ERR(dwc->usb3_phy)) { in dwc3_core_get_phy()
1169 ret = PTR_ERR(dwc->usb3_phy); in dwc3_core_get_phy()
1171 dwc->usb3_phy = NULL; in dwc3_core_get_phy()
1177 dwc->usb2_generic_phy = devm_phy_get(dev, "usb2-phy"); in dwc3_core_get_phy()
1178 if (IS_ERR(dwc->usb2_generic_phy)) { in dwc3_core_get_phy()
1179 ret = PTR_ERR(dwc->usb2_generic_phy); in dwc3_core_get_phy()
1181 dwc->usb2_generic_phy = NULL; in dwc3_core_get_phy()
1187 dwc->usb3_generic_phy = devm_phy_get(dev, "usb3-phy"); in dwc3_core_get_phy()
1188 if (IS_ERR(dwc->usb3_generic_phy)) { in dwc3_core_get_phy()
1189 ret = PTR_ERR(dwc->usb3_generic_phy); in dwc3_core_get_phy()
1191 dwc->usb3_generic_phy = NULL; in dwc3_core_get_phy()
1200 static int dwc3_core_init_mode(struct dwc3 *dwc) in dwc3_core_init_mode() argument
1202 struct device *dev = dwc->dev; in dwc3_core_init_mode()
1205 switch (dwc->dr_mode) { in dwc3_core_init_mode()
1207 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE); in dwc3_core_init_mode()
1209 if (dwc->usb2_phy) in dwc3_core_init_mode()
1210 otg_set_vbus(dwc->usb2_phy->otg, false); in dwc3_core_init_mode()
1211 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_DEVICE); in dwc3_core_init_mode()
1212 phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_DEVICE); in dwc3_core_init_mode()
1214 ret = dwc3_gadget_init(dwc); in dwc3_core_init_mode()
1219 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST); in dwc3_core_init_mode()
1221 if (dwc->usb2_phy) in dwc3_core_init_mode()
1222 otg_set_vbus(dwc->usb2_phy->otg, true); in dwc3_core_init_mode()
1223 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST); in dwc3_core_init_mode()
1224 phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST); in dwc3_core_init_mode()
1226 ret = dwc3_host_init(dwc); in dwc3_core_init_mode()
1231 INIT_WORK(&dwc->drd_work, __dwc3_set_mode); in dwc3_core_init_mode()
1232 ret = dwc3_drd_init(dwc); in dwc3_core_init_mode()
1237 dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode); in dwc3_core_init_mode()
1244 static void dwc3_core_exit_mode(struct dwc3 *dwc) in dwc3_core_exit_mode() argument
1246 switch (dwc->dr_mode) { in dwc3_core_exit_mode()
1248 dwc3_gadget_exit(dwc); in dwc3_core_exit_mode()
1251 dwc3_host_exit(dwc); in dwc3_core_exit_mode()
1254 dwc3_drd_exit(dwc); in dwc3_core_exit_mode()
1262 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE); in dwc3_core_exit_mode()
1265 static void dwc3_get_properties(struct dwc3 *dwc) in dwc3_get_properties() argument
1267 struct device *dev = dwc->dev; in dwc3_get_properties()
1298 dwc->maximum_speed = usb_get_maximum_speed(dev); in dwc3_get_properties()
1299 dwc->max_ssp_rate = usb_get_maximum_ssp_rate(dev); in dwc3_get_properties()
1300 dwc->dr_mode = usb_get_dr_mode(dev); in dwc3_get_properties()
1301 dwc->hsphy_mode = of_usb_get_phy_mode(dev->of_node); in dwc3_get_properties()
1303 dwc->sysdev_is_parent = device_property_read_bool(dev, in dwc3_get_properties()
1305 if (dwc->sysdev_is_parent) in dwc3_get_properties()
1306 dwc->sysdev = dwc->dev->parent; in dwc3_get_properties()
1308 dwc->sysdev = dwc->dev; in dwc3_get_properties()
1312 dwc->usb_psy = power_supply_get_by_name(usb_psy_name); in dwc3_get_properties()
1313 if (!dwc->usb_psy) in dwc3_get_properties()
1317 dwc->has_lpm_erratum = device_property_read_bool(dev, in dwc3_get_properties()
1321 dwc->is_utmi_l1_suspend = device_property_read_bool(dev, in dwc3_get_properties()
1325 dwc->dis_start_transfer_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1327 dwc->usb3_lpm_capable = device_property_read_bool(dev, in dwc3_get_properties()
1329 dwc->usb2_lpm_disable = device_property_read_bool(dev, in dwc3_get_properties()
1331 dwc->usb2_gadget_lpm_disable = device_property_read_bool(dev, in dwc3_get_properties()
1341 dwc->do_fifo_resize = device_property_read_bool(dev, in dwc3_get_properties()
1343 if (dwc->do_fifo_resize) in dwc3_get_properties()
1347 dwc->disable_scramble_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1349 dwc->u2exit_lfps_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1351 dwc->u2ss_inp3_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1353 dwc->req_p1p2p3_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1355 dwc->del_p1p2p3_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1357 dwc->del_phy_power_chg_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1359 dwc->lfps_filter_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1361 dwc->rx_detect_poll_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1363 dwc->dis_u3_susphy_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1365 dwc->dis_u2_susphy_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1367 dwc->dis_enblslpm_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1369 dwc->dis_u1_entry_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1371 dwc->dis_u2_entry_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1373 dwc->dis_rxdet_inp3_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1375 dwc->dis_u2_freeclk_exists_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1377 dwc->dis_del_phy_power_chg_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1379 dwc->dis_tx_ipgap_linecheck_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1381 dwc->parkmode_disable_ss_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1384 dwc->tx_de_emphasis_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1389 &dwc->hsphy_interface); in dwc3_get_properties()
1391 &dwc->fladj); in dwc3_get_properties()
1393 dwc->dis_metastability_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1396 dwc->dis_split_quirk = device_property_read_bool(dev, in dwc3_get_properties()
1399 dwc->lpm_nyet_threshold = lpm_nyet_threshold; in dwc3_get_properties()
1400 dwc->tx_de_emphasis = tx_de_emphasis; in dwc3_get_properties()
1402 dwc->hird_threshold = hird_threshold; in dwc3_get_properties()
1404 dwc->rx_thr_num_pkt_prd = rx_thr_num_pkt_prd; in dwc3_get_properties()
1405 dwc->rx_max_burst_prd = rx_max_burst_prd; in dwc3_get_properties()
1407 dwc->tx_thr_num_pkt_prd = tx_thr_num_pkt_prd; in dwc3_get_properties()
1408 dwc->tx_max_burst_prd = tx_max_burst_prd; in dwc3_get_properties()
1410 dwc->imod_interval = 0; in dwc3_get_properties()
1412 dwc->tx_fifo_resize_max_num = tx_fifo_resize_max_num; in dwc3_get_properties()
1416 bool dwc3_has_imod(struct dwc3 *dwc) in dwc3_has_imod() argument
1423 static void dwc3_check_params(struct dwc3 *dwc) in dwc3_check_params() argument
1425 struct device *dev = dwc->dev; in dwc3_check_params()
1427 DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3); in dwc3_check_params()
1430 if (dwc->imod_interval && !dwc3_has_imod(dwc)) { in dwc3_check_params()
1431 dev_warn(dwc->dev, "Interrupt moderation not supported\n"); in dwc3_check_params()
1432 dwc->imod_interval = 0; in dwc3_check_params()
1442 if (!dwc->imod_interval && in dwc3_check_params()
1444 dwc->imod_interval = 1; in dwc3_check_params()
1447 switch (dwc->maximum_speed) { in dwc3_check_params()
1464 dwc->maximum_speed); in dwc3_check_params()
1469 dwc->maximum_speed = USB_SPEED_SUPER_PLUS; in dwc3_check_params()
1473 dwc->maximum_speed = USB_SPEED_SUPER_PLUS; in dwc3_check_params()
1475 dwc->maximum_speed = USB_SPEED_SUPER; in dwc3_check_params()
1478 dwc->maximum_speed = USB_SPEED_HIGH; in dwc3_check_params()
1481 dwc->maximum_speed = USB_SPEED_SUPER; in dwc3_check_params()
1494 if (dwc->maximum_speed == USB_SPEED_SUPER_PLUS) { in dwc3_check_params()
1495 switch (dwc->max_ssp_rate) { in dwc3_check_params()
1510 dwc->max_ssp_rate = USB_SSP_GEN_2x2; in dwc3_check_params()
1512 dwc->max_ssp_rate = USB_SSP_GEN_2x1; in dwc3_check_params()
1516 dwc->max_ssp_rate = USB_SSP_GEN_1x2; in dwc3_check_params()
1528 struct dwc3 *dwc; in dwc3_probe() local
1534 dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL); in dwc3_probe()
1535 if (!dwc) in dwc3_probe()
1538 dwc->dev = dev; in dwc3_probe()
1546 dwc->xhci_resources[0].start = res->start; in dwc3_probe()
1547 dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + in dwc3_probe()
1549 dwc->xhci_resources[0].flags = res->flags; in dwc3_probe()
1550 dwc->xhci_resources[0].name = res->name; in dwc3_probe()
1563 dwc->regs = regs; in dwc3_probe()
1564 dwc->regs_size = resource_size(&dwc_res); in dwc3_probe()
1566 dwc3_get_properties(dwc); in dwc3_probe()
1568 ret = dma_set_mask_and_coherent(dwc->sysdev, DMA_BIT_MASK(64)); in dwc3_probe()
1572 dwc->reset = devm_reset_control_array_get_optional_shared(dev); in dwc3_probe()
1573 if (IS_ERR(dwc->reset)) in dwc3_probe()
1574 return PTR_ERR(dwc->reset); in dwc3_probe()
1577 ret = devm_clk_bulk_get_all(dev, &dwc->clks); in dwc3_probe()
1585 dwc->num_clks = 0; in dwc3_probe()
1587 dwc->num_clks = ret; in dwc3_probe()
1591 ret = reset_control_deassert(dwc->reset); in dwc3_probe()
1595 ret = clk_bulk_prepare_enable(dwc->num_clks, dwc->clks); in dwc3_probe()
1599 if (!dwc3_core_is_valid(dwc)) { in dwc3_probe()
1600 dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n"); in dwc3_probe()
1605 platform_set_drvdata(pdev, dwc); in dwc3_probe()
1606 dwc3_cache_hwparams(dwc); in dwc3_probe()
1608 spin_lock_init(&dwc->lock); in dwc3_probe()
1609 mutex_init(&dwc->mutex); in dwc3_probe()
1621 ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); in dwc3_probe()
1623 dev_err(dwc->dev, "failed to allocate event buffers\n"); in dwc3_probe()
1628 ret = dwc3_get_dr_mode(dwc); in dwc3_probe()
1632 ret = dwc3_alloc_scratch_buffers(dwc); in dwc3_probe()
1636 ret = dwc3_core_init(dwc); in dwc3_probe()
1642 dwc3_check_params(dwc); in dwc3_probe()
1643 dwc3_debugfs_init(dwc); in dwc3_probe()
1645 ret = dwc3_core_init_mode(dwc); in dwc3_probe()
1654 dwc3_debugfs_exit(dwc); in dwc3_probe()
1655 dwc3_event_buffers_cleanup(dwc); in dwc3_probe()
1657 usb_phy_shutdown(dwc->usb2_phy); in dwc3_probe()
1658 usb_phy_shutdown(dwc->usb3_phy); in dwc3_probe()
1659 phy_exit(dwc->usb2_generic_phy); in dwc3_probe()
1660 phy_exit(dwc->usb3_generic_phy); in dwc3_probe()
1662 usb_phy_set_suspend(dwc->usb2_phy, 1); in dwc3_probe()
1663 usb_phy_set_suspend(dwc->usb3_phy, 1); in dwc3_probe()
1664 phy_power_off(dwc->usb2_generic_phy); in dwc3_probe()
1665 phy_power_off(dwc->usb3_generic_phy); in dwc3_probe()
1667 dwc3_ulpi_exit(dwc); in dwc3_probe()
1670 dwc3_free_scratch_buffers(dwc); in dwc3_probe()
1673 dwc3_free_event_buffers(dwc); in dwc3_probe()
1683 clk_bulk_disable_unprepare(dwc->num_clks, dwc->clks); in dwc3_probe()
1685 reset_control_assert(dwc->reset); in dwc3_probe()
1687 if (dwc->usb_psy) in dwc3_probe()
1688 power_supply_put(dwc->usb_psy); in dwc3_probe()
1695 struct dwc3 *dwc = platform_get_drvdata(pdev); in dwc3_remove() local
1699 dwc3_core_exit_mode(dwc); in dwc3_remove()
1700 dwc3_debugfs_exit(dwc); in dwc3_remove()
1702 dwc3_core_exit(dwc); in dwc3_remove()
1703 dwc3_ulpi_exit(dwc); in dwc3_remove()
1709 dwc3_free_event_buffers(dwc); in dwc3_remove()
1710 dwc3_free_scratch_buffers(dwc); in dwc3_remove()
1712 if (dwc->usb_psy) in dwc3_remove()
1713 power_supply_put(dwc->usb_psy); in dwc3_remove()
1719 static int dwc3_core_init_for_resume(struct dwc3 *dwc) in dwc3_core_init_for_resume() argument
1723 ret = reset_control_deassert(dwc->reset); in dwc3_core_init_for_resume()
1727 ret = clk_bulk_prepare_enable(dwc->num_clks, dwc->clks); in dwc3_core_init_for_resume()
1731 ret = dwc3_core_init(dwc); in dwc3_core_init_for_resume()
1738 clk_bulk_disable_unprepare(dwc->num_clks, dwc->clks); in dwc3_core_init_for_resume()
1740 reset_control_assert(dwc->reset); in dwc3_core_init_for_resume()
1745 static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg) in dwc3_suspend_common() argument
1750 switch (dwc->current_dr_role) { in dwc3_suspend_common()
1752 if (pm_runtime_suspended(dwc->dev)) in dwc3_suspend_common()
1754 spin_lock_irqsave(&dwc->lock, flags); in dwc3_suspend_common()
1755 dwc3_gadget_suspend(dwc); in dwc3_suspend_common()
1756 spin_unlock_irqrestore(&dwc->lock, flags); in dwc3_suspend_common()
1757 synchronize_irq(dwc->irq_gadget); in dwc3_suspend_common()
1758 dwc3_core_exit(dwc); in dwc3_suspend_common()
1762 dwc3_core_exit(dwc); in dwc3_suspend_common()
1767 if (dwc->dis_u2_susphy_quirk || in dwc3_suspend_common()
1768 dwc->dis_enblslpm_quirk) { in dwc3_suspend_common()
1769 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_suspend_common()
1772 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_suspend_common()
1778 phy_pm_runtime_put_sync(dwc->usb2_generic_phy); in dwc3_suspend_common()
1779 phy_pm_runtime_put_sync(dwc->usb3_generic_phy); in dwc3_suspend_common()
1786 if (dwc->current_otg_role == DWC3_OTG_ROLE_DEVICE) { in dwc3_suspend_common()
1787 spin_lock_irqsave(&dwc->lock, flags); in dwc3_suspend_common()
1788 dwc3_gadget_suspend(dwc); in dwc3_suspend_common()
1789 spin_unlock_irqrestore(&dwc->lock, flags); in dwc3_suspend_common()
1790 synchronize_irq(dwc->irq_gadget); in dwc3_suspend_common()
1793 dwc3_otg_exit(dwc); in dwc3_suspend_common()
1794 dwc3_core_exit(dwc); in dwc3_suspend_common()
1804 static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg) in dwc3_resume_common() argument
1810 switch (dwc->current_dr_role) { in dwc3_resume_common()
1812 ret = dwc3_core_init_for_resume(dwc); in dwc3_resume_common()
1816 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE); in dwc3_resume_common()
1817 spin_lock_irqsave(&dwc->lock, flags); in dwc3_resume_common()
1818 dwc3_gadget_resume(dwc); in dwc3_resume_common()
1819 spin_unlock_irqrestore(&dwc->lock, flags); in dwc3_resume_common()
1823 ret = dwc3_core_init_for_resume(dwc); in dwc3_resume_common()
1826 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST); in dwc3_resume_common()
1830 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_resume_common()
1831 if (dwc->dis_u2_susphy_quirk) in dwc3_resume_common()
1834 if (dwc->dis_enblslpm_quirk) in dwc3_resume_common()
1837 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_resume_common()
1839 phy_pm_runtime_get_sync(dwc->usb2_generic_phy); in dwc3_resume_common()
1840 phy_pm_runtime_get_sync(dwc->usb3_generic_phy); in dwc3_resume_common()
1847 ret = dwc3_core_init_for_resume(dwc); in dwc3_resume_common()
1851 dwc3_set_prtcap(dwc, dwc->current_dr_role); in dwc3_resume_common()
1853 dwc3_otg_init(dwc); in dwc3_resume_common()
1854 if (dwc->current_otg_role == DWC3_OTG_ROLE_HOST) { in dwc3_resume_common()
1855 dwc3_otg_host_init(dwc); in dwc3_resume_common()
1856 } else if (dwc->current_otg_role == DWC3_OTG_ROLE_DEVICE) { in dwc3_resume_common()
1857 spin_lock_irqsave(&dwc->lock, flags); in dwc3_resume_common()
1858 dwc3_gadget_resume(dwc); in dwc3_resume_common()
1859 spin_unlock_irqrestore(&dwc->lock, flags); in dwc3_resume_common()
1871 static int dwc3_runtime_checks(struct dwc3 *dwc) in dwc3_runtime_checks() argument
1873 switch (dwc->current_dr_role) { in dwc3_runtime_checks()
1875 if (dwc->connected) in dwc3_runtime_checks()
1889 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_runtime_suspend() local
1892 if (dwc3_runtime_checks(dwc)) in dwc3_runtime_suspend()
1895 ret = dwc3_suspend_common(dwc, PMSG_AUTO_SUSPEND); in dwc3_runtime_suspend()
1906 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_runtime_resume() local
1911 ret = dwc3_resume_common(dwc, PMSG_AUTO_RESUME); in dwc3_runtime_resume()
1915 switch (dwc->current_dr_role) { in dwc3_runtime_resume()
1917 dwc3_gadget_process_pending_events(dwc); in dwc3_runtime_resume()
1932 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_runtime_idle() local
1934 switch (dwc->current_dr_role) { in dwc3_runtime_idle()
1936 if (dwc3_runtime_checks(dwc)) in dwc3_runtime_idle()
1955 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_suspend() local
1958 ret = dwc3_suspend_common(dwc, PMSG_SUSPEND); in dwc3_suspend()
1969 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_resume() local
1974 ret = dwc3_resume_common(dwc, PMSG_RESUME); in dwc3_resume()
1987 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_complete() local
1990 if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST && in dwc3_complete()
1991 dwc->dis_split_quirk) { in dwc3_complete()
1992 reg = dwc3_readl(dwc->regs, DWC3_GUCTL3); in dwc3_complete()
1994 dwc3_writel(dwc->regs, DWC3_GUCTL3, reg); in dwc3_complete()