Lines Matching refs:dwc

52 void dwc3_set_mode(struct dwc3 *dwc, u32 mode)  in dwc3_set_mode()  argument
56 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in dwc3_set_mode()
59 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in dwc3_set_mode()
66 static int dwc3_core_soft_reset(struct dwc3 *dwc) in dwc3_core_soft_reset() argument
72 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in dwc3_core_soft_reset()
74 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in dwc3_core_soft_reset()
77 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); in dwc3_core_soft_reset()
79 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); in dwc3_core_soft_reset()
82 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_core_soft_reset()
84 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_core_soft_reset()
86 usb_phy_init(dwc->usb2_phy); in dwc3_core_soft_reset()
87 usb_phy_init(dwc->usb3_phy); in dwc3_core_soft_reset()
88 ret = phy_init(dwc->usb2_generic_phy); in dwc3_core_soft_reset()
92 ret = phy_init(dwc->usb3_generic_phy); in dwc3_core_soft_reset()
94 phy_exit(dwc->usb2_generic_phy); in dwc3_core_soft_reset()
100 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); in dwc3_core_soft_reset()
102 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); in dwc3_core_soft_reset()
105 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_core_soft_reset()
107 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_core_soft_reset()
112 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in dwc3_core_soft_reset()
114 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in dwc3_core_soft_reset()
124 static void dwc3_free_one_event_buffer(struct dwc3 *dwc, in dwc3_free_one_event_buffer() argument
127 dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma); in dwc3_free_one_event_buffer()
138 static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc, in dwc3_alloc_one_event_buffer() argument
143 evt = devm_kzalloc(dwc->dev, sizeof(*evt), GFP_KERNEL); in dwc3_alloc_one_event_buffer()
147 evt->dwc = dwc; in dwc3_alloc_one_event_buffer()
149 evt->buf = dma_alloc_coherent(dwc->dev, length, in dwc3_alloc_one_event_buffer()
161 static void dwc3_free_event_buffers(struct dwc3 *dwc) in dwc3_free_event_buffers() argument
166 for (i = 0; i < dwc->num_event_buffers; i++) { in dwc3_free_event_buffers()
167 evt = dwc->ev_buffs[i]; in dwc3_free_event_buffers()
169 dwc3_free_one_event_buffer(dwc, evt); in dwc3_free_event_buffers()
181 static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) in dwc3_alloc_event_buffers() argument
186 num = DWC3_NUM_INT(dwc->hwparams.hwparams1); in dwc3_alloc_event_buffers()
187 dwc->num_event_buffers = num; in dwc3_alloc_event_buffers()
189 dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num, in dwc3_alloc_event_buffers()
191 if (!dwc->ev_buffs) in dwc3_alloc_event_buffers()
197 evt = dwc3_alloc_one_event_buffer(dwc, length); in dwc3_alloc_event_buffers()
199 dev_err(dwc->dev, "can't allocate event buffer\n"); in dwc3_alloc_event_buffers()
202 dwc->ev_buffs[i] = evt; in dwc3_alloc_event_buffers()
214 static int dwc3_event_buffers_setup(struct dwc3 *dwc) in dwc3_event_buffers_setup() argument
219 for (n = 0; n < dwc->num_event_buffers; n++) { in dwc3_event_buffers_setup()
220 evt = dwc->ev_buffs[n]; in dwc3_event_buffers_setup()
221 dev_dbg(dwc->dev, "Event buf %p dma %08llx length %d\n", in dwc3_event_buffers_setup()
227 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), in dwc3_event_buffers_setup()
229 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), in dwc3_event_buffers_setup()
231 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), in dwc3_event_buffers_setup()
233 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); in dwc3_event_buffers_setup()
239 static void dwc3_event_buffers_cleanup(struct dwc3 *dwc) in dwc3_event_buffers_cleanup() argument
244 for (n = 0; n < dwc->num_event_buffers; n++) { in dwc3_event_buffers_cleanup()
245 evt = dwc->ev_buffs[n]; in dwc3_event_buffers_cleanup()
249 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), 0); in dwc3_event_buffers_cleanup()
250 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), 0); in dwc3_event_buffers_cleanup()
251 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), DWC3_GEVNTSIZ_INTMASK in dwc3_event_buffers_cleanup()
253 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); in dwc3_event_buffers_cleanup()
257 static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc) in dwc3_alloc_scratch_buffers() argument
259 if (!dwc->has_hibernation) in dwc3_alloc_scratch_buffers()
262 if (!dwc->nr_scratch) in dwc3_alloc_scratch_buffers()
265 dwc->scratchbuf = kmalloc_array(dwc->nr_scratch, in dwc3_alloc_scratch_buffers()
267 if (!dwc->scratchbuf) in dwc3_alloc_scratch_buffers()
273 static int dwc3_setup_scratch_buffers(struct dwc3 *dwc) in dwc3_setup_scratch_buffers() argument
279 if (!dwc->has_hibernation) in dwc3_setup_scratch_buffers()
282 if (!dwc->nr_scratch) in dwc3_setup_scratch_buffers()
286 if (!WARN_ON(dwc->scratchbuf)) in dwc3_setup_scratch_buffers()
289 scratch_addr = dma_map_single(dwc->dev, dwc->scratchbuf, in dwc3_setup_scratch_buffers()
290 dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE, in dwc3_setup_scratch_buffers()
292 if (dma_mapping_error(dwc->dev, scratch_addr)) { in dwc3_setup_scratch_buffers()
293 dev_err(dwc->dev, "failed to map scratch buffer\n"); in dwc3_setup_scratch_buffers()
298 dwc->scratch_addr = scratch_addr; in dwc3_setup_scratch_buffers()
302 ret = dwc3_send_gadget_generic_command(dwc, in dwc3_setup_scratch_buffers()
309 ret = dwc3_send_gadget_generic_command(dwc, in dwc3_setup_scratch_buffers()
317 dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch * in dwc3_setup_scratch_buffers()
324 static void dwc3_free_scratch_buffers(struct dwc3 *dwc) in dwc3_free_scratch_buffers() argument
326 if (!dwc->has_hibernation) in dwc3_free_scratch_buffers()
329 if (!dwc->nr_scratch) in dwc3_free_scratch_buffers()
333 if (!WARN_ON(dwc->scratchbuf)) in dwc3_free_scratch_buffers()
336 dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch * in dwc3_free_scratch_buffers()
338 kfree(dwc->scratchbuf); in dwc3_free_scratch_buffers()
341 static void dwc3_core_num_eps(struct dwc3 *dwc) in dwc3_core_num_eps() argument
343 struct dwc3_hwparams *parms = &dwc->hwparams; in dwc3_core_num_eps()
345 dwc->num_in_eps = DWC3_NUM_IN_EPS(parms); in dwc3_core_num_eps()
346 dwc->num_out_eps = DWC3_NUM_EPS(parms) - dwc->num_in_eps; in dwc3_core_num_eps()
349 dwc->num_in_eps, dwc->num_out_eps); in dwc3_core_num_eps()
352 static void dwc3_cache_hwparams(struct dwc3 *dwc) in dwc3_cache_hwparams() argument
354 struct dwc3_hwparams *parms = &dwc->hwparams; in dwc3_cache_hwparams()
356 parms->hwparams0 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS0); in dwc3_cache_hwparams()
357 parms->hwparams1 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS1); in dwc3_cache_hwparams()
358 parms->hwparams2 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS2); in dwc3_cache_hwparams()
359 parms->hwparams3 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS3); in dwc3_cache_hwparams()
360 parms->hwparams4 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS4); in dwc3_cache_hwparams()
361 parms->hwparams5 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS5); in dwc3_cache_hwparams()
362 parms->hwparams6 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS6); in dwc3_cache_hwparams()
363 parms->hwparams7 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS7); in dwc3_cache_hwparams()
364 parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8); in dwc3_cache_hwparams()
371 static void dwc3_phy_setup(struct dwc3 *dwc) in dwc3_phy_setup() argument
375 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); in dwc3_phy_setup()
383 if (dwc->revision > DWC3_REVISION_194A) in dwc3_phy_setup()
386 if (dwc->u2ss_inp3_quirk) in dwc3_phy_setup()
389 if (dwc->req_p1p2p3_quirk) in dwc3_phy_setup()
392 if (dwc->del_p1p2p3_quirk) in dwc3_phy_setup()
395 if (dwc->del_phy_power_chg_quirk) in dwc3_phy_setup()
398 if (dwc->lfps_filter_quirk) in dwc3_phy_setup()
401 if (dwc->rx_detect_poll_quirk) in dwc3_phy_setup()
404 if (dwc->tx_de_emphasis_quirk) in dwc3_phy_setup()
405 reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis); in dwc3_phy_setup()
407 if (dwc->dis_u3_susphy_quirk) in dwc3_phy_setup()
410 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); in dwc3_phy_setup()
414 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_phy_setup()
422 if (dwc->revision > DWC3_REVISION_194A) in dwc3_phy_setup()
425 if (dwc->dis_u2_susphy_quirk) in dwc3_phy_setup()
428 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_phy_setup()
439 static int dwc3_core_init(struct dwc3 *dwc) in dwc3_core_init() argument
442 u32 hwparams4 = dwc->hwparams.hwparams4; in dwc3_core_init()
446 reg = dwc3_readl(dwc->regs, DWC3_GSNPSID); in dwc3_core_init()
450 dwc->revision = reg; in dwc3_core_init()
453 dwc->revision = dwc3_readl(dwc->regs, DWC3_VER_NUMBER); in dwc3_core_init()
454 dwc->revision |= DWC3_REVISION_IS_DWC31; in dwc3_core_init()
456 dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n"); in dwc3_core_init()
465 dwc3_writel(dwc->regs, DWC3_GUID, LINUX_VERSION_CODE); in dwc3_core_init()
468 if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) == in dwc3_core_init()
470 if (dwc->maximum_speed == USB_SPEED_SUPER) in dwc3_core_init()
471 dwc->maximum_speed = USB_SPEED_HIGH; in dwc3_core_init()
476 dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST); in dwc3_core_init()
478 reg = dwc3_readl(dwc->regs, DWC3_DCTL); in dwc3_core_init()
483 dev_err(dwc->dev, "Reset Timed Out\n"); in dwc3_core_init()
491 ret = dwc3_core_soft_reset(dwc); in dwc3_core_init()
495 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in dwc3_core_init()
498 switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) { in dwc3_core_init()
512 if ((dwc->dr_mode == USB_DR_MODE_HOST || in dwc3_core_init()
513 dwc->dr_mode == USB_DR_MODE_OTG) && in dwc3_core_init()
514 (dwc->revision >= DWC3_REVISION_210A && in dwc3_core_init()
515 dwc->revision <= DWC3_REVISION_250A)) in dwc3_core_init()
522 dwc->nr_scratch = DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4); in dwc3_core_init()
531 dev_dbg(dwc->dev, "No power optimization available\n"); in dwc3_core_init()
535 if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) { in dwc3_core_init()
536 dev_dbg(dwc->dev, "it is on FPGA board\n"); in dwc3_core_init()
537 dwc->is_fpga = true; in dwc3_core_init()
540 WARN_ONCE(dwc->disable_scramble_quirk && !dwc->is_fpga, in dwc3_core_init()
543 if (dwc->disable_scramble_quirk && dwc->is_fpga) in dwc3_core_init()
548 if (dwc->u2exit_lfps_quirk) in dwc3_core_init()
557 if (dwc->revision < DWC3_REVISION_190A) in dwc3_core_init()
560 dwc3_core_num_eps(dwc); in dwc3_core_init()
562 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in dwc3_core_init()
564 dwc3_phy_setup(dwc); in dwc3_core_init()
566 ret = dwc3_alloc_scratch_buffers(dwc); in dwc3_core_init()
570 ret = dwc3_setup_scratch_buffers(dwc); in dwc3_core_init()
577 dwc3_free_scratch_buffers(dwc); in dwc3_core_init()
580 usb_phy_shutdown(dwc->usb2_phy); in dwc3_core_init()
581 usb_phy_shutdown(dwc->usb3_phy); in dwc3_core_init()
582 phy_exit(dwc->usb2_generic_phy); in dwc3_core_init()
583 phy_exit(dwc->usb3_generic_phy); in dwc3_core_init()
589 static void dwc3_core_exit(struct dwc3 *dwc) in dwc3_core_exit() argument
591 dwc3_free_scratch_buffers(dwc); in dwc3_core_exit()
592 usb_phy_shutdown(dwc->usb2_phy); in dwc3_core_exit()
593 usb_phy_shutdown(dwc->usb3_phy); in dwc3_core_exit()
594 phy_exit(dwc->usb2_generic_phy); in dwc3_core_exit()
595 phy_exit(dwc->usb3_generic_phy); in dwc3_core_exit()
598 static int dwc3_core_get_phy(struct dwc3 *dwc) in dwc3_core_get_phy() argument
600 struct device *dev = dwc->dev; in dwc3_core_get_phy()
605 dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); in dwc3_core_get_phy()
606 dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1); in dwc3_core_get_phy()
608 dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); in dwc3_core_get_phy()
609 dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); in dwc3_core_get_phy()
612 if (IS_ERR(dwc->usb2_phy)) { in dwc3_core_get_phy()
613 ret = PTR_ERR(dwc->usb2_phy); in dwc3_core_get_phy()
615 dwc->usb2_phy = NULL; in dwc3_core_get_phy()
624 if (IS_ERR(dwc->usb3_phy)) { in dwc3_core_get_phy()
625 ret = PTR_ERR(dwc->usb3_phy); in dwc3_core_get_phy()
627 dwc->usb3_phy = NULL; in dwc3_core_get_phy()
636 dwc->usb2_generic_phy = devm_phy_get(dev, "usb2-phy"); in dwc3_core_get_phy()
637 if (IS_ERR(dwc->usb2_generic_phy)) { in dwc3_core_get_phy()
638 ret = PTR_ERR(dwc->usb2_generic_phy); in dwc3_core_get_phy()
640 dwc->usb2_generic_phy = NULL; in dwc3_core_get_phy()
649 dwc->usb3_generic_phy = devm_phy_get(dev, "usb3-phy"); in dwc3_core_get_phy()
650 if (IS_ERR(dwc->usb3_generic_phy)) { in dwc3_core_get_phy()
651 ret = PTR_ERR(dwc->usb3_generic_phy); in dwc3_core_get_phy()
653 dwc->usb3_generic_phy = NULL; in dwc3_core_get_phy()
665 static int dwc3_core_init_mode(struct dwc3 *dwc) in dwc3_core_init_mode() argument
667 struct device *dev = dwc->dev; in dwc3_core_init_mode()
670 switch (dwc->dr_mode) { in dwc3_core_init_mode()
672 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); in dwc3_core_init_mode()
673 ret = dwc3_gadget_init(dwc); in dwc3_core_init_mode()
680 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); in dwc3_core_init_mode()
681 ret = dwc3_host_init(dwc); in dwc3_core_init_mode()
688 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); in dwc3_core_init_mode()
689 ret = dwc3_host_init(dwc); in dwc3_core_init_mode()
695 ret = dwc3_gadget_init(dwc); in dwc3_core_init_mode()
702 dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode); in dwc3_core_init_mode()
709 static void dwc3_core_exit_mode(struct dwc3 *dwc) in dwc3_core_exit_mode() argument
711 switch (dwc->dr_mode) { in dwc3_core_exit_mode()
713 dwc3_gadget_exit(dwc); in dwc3_core_exit_mode()
716 dwc3_host_exit(dwc); in dwc3_core_exit_mode()
719 dwc3_host_exit(dwc); in dwc3_core_exit_mode()
720 dwc3_gadget_exit(dwc); in dwc3_core_exit_mode()
736 struct dwc3 *dwc; in dwc3_probe() local
746 mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); in dwc3_probe()
750 dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); in dwc3_probe()
751 dwc->mem = mem; in dwc3_probe()
752 dwc->dev = dev; in dwc3_probe()
759 dwc->xhci_resources[1].start = res->start; in dwc3_probe()
760 dwc->xhci_resources[1].end = res->end; in dwc3_probe()
761 dwc->xhci_resources[1].flags = res->flags; in dwc3_probe()
762 dwc->xhci_resources[1].name = res->name; in dwc3_probe()
770 dwc->xhci_resources[0].start = res->start; in dwc3_probe()
771 dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + in dwc3_probe()
773 dwc->xhci_resources[0].flags = res->flags; in dwc3_probe()
774 dwc->xhci_resources[0].name = res->name; in dwc3_probe()
788 dwc->regs = regs; in dwc3_probe()
789 dwc->regs_size = resource_size(res); in dwc3_probe()
804 dwc->maximum_speed = of_usb_get_maximum_speed(node); in dwc3_probe()
805 dwc->has_lpm_erratum = of_property_read_bool(node, in dwc3_probe()
809 dwc->is_utmi_l1_suspend = of_property_read_bool(node, in dwc3_probe()
813 dwc->usb3_lpm_capable = of_property_read_bool(node, in dwc3_probe()
816 dwc->needs_fifo_resize = of_property_read_bool(node, in dwc3_probe()
818 dwc->dr_mode = of_usb_get_dr_mode(node); in dwc3_probe()
820 dwc->disable_scramble_quirk = of_property_read_bool(node, in dwc3_probe()
822 dwc->u2exit_lfps_quirk = of_property_read_bool(node, in dwc3_probe()
824 dwc->u2ss_inp3_quirk = of_property_read_bool(node, in dwc3_probe()
826 dwc->req_p1p2p3_quirk = of_property_read_bool(node, in dwc3_probe()
828 dwc->del_p1p2p3_quirk = of_property_read_bool(node, in dwc3_probe()
830 dwc->del_phy_power_chg_quirk = of_property_read_bool(node, in dwc3_probe()
832 dwc->lfps_filter_quirk = of_property_read_bool(node, in dwc3_probe()
834 dwc->rx_detect_poll_quirk = of_property_read_bool(node, in dwc3_probe()
836 dwc->dis_u3_susphy_quirk = of_property_read_bool(node, in dwc3_probe()
838 dwc->dis_u2_susphy_quirk = of_property_read_bool(node, in dwc3_probe()
841 dwc->tx_de_emphasis_quirk = of_property_read_bool(node, in dwc3_probe()
846 dwc->maximum_speed = pdata->maximum_speed; in dwc3_probe()
847 dwc->has_lpm_erratum = pdata->has_lpm_erratum; in dwc3_probe()
850 dwc->is_utmi_l1_suspend = pdata->is_utmi_l1_suspend; in dwc3_probe()
854 dwc->needs_fifo_resize = pdata->tx_fifo_resize; in dwc3_probe()
855 dwc->usb3_lpm_capable = pdata->usb3_lpm_capable; in dwc3_probe()
856 dwc->dr_mode = pdata->dr_mode; in dwc3_probe()
858 dwc->disable_scramble_quirk = pdata->disable_scramble_quirk; in dwc3_probe()
859 dwc->u2exit_lfps_quirk = pdata->u2exit_lfps_quirk; in dwc3_probe()
860 dwc->u2ss_inp3_quirk = pdata->u2ss_inp3_quirk; in dwc3_probe()
861 dwc->req_p1p2p3_quirk = pdata->req_p1p2p3_quirk; in dwc3_probe()
862 dwc->del_p1p2p3_quirk = pdata->del_p1p2p3_quirk; in dwc3_probe()
863 dwc->del_phy_power_chg_quirk = pdata->del_phy_power_chg_quirk; in dwc3_probe()
864 dwc->lfps_filter_quirk = pdata->lfps_filter_quirk; in dwc3_probe()
865 dwc->rx_detect_poll_quirk = pdata->rx_detect_poll_quirk; in dwc3_probe()
866 dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk; in dwc3_probe()
867 dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk; in dwc3_probe()
869 dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk; in dwc3_probe()
875 if (dwc->maximum_speed == USB_SPEED_UNKNOWN) in dwc3_probe()
876 dwc->maximum_speed = USB_SPEED_SUPER; in dwc3_probe()
878 dwc->lpm_nyet_threshold = lpm_nyet_threshold; in dwc3_probe()
879 dwc->tx_de_emphasis = tx_de_emphasis; in dwc3_probe()
881 dwc->hird_threshold = hird_threshold in dwc3_probe()
882 | (dwc->is_utmi_l1_suspend << 4); in dwc3_probe()
884 ret = dwc3_core_get_phy(dwc); in dwc3_probe()
888 spin_lock_init(&dwc->lock); in dwc3_probe()
889 platform_set_drvdata(pdev, dwc); in dwc3_probe()
901 dwc3_cache_hwparams(dwc); in dwc3_probe()
903 ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); in dwc3_probe()
905 dev_err(dwc->dev, "failed to allocate event buffers\n"); in dwc3_probe()
911 dwc->dr_mode = USB_DR_MODE_HOST; in dwc3_probe()
913 dwc->dr_mode = USB_DR_MODE_PERIPHERAL; in dwc3_probe()
915 if (dwc->dr_mode == USB_DR_MODE_UNKNOWN) in dwc3_probe()
916 dwc->dr_mode = USB_DR_MODE_OTG; in dwc3_probe()
918 ret = dwc3_core_init(dwc); in dwc3_probe()
924 usb_phy_set_suspend(dwc->usb2_phy, 0); in dwc3_probe()
925 usb_phy_set_suspend(dwc->usb3_phy, 0); in dwc3_probe()
926 ret = phy_power_on(dwc->usb2_generic_phy); in dwc3_probe()
930 ret = phy_power_on(dwc->usb3_generic_phy); in dwc3_probe()
934 ret = dwc3_event_buffers_setup(dwc); in dwc3_probe()
936 dev_err(dwc->dev, "failed to setup event buffers\n"); in dwc3_probe()
940 ret = dwc3_core_init_mode(dwc); in dwc3_probe()
944 ret = dwc3_debugfs_init(dwc); in dwc3_probe()
955 dwc3_core_exit_mode(dwc); in dwc3_probe()
958 dwc3_event_buffers_cleanup(dwc); in dwc3_probe()
961 phy_power_off(dwc->usb3_generic_phy); in dwc3_probe()
964 phy_power_off(dwc->usb2_generic_phy); in dwc3_probe()
967 usb_phy_set_suspend(dwc->usb2_phy, 1); in dwc3_probe()
968 usb_phy_set_suspend(dwc->usb3_phy, 1); in dwc3_probe()
969 dwc3_core_exit(dwc); in dwc3_probe()
972 dwc3_free_event_buffers(dwc); in dwc3_probe()
987 struct dwc3 *dwc = platform_get_drvdata(pdev); in dwc3_remove() local
997 dwc3_debugfs_exit(dwc); in dwc3_remove()
998 dwc3_core_exit_mode(dwc); in dwc3_remove()
999 dwc3_event_buffers_cleanup(dwc); in dwc3_remove()
1000 dwc3_free_event_buffers(dwc); in dwc3_remove()
1002 usb_phy_set_suspend(dwc->usb2_phy, 1); in dwc3_remove()
1003 usb_phy_set_suspend(dwc->usb3_phy, 1); in dwc3_remove()
1004 phy_power_off(dwc->usb2_generic_phy); in dwc3_remove()
1005 phy_power_off(dwc->usb3_generic_phy); in dwc3_remove()
1007 dwc3_core_exit(dwc); in dwc3_remove()
1018 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_suspend() local
1021 spin_lock_irqsave(&dwc->lock, flags); in dwc3_suspend()
1023 switch (dwc->dr_mode) { in dwc3_suspend()
1026 dwc3_gadget_suspend(dwc); in dwc3_suspend()
1030 dwc3_event_buffers_cleanup(dwc); in dwc3_suspend()
1034 dwc->gctl = dwc3_readl(dwc->regs, DWC3_GCTL); in dwc3_suspend()
1035 spin_unlock_irqrestore(&dwc->lock, flags); in dwc3_suspend()
1037 usb_phy_shutdown(dwc->usb3_phy); in dwc3_suspend()
1038 usb_phy_shutdown(dwc->usb2_phy); in dwc3_suspend()
1039 phy_exit(dwc->usb2_generic_phy); in dwc3_suspend()
1040 phy_exit(dwc->usb3_generic_phy); in dwc3_suspend()
1047 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_resume() local
1051 usb_phy_init(dwc->usb3_phy); in dwc3_resume()
1052 usb_phy_init(dwc->usb2_phy); in dwc3_resume()
1053 ret = phy_init(dwc->usb2_generic_phy); in dwc3_resume()
1057 ret = phy_init(dwc->usb3_generic_phy); in dwc3_resume()
1061 spin_lock_irqsave(&dwc->lock, flags); in dwc3_resume()
1063 dwc3_event_buffers_setup(dwc); in dwc3_resume()
1064 dwc3_writel(dwc->regs, DWC3_GCTL, dwc->gctl); in dwc3_resume()
1066 switch (dwc->dr_mode) { in dwc3_resume()
1069 dwc3_gadget_resume(dwc); in dwc3_resume()
1077 spin_unlock_irqrestore(&dwc->lock, flags); in dwc3_resume()
1086 phy_exit(dwc->usb2_generic_phy); in dwc3_resume()