Lines Matching refs:dwc

53 void dwc3_set_mode(struct dwc3 *dwc, u32 mode)  in dwc3_set_mode()  argument
57 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in dwc3_set_mode()
60 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in dwc3_set_mode()
67 static int dwc3_core_soft_reset(struct dwc3 *dwc) in dwc3_core_soft_reset() argument
73 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in dwc3_core_soft_reset()
75 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in dwc3_core_soft_reset()
78 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); in dwc3_core_soft_reset()
80 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); in dwc3_core_soft_reset()
83 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_core_soft_reset()
85 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_core_soft_reset()
87 usb_phy_init(dwc->usb2_phy); in dwc3_core_soft_reset()
88 usb_phy_init(dwc->usb3_phy); in dwc3_core_soft_reset()
89 ret = phy_init(dwc->usb2_generic_phy); in dwc3_core_soft_reset()
93 ret = phy_init(dwc->usb3_generic_phy); in dwc3_core_soft_reset()
95 phy_exit(dwc->usb2_generic_phy); in dwc3_core_soft_reset()
101 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); in dwc3_core_soft_reset()
103 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); in dwc3_core_soft_reset()
106 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_core_soft_reset()
108 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_core_soft_reset()
113 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in dwc3_core_soft_reset()
115 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in dwc3_core_soft_reset()
124 static int dwc3_soft_reset(struct dwc3 *dwc) in dwc3_soft_reset() argument
130 dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST); in dwc3_soft_reset()
132 reg = dwc3_readl(dwc->regs, DWC3_DCTL); in dwc3_soft_reset()
137 dev_err(dwc->dev, "Reset Timed Out\n"); in dwc3_soft_reset()
152 static void dwc3_frame_length_adjustment(struct dwc3 *dwc, u32 fladj) in dwc3_frame_length_adjustment() argument
157 if (dwc->revision < DWC3_REVISION_250A) in dwc3_frame_length_adjustment()
163 reg = dwc3_readl(dwc->regs, DWC3_GFLADJ); in dwc3_frame_length_adjustment()
165 if (!dev_WARN_ONCE(dwc->dev, dft == fladj, in dwc3_frame_length_adjustment()
169 dwc3_writel(dwc->regs, DWC3_GFLADJ, reg); in dwc3_frame_length_adjustment()
178 static void dwc3_free_one_event_buffer(struct dwc3 *dwc, in dwc3_free_one_event_buffer() argument
181 dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma); in dwc3_free_one_event_buffer()
192 static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc, in dwc3_alloc_one_event_buffer() argument
197 evt = devm_kzalloc(dwc->dev, sizeof(*evt), GFP_KERNEL); in dwc3_alloc_one_event_buffer()
201 evt->dwc = dwc; in dwc3_alloc_one_event_buffer()
203 evt->buf = dma_alloc_coherent(dwc->dev, length, in dwc3_alloc_one_event_buffer()
215 static void dwc3_free_event_buffers(struct dwc3 *dwc) in dwc3_free_event_buffers() argument
220 for (i = 0; i < dwc->num_event_buffers; i++) { in dwc3_free_event_buffers()
221 evt = dwc->ev_buffs[i]; in dwc3_free_event_buffers()
223 dwc3_free_one_event_buffer(dwc, evt); in dwc3_free_event_buffers()
235 static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) in dwc3_alloc_event_buffers() argument
240 num = DWC3_NUM_INT(dwc->hwparams.hwparams1); in dwc3_alloc_event_buffers()
241 dwc->num_event_buffers = num; in dwc3_alloc_event_buffers()
243 dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num, in dwc3_alloc_event_buffers()
245 if (!dwc->ev_buffs) in dwc3_alloc_event_buffers()
251 evt = dwc3_alloc_one_event_buffer(dwc, length); in dwc3_alloc_event_buffers()
253 dev_err(dwc->dev, "can't allocate event buffer\n"); in dwc3_alloc_event_buffers()
256 dwc->ev_buffs[i] = evt; in dwc3_alloc_event_buffers()
268 static int dwc3_event_buffers_setup(struct dwc3 *dwc) in dwc3_event_buffers_setup() argument
273 for (n = 0; n < dwc->num_event_buffers; n++) { in dwc3_event_buffers_setup()
274 evt = dwc->ev_buffs[n]; in dwc3_event_buffers_setup()
275 dev_dbg(dwc->dev, "Event buf %p dma %08llx length %d\n", in dwc3_event_buffers_setup()
281 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), in dwc3_event_buffers_setup()
283 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), in dwc3_event_buffers_setup()
285 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), in dwc3_event_buffers_setup()
287 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); in dwc3_event_buffers_setup()
293 static void dwc3_event_buffers_cleanup(struct dwc3 *dwc) in dwc3_event_buffers_cleanup() argument
298 for (n = 0; n < dwc->num_event_buffers; n++) { in dwc3_event_buffers_cleanup()
299 evt = dwc->ev_buffs[n]; in dwc3_event_buffers_cleanup()
303 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), 0); in dwc3_event_buffers_cleanup()
304 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), 0); in dwc3_event_buffers_cleanup()
305 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), DWC3_GEVNTSIZ_INTMASK in dwc3_event_buffers_cleanup()
307 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); in dwc3_event_buffers_cleanup()
311 static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc) in dwc3_alloc_scratch_buffers() argument
313 if (!dwc->has_hibernation) in dwc3_alloc_scratch_buffers()
316 if (!dwc->nr_scratch) in dwc3_alloc_scratch_buffers()
319 dwc->scratchbuf = kmalloc_array(dwc->nr_scratch, in dwc3_alloc_scratch_buffers()
321 if (!dwc->scratchbuf) in dwc3_alloc_scratch_buffers()
327 static int dwc3_setup_scratch_buffers(struct dwc3 *dwc) in dwc3_setup_scratch_buffers() argument
333 if (!dwc->has_hibernation) in dwc3_setup_scratch_buffers()
336 if (!dwc->nr_scratch) in dwc3_setup_scratch_buffers()
340 if (!WARN_ON(dwc->scratchbuf)) in dwc3_setup_scratch_buffers()
343 scratch_addr = dma_map_single(dwc->dev, dwc->scratchbuf, in dwc3_setup_scratch_buffers()
344 dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE, in dwc3_setup_scratch_buffers()
346 if (dma_mapping_error(dwc->dev, scratch_addr)) { in dwc3_setup_scratch_buffers()
347 dev_err(dwc->dev, "failed to map scratch buffer\n"); in dwc3_setup_scratch_buffers()
352 dwc->scratch_addr = scratch_addr; in dwc3_setup_scratch_buffers()
356 ret = dwc3_send_gadget_generic_command(dwc, in dwc3_setup_scratch_buffers()
363 ret = dwc3_send_gadget_generic_command(dwc, in dwc3_setup_scratch_buffers()
371 dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch * in dwc3_setup_scratch_buffers()
378 static void dwc3_free_scratch_buffers(struct dwc3 *dwc) in dwc3_free_scratch_buffers() argument
380 if (!dwc->has_hibernation) in dwc3_free_scratch_buffers()
383 if (!dwc->nr_scratch) in dwc3_free_scratch_buffers()
387 if (!WARN_ON(dwc->scratchbuf)) in dwc3_free_scratch_buffers()
390 dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch * in dwc3_free_scratch_buffers()
392 kfree(dwc->scratchbuf); in dwc3_free_scratch_buffers()
395 static void dwc3_core_num_eps(struct dwc3 *dwc) in dwc3_core_num_eps() argument
397 struct dwc3_hwparams *parms = &dwc->hwparams; in dwc3_core_num_eps()
399 dwc->num_in_eps = DWC3_NUM_IN_EPS(parms); in dwc3_core_num_eps()
400 dwc->num_out_eps = DWC3_NUM_EPS(parms) - dwc->num_in_eps; in dwc3_core_num_eps()
403 dwc->num_in_eps, dwc->num_out_eps); in dwc3_core_num_eps()
406 static void dwc3_cache_hwparams(struct dwc3 *dwc) in dwc3_cache_hwparams() argument
408 struct dwc3_hwparams *parms = &dwc->hwparams; in dwc3_cache_hwparams()
410 parms->hwparams0 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS0); in dwc3_cache_hwparams()
411 parms->hwparams1 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS1); in dwc3_cache_hwparams()
412 parms->hwparams2 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS2); in dwc3_cache_hwparams()
413 parms->hwparams3 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS3); in dwc3_cache_hwparams()
414 parms->hwparams4 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS4); in dwc3_cache_hwparams()
415 parms->hwparams5 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS5); in dwc3_cache_hwparams()
416 parms->hwparams6 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS6); in dwc3_cache_hwparams()
417 parms->hwparams7 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS7); in dwc3_cache_hwparams()
418 parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8); in dwc3_cache_hwparams()
429 static int dwc3_phy_setup(struct dwc3 *dwc) in dwc3_phy_setup() argument
434 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); in dwc3_phy_setup()
442 if (dwc->revision > DWC3_REVISION_194A) in dwc3_phy_setup()
445 if (dwc->u2ss_inp3_quirk) in dwc3_phy_setup()
448 if (dwc->req_p1p2p3_quirk) in dwc3_phy_setup()
451 if (dwc->del_p1p2p3_quirk) in dwc3_phy_setup()
454 if (dwc->del_phy_power_chg_quirk) in dwc3_phy_setup()
457 if (dwc->lfps_filter_quirk) in dwc3_phy_setup()
460 if (dwc->rx_detect_poll_quirk) in dwc3_phy_setup()
463 if (dwc->tx_de_emphasis_quirk) in dwc3_phy_setup()
464 reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis); in dwc3_phy_setup()
466 if (dwc->dis_u3_susphy_quirk) in dwc3_phy_setup()
469 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); in dwc3_phy_setup()
471 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_phy_setup()
474 switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) { in dwc3_phy_setup()
476 if (dwc->hsphy_interface && in dwc3_phy_setup()
477 !strncmp(dwc->hsphy_interface, "utmi", 4)) { in dwc3_phy_setup()
480 } else if (dwc->hsphy_interface && in dwc3_phy_setup()
481 !strncmp(dwc->hsphy_interface, "ulpi", 4)) { in dwc3_phy_setup()
483 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_phy_setup()
492 ret = dwc3_soft_reset(dwc); in dwc3_phy_setup()
498 ret = dwc3_ulpi_init(dwc); in dwc3_phy_setup()
512 if (dwc->revision > DWC3_REVISION_194A) in dwc3_phy_setup()
515 if (dwc->dis_u2_susphy_quirk) in dwc3_phy_setup()
518 if (dwc->dis_enblslpm_quirk) in dwc3_phy_setup()
521 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); in dwc3_phy_setup()
532 static int dwc3_core_init(struct dwc3 *dwc) in dwc3_core_init() argument
534 u32 hwparams4 = dwc->hwparams.hwparams4; in dwc3_core_init()
538 reg = dwc3_readl(dwc->regs, DWC3_GSNPSID); in dwc3_core_init()
542 dwc->revision = reg; in dwc3_core_init()
545 dwc->revision = dwc3_readl(dwc->regs, DWC3_VER_NUMBER); in dwc3_core_init()
546 dwc->revision |= DWC3_REVISION_IS_DWC31; in dwc3_core_init()
548 dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n"); in dwc3_core_init()
557 dwc3_writel(dwc->regs, DWC3_GUID, LINUX_VERSION_CODE); in dwc3_core_init()
560 if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) == in dwc3_core_init()
562 if (dwc->maximum_speed == USB_SPEED_SUPER) in dwc3_core_init()
563 dwc->maximum_speed = USB_SPEED_HIGH; in dwc3_core_init()
567 ret = dwc3_soft_reset(dwc); in dwc3_core_init()
571 ret = dwc3_core_soft_reset(dwc); in dwc3_core_init()
575 reg = dwc3_readl(dwc->regs, DWC3_GCTL); in dwc3_core_init()
578 switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) { in dwc3_core_init()
592 if ((dwc->dr_mode == USB_DR_MODE_HOST || in dwc3_core_init()
593 dwc->dr_mode == USB_DR_MODE_OTG) && in dwc3_core_init()
594 (dwc->revision >= DWC3_REVISION_210A && in dwc3_core_init()
595 dwc->revision <= DWC3_REVISION_250A)) in dwc3_core_init()
602 dwc->nr_scratch = DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4); in dwc3_core_init()
611 dev_dbg(dwc->dev, "No power optimization available\n"); in dwc3_core_init()
615 if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) { in dwc3_core_init()
616 dev_dbg(dwc->dev, "it is on FPGA board\n"); in dwc3_core_init()
617 dwc->is_fpga = true; in dwc3_core_init()
620 WARN_ONCE(dwc->disable_scramble_quirk && !dwc->is_fpga, in dwc3_core_init()
623 if (dwc->disable_scramble_quirk && dwc->is_fpga) in dwc3_core_init()
628 if (dwc->u2exit_lfps_quirk) in dwc3_core_init()
637 if (dwc->revision < DWC3_REVISION_190A) in dwc3_core_init()
640 dwc3_core_num_eps(dwc); in dwc3_core_init()
642 dwc3_writel(dwc->regs, DWC3_GCTL, reg); in dwc3_core_init()
644 ret = dwc3_alloc_scratch_buffers(dwc); in dwc3_core_init()
648 ret = dwc3_setup_scratch_buffers(dwc); in dwc3_core_init()
655 dwc3_free_scratch_buffers(dwc); in dwc3_core_init()
658 usb_phy_shutdown(dwc->usb2_phy); in dwc3_core_init()
659 usb_phy_shutdown(dwc->usb3_phy); in dwc3_core_init()
660 phy_exit(dwc->usb2_generic_phy); in dwc3_core_init()
661 phy_exit(dwc->usb3_generic_phy); in dwc3_core_init()
667 static void dwc3_core_exit(struct dwc3 *dwc) in dwc3_core_exit() argument
669 dwc3_free_scratch_buffers(dwc); in dwc3_core_exit()
670 usb_phy_shutdown(dwc->usb2_phy); in dwc3_core_exit()
671 usb_phy_shutdown(dwc->usb3_phy); in dwc3_core_exit()
672 phy_exit(dwc->usb2_generic_phy); in dwc3_core_exit()
673 phy_exit(dwc->usb3_generic_phy); in dwc3_core_exit()
676 static int dwc3_core_get_phy(struct dwc3 *dwc) in dwc3_core_get_phy() argument
678 struct device *dev = dwc->dev; in dwc3_core_get_phy()
683 dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); in dwc3_core_get_phy()
684 dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1); in dwc3_core_get_phy()
686 dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); in dwc3_core_get_phy()
687 dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); in dwc3_core_get_phy()
690 if (IS_ERR(dwc->usb2_phy)) { in dwc3_core_get_phy()
691 ret = PTR_ERR(dwc->usb2_phy); in dwc3_core_get_phy()
693 dwc->usb2_phy = NULL; in dwc3_core_get_phy()
702 if (IS_ERR(dwc->usb3_phy)) { in dwc3_core_get_phy()
703 ret = PTR_ERR(dwc->usb3_phy); in dwc3_core_get_phy()
705 dwc->usb3_phy = NULL; in dwc3_core_get_phy()
714 dwc->usb2_generic_phy = devm_phy_get(dev, "usb2-phy"); in dwc3_core_get_phy()
715 if (IS_ERR(dwc->usb2_generic_phy)) { in dwc3_core_get_phy()
716 ret = PTR_ERR(dwc->usb2_generic_phy); in dwc3_core_get_phy()
718 dwc->usb2_generic_phy = NULL; in dwc3_core_get_phy()
727 dwc->usb3_generic_phy = devm_phy_get(dev, "usb3-phy"); in dwc3_core_get_phy()
728 if (IS_ERR(dwc->usb3_generic_phy)) { in dwc3_core_get_phy()
729 ret = PTR_ERR(dwc->usb3_generic_phy); in dwc3_core_get_phy()
731 dwc->usb3_generic_phy = NULL; in dwc3_core_get_phy()
743 static int dwc3_core_init_mode(struct dwc3 *dwc) in dwc3_core_init_mode() argument
745 struct device *dev = dwc->dev; in dwc3_core_init_mode()
748 switch (dwc->dr_mode) { in dwc3_core_init_mode()
750 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); in dwc3_core_init_mode()
751 ret = dwc3_gadget_init(dwc); in dwc3_core_init_mode()
758 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); in dwc3_core_init_mode()
759 ret = dwc3_host_init(dwc); in dwc3_core_init_mode()
766 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); in dwc3_core_init_mode()
767 ret = dwc3_host_init(dwc); in dwc3_core_init_mode()
773 ret = dwc3_gadget_init(dwc); in dwc3_core_init_mode()
780 dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode); in dwc3_core_init_mode()
787 static void dwc3_core_exit_mode(struct dwc3 *dwc) in dwc3_core_exit_mode() argument
789 switch (dwc->dr_mode) { in dwc3_core_exit_mode()
791 dwc3_gadget_exit(dwc); in dwc3_core_exit_mode()
794 dwc3_host_exit(dwc); in dwc3_core_exit_mode()
797 dwc3_host_exit(dwc); in dwc3_core_exit_mode()
798 dwc3_gadget_exit(dwc); in dwc3_core_exit_mode()
813 struct dwc3 *dwc; in dwc3_probe() local
824 mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); in dwc3_probe()
828 dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); in dwc3_probe()
829 dwc->mem = mem; in dwc3_probe()
830 dwc->dev = dev; in dwc3_probe()
837 dwc->xhci_resources[1].start = res->start; in dwc3_probe()
838 dwc->xhci_resources[1].end = res->end; in dwc3_probe()
839 dwc->xhci_resources[1].flags = res->flags; in dwc3_probe()
840 dwc->xhci_resources[1].name = res->name; in dwc3_probe()
848 dwc->xhci_resources[0].start = res->start; in dwc3_probe()
849 dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + in dwc3_probe()
851 dwc->xhci_resources[0].flags = res->flags; in dwc3_probe()
852 dwc->xhci_resources[0].name = res->name; in dwc3_probe()
866 dwc->regs = regs; in dwc3_probe()
867 dwc->regs_size = resource_size(res); in dwc3_probe()
881 dwc->maximum_speed = usb_get_maximum_speed(dev); in dwc3_probe()
882 dwc->dr_mode = usb_get_dr_mode(dev); in dwc3_probe()
884 dwc->has_lpm_erratum = device_property_read_bool(dev, in dwc3_probe()
888 dwc->is_utmi_l1_suspend = device_property_read_bool(dev, in dwc3_probe()
892 dwc->usb3_lpm_capable = device_property_read_bool(dev, in dwc3_probe()
895 dwc->needs_fifo_resize = device_property_read_bool(dev, in dwc3_probe()
898 dwc->disable_scramble_quirk = device_property_read_bool(dev, in dwc3_probe()
900 dwc->u2exit_lfps_quirk = device_property_read_bool(dev, in dwc3_probe()
902 dwc->u2ss_inp3_quirk = device_property_read_bool(dev, in dwc3_probe()
904 dwc->req_p1p2p3_quirk = device_property_read_bool(dev, in dwc3_probe()
906 dwc->del_p1p2p3_quirk = device_property_read_bool(dev, in dwc3_probe()
908 dwc->del_phy_power_chg_quirk = device_property_read_bool(dev, in dwc3_probe()
910 dwc->lfps_filter_quirk = device_property_read_bool(dev, in dwc3_probe()
912 dwc->rx_detect_poll_quirk = device_property_read_bool(dev, in dwc3_probe()
914 dwc->dis_u3_susphy_quirk = device_property_read_bool(dev, in dwc3_probe()
916 dwc->dis_u2_susphy_quirk = device_property_read_bool(dev, in dwc3_probe()
918 dwc->dis_enblslpm_quirk = device_property_read_bool(dev, in dwc3_probe()
921 dwc->tx_de_emphasis_quirk = device_property_read_bool(dev, in dwc3_probe()
926 &dwc->hsphy_interface); in dwc3_probe()
931 dwc->maximum_speed = pdata->maximum_speed; in dwc3_probe()
932 dwc->has_lpm_erratum = pdata->has_lpm_erratum; in dwc3_probe()
935 dwc->is_utmi_l1_suspend = pdata->is_utmi_l1_suspend; in dwc3_probe()
939 dwc->needs_fifo_resize = pdata->tx_fifo_resize; in dwc3_probe()
940 dwc->usb3_lpm_capable = pdata->usb3_lpm_capable; in dwc3_probe()
941 dwc->dr_mode = pdata->dr_mode; in dwc3_probe()
943 dwc->disable_scramble_quirk = pdata->disable_scramble_quirk; in dwc3_probe()
944 dwc->u2exit_lfps_quirk = pdata->u2exit_lfps_quirk; in dwc3_probe()
945 dwc->u2ss_inp3_quirk = pdata->u2ss_inp3_quirk; in dwc3_probe()
946 dwc->req_p1p2p3_quirk = pdata->req_p1p2p3_quirk; in dwc3_probe()
947 dwc->del_p1p2p3_quirk = pdata->del_p1p2p3_quirk; in dwc3_probe()
948 dwc->del_phy_power_chg_quirk = pdata->del_phy_power_chg_quirk; in dwc3_probe()
949 dwc->lfps_filter_quirk = pdata->lfps_filter_quirk; in dwc3_probe()
950 dwc->rx_detect_poll_quirk = pdata->rx_detect_poll_quirk; in dwc3_probe()
951 dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk; in dwc3_probe()
952 dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk; in dwc3_probe()
953 dwc->dis_enblslpm_quirk = pdata->dis_enblslpm_quirk; in dwc3_probe()
955 dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk; in dwc3_probe()
959 dwc->hsphy_interface = pdata->hsphy_interface; in dwc3_probe()
964 if (dwc->maximum_speed == USB_SPEED_UNKNOWN) in dwc3_probe()
965 dwc->maximum_speed = USB_SPEED_SUPER; in dwc3_probe()
967 dwc->lpm_nyet_threshold = lpm_nyet_threshold; in dwc3_probe()
968 dwc->tx_de_emphasis = tx_de_emphasis; in dwc3_probe()
970 dwc->hird_threshold = hird_threshold in dwc3_probe()
971 | (dwc->is_utmi_l1_suspend << 4); in dwc3_probe()
973 platform_set_drvdata(pdev, dwc); in dwc3_probe()
974 dwc3_cache_hwparams(dwc); in dwc3_probe()
976 ret = dwc3_phy_setup(dwc); in dwc3_probe()
980 ret = dwc3_core_get_phy(dwc); in dwc3_probe()
984 spin_lock_init(&dwc->lock); in dwc3_probe()
996 ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); in dwc3_probe()
998 dev_err(dwc->dev, "failed to allocate event buffers\n"); in dwc3_probe()
1004 dwc->dr_mode = USB_DR_MODE_HOST; in dwc3_probe()
1006 dwc->dr_mode = USB_DR_MODE_PERIPHERAL; in dwc3_probe()
1008 if (dwc->dr_mode == USB_DR_MODE_UNKNOWN) in dwc3_probe()
1009 dwc->dr_mode = USB_DR_MODE_OTG; in dwc3_probe()
1011 ret = dwc3_core_init(dwc); in dwc3_probe()
1018 dwc3_frame_length_adjustment(dwc, fladj); in dwc3_probe()
1020 usb_phy_set_suspend(dwc->usb2_phy, 0); in dwc3_probe()
1021 usb_phy_set_suspend(dwc->usb3_phy, 0); in dwc3_probe()
1022 ret = phy_power_on(dwc->usb2_generic_phy); in dwc3_probe()
1026 ret = phy_power_on(dwc->usb3_generic_phy); in dwc3_probe()
1030 ret = dwc3_event_buffers_setup(dwc); in dwc3_probe()
1032 dev_err(dwc->dev, "failed to setup event buffers\n"); in dwc3_probe()
1036 ret = dwc3_core_init_mode(dwc); in dwc3_probe()
1040 ret = dwc3_debugfs_init(dwc); in dwc3_probe()
1051 dwc3_core_exit_mode(dwc); in dwc3_probe()
1054 dwc3_event_buffers_cleanup(dwc); in dwc3_probe()
1057 phy_power_off(dwc->usb3_generic_phy); in dwc3_probe()
1060 phy_power_off(dwc->usb2_generic_phy); in dwc3_probe()
1063 usb_phy_set_suspend(dwc->usb2_phy, 1); in dwc3_probe()
1064 usb_phy_set_suspend(dwc->usb3_phy, 1); in dwc3_probe()
1065 dwc3_core_exit(dwc); in dwc3_probe()
1068 dwc3_free_event_buffers(dwc); in dwc3_probe()
1069 dwc3_ulpi_exit(dwc); in dwc3_probe()
1084 struct dwc3 *dwc = platform_get_drvdata(pdev); in dwc3_remove() local
1094 dwc3_debugfs_exit(dwc); in dwc3_remove()
1095 dwc3_core_exit_mode(dwc); in dwc3_remove()
1096 dwc3_event_buffers_cleanup(dwc); in dwc3_remove()
1097 dwc3_free_event_buffers(dwc); in dwc3_remove()
1099 usb_phy_set_suspend(dwc->usb2_phy, 1); in dwc3_remove()
1100 usb_phy_set_suspend(dwc->usb3_phy, 1); in dwc3_remove()
1101 phy_power_off(dwc->usb2_generic_phy); in dwc3_remove()
1102 phy_power_off(dwc->usb3_generic_phy); in dwc3_remove()
1104 dwc3_core_exit(dwc); in dwc3_remove()
1105 dwc3_ulpi_exit(dwc); in dwc3_remove()
1116 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_suspend() local
1119 spin_lock_irqsave(&dwc->lock, flags); in dwc3_suspend()
1121 switch (dwc->dr_mode) { in dwc3_suspend()
1124 dwc3_gadget_suspend(dwc); in dwc3_suspend()
1128 dwc3_event_buffers_cleanup(dwc); in dwc3_suspend()
1132 dwc->gctl = dwc3_readl(dwc->regs, DWC3_GCTL); in dwc3_suspend()
1133 spin_unlock_irqrestore(&dwc->lock, flags); in dwc3_suspend()
1135 usb_phy_shutdown(dwc->usb3_phy); in dwc3_suspend()
1136 usb_phy_shutdown(dwc->usb2_phy); in dwc3_suspend()
1137 phy_exit(dwc->usb2_generic_phy); in dwc3_suspend()
1138 phy_exit(dwc->usb3_generic_phy); in dwc3_suspend()
1147 struct dwc3 *dwc = dev_get_drvdata(dev); in dwc3_resume() local
1153 usb_phy_init(dwc->usb3_phy); in dwc3_resume()
1154 usb_phy_init(dwc->usb2_phy); in dwc3_resume()
1155 ret = phy_init(dwc->usb2_generic_phy); in dwc3_resume()
1159 ret = phy_init(dwc->usb3_generic_phy); in dwc3_resume()
1163 spin_lock_irqsave(&dwc->lock, flags); in dwc3_resume()
1165 dwc3_event_buffers_setup(dwc); in dwc3_resume()
1166 dwc3_writel(dwc->regs, DWC3_GCTL, dwc->gctl); in dwc3_resume()
1168 switch (dwc->dr_mode) { in dwc3_resume()
1171 dwc3_gadget_resume(dwc); in dwc3_resume()
1179 spin_unlock_irqrestore(&dwc->lock, flags); in dwc3_resume()
1188 phy_exit(dwc->usb2_generic_phy); in dwc3_resume()