1 // SPDX-License-Identifier: GPL-2.0
3 * core.c - DesignWare USB3 DRD Controller Core file
5 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
7 * Authors: Felipe Balbi <balbi@ti.com>,
8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
11 #include <linux/version.h>
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/slab.h>
15 #include <linux/spinlock.h>
16 #include <linux/platform_device.h>
17 #include <linux/pm_runtime.h>
18 #include <linux/interrupt.h>
19 #include <linux/ioport.h>
21 #include <linux/list.h>
22 #include <linux/delay.h>
23 #include <linux/dma-mapping.h>
25 #include <linux/acpi.h>
26 #include <linux/pinctrl/consumer.h>
28 #include <linux/usb/ch9.h>
29 #include <linux/usb/gadget.h>
30 #include <linux/usb/of.h>
31 #include <linux/usb/otg.h>
39 #define DWC3_DEFAULT_AUTOSUSPEND_DELAY 5000 /* ms */
42 * dwc3_get_dr_mode - Validates and sets dr_mode
43 * @dwc: pointer to our context structure
45 static int dwc3_get_dr_mode(struct dwc3
*dwc
)
47 enum usb_dr_mode mode
;
48 struct device
*dev
= dwc
->dev
;
51 if (dwc
->dr_mode
== USB_DR_MODE_UNKNOWN
)
52 dwc
->dr_mode
= USB_DR_MODE_OTG
;
55 hw_mode
= DWC3_GHWPARAMS0_MODE(dwc
->hwparams
.hwparams0
);
58 case DWC3_GHWPARAMS0_MODE_GADGET
:
59 if (IS_ENABLED(CONFIG_USB_DWC3_HOST
)) {
61 "Controller does not support host mode.\n");
64 mode
= USB_DR_MODE_PERIPHERAL
;
66 case DWC3_GHWPARAMS0_MODE_HOST
:
67 if (IS_ENABLED(CONFIG_USB_DWC3_GADGET
)) {
69 "Controller does not support device mode.\n");
72 mode
= USB_DR_MODE_HOST
;
75 if (IS_ENABLED(CONFIG_USB_DWC3_HOST
))
76 mode
= USB_DR_MODE_HOST
;
77 else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET
))
78 mode
= USB_DR_MODE_PERIPHERAL
;
81 if (mode
!= dwc
->dr_mode
) {
83 "Configuration mismatch. dr_mode forced to %s\n",
84 mode
== USB_DR_MODE_HOST
? "host" : "gadget");
92 static void dwc3_event_buffers_cleanup(struct dwc3
*dwc
);
93 static int dwc3_event_buffers_setup(struct dwc3
*dwc
);
95 static void dwc3_set_prtcap(struct dwc3
*dwc
, u32 mode
)
99 reg
= dwc3_readl(dwc
->regs
, DWC3_GCTL
);
100 reg
&= ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG
));
101 reg
|= DWC3_GCTL_PRTCAPDIR(mode
);
102 dwc3_writel(dwc
->regs
, DWC3_GCTL
, reg
);
104 dwc
->current_dr_role
= mode
;
107 static void __dwc3_set_mode(struct work_struct
*work
)
109 struct dwc3
*dwc
= work_to_dwc(work
);
113 if (!dwc
->desired_dr_role
)
116 if (dwc
->desired_dr_role
== dwc
->current_dr_role
)
119 if (dwc
->dr_mode
!= USB_DR_MODE_OTG
)
122 if (dwc
->desired_dr_role
== DWC3_GCTL_PRTCAP_OTG
)
125 switch (dwc
->current_dr_role
) {
126 case DWC3_GCTL_PRTCAP_HOST
:
129 case DWC3_GCTL_PRTCAP_DEVICE
:
130 dwc3_gadget_exit(dwc
);
131 dwc3_event_buffers_cleanup(dwc
);
137 spin_lock_irqsave(&dwc
->lock
, flags
);
139 dwc3_set_prtcap(dwc
, dwc
->desired_dr_role
);
141 spin_unlock_irqrestore(&dwc
->lock
, flags
);
143 switch (dwc
->desired_dr_role
) {
144 case DWC3_GCTL_PRTCAP_HOST
:
145 ret
= dwc3_host_init(dwc
);
147 dev_err(dwc
->dev
, "failed to initialize host\n");
150 otg_set_vbus(dwc
->usb2_phy
->otg
, true);
151 phy_set_mode(dwc
->usb2_generic_phy
, PHY_MODE_USB_HOST
);
152 phy_set_mode(dwc
->usb3_generic_phy
, PHY_MODE_USB_HOST
);
155 case DWC3_GCTL_PRTCAP_DEVICE
:
156 dwc3_event_buffers_setup(dwc
);
159 otg_set_vbus(dwc
->usb2_phy
->otg
, false);
160 phy_set_mode(dwc
->usb2_generic_phy
, PHY_MODE_USB_DEVICE
);
161 phy_set_mode(dwc
->usb3_generic_phy
, PHY_MODE_USB_DEVICE
);
163 ret
= dwc3_gadget_init(dwc
);
165 dev_err(dwc
->dev
, "failed to initialize peripheral\n");
172 void dwc3_set_mode(struct dwc3
*dwc
, u32 mode
)
176 spin_lock_irqsave(&dwc
->lock
, flags
);
177 dwc
->desired_dr_role
= mode
;
178 spin_unlock_irqrestore(&dwc
->lock
, flags
);
180 queue_work(system_freezable_wq
, &dwc
->drd_work
);
183 u32
dwc3_core_fifo_space(struct dwc3_ep
*dep
, u8 type
)
185 struct dwc3
*dwc
= dep
->dwc
;
188 dwc3_writel(dwc
->regs
, DWC3_GDBGFIFOSPACE
,
189 DWC3_GDBGFIFOSPACE_NUM(dep
->number
) |
190 DWC3_GDBGFIFOSPACE_TYPE(type
));
192 reg
= dwc3_readl(dwc
->regs
, DWC3_GDBGFIFOSPACE
);
194 return DWC3_GDBGFIFOSPACE_SPACE_AVAILABLE(reg
);
198 * dwc3_core_soft_reset - Issues core soft reset and PHY reset
199 * @dwc: pointer to our context structure
201 static int dwc3_core_soft_reset(struct dwc3
*dwc
)
207 usb_phy_init(dwc
->usb2_phy
);
208 usb_phy_init(dwc
->usb3_phy
);
209 ret
= phy_init(dwc
->usb2_generic_phy
);
213 ret
= phy_init(dwc
->usb3_generic_phy
);
215 phy_exit(dwc
->usb2_generic_phy
);
220 * We're resetting only the device side because, if we're in host mode,
221 * XHCI driver will reset the host block. If dwc3 was configured for
222 * host-only mode, then we can return early.
224 if (dwc
->current_dr_role
== DWC3_GCTL_PRTCAP_HOST
)
227 reg
= dwc3_readl(dwc
->regs
, DWC3_DCTL
);
228 reg
|= DWC3_DCTL_CSFTRST
;
229 dwc3_writel(dwc
->regs
, DWC3_DCTL
, reg
);
232 reg
= dwc3_readl(dwc
->regs
, DWC3_DCTL
);
233 if (!(reg
& DWC3_DCTL_CSFTRST
))
239 phy_exit(dwc
->usb3_generic_phy
);
240 phy_exit(dwc
->usb2_generic_phy
);
246 * For DWC_usb31 controller, once DWC3_DCTL_CSFTRST bit is cleared,
247 * we must wait at least 50ms before accessing the PHY domain
248 * (synchronization delay). DWC_usb31 programming guide section 1.3.2.
250 if (dwc3_is_usb31(dwc
))
257 * dwc3_frame_length_adjustment - Adjusts frame length if required
258 * @dwc3: Pointer to our controller context structure
260 static void dwc3_frame_length_adjustment(struct dwc3
*dwc
)
265 if (dwc
->revision
< DWC3_REVISION_250A
)
271 reg
= dwc3_readl(dwc
->regs
, DWC3_GFLADJ
);
272 dft
= reg
& DWC3_GFLADJ_30MHZ_MASK
;
273 if (!dev_WARN_ONCE(dwc
->dev
, dft
== dwc
->fladj
,
274 "request value same as default, ignoring\n")) {
275 reg
&= ~DWC3_GFLADJ_30MHZ_MASK
;
276 reg
|= DWC3_GFLADJ_30MHZ_SDBND_SEL
| dwc
->fladj
;
277 dwc3_writel(dwc
->regs
, DWC3_GFLADJ
, reg
);
282 * dwc3_free_one_event_buffer - Frees one event buffer
283 * @dwc: Pointer to our controller context structure
284 * @evt: Pointer to event buffer to be freed
286 static void dwc3_free_one_event_buffer(struct dwc3
*dwc
,
287 struct dwc3_event_buffer
*evt
)
289 dma_free_coherent(dwc
->sysdev
, evt
->length
, evt
->buf
, evt
->dma
);
293 * dwc3_alloc_one_event_buffer - Allocates one event buffer structure
294 * @dwc: Pointer to our controller context structure
295 * @length: size of the event buffer
297 * Returns a pointer to the allocated event buffer structure on success
298 * otherwise ERR_PTR(errno).
300 static struct dwc3_event_buffer
*dwc3_alloc_one_event_buffer(struct dwc3
*dwc
,
303 struct dwc3_event_buffer
*evt
;
305 evt
= devm_kzalloc(dwc
->dev
, sizeof(*evt
), GFP_KERNEL
);
307 return ERR_PTR(-ENOMEM
);
310 evt
->length
= length
;
311 evt
->cache
= devm_kzalloc(dwc
->dev
, length
, GFP_KERNEL
);
313 return ERR_PTR(-ENOMEM
);
315 evt
->buf
= dma_alloc_coherent(dwc
->sysdev
, length
,
316 &evt
->dma
, GFP_KERNEL
);
318 return ERR_PTR(-ENOMEM
);
324 * dwc3_free_event_buffers - frees all allocated event buffers
325 * @dwc: Pointer to our controller context structure
327 static void dwc3_free_event_buffers(struct dwc3
*dwc
)
329 struct dwc3_event_buffer
*evt
;
333 dwc3_free_one_event_buffer(dwc
, evt
);
337 * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length
338 * @dwc: pointer to our controller context structure
339 * @length: size of event buffer
341 * Returns 0 on success otherwise negative errno. In the error case, dwc
342 * may contain some buffers allocated but not all which were requested.
344 static int dwc3_alloc_event_buffers(struct dwc3
*dwc
, unsigned length
)
346 struct dwc3_event_buffer
*evt
;
348 evt
= dwc3_alloc_one_event_buffer(dwc
, length
);
350 dev_err(dwc
->dev
, "can't allocate event buffer\n");
359 * dwc3_event_buffers_setup - setup our allocated event buffers
360 * @dwc: pointer to our controller context structure
362 * Returns 0 on success otherwise negative errno.
364 static int dwc3_event_buffers_setup(struct dwc3
*dwc
)
366 struct dwc3_event_buffer
*evt
;
370 dwc3_writel(dwc
->regs
, DWC3_GEVNTADRLO(0),
371 lower_32_bits(evt
->dma
));
372 dwc3_writel(dwc
->regs
, DWC3_GEVNTADRHI(0),
373 upper_32_bits(evt
->dma
));
374 dwc3_writel(dwc
->regs
, DWC3_GEVNTSIZ(0),
375 DWC3_GEVNTSIZ_SIZE(evt
->length
));
376 dwc3_writel(dwc
->regs
, DWC3_GEVNTCOUNT(0), 0);
381 static void dwc3_event_buffers_cleanup(struct dwc3
*dwc
)
383 struct dwc3_event_buffer
*evt
;
389 dwc3_writel(dwc
->regs
, DWC3_GEVNTADRLO(0), 0);
390 dwc3_writel(dwc
->regs
, DWC3_GEVNTADRHI(0), 0);
391 dwc3_writel(dwc
->regs
, DWC3_GEVNTSIZ(0), DWC3_GEVNTSIZ_INTMASK
392 | DWC3_GEVNTSIZ_SIZE(0));
393 dwc3_writel(dwc
->regs
, DWC3_GEVNTCOUNT(0), 0);
396 static int dwc3_alloc_scratch_buffers(struct dwc3
*dwc
)
398 if (!dwc
->has_hibernation
)
401 if (!dwc
->nr_scratch
)
404 dwc
->scratchbuf
= kmalloc_array(dwc
->nr_scratch
,
405 DWC3_SCRATCHBUF_SIZE
, GFP_KERNEL
);
406 if (!dwc
->scratchbuf
)
412 static int dwc3_setup_scratch_buffers(struct dwc3
*dwc
)
414 dma_addr_t scratch_addr
;
418 if (!dwc
->has_hibernation
)
421 if (!dwc
->nr_scratch
)
424 /* should never fall here */
425 if (!WARN_ON(dwc
->scratchbuf
))
428 scratch_addr
= dma_map_single(dwc
->sysdev
, dwc
->scratchbuf
,
429 dwc
->nr_scratch
* DWC3_SCRATCHBUF_SIZE
,
431 if (dma_mapping_error(dwc
->sysdev
, scratch_addr
)) {
432 dev_err(dwc
->sysdev
, "failed to map scratch buffer\n");
437 dwc
->scratch_addr
= scratch_addr
;
439 param
= lower_32_bits(scratch_addr
);
441 ret
= dwc3_send_gadget_generic_command(dwc
,
442 DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO
, param
);
446 param
= upper_32_bits(scratch_addr
);
448 ret
= dwc3_send_gadget_generic_command(dwc
,
449 DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI
, param
);
456 dma_unmap_single(dwc
->sysdev
, dwc
->scratch_addr
, dwc
->nr_scratch
*
457 DWC3_SCRATCHBUF_SIZE
, DMA_BIDIRECTIONAL
);
463 static void dwc3_free_scratch_buffers(struct dwc3
*dwc
)
465 if (!dwc
->has_hibernation
)
468 if (!dwc
->nr_scratch
)
471 /* should never fall here */
472 if (!WARN_ON(dwc
->scratchbuf
))
475 dma_unmap_single(dwc
->sysdev
, dwc
->scratch_addr
, dwc
->nr_scratch
*
476 DWC3_SCRATCHBUF_SIZE
, DMA_BIDIRECTIONAL
);
477 kfree(dwc
->scratchbuf
);
480 static void dwc3_core_num_eps(struct dwc3
*dwc
)
482 struct dwc3_hwparams
*parms
= &dwc
->hwparams
;
484 dwc
->num_eps
= DWC3_NUM_EPS(parms
);
487 static void dwc3_cache_hwparams(struct dwc3
*dwc
)
489 struct dwc3_hwparams
*parms
= &dwc
->hwparams
;
491 parms
->hwparams0
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS0
);
492 parms
->hwparams1
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS1
);
493 parms
->hwparams2
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS2
);
494 parms
->hwparams3
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS3
);
495 parms
->hwparams4
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS4
);
496 parms
->hwparams5
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS5
);
497 parms
->hwparams6
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS6
);
498 parms
->hwparams7
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS7
);
499 parms
->hwparams8
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS8
);
502 static int dwc3_core_ulpi_init(struct dwc3
*dwc
)
507 intf
= DWC3_GHWPARAMS3_HSPHY_IFC(dwc
->hwparams
.hwparams3
);
509 if (intf
== DWC3_GHWPARAMS3_HSPHY_IFC_ULPI
||
510 (intf
== DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI
&&
511 dwc
->hsphy_interface
&&
512 !strncmp(dwc
->hsphy_interface
, "ulpi", 4)))
513 ret
= dwc3_ulpi_init(dwc
);
519 * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core
520 * @dwc: Pointer to our controller context structure
522 * Returns 0 on success. The USB PHY interfaces are configured but not
523 * initialized. The PHY interfaces and the PHYs get initialized together with
524 * the core in dwc3_core_init.
526 static int dwc3_phy_setup(struct dwc3
*dwc
)
530 reg
= dwc3_readl(dwc
->regs
, DWC3_GUSB3PIPECTL(0));
533 * Make sure UX_EXIT_PX is cleared as that causes issues with some
534 * PHYs. Also, this bit is not supposed to be used in normal operation.
536 reg
&= ~DWC3_GUSB3PIPECTL_UX_EXIT_PX
;
539 * Above 1.94a, it is recommended to set DWC3_GUSB3PIPECTL_SUSPHY
540 * to '0' during coreConsultant configuration. So default value
541 * will be '0' when the core is reset. Application needs to set it
542 * to '1' after the core initialization is completed.
544 if (dwc
->revision
> DWC3_REVISION_194A
)
545 reg
|= DWC3_GUSB3PIPECTL_SUSPHY
;
547 if (dwc
->u2ss_inp3_quirk
)
548 reg
|= DWC3_GUSB3PIPECTL_U2SSINP3OK
;
550 if (dwc
->dis_rxdet_inp3_quirk
)
551 reg
|= DWC3_GUSB3PIPECTL_DISRXDETINP3
;
553 if (dwc
->req_p1p2p3_quirk
)
554 reg
|= DWC3_GUSB3PIPECTL_REQP1P2P3
;
556 if (dwc
->del_p1p2p3_quirk
)
557 reg
|= DWC3_GUSB3PIPECTL_DEP1P2P3_EN
;
559 if (dwc
->del_phy_power_chg_quirk
)
560 reg
|= DWC3_GUSB3PIPECTL_DEPOCHANGE
;
562 if (dwc
->lfps_filter_quirk
)
563 reg
|= DWC3_GUSB3PIPECTL_LFPSFILT
;
565 if (dwc
->rx_detect_poll_quirk
)
566 reg
|= DWC3_GUSB3PIPECTL_RX_DETOPOLL
;
568 if (dwc
->tx_de_emphasis_quirk
)
569 reg
|= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc
->tx_de_emphasis
);
571 if (dwc
->dis_u3_susphy_quirk
)
572 reg
&= ~DWC3_GUSB3PIPECTL_SUSPHY
;
574 if (dwc
->dis_del_phy_power_chg_quirk
)
575 reg
&= ~DWC3_GUSB3PIPECTL_DEPOCHANGE
;
577 dwc3_writel(dwc
->regs
, DWC3_GUSB3PIPECTL(0), reg
);
579 reg
= dwc3_readl(dwc
->regs
, DWC3_GUSB2PHYCFG(0));
581 /* Select the HS PHY interface */
582 switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc
->hwparams
.hwparams3
)) {
583 case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI
:
584 if (dwc
->hsphy_interface
&&
585 !strncmp(dwc
->hsphy_interface
, "utmi", 4)) {
586 reg
&= ~DWC3_GUSB2PHYCFG_ULPI_UTMI
;
588 } else if (dwc
->hsphy_interface
&&
589 !strncmp(dwc
->hsphy_interface
, "ulpi", 4)) {
590 reg
|= DWC3_GUSB2PHYCFG_ULPI_UTMI
;
591 dwc3_writel(dwc
->regs
, DWC3_GUSB2PHYCFG(0), reg
);
593 /* Relying on default value. */
594 if (!(reg
& DWC3_GUSB2PHYCFG_ULPI_UTMI
))
598 case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI
:
604 switch (dwc
->hsphy_mode
) {
605 case USBPHY_INTERFACE_MODE_UTMI
:
606 reg
&= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK
|
607 DWC3_GUSB2PHYCFG_USBTRDTIM_MASK
);
608 reg
|= DWC3_GUSB2PHYCFG_PHYIF(UTMI_PHYIF_8_BIT
) |
609 DWC3_GUSB2PHYCFG_USBTRDTIM(USBTRDTIM_UTMI_8_BIT
);
611 case USBPHY_INTERFACE_MODE_UTMIW
:
612 reg
&= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK
|
613 DWC3_GUSB2PHYCFG_USBTRDTIM_MASK
);
614 reg
|= DWC3_GUSB2PHYCFG_PHYIF(UTMI_PHYIF_16_BIT
) |
615 DWC3_GUSB2PHYCFG_USBTRDTIM(USBTRDTIM_UTMI_16_BIT
);
622 * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to
623 * '0' during coreConsultant configuration. So default value will
624 * be '0' when the core is reset. Application needs to set it to
625 * '1' after the core initialization is completed.
627 if (dwc
->revision
> DWC3_REVISION_194A
)
628 reg
|= DWC3_GUSB2PHYCFG_SUSPHY
;
630 if (dwc
->dis_u2_susphy_quirk
)
631 reg
&= ~DWC3_GUSB2PHYCFG_SUSPHY
;
633 if (dwc
->dis_enblslpm_quirk
)
634 reg
&= ~DWC3_GUSB2PHYCFG_ENBLSLPM
;
636 if (dwc
->dis_u2_freeclk_exists_quirk
)
637 reg
&= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS
;
639 dwc3_writel(dwc
->regs
, DWC3_GUSB2PHYCFG(0), reg
);
644 static void dwc3_core_exit(struct dwc3
*dwc
)
646 dwc3_event_buffers_cleanup(dwc
);
648 usb_phy_shutdown(dwc
->usb2_phy
);
649 usb_phy_shutdown(dwc
->usb3_phy
);
650 phy_exit(dwc
->usb2_generic_phy
);
651 phy_exit(dwc
->usb3_generic_phy
);
653 usb_phy_set_suspend(dwc
->usb2_phy
, 1);
654 usb_phy_set_suspend(dwc
->usb3_phy
, 1);
655 phy_power_off(dwc
->usb2_generic_phy
);
656 phy_power_off(dwc
->usb3_generic_phy
);
659 static bool dwc3_core_is_valid(struct dwc3
*dwc
)
663 reg
= dwc3_readl(dwc
->regs
, DWC3_GSNPSID
);
665 /* This should read as U3 followed by revision number */
666 if ((reg
& DWC3_GSNPSID_MASK
) == 0x55330000) {
667 /* Detected DWC_usb3 IP */
669 } else if ((reg
& DWC3_GSNPSID_MASK
) == 0x33310000) {
670 /* Detected DWC_usb31 IP */
671 dwc
->revision
= dwc3_readl(dwc
->regs
, DWC3_VER_NUMBER
);
672 dwc
->revision
|= DWC3_REVISION_IS_DWC31
;
680 static void dwc3_core_setup_global_control(struct dwc3
*dwc
)
682 u32 hwparams4
= dwc
->hwparams
.hwparams4
;
685 reg
= dwc3_readl(dwc
->regs
, DWC3_GCTL
);
686 reg
&= ~DWC3_GCTL_SCALEDOWN_MASK
;
688 switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc
->hwparams
.hwparams1
)) {
689 case DWC3_GHWPARAMS1_EN_PWROPT_CLK
:
691 * WORKAROUND: DWC3 revisions between 2.10a and 2.50a have an
692 * issue which would cause xHCI compliance tests to fail.
694 * Because of that we cannot enable clock gating on such
699 * STAR#9000588375: Clock Gating, SOF Issues when ref_clk-Based
702 if ((dwc
->dr_mode
== USB_DR_MODE_HOST
||
703 dwc
->dr_mode
== USB_DR_MODE_OTG
) &&
704 (dwc
->revision
>= DWC3_REVISION_210A
&&
705 dwc
->revision
<= DWC3_REVISION_250A
))
706 reg
|= DWC3_GCTL_DSBLCLKGTNG
| DWC3_GCTL_SOFITPSYNC
;
708 reg
&= ~DWC3_GCTL_DSBLCLKGTNG
;
710 case DWC3_GHWPARAMS1_EN_PWROPT_HIB
:
711 /* enable hibernation here */
712 dwc
->nr_scratch
= DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4
);
715 * REVISIT Enabling this bit so that host-mode hibernation
716 * will work. Device-mode hibernation is not yet implemented.
718 reg
|= DWC3_GCTL_GBLHIBERNATIONEN
;
725 /* check if current dwc3 is on simulation board */
726 if (dwc
->hwparams
.hwparams6
& DWC3_GHWPARAMS6_EN_FPGA
) {
727 dev_info(dwc
->dev
, "Running with FPGA optmizations\n");
731 WARN_ONCE(dwc
->disable_scramble_quirk
&& !dwc
->is_fpga
,
732 "disable_scramble cannot be used on non-FPGA builds\n");
734 if (dwc
->disable_scramble_quirk
&& dwc
->is_fpga
)
735 reg
|= DWC3_GCTL_DISSCRAMBLE
;
737 reg
&= ~DWC3_GCTL_DISSCRAMBLE
;
739 if (dwc
->u2exit_lfps_quirk
)
740 reg
|= DWC3_GCTL_U2EXIT_LFPS
;
743 * WORKAROUND: DWC3 revisions <1.90a have a bug
744 * where the device can fail to connect at SuperSpeed
745 * and falls back to high-speed mode which causes
746 * the device to enter a Connect/Disconnect loop
748 if (dwc
->revision
< DWC3_REVISION_190A
)
749 reg
|= DWC3_GCTL_U2RSTECN
;
751 dwc3_writel(dwc
->regs
, DWC3_GCTL
, reg
);
754 static int dwc3_core_get_phy(struct dwc3
*dwc
);
755 static int dwc3_core_ulpi_init(struct dwc3
*dwc
);
758 * dwc3_core_init - Low-level initialization of DWC3 Core
759 * @dwc: Pointer to our controller context structure
761 * Returns 0 on success otherwise negative errno.
763 static int dwc3_core_init(struct dwc3
*dwc
)
768 if (!dwc3_core_is_valid(dwc
)) {
769 dev_err(dwc
->dev
, "this is not a DesignWare USB3 DRD Core\n");
775 * Write Linux Version Code to our GUID register so it's easy to figure
776 * out which kernel version a bug was found.
778 dwc3_writel(dwc
->regs
, DWC3_GUID
, LINUX_VERSION_CODE
);
780 /* Handle USB2.0-only core configuration */
781 if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc
->hwparams
.hwparams3
) ==
782 DWC3_GHWPARAMS3_SSPHY_IFC_DIS
) {
783 if (dwc
->maximum_speed
== USB_SPEED_SUPER
)
784 dwc
->maximum_speed
= USB_SPEED_HIGH
;
787 ret
= dwc3_phy_setup(dwc
);
791 if (!dwc
->ulpi_ready
) {
792 ret
= dwc3_core_ulpi_init(dwc
);
795 dwc
->ulpi_ready
= true;
798 if (!dwc
->phys_ready
) {
799 ret
= dwc3_core_get_phy(dwc
);
802 dwc
->phys_ready
= true;
805 ret
= dwc3_core_soft_reset(dwc
);
809 dwc3_core_setup_global_control(dwc
);
810 dwc3_core_num_eps(dwc
);
812 ret
= dwc3_setup_scratch_buffers(dwc
);
816 /* Adjust Frame Length */
817 dwc3_frame_length_adjustment(dwc
);
819 usb_phy_set_suspend(dwc
->usb2_phy
, 0);
820 usb_phy_set_suspend(dwc
->usb3_phy
, 0);
821 ret
= phy_power_on(dwc
->usb2_generic_phy
);
825 ret
= phy_power_on(dwc
->usb3_generic_phy
);
829 ret
= dwc3_event_buffers_setup(dwc
);
831 dev_err(dwc
->dev
, "failed to setup event buffers\n");
836 * ENDXFER polling is available on version 3.10a and later of
837 * the DWC_usb3 controller. It is NOT available in the
838 * DWC_usb31 controller.
840 if (!dwc3_is_usb31(dwc
) && dwc
->revision
>= DWC3_REVISION_310A
) {
841 reg
= dwc3_readl(dwc
->regs
, DWC3_GUCTL2
);
842 reg
|= DWC3_GUCTL2_RST_ACTBITLATER
;
843 dwc3_writel(dwc
->regs
, DWC3_GUCTL2
, reg
);
846 if (dwc
->revision
>= DWC3_REVISION_250A
) {
847 reg
= dwc3_readl(dwc
->regs
, DWC3_GUCTL1
);
850 * Enable hardware control of sending remote wakeup
851 * in HS when the device is in the L1 state.
853 if (dwc
->revision
>= DWC3_REVISION_290A
)
854 reg
|= DWC3_GUCTL1_DEV_L1_EXIT_BY_HW
;
856 if (dwc
->dis_tx_ipgap_linecheck_quirk
)
857 reg
|= DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS
;
859 dwc3_writel(dwc
->regs
, DWC3_GUCTL1
, reg
);
865 phy_power_off(dwc
->usb3_generic_phy
);
868 phy_power_off(dwc
->usb2_generic_phy
);
871 usb_phy_set_suspend(dwc
->usb2_phy
, 1);
872 usb_phy_set_suspend(dwc
->usb3_phy
, 1);
875 usb_phy_shutdown(dwc
->usb2_phy
);
876 usb_phy_shutdown(dwc
->usb3_phy
);
877 phy_exit(dwc
->usb2_generic_phy
);
878 phy_exit(dwc
->usb3_generic_phy
);
887 static int dwc3_core_get_phy(struct dwc3
*dwc
)
889 struct device
*dev
= dwc
->dev
;
890 struct device_node
*node
= dev
->of_node
;
894 dwc
->usb2_phy
= devm_usb_get_phy_by_phandle(dev
, "usb-phy", 0);
895 dwc
->usb3_phy
= devm_usb_get_phy_by_phandle(dev
, "usb-phy", 1);
897 dwc
->usb2_phy
= devm_usb_get_phy(dev
, USB_PHY_TYPE_USB2
);
898 dwc
->usb3_phy
= devm_usb_get_phy(dev
, USB_PHY_TYPE_USB3
);
901 if (IS_ERR(dwc
->usb2_phy
)) {
902 ret
= PTR_ERR(dwc
->usb2_phy
);
903 if (ret
== -ENXIO
|| ret
== -ENODEV
) {
904 dwc
->usb2_phy
= NULL
;
905 } else if (ret
== -EPROBE_DEFER
) {
908 dev_err(dev
, "no usb2 phy configured\n");
913 if (IS_ERR(dwc
->usb3_phy
)) {
914 ret
= PTR_ERR(dwc
->usb3_phy
);
915 if (ret
== -ENXIO
|| ret
== -ENODEV
) {
916 dwc
->usb3_phy
= NULL
;
917 } else if (ret
== -EPROBE_DEFER
) {
920 dev_err(dev
, "no usb3 phy configured\n");
925 dwc
->usb2_generic_phy
= devm_phy_get(dev
, "usb2-phy");
926 if (IS_ERR(dwc
->usb2_generic_phy
)) {
927 ret
= PTR_ERR(dwc
->usb2_generic_phy
);
928 if (ret
== -ENOSYS
|| ret
== -ENODEV
) {
929 dwc
->usb2_generic_phy
= NULL
;
930 } else if (ret
== -EPROBE_DEFER
) {
933 dev_err(dev
, "no usb2 phy configured\n");
938 dwc
->usb3_generic_phy
= devm_phy_get(dev
, "usb3-phy");
939 if (IS_ERR(dwc
->usb3_generic_phy
)) {
940 ret
= PTR_ERR(dwc
->usb3_generic_phy
);
941 if (ret
== -ENOSYS
|| ret
== -ENODEV
) {
942 dwc
->usb3_generic_phy
= NULL
;
943 } else if (ret
== -EPROBE_DEFER
) {
946 dev_err(dev
, "no usb3 phy configured\n");
954 static int dwc3_core_init_mode(struct dwc3
*dwc
)
956 struct device
*dev
= dwc
->dev
;
959 switch (dwc
->dr_mode
) {
960 case USB_DR_MODE_PERIPHERAL
:
961 dwc3_set_prtcap(dwc
, DWC3_GCTL_PRTCAP_DEVICE
);
964 otg_set_vbus(dwc
->usb2_phy
->otg
, false);
965 phy_set_mode(dwc
->usb2_generic_phy
, PHY_MODE_USB_DEVICE
);
966 phy_set_mode(dwc
->usb3_generic_phy
, PHY_MODE_USB_DEVICE
);
968 ret
= dwc3_gadget_init(dwc
);
970 if (ret
!= -EPROBE_DEFER
)
971 dev_err(dev
, "failed to initialize gadget\n");
975 case USB_DR_MODE_HOST
:
976 dwc3_set_prtcap(dwc
, DWC3_GCTL_PRTCAP_HOST
);
979 otg_set_vbus(dwc
->usb2_phy
->otg
, true);
980 phy_set_mode(dwc
->usb2_generic_phy
, PHY_MODE_USB_HOST
);
981 phy_set_mode(dwc
->usb3_generic_phy
, PHY_MODE_USB_HOST
);
983 ret
= dwc3_host_init(dwc
);
985 if (ret
!= -EPROBE_DEFER
)
986 dev_err(dev
, "failed to initialize host\n");
990 case USB_DR_MODE_OTG
:
991 INIT_WORK(&dwc
->drd_work
, __dwc3_set_mode
);
992 ret
= dwc3_drd_init(dwc
);
994 if (ret
!= -EPROBE_DEFER
)
995 dev_err(dev
, "failed to initialize dual-role\n");
1000 dev_err(dev
, "Unsupported mode of operation %d\n", dwc
->dr_mode
);
1007 static void dwc3_core_exit_mode(struct dwc3
*dwc
)
1009 switch (dwc
->dr_mode
) {
1010 case USB_DR_MODE_PERIPHERAL
:
1011 dwc3_gadget_exit(dwc
);
1013 case USB_DR_MODE_HOST
:
1014 dwc3_host_exit(dwc
);
1016 case USB_DR_MODE_OTG
:
1025 static void dwc3_get_properties(struct dwc3
*dwc
)
1027 struct device
*dev
= dwc
->dev
;
1028 u8 lpm_nyet_threshold
;
1032 /* default to highest possible threshold */
1033 lpm_nyet_threshold
= 0xff;
1035 /* default to -3.5dB de-emphasis */
1039 * default to assert utmi_sleep_n and use maximum allowed HIRD
1040 * threshold value of 0b1100
1042 hird_threshold
= 12;
1044 dwc
->maximum_speed
= usb_get_maximum_speed(dev
);
1045 dwc
->dr_mode
= usb_get_dr_mode(dev
);
1046 dwc
->hsphy_mode
= of_usb_get_phy_mode(dev
->of_node
);
1048 dwc
->sysdev_is_parent
= device_property_read_bool(dev
,
1049 "linux,sysdev_is_parent");
1050 if (dwc
->sysdev_is_parent
)
1051 dwc
->sysdev
= dwc
->dev
->parent
;
1053 dwc
->sysdev
= dwc
->dev
;
1055 dwc
->has_lpm_erratum
= device_property_read_bool(dev
,
1056 "snps,has-lpm-erratum");
1057 device_property_read_u8(dev
, "snps,lpm-nyet-threshold",
1058 &lpm_nyet_threshold
);
1059 dwc
->is_utmi_l1_suspend
= device_property_read_bool(dev
,
1060 "snps,is-utmi-l1-suspend");
1061 device_property_read_u8(dev
, "snps,hird-threshold",
1063 dwc
->usb3_lpm_capable
= device_property_read_bool(dev
,
1064 "snps,usb3_lpm_capable");
1066 dwc
->disable_scramble_quirk
= device_property_read_bool(dev
,
1067 "snps,disable_scramble_quirk");
1068 dwc
->u2exit_lfps_quirk
= device_property_read_bool(dev
,
1069 "snps,u2exit_lfps_quirk");
1070 dwc
->u2ss_inp3_quirk
= device_property_read_bool(dev
,
1071 "snps,u2ss_inp3_quirk");
1072 dwc
->req_p1p2p3_quirk
= device_property_read_bool(dev
,
1073 "snps,req_p1p2p3_quirk");
1074 dwc
->del_p1p2p3_quirk
= device_property_read_bool(dev
,
1075 "snps,del_p1p2p3_quirk");
1076 dwc
->del_phy_power_chg_quirk
= device_property_read_bool(dev
,
1077 "snps,del_phy_power_chg_quirk");
1078 dwc
->lfps_filter_quirk
= device_property_read_bool(dev
,
1079 "snps,lfps_filter_quirk");
1080 dwc
->rx_detect_poll_quirk
= device_property_read_bool(dev
,
1081 "snps,rx_detect_poll_quirk");
1082 dwc
->dis_u3_susphy_quirk
= device_property_read_bool(dev
,
1083 "snps,dis_u3_susphy_quirk");
1084 dwc
->dis_u2_susphy_quirk
= device_property_read_bool(dev
,
1085 "snps,dis_u2_susphy_quirk");
1086 dwc
->dis_enblslpm_quirk
= device_property_read_bool(dev
,
1087 "snps,dis_enblslpm_quirk");
1088 dwc
->dis_rxdet_inp3_quirk
= device_property_read_bool(dev
,
1089 "snps,dis_rxdet_inp3_quirk");
1090 dwc
->dis_u2_freeclk_exists_quirk
= device_property_read_bool(dev
,
1091 "snps,dis-u2-freeclk-exists-quirk");
1092 dwc
->dis_del_phy_power_chg_quirk
= device_property_read_bool(dev
,
1093 "snps,dis-del-phy-power-chg-quirk");
1094 dwc
->dis_tx_ipgap_linecheck_quirk
= device_property_read_bool(dev
,
1095 "snps,dis-tx-ipgap-linecheck-quirk");
1097 dwc
->tx_de_emphasis_quirk
= device_property_read_bool(dev
,
1098 "snps,tx_de_emphasis_quirk");
1099 device_property_read_u8(dev
, "snps,tx_de_emphasis",
1101 device_property_read_string(dev
, "snps,hsphy_interface",
1102 &dwc
->hsphy_interface
);
1103 device_property_read_u32(dev
, "snps,quirk-frame-length-adjustment",
1106 dwc
->lpm_nyet_threshold
= lpm_nyet_threshold
;
1107 dwc
->tx_de_emphasis
= tx_de_emphasis
;
1109 dwc
->hird_threshold
= hird_threshold
1110 | (dwc
->is_utmi_l1_suspend
<< 4);
1112 dwc
->imod_interval
= 0;
1115 /* check whether the core supports IMOD */
1116 bool dwc3_has_imod(struct dwc3
*dwc
)
1118 return ((dwc3_is_usb3(dwc
) &&
1119 dwc
->revision
>= DWC3_REVISION_300A
) ||
1120 (dwc3_is_usb31(dwc
) &&
1121 dwc
->revision
>= DWC3_USB31_REVISION_120A
));
1124 static void dwc3_check_params(struct dwc3
*dwc
)
1126 struct device
*dev
= dwc
->dev
;
1128 /* Check for proper value of imod_interval */
1129 if (dwc
->imod_interval
&& !dwc3_has_imod(dwc
)) {
1130 dev_warn(dwc
->dev
, "Interrupt moderation not supported\n");
1131 dwc
->imod_interval
= 0;
1135 * Workaround for STAR 9000961433 which affects only version
1136 * 3.00a of the DWC_usb3 core. This prevents the controller
1137 * interrupt from being masked while handling events. IMOD
1138 * allows us to work around this issue. Enable it for the
1141 if (!dwc
->imod_interval
&&
1142 (dwc
->revision
== DWC3_REVISION_300A
))
1143 dwc
->imod_interval
= 1;
1145 /* Check the maximum_speed parameter */
1146 switch (dwc
->maximum_speed
) {
1148 case USB_SPEED_FULL
:
1149 case USB_SPEED_HIGH
:
1150 case USB_SPEED_SUPER
:
1151 case USB_SPEED_SUPER_PLUS
:
1154 dev_err(dev
, "invalid maximum_speed parameter %d\n",
1155 dwc
->maximum_speed
);
1157 case USB_SPEED_UNKNOWN
:
1158 /* default to superspeed */
1159 dwc
->maximum_speed
= USB_SPEED_SUPER
;
1162 * default to superspeed plus if we are capable.
1164 if (dwc3_is_usb31(dwc
) &&
1165 (DWC3_GHWPARAMS3_SSPHY_IFC(dwc
->hwparams
.hwparams3
) ==
1166 DWC3_GHWPARAMS3_SSPHY_IFC_GEN2
))
1167 dwc
->maximum_speed
= USB_SPEED_SUPER_PLUS
;
1173 static int dwc3_probe(struct platform_device
*pdev
)
1175 struct device
*dev
= &pdev
->dev
;
1176 struct resource
*res
;
1183 dwc
= devm_kzalloc(dev
, sizeof(*dwc
), GFP_KERNEL
);
1189 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
1191 dev_err(dev
, "missing memory resource\n");
1195 dwc
->xhci_resources
[0].start
= res
->start
;
1196 dwc
->xhci_resources
[0].end
= dwc
->xhci_resources
[0].start
+
1198 dwc
->xhci_resources
[0].flags
= res
->flags
;
1199 dwc
->xhci_resources
[0].name
= res
->name
;
1201 res
->start
+= DWC3_GLOBALS_REGS_START
;
1204 * Request memory region but exclude xHCI regs,
1205 * since it will be requested by the xhci-plat driver.
1207 regs
= devm_ioremap_resource(dev
, res
);
1209 ret
= PTR_ERR(regs
);
1214 dwc
->regs_size
= resource_size(res
);
1216 dwc3_get_properties(dwc
);
1218 platform_set_drvdata(pdev
, dwc
);
1219 dwc3_cache_hwparams(dwc
);
1221 spin_lock_init(&dwc
->lock
);
1223 pm_runtime_set_active(dev
);
1224 pm_runtime_use_autosuspend(dev
);
1225 pm_runtime_set_autosuspend_delay(dev
, DWC3_DEFAULT_AUTOSUSPEND_DELAY
);
1226 pm_runtime_enable(dev
);
1227 ret
= pm_runtime_get_sync(dev
);
1231 pm_runtime_forbid(dev
);
1233 ret
= dwc3_alloc_event_buffers(dwc
, DWC3_EVENT_BUFFERS_SIZE
);
1235 dev_err(dwc
->dev
, "failed to allocate event buffers\n");
1240 ret
= dwc3_get_dr_mode(dwc
);
1244 ret
= dwc3_alloc_scratch_buffers(dwc
);
1248 ret
= dwc3_core_init(dwc
);
1250 dev_err(dev
, "failed to initialize core\n");
1254 dwc3_check_params(dwc
);
1256 ret
= dwc3_core_init_mode(dwc
);
1260 dwc3_debugfs_init(dwc
);
1261 pm_runtime_put(dev
);
1266 dwc3_event_buffers_cleanup(dwc
);
1269 dwc3_free_scratch_buffers(dwc
);
1272 dwc3_free_event_buffers(dwc
);
1275 pm_runtime_allow(&pdev
->dev
);
1278 pm_runtime_put_sync(&pdev
->dev
);
1279 pm_runtime_disable(&pdev
->dev
);
1283 * restore res->start back to its original value so that, in case the
1284 * probe is deferred, we don't end up getting error in request the
1285 * memory region the next time probe is called.
1287 res
->start
-= DWC3_GLOBALS_REGS_START
;
1292 static int dwc3_remove(struct platform_device
*pdev
)
1294 struct dwc3
*dwc
= platform_get_drvdata(pdev
);
1295 struct resource
*res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
1297 pm_runtime_get_sync(&pdev
->dev
);
1299 * restore res->start back to its original value so that, in case the
1300 * probe is deferred, we don't end up getting error in request the
1301 * memory region the next time probe is called.
1303 res
->start
-= DWC3_GLOBALS_REGS_START
;
1305 dwc3_debugfs_exit(dwc
);
1306 dwc3_core_exit_mode(dwc
);
1308 dwc3_core_exit(dwc
);
1309 dwc3_ulpi_exit(dwc
);
1311 pm_runtime_put_sync(&pdev
->dev
);
1312 pm_runtime_allow(&pdev
->dev
);
1313 pm_runtime_disable(&pdev
->dev
);
1315 dwc3_free_event_buffers(dwc
);
1316 dwc3_free_scratch_buffers(dwc
);
1322 static int dwc3_suspend_common(struct dwc3
*dwc
, pm_message_t msg
)
1324 unsigned long flags
;
1326 switch (dwc
->current_dr_role
) {
1327 case DWC3_GCTL_PRTCAP_DEVICE
:
1328 spin_lock_irqsave(&dwc
->lock
, flags
);
1329 dwc3_gadget_suspend(dwc
);
1330 spin_unlock_irqrestore(&dwc
->lock
, flags
);
1331 dwc3_core_exit(dwc
);
1333 case DWC3_GCTL_PRTCAP_HOST
:
1334 /* do nothing during host runtime_suspend */
1335 if (!PMSG_IS_AUTO(msg
))
1336 dwc3_core_exit(dwc
);
1346 static int dwc3_resume_common(struct dwc3
*dwc
, pm_message_t msg
)
1348 unsigned long flags
;
1351 switch (dwc
->current_dr_role
) {
1352 case DWC3_GCTL_PRTCAP_DEVICE
:
1353 ret
= dwc3_core_init(dwc
);
1357 spin_lock_irqsave(&dwc
->lock
, flags
);
1358 dwc3_gadget_resume(dwc
);
1359 spin_unlock_irqrestore(&dwc
->lock
, flags
);
1361 case DWC3_GCTL_PRTCAP_HOST
:
1362 /* nothing to do on host runtime_resume */
1363 if (!PMSG_IS_AUTO(msg
)) {
1364 ret
= dwc3_core_init(dwc
);
1377 static int dwc3_runtime_checks(struct dwc3
*dwc
)
1379 switch (dwc
->current_dr_role
) {
1380 case DWC3_GCTL_PRTCAP_DEVICE
:
1384 case DWC3_GCTL_PRTCAP_HOST
:
1393 static int dwc3_runtime_suspend(struct device
*dev
)
1395 struct dwc3
*dwc
= dev_get_drvdata(dev
);
1398 if (dwc3_runtime_checks(dwc
))
1401 ret
= dwc3_suspend_common(dwc
, PMSG_AUTO_SUSPEND
);
1405 device_init_wakeup(dev
, true);
1410 static int dwc3_runtime_resume(struct device
*dev
)
1412 struct dwc3
*dwc
= dev_get_drvdata(dev
);
1415 device_init_wakeup(dev
, false);
1417 ret
= dwc3_resume_common(dwc
, PMSG_AUTO_RESUME
);
1421 switch (dwc
->current_dr_role
) {
1422 case DWC3_GCTL_PRTCAP_DEVICE
:
1423 dwc3_gadget_process_pending_events(dwc
);
1425 case DWC3_GCTL_PRTCAP_HOST
:
1431 pm_runtime_mark_last_busy(dev
);
1436 static int dwc3_runtime_idle(struct device
*dev
)
1438 struct dwc3
*dwc
= dev_get_drvdata(dev
);
1440 switch (dwc
->current_dr_role
) {
1441 case DWC3_GCTL_PRTCAP_DEVICE
:
1442 if (dwc3_runtime_checks(dwc
))
1445 case DWC3_GCTL_PRTCAP_HOST
:
1451 pm_runtime_mark_last_busy(dev
);
1452 pm_runtime_autosuspend(dev
);
1456 #endif /* CONFIG_PM */
1458 #ifdef CONFIG_PM_SLEEP
1459 static int dwc3_suspend(struct device
*dev
)
1461 struct dwc3
*dwc
= dev_get_drvdata(dev
);
1464 ret
= dwc3_suspend_common(dwc
, PMSG_SUSPEND
);
1468 pinctrl_pm_select_sleep_state(dev
);
1473 static int dwc3_resume(struct device
*dev
)
1475 struct dwc3
*dwc
= dev_get_drvdata(dev
);
1478 pinctrl_pm_select_default_state(dev
);
1480 ret
= dwc3_resume_common(dwc
, PMSG_RESUME
);
1484 pm_runtime_disable(dev
);
1485 pm_runtime_set_active(dev
);
1486 pm_runtime_enable(dev
);
1490 #endif /* CONFIG_PM_SLEEP */
1492 static const struct dev_pm_ops dwc3_dev_pm_ops
= {
1493 SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend
, dwc3_resume
)
1494 SET_RUNTIME_PM_OPS(dwc3_runtime_suspend
, dwc3_runtime_resume
,
1499 static const struct of_device_id of_dwc3_match
[] = {
1501 .compatible
= "snps,dwc3"
1504 .compatible
= "synopsys,dwc3"
1508 MODULE_DEVICE_TABLE(of
, of_dwc3_match
);
1513 #define ACPI_ID_INTEL_BSW "808622B7"
1515 static const struct acpi_device_id dwc3_acpi_match
[] = {
1516 { ACPI_ID_INTEL_BSW
, 0 },
1519 MODULE_DEVICE_TABLE(acpi
, dwc3_acpi_match
);
1522 static struct platform_driver dwc3_driver
= {
1523 .probe
= dwc3_probe
,
1524 .remove
= dwc3_remove
,
1527 .of_match_table
= of_match_ptr(of_dwc3_match
),
1528 .acpi_match_table
= ACPI_PTR(dwc3_acpi_match
),
1529 .pm
= &dwc3_dev_pm_ops
,
1533 module_platform_driver(dwc3_driver
);
1535 MODULE_ALIAS("platform:dwc3");
1536 MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
1537 MODULE_LICENSE("GPL v2");
1538 MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");