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 (dft
!= dwc
->fladj
) {
274 reg
&= ~DWC3_GFLADJ_30MHZ_MASK
;
275 reg
|= DWC3_GFLADJ_30MHZ_SDBND_SEL
| dwc
->fladj
;
276 dwc3_writel(dwc
->regs
, DWC3_GFLADJ
, reg
);
281 * dwc3_free_one_event_buffer - Frees one event buffer
282 * @dwc: Pointer to our controller context structure
283 * @evt: Pointer to event buffer to be freed
285 static void dwc3_free_one_event_buffer(struct dwc3
*dwc
,
286 struct dwc3_event_buffer
*evt
)
288 dma_free_coherent(dwc
->sysdev
, evt
->length
, evt
->buf
, evt
->dma
);
292 * dwc3_alloc_one_event_buffer - Allocates one event buffer structure
293 * @dwc: Pointer to our controller context structure
294 * @length: size of the event buffer
296 * Returns a pointer to the allocated event buffer structure on success
297 * otherwise ERR_PTR(errno).
299 static struct dwc3_event_buffer
*dwc3_alloc_one_event_buffer(struct dwc3
*dwc
,
302 struct dwc3_event_buffer
*evt
;
304 evt
= devm_kzalloc(dwc
->dev
, sizeof(*evt
), GFP_KERNEL
);
306 return ERR_PTR(-ENOMEM
);
309 evt
->length
= length
;
310 evt
->cache
= devm_kzalloc(dwc
->dev
, length
, GFP_KERNEL
);
312 return ERR_PTR(-ENOMEM
);
314 evt
->buf
= dma_alloc_coherent(dwc
->sysdev
, length
,
315 &evt
->dma
, GFP_KERNEL
);
317 return ERR_PTR(-ENOMEM
);
323 * dwc3_free_event_buffers - frees all allocated event buffers
324 * @dwc: Pointer to our controller context structure
326 static void dwc3_free_event_buffers(struct dwc3
*dwc
)
328 struct dwc3_event_buffer
*evt
;
332 dwc3_free_one_event_buffer(dwc
, evt
);
336 * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length
337 * @dwc: pointer to our controller context structure
338 * @length: size of event buffer
340 * Returns 0 on success otherwise negative errno. In the error case, dwc
341 * may contain some buffers allocated but not all which were requested.
343 static int dwc3_alloc_event_buffers(struct dwc3
*dwc
, unsigned length
)
345 struct dwc3_event_buffer
*evt
;
347 evt
= dwc3_alloc_one_event_buffer(dwc
, length
);
349 dev_err(dwc
->dev
, "can't allocate event buffer\n");
358 * dwc3_event_buffers_setup - setup our allocated event buffers
359 * @dwc: pointer to our controller context structure
361 * Returns 0 on success otherwise negative errno.
363 static int dwc3_event_buffers_setup(struct dwc3
*dwc
)
365 struct dwc3_event_buffer
*evt
;
369 dwc3_writel(dwc
->regs
, DWC3_GEVNTADRLO(0),
370 lower_32_bits(evt
->dma
));
371 dwc3_writel(dwc
->regs
, DWC3_GEVNTADRHI(0),
372 upper_32_bits(evt
->dma
));
373 dwc3_writel(dwc
->regs
, DWC3_GEVNTSIZ(0),
374 DWC3_GEVNTSIZ_SIZE(evt
->length
));
375 dwc3_writel(dwc
->regs
, DWC3_GEVNTCOUNT(0), 0);
380 static void dwc3_event_buffers_cleanup(struct dwc3
*dwc
)
382 struct dwc3_event_buffer
*evt
;
388 dwc3_writel(dwc
->regs
, DWC3_GEVNTADRLO(0), 0);
389 dwc3_writel(dwc
->regs
, DWC3_GEVNTADRHI(0), 0);
390 dwc3_writel(dwc
->regs
, DWC3_GEVNTSIZ(0), DWC3_GEVNTSIZ_INTMASK
391 | DWC3_GEVNTSIZ_SIZE(0));
392 dwc3_writel(dwc
->regs
, DWC3_GEVNTCOUNT(0), 0);
395 static int dwc3_alloc_scratch_buffers(struct dwc3
*dwc
)
397 if (!dwc
->has_hibernation
)
400 if (!dwc
->nr_scratch
)
403 dwc
->scratchbuf
= kmalloc_array(dwc
->nr_scratch
,
404 DWC3_SCRATCHBUF_SIZE
, GFP_KERNEL
);
405 if (!dwc
->scratchbuf
)
411 static int dwc3_setup_scratch_buffers(struct dwc3
*dwc
)
413 dma_addr_t scratch_addr
;
417 if (!dwc
->has_hibernation
)
420 if (!dwc
->nr_scratch
)
423 /* should never fall here */
424 if (!WARN_ON(dwc
->scratchbuf
))
427 scratch_addr
= dma_map_single(dwc
->sysdev
, dwc
->scratchbuf
,
428 dwc
->nr_scratch
* DWC3_SCRATCHBUF_SIZE
,
430 if (dma_mapping_error(dwc
->sysdev
, scratch_addr
)) {
431 dev_err(dwc
->sysdev
, "failed to map scratch buffer\n");
436 dwc
->scratch_addr
= scratch_addr
;
438 param
= lower_32_bits(scratch_addr
);
440 ret
= dwc3_send_gadget_generic_command(dwc
,
441 DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO
, param
);
445 param
= upper_32_bits(scratch_addr
);
447 ret
= dwc3_send_gadget_generic_command(dwc
,
448 DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI
, param
);
455 dma_unmap_single(dwc
->sysdev
, dwc
->scratch_addr
, dwc
->nr_scratch
*
456 DWC3_SCRATCHBUF_SIZE
, DMA_BIDIRECTIONAL
);
462 static void dwc3_free_scratch_buffers(struct dwc3
*dwc
)
464 if (!dwc
->has_hibernation
)
467 if (!dwc
->nr_scratch
)
470 /* should never fall here */
471 if (!WARN_ON(dwc
->scratchbuf
))
474 dma_unmap_single(dwc
->sysdev
, dwc
->scratch_addr
, dwc
->nr_scratch
*
475 DWC3_SCRATCHBUF_SIZE
, DMA_BIDIRECTIONAL
);
476 kfree(dwc
->scratchbuf
);
479 static void dwc3_core_num_eps(struct dwc3
*dwc
)
481 struct dwc3_hwparams
*parms
= &dwc
->hwparams
;
483 dwc
->num_eps
= DWC3_NUM_EPS(parms
);
486 static void dwc3_cache_hwparams(struct dwc3
*dwc
)
488 struct dwc3_hwparams
*parms
= &dwc
->hwparams
;
490 parms
->hwparams0
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS0
);
491 parms
->hwparams1
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS1
);
492 parms
->hwparams2
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS2
);
493 parms
->hwparams3
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS3
);
494 parms
->hwparams4
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS4
);
495 parms
->hwparams5
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS5
);
496 parms
->hwparams6
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS6
);
497 parms
->hwparams7
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS7
);
498 parms
->hwparams8
= dwc3_readl(dwc
->regs
, DWC3_GHWPARAMS8
);
501 static int dwc3_core_ulpi_init(struct dwc3
*dwc
)
506 intf
= DWC3_GHWPARAMS3_HSPHY_IFC(dwc
->hwparams
.hwparams3
);
508 if (intf
== DWC3_GHWPARAMS3_HSPHY_IFC_ULPI
||
509 (intf
== DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI
&&
510 dwc
->hsphy_interface
&&
511 !strncmp(dwc
->hsphy_interface
, "ulpi", 4)))
512 ret
= dwc3_ulpi_init(dwc
);
518 * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core
519 * @dwc: Pointer to our controller context structure
521 * Returns 0 on success. The USB PHY interfaces are configured but not
522 * initialized. The PHY interfaces and the PHYs get initialized together with
523 * the core in dwc3_core_init.
525 static int dwc3_phy_setup(struct dwc3
*dwc
)
529 reg
= dwc3_readl(dwc
->regs
, DWC3_GUSB3PIPECTL(0));
532 * Make sure UX_EXIT_PX is cleared as that causes issues with some
533 * PHYs. Also, this bit is not supposed to be used in normal operation.
535 reg
&= ~DWC3_GUSB3PIPECTL_UX_EXIT_PX
;
538 * Above 1.94a, it is recommended to set DWC3_GUSB3PIPECTL_SUSPHY
539 * to '0' during coreConsultant configuration. So default value
540 * will be '0' when the core is reset. Application needs to set it
541 * to '1' after the core initialization is completed.
543 if (dwc
->revision
> DWC3_REVISION_194A
)
544 reg
|= DWC3_GUSB3PIPECTL_SUSPHY
;
546 if (dwc
->u2ss_inp3_quirk
)
547 reg
|= DWC3_GUSB3PIPECTL_U2SSINP3OK
;
549 if (dwc
->dis_rxdet_inp3_quirk
)
550 reg
|= DWC3_GUSB3PIPECTL_DISRXDETINP3
;
552 if (dwc
->req_p1p2p3_quirk
)
553 reg
|= DWC3_GUSB3PIPECTL_REQP1P2P3
;
555 if (dwc
->del_p1p2p3_quirk
)
556 reg
|= DWC3_GUSB3PIPECTL_DEP1P2P3_EN
;
558 if (dwc
->del_phy_power_chg_quirk
)
559 reg
|= DWC3_GUSB3PIPECTL_DEPOCHANGE
;
561 if (dwc
->lfps_filter_quirk
)
562 reg
|= DWC3_GUSB3PIPECTL_LFPSFILT
;
564 if (dwc
->rx_detect_poll_quirk
)
565 reg
|= DWC3_GUSB3PIPECTL_RX_DETOPOLL
;
567 if (dwc
->tx_de_emphasis_quirk
)
568 reg
|= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc
->tx_de_emphasis
);
570 if (dwc
->dis_u3_susphy_quirk
)
571 reg
&= ~DWC3_GUSB3PIPECTL_SUSPHY
;
573 if (dwc
->dis_del_phy_power_chg_quirk
)
574 reg
&= ~DWC3_GUSB3PIPECTL_DEPOCHANGE
;
576 dwc3_writel(dwc
->regs
, DWC3_GUSB3PIPECTL(0), reg
);
578 reg
= dwc3_readl(dwc
->regs
, DWC3_GUSB2PHYCFG(0));
580 /* Select the HS PHY interface */
581 switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc
->hwparams
.hwparams3
)) {
582 case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI
:
583 if (dwc
->hsphy_interface
&&
584 !strncmp(dwc
->hsphy_interface
, "utmi", 4)) {
585 reg
&= ~DWC3_GUSB2PHYCFG_ULPI_UTMI
;
587 } else if (dwc
->hsphy_interface
&&
588 !strncmp(dwc
->hsphy_interface
, "ulpi", 4)) {
589 reg
|= DWC3_GUSB2PHYCFG_ULPI_UTMI
;
590 dwc3_writel(dwc
->regs
, DWC3_GUSB2PHYCFG(0), reg
);
592 /* Relying on default value. */
593 if (!(reg
& DWC3_GUSB2PHYCFG_ULPI_UTMI
))
597 case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI
:
603 switch (dwc
->hsphy_mode
) {
604 case USBPHY_INTERFACE_MODE_UTMI
:
605 reg
&= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK
|
606 DWC3_GUSB2PHYCFG_USBTRDTIM_MASK
);
607 reg
|= DWC3_GUSB2PHYCFG_PHYIF(UTMI_PHYIF_8_BIT
) |
608 DWC3_GUSB2PHYCFG_USBTRDTIM(USBTRDTIM_UTMI_8_BIT
);
610 case USBPHY_INTERFACE_MODE_UTMIW
:
611 reg
&= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK
|
612 DWC3_GUSB2PHYCFG_USBTRDTIM_MASK
);
613 reg
|= DWC3_GUSB2PHYCFG_PHYIF(UTMI_PHYIF_16_BIT
) |
614 DWC3_GUSB2PHYCFG_USBTRDTIM(USBTRDTIM_UTMI_16_BIT
);
621 * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to
622 * '0' during coreConsultant configuration. So default value will
623 * be '0' when the core is reset. Application needs to set it to
624 * '1' after the core initialization is completed.
626 if (dwc
->revision
> DWC3_REVISION_194A
)
627 reg
|= DWC3_GUSB2PHYCFG_SUSPHY
;
629 if (dwc
->dis_u2_susphy_quirk
)
630 reg
&= ~DWC3_GUSB2PHYCFG_SUSPHY
;
632 if (dwc
->dis_enblslpm_quirk
)
633 reg
&= ~DWC3_GUSB2PHYCFG_ENBLSLPM
;
635 if (dwc
->dis_u2_freeclk_exists_quirk
)
636 reg
&= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS
;
638 dwc3_writel(dwc
->regs
, DWC3_GUSB2PHYCFG(0), reg
);
643 static void dwc3_core_exit(struct dwc3
*dwc
)
645 dwc3_event_buffers_cleanup(dwc
);
647 usb_phy_shutdown(dwc
->usb2_phy
);
648 usb_phy_shutdown(dwc
->usb3_phy
);
649 phy_exit(dwc
->usb2_generic_phy
);
650 phy_exit(dwc
->usb3_generic_phy
);
652 usb_phy_set_suspend(dwc
->usb2_phy
, 1);
653 usb_phy_set_suspend(dwc
->usb3_phy
, 1);
654 phy_power_off(dwc
->usb2_generic_phy
);
655 phy_power_off(dwc
->usb3_generic_phy
);
658 static bool dwc3_core_is_valid(struct dwc3
*dwc
)
662 reg
= dwc3_readl(dwc
->regs
, DWC3_GSNPSID
);
664 /* This should read as U3 followed by revision number */
665 if ((reg
& DWC3_GSNPSID_MASK
) == 0x55330000) {
666 /* Detected DWC_usb3 IP */
668 } else if ((reg
& DWC3_GSNPSID_MASK
) == 0x33310000) {
669 /* Detected DWC_usb31 IP */
670 dwc
->revision
= dwc3_readl(dwc
->regs
, DWC3_VER_NUMBER
);
671 dwc
->revision
|= DWC3_REVISION_IS_DWC31
;
679 static void dwc3_core_setup_global_control(struct dwc3
*dwc
)
681 u32 hwparams4
= dwc
->hwparams
.hwparams4
;
684 reg
= dwc3_readl(dwc
->regs
, DWC3_GCTL
);
685 reg
&= ~DWC3_GCTL_SCALEDOWN_MASK
;
687 switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc
->hwparams
.hwparams1
)) {
688 case DWC3_GHWPARAMS1_EN_PWROPT_CLK
:
690 * WORKAROUND: DWC3 revisions between 2.10a and 2.50a have an
691 * issue which would cause xHCI compliance tests to fail.
693 * Because of that we cannot enable clock gating on such
698 * STAR#9000588375: Clock Gating, SOF Issues when ref_clk-Based
701 if ((dwc
->dr_mode
== USB_DR_MODE_HOST
||
702 dwc
->dr_mode
== USB_DR_MODE_OTG
) &&
703 (dwc
->revision
>= DWC3_REVISION_210A
&&
704 dwc
->revision
<= DWC3_REVISION_250A
))
705 reg
|= DWC3_GCTL_DSBLCLKGTNG
| DWC3_GCTL_SOFITPSYNC
;
707 reg
&= ~DWC3_GCTL_DSBLCLKGTNG
;
709 case DWC3_GHWPARAMS1_EN_PWROPT_HIB
:
710 /* enable hibernation here */
711 dwc
->nr_scratch
= DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4
);
714 * REVISIT Enabling this bit so that host-mode hibernation
715 * will work. Device-mode hibernation is not yet implemented.
717 reg
|= DWC3_GCTL_GBLHIBERNATIONEN
;
724 /* check if current dwc3 is on simulation board */
725 if (dwc
->hwparams
.hwparams6
& DWC3_GHWPARAMS6_EN_FPGA
) {
726 dev_info(dwc
->dev
, "Running with FPGA optmizations\n");
730 WARN_ONCE(dwc
->disable_scramble_quirk
&& !dwc
->is_fpga
,
731 "disable_scramble cannot be used on non-FPGA builds\n");
733 if (dwc
->disable_scramble_quirk
&& dwc
->is_fpga
)
734 reg
|= DWC3_GCTL_DISSCRAMBLE
;
736 reg
&= ~DWC3_GCTL_DISSCRAMBLE
;
738 if (dwc
->u2exit_lfps_quirk
)
739 reg
|= DWC3_GCTL_U2EXIT_LFPS
;
742 * WORKAROUND: DWC3 revisions <1.90a have a bug
743 * where the device can fail to connect at SuperSpeed
744 * and falls back to high-speed mode which causes
745 * the device to enter a Connect/Disconnect loop
747 if (dwc
->revision
< DWC3_REVISION_190A
)
748 reg
|= DWC3_GCTL_U2RSTECN
;
750 dwc3_writel(dwc
->regs
, DWC3_GCTL
, reg
);
753 static int dwc3_core_get_phy(struct dwc3
*dwc
);
754 static int dwc3_core_ulpi_init(struct dwc3
*dwc
);
757 * dwc3_core_init - Low-level initialization of DWC3 Core
758 * @dwc: Pointer to our controller context structure
760 * Returns 0 on success otherwise negative errno.
762 static int dwc3_core_init(struct dwc3
*dwc
)
767 if (!dwc3_core_is_valid(dwc
)) {
768 dev_err(dwc
->dev
, "this is not a DesignWare USB3 DRD Core\n");
774 * Write Linux Version Code to our GUID register so it's easy to figure
775 * out which kernel version a bug was found.
777 dwc3_writel(dwc
->regs
, DWC3_GUID
, LINUX_VERSION_CODE
);
779 /* Handle USB2.0-only core configuration */
780 if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc
->hwparams
.hwparams3
) ==
781 DWC3_GHWPARAMS3_SSPHY_IFC_DIS
) {
782 if (dwc
->maximum_speed
== USB_SPEED_SUPER
)
783 dwc
->maximum_speed
= USB_SPEED_HIGH
;
786 ret
= dwc3_phy_setup(dwc
);
790 if (!dwc
->ulpi_ready
) {
791 ret
= dwc3_core_ulpi_init(dwc
);
794 dwc
->ulpi_ready
= true;
797 if (!dwc
->phys_ready
) {
798 ret
= dwc3_core_get_phy(dwc
);
801 dwc
->phys_ready
= true;
804 ret
= dwc3_core_soft_reset(dwc
);
808 dwc3_core_setup_global_control(dwc
);
809 dwc3_core_num_eps(dwc
);
811 ret
= dwc3_setup_scratch_buffers(dwc
);
815 /* Adjust Frame Length */
816 dwc3_frame_length_adjustment(dwc
);
818 usb_phy_set_suspend(dwc
->usb2_phy
, 0);
819 usb_phy_set_suspend(dwc
->usb3_phy
, 0);
820 ret
= phy_power_on(dwc
->usb2_generic_phy
);
824 ret
= phy_power_on(dwc
->usb3_generic_phy
);
828 ret
= dwc3_event_buffers_setup(dwc
);
830 dev_err(dwc
->dev
, "failed to setup event buffers\n");
835 * ENDXFER polling is available on version 3.10a and later of
836 * the DWC_usb3 controller. It is NOT available in the
837 * DWC_usb31 controller.
839 if (!dwc3_is_usb31(dwc
) && dwc
->revision
>= DWC3_REVISION_310A
) {
840 reg
= dwc3_readl(dwc
->regs
, DWC3_GUCTL2
);
841 reg
|= DWC3_GUCTL2_RST_ACTBITLATER
;
842 dwc3_writel(dwc
->regs
, DWC3_GUCTL2
, reg
);
845 if (dwc
->revision
>= DWC3_REVISION_250A
) {
846 reg
= dwc3_readl(dwc
->regs
, DWC3_GUCTL1
);
849 * Enable hardware control of sending remote wakeup
850 * in HS when the device is in the L1 state.
852 if (dwc
->revision
>= DWC3_REVISION_290A
)
853 reg
|= DWC3_GUCTL1_DEV_L1_EXIT_BY_HW
;
855 if (dwc
->dis_tx_ipgap_linecheck_quirk
)
856 reg
|= DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS
;
858 dwc3_writel(dwc
->regs
, DWC3_GUCTL1
, reg
);
864 phy_power_off(dwc
->usb3_generic_phy
);
867 phy_power_off(dwc
->usb2_generic_phy
);
870 usb_phy_set_suspend(dwc
->usb2_phy
, 1);
871 usb_phy_set_suspend(dwc
->usb3_phy
, 1);
874 usb_phy_shutdown(dwc
->usb2_phy
);
875 usb_phy_shutdown(dwc
->usb3_phy
);
876 phy_exit(dwc
->usb2_generic_phy
);
877 phy_exit(dwc
->usb3_generic_phy
);
886 static int dwc3_core_get_phy(struct dwc3
*dwc
)
888 struct device
*dev
= dwc
->dev
;
889 struct device_node
*node
= dev
->of_node
;
893 dwc
->usb2_phy
= devm_usb_get_phy_by_phandle(dev
, "usb-phy", 0);
894 dwc
->usb3_phy
= devm_usb_get_phy_by_phandle(dev
, "usb-phy", 1);
896 dwc
->usb2_phy
= devm_usb_get_phy(dev
, USB_PHY_TYPE_USB2
);
897 dwc
->usb3_phy
= devm_usb_get_phy(dev
, USB_PHY_TYPE_USB3
);
900 if (IS_ERR(dwc
->usb2_phy
)) {
901 ret
= PTR_ERR(dwc
->usb2_phy
);
902 if (ret
== -ENXIO
|| ret
== -ENODEV
) {
903 dwc
->usb2_phy
= NULL
;
904 } else if (ret
== -EPROBE_DEFER
) {
907 dev_err(dev
, "no usb2 phy configured\n");
912 if (IS_ERR(dwc
->usb3_phy
)) {
913 ret
= PTR_ERR(dwc
->usb3_phy
);
914 if (ret
== -ENXIO
|| ret
== -ENODEV
) {
915 dwc
->usb3_phy
= NULL
;
916 } else if (ret
== -EPROBE_DEFER
) {
919 dev_err(dev
, "no usb3 phy configured\n");
924 dwc
->usb2_generic_phy
= devm_phy_get(dev
, "usb2-phy");
925 if (IS_ERR(dwc
->usb2_generic_phy
)) {
926 ret
= PTR_ERR(dwc
->usb2_generic_phy
);
927 if (ret
== -ENOSYS
|| ret
== -ENODEV
) {
928 dwc
->usb2_generic_phy
= NULL
;
929 } else if (ret
== -EPROBE_DEFER
) {
932 dev_err(dev
, "no usb2 phy configured\n");
937 dwc
->usb3_generic_phy
= devm_phy_get(dev
, "usb3-phy");
938 if (IS_ERR(dwc
->usb3_generic_phy
)) {
939 ret
= PTR_ERR(dwc
->usb3_generic_phy
);
940 if (ret
== -ENOSYS
|| ret
== -ENODEV
) {
941 dwc
->usb3_generic_phy
= NULL
;
942 } else if (ret
== -EPROBE_DEFER
) {
945 dev_err(dev
, "no usb3 phy configured\n");
953 static int dwc3_core_init_mode(struct dwc3
*dwc
)
955 struct device
*dev
= dwc
->dev
;
958 switch (dwc
->dr_mode
) {
959 case USB_DR_MODE_PERIPHERAL
:
960 dwc3_set_prtcap(dwc
, DWC3_GCTL_PRTCAP_DEVICE
);
963 otg_set_vbus(dwc
->usb2_phy
->otg
, false);
964 phy_set_mode(dwc
->usb2_generic_phy
, PHY_MODE_USB_DEVICE
);
965 phy_set_mode(dwc
->usb3_generic_phy
, PHY_MODE_USB_DEVICE
);
967 ret
= dwc3_gadget_init(dwc
);
969 if (ret
!= -EPROBE_DEFER
)
970 dev_err(dev
, "failed to initialize gadget\n");
974 case USB_DR_MODE_HOST
:
975 dwc3_set_prtcap(dwc
, DWC3_GCTL_PRTCAP_HOST
);
978 otg_set_vbus(dwc
->usb2_phy
->otg
, true);
979 phy_set_mode(dwc
->usb2_generic_phy
, PHY_MODE_USB_HOST
);
980 phy_set_mode(dwc
->usb3_generic_phy
, PHY_MODE_USB_HOST
);
982 ret
= dwc3_host_init(dwc
);
984 if (ret
!= -EPROBE_DEFER
)
985 dev_err(dev
, "failed to initialize host\n");
989 case USB_DR_MODE_OTG
:
990 INIT_WORK(&dwc
->drd_work
, __dwc3_set_mode
);
991 ret
= dwc3_drd_init(dwc
);
993 if (ret
!= -EPROBE_DEFER
)
994 dev_err(dev
, "failed to initialize dual-role\n");
999 dev_err(dev
, "Unsupported mode of operation %d\n", dwc
->dr_mode
);
1006 static void dwc3_core_exit_mode(struct dwc3
*dwc
)
1008 switch (dwc
->dr_mode
) {
1009 case USB_DR_MODE_PERIPHERAL
:
1010 dwc3_gadget_exit(dwc
);
1012 case USB_DR_MODE_HOST
:
1013 dwc3_host_exit(dwc
);
1015 case USB_DR_MODE_OTG
:
1024 static void dwc3_get_properties(struct dwc3
*dwc
)
1026 struct device
*dev
= dwc
->dev
;
1027 u8 lpm_nyet_threshold
;
1031 /* default to highest possible threshold */
1032 lpm_nyet_threshold
= 0xf;
1034 /* default to -3.5dB de-emphasis */
1038 * default to assert utmi_sleep_n and use maximum allowed HIRD
1039 * threshold value of 0b1100
1041 hird_threshold
= 12;
1043 dwc
->maximum_speed
= usb_get_maximum_speed(dev
);
1044 dwc
->dr_mode
= usb_get_dr_mode(dev
);
1045 dwc
->hsphy_mode
= of_usb_get_phy_mode(dev
->of_node
);
1047 dwc
->sysdev_is_parent
= device_property_read_bool(dev
,
1048 "linux,sysdev_is_parent");
1049 if (dwc
->sysdev_is_parent
)
1050 dwc
->sysdev
= dwc
->dev
->parent
;
1052 dwc
->sysdev
= dwc
->dev
;
1054 dwc
->has_lpm_erratum
= device_property_read_bool(dev
,
1055 "snps,has-lpm-erratum");
1056 device_property_read_u8(dev
, "snps,lpm-nyet-threshold",
1057 &lpm_nyet_threshold
);
1058 dwc
->is_utmi_l1_suspend
= device_property_read_bool(dev
,
1059 "snps,is-utmi-l1-suspend");
1060 device_property_read_u8(dev
, "snps,hird-threshold",
1062 dwc
->usb3_lpm_capable
= device_property_read_bool(dev
,
1063 "snps,usb3_lpm_capable");
1065 dwc
->disable_scramble_quirk
= device_property_read_bool(dev
,
1066 "snps,disable_scramble_quirk");
1067 dwc
->u2exit_lfps_quirk
= device_property_read_bool(dev
,
1068 "snps,u2exit_lfps_quirk");
1069 dwc
->u2ss_inp3_quirk
= device_property_read_bool(dev
,
1070 "snps,u2ss_inp3_quirk");
1071 dwc
->req_p1p2p3_quirk
= device_property_read_bool(dev
,
1072 "snps,req_p1p2p3_quirk");
1073 dwc
->del_p1p2p3_quirk
= device_property_read_bool(dev
,
1074 "snps,del_p1p2p3_quirk");
1075 dwc
->del_phy_power_chg_quirk
= device_property_read_bool(dev
,
1076 "snps,del_phy_power_chg_quirk");
1077 dwc
->lfps_filter_quirk
= device_property_read_bool(dev
,
1078 "snps,lfps_filter_quirk");
1079 dwc
->rx_detect_poll_quirk
= device_property_read_bool(dev
,
1080 "snps,rx_detect_poll_quirk");
1081 dwc
->dis_u3_susphy_quirk
= device_property_read_bool(dev
,
1082 "snps,dis_u3_susphy_quirk");
1083 dwc
->dis_u2_susphy_quirk
= device_property_read_bool(dev
,
1084 "snps,dis_u2_susphy_quirk");
1085 dwc
->dis_enblslpm_quirk
= device_property_read_bool(dev
,
1086 "snps,dis_enblslpm_quirk");
1087 dwc
->dis_rxdet_inp3_quirk
= device_property_read_bool(dev
,
1088 "snps,dis_rxdet_inp3_quirk");
1089 dwc
->dis_u2_freeclk_exists_quirk
= device_property_read_bool(dev
,
1090 "snps,dis-u2-freeclk-exists-quirk");
1091 dwc
->dis_del_phy_power_chg_quirk
= device_property_read_bool(dev
,
1092 "snps,dis-del-phy-power-chg-quirk");
1093 dwc
->dis_tx_ipgap_linecheck_quirk
= device_property_read_bool(dev
,
1094 "snps,dis-tx-ipgap-linecheck-quirk");
1096 dwc
->tx_de_emphasis_quirk
= device_property_read_bool(dev
,
1097 "snps,tx_de_emphasis_quirk");
1098 device_property_read_u8(dev
, "snps,tx_de_emphasis",
1100 device_property_read_string(dev
, "snps,hsphy_interface",
1101 &dwc
->hsphy_interface
);
1102 device_property_read_u32(dev
, "snps,quirk-frame-length-adjustment",
1105 dwc
->dis_metastability_quirk
= device_property_read_bool(dev
,
1106 "snps,dis_metastability_quirk");
1108 dwc
->lpm_nyet_threshold
= lpm_nyet_threshold
;
1109 dwc
->tx_de_emphasis
= tx_de_emphasis
;
1111 dwc
->hird_threshold
= hird_threshold
1112 | (dwc
->is_utmi_l1_suspend
<< 4);
1114 dwc
->imod_interval
= 0;
1117 /* check whether the core supports IMOD */
1118 bool dwc3_has_imod(struct dwc3
*dwc
)
1120 return ((dwc3_is_usb3(dwc
) &&
1121 dwc
->revision
>= DWC3_REVISION_300A
) ||
1122 (dwc3_is_usb31(dwc
) &&
1123 dwc
->revision
>= DWC3_USB31_REVISION_120A
));
1126 static void dwc3_check_params(struct dwc3
*dwc
)
1128 struct device
*dev
= dwc
->dev
;
1130 /* Check for proper value of imod_interval */
1131 if (dwc
->imod_interval
&& !dwc3_has_imod(dwc
)) {
1132 dev_warn(dwc
->dev
, "Interrupt moderation not supported\n");
1133 dwc
->imod_interval
= 0;
1137 * Workaround for STAR 9000961433 which affects only version
1138 * 3.00a of the DWC_usb3 core. This prevents the controller
1139 * interrupt from being masked while handling events. IMOD
1140 * allows us to work around this issue. Enable it for the
1143 if (!dwc
->imod_interval
&&
1144 (dwc
->revision
== DWC3_REVISION_300A
))
1145 dwc
->imod_interval
= 1;
1147 /* Check the maximum_speed parameter */
1148 switch (dwc
->maximum_speed
) {
1150 case USB_SPEED_FULL
:
1151 case USB_SPEED_HIGH
:
1152 case USB_SPEED_SUPER
:
1153 case USB_SPEED_SUPER_PLUS
:
1156 dev_err(dev
, "invalid maximum_speed parameter %d\n",
1157 dwc
->maximum_speed
);
1159 case USB_SPEED_UNKNOWN
:
1160 /* default to superspeed */
1161 dwc
->maximum_speed
= USB_SPEED_SUPER
;
1164 * default to superspeed plus if we are capable.
1166 if (dwc3_is_usb31(dwc
) &&
1167 (DWC3_GHWPARAMS3_SSPHY_IFC(dwc
->hwparams
.hwparams3
) ==
1168 DWC3_GHWPARAMS3_SSPHY_IFC_GEN2
))
1169 dwc
->maximum_speed
= USB_SPEED_SUPER_PLUS
;
1175 static int dwc3_probe(struct platform_device
*pdev
)
1177 struct device
*dev
= &pdev
->dev
;
1178 struct resource
*res
;
1185 dwc
= devm_kzalloc(dev
, sizeof(*dwc
), GFP_KERNEL
);
1191 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
1193 dev_err(dev
, "missing memory resource\n");
1197 dwc
->xhci_resources
[0].start
= res
->start
;
1198 dwc
->xhci_resources
[0].end
= dwc
->xhci_resources
[0].start
+
1200 dwc
->xhci_resources
[0].flags
= res
->flags
;
1201 dwc
->xhci_resources
[0].name
= res
->name
;
1203 res
->start
+= DWC3_GLOBALS_REGS_START
;
1206 * Request memory region but exclude xHCI regs,
1207 * since it will be requested by the xhci-plat driver.
1209 regs
= devm_ioremap_resource(dev
, res
);
1211 ret
= PTR_ERR(regs
);
1216 dwc
->regs_size
= resource_size(res
);
1218 dwc3_get_properties(dwc
);
1220 platform_set_drvdata(pdev
, dwc
);
1221 dwc3_cache_hwparams(dwc
);
1223 spin_lock_init(&dwc
->lock
);
1225 pm_runtime_set_active(dev
);
1226 pm_runtime_use_autosuspend(dev
);
1227 pm_runtime_set_autosuspend_delay(dev
, DWC3_DEFAULT_AUTOSUSPEND_DELAY
);
1228 pm_runtime_enable(dev
);
1229 ret
= pm_runtime_get_sync(dev
);
1233 pm_runtime_forbid(dev
);
1235 ret
= dwc3_alloc_event_buffers(dwc
, DWC3_EVENT_BUFFERS_SIZE
);
1237 dev_err(dwc
->dev
, "failed to allocate event buffers\n");
1242 ret
= dwc3_get_dr_mode(dwc
);
1246 ret
= dwc3_alloc_scratch_buffers(dwc
);
1250 ret
= dwc3_core_init(dwc
);
1252 if (ret
!= -EPROBE_DEFER
)
1253 dev_err(dev
, "failed to initialize core: %d\n", ret
);
1257 dwc3_check_params(dwc
);
1259 ret
= dwc3_core_init_mode(dwc
);
1263 dwc3_debugfs_init(dwc
);
1264 pm_runtime_put(dev
);
1269 dwc3_event_buffers_cleanup(dwc
);
1270 dwc3_ulpi_exit(dwc
);
1273 dwc3_free_scratch_buffers(dwc
);
1276 dwc3_free_event_buffers(dwc
);
1279 pm_runtime_allow(&pdev
->dev
);
1282 pm_runtime_put_sync(&pdev
->dev
);
1283 pm_runtime_disable(&pdev
->dev
);
1287 * restore res->start back to its original value so that, in case the
1288 * probe is deferred, we don't end up getting error in request the
1289 * memory region the next time probe is called.
1291 res
->start
-= DWC3_GLOBALS_REGS_START
;
1296 static int dwc3_remove(struct platform_device
*pdev
)
1298 struct dwc3
*dwc
= platform_get_drvdata(pdev
);
1299 struct resource
*res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
1301 pm_runtime_get_sync(&pdev
->dev
);
1303 * restore res->start back to its original value so that, in case the
1304 * probe is deferred, we don't end up getting error in request the
1305 * memory region the next time probe is called.
1307 res
->start
-= DWC3_GLOBALS_REGS_START
;
1309 dwc3_debugfs_exit(dwc
);
1310 dwc3_core_exit_mode(dwc
);
1312 dwc3_core_exit(dwc
);
1313 dwc3_ulpi_exit(dwc
);
1315 pm_runtime_put_sync(&pdev
->dev
);
1316 pm_runtime_allow(&pdev
->dev
);
1317 pm_runtime_disable(&pdev
->dev
);
1319 dwc3_free_event_buffers(dwc
);
1320 dwc3_free_scratch_buffers(dwc
);
1326 static int dwc3_suspend_common(struct dwc3
*dwc
, pm_message_t msg
)
1328 unsigned long flags
;
1330 switch (dwc
->current_dr_role
) {
1331 case DWC3_GCTL_PRTCAP_DEVICE
:
1332 spin_lock_irqsave(&dwc
->lock
, flags
);
1333 dwc3_gadget_suspend(dwc
);
1334 spin_unlock_irqrestore(&dwc
->lock
, flags
);
1335 dwc3_core_exit(dwc
);
1337 case DWC3_GCTL_PRTCAP_HOST
:
1338 /* do nothing during host runtime_suspend */
1339 if (!PMSG_IS_AUTO(msg
))
1340 dwc3_core_exit(dwc
);
1350 static int dwc3_resume_common(struct dwc3
*dwc
, pm_message_t msg
)
1352 unsigned long flags
;
1355 switch (dwc
->current_dr_role
) {
1356 case DWC3_GCTL_PRTCAP_DEVICE
:
1357 ret
= dwc3_core_init(dwc
);
1361 spin_lock_irqsave(&dwc
->lock
, flags
);
1362 dwc3_gadget_resume(dwc
);
1363 spin_unlock_irqrestore(&dwc
->lock
, flags
);
1365 case DWC3_GCTL_PRTCAP_HOST
:
1366 /* nothing to do on host runtime_resume */
1367 if (!PMSG_IS_AUTO(msg
)) {
1368 ret
= dwc3_core_init(dwc
);
1381 static int dwc3_runtime_checks(struct dwc3
*dwc
)
1383 switch (dwc
->current_dr_role
) {
1384 case DWC3_GCTL_PRTCAP_DEVICE
:
1388 case DWC3_GCTL_PRTCAP_HOST
:
1397 static int dwc3_runtime_suspend(struct device
*dev
)
1399 struct dwc3
*dwc
= dev_get_drvdata(dev
);
1402 if (dwc3_runtime_checks(dwc
))
1405 ret
= dwc3_suspend_common(dwc
, PMSG_AUTO_SUSPEND
);
1409 device_init_wakeup(dev
, true);
1414 static int dwc3_runtime_resume(struct device
*dev
)
1416 struct dwc3
*dwc
= dev_get_drvdata(dev
);
1419 device_init_wakeup(dev
, false);
1421 ret
= dwc3_resume_common(dwc
, PMSG_AUTO_RESUME
);
1425 switch (dwc
->current_dr_role
) {
1426 case DWC3_GCTL_PRTCAP_DEVICE
:
1427 dwc3_gadget_process_pending_events(dwc
);
1429 case DWC3_GCTL_PRTCAP_HOST
:
1435 pm_runtime_mark_last_busy(dev
);
1440 static int dwc3_runtime_idle(struct device
*dev
)
1442 struct dwc3
*dwc
= dev_get_drvdata(dev
);
1444 switch (dwc
->current_dr_role
) {
1445 case DWC3_GCTL_PRTCAP_DEVICE
:
1446 if (dwc3_runtime_checks(dwc
))
1449 case DWC3_GCTL_PRTCAP_HOST
:
1455 pm_runtime_mark_last_busy(dev
);
1456 pm_runtime_autosuspend(dev
);
1460 #endif /* CONFIG_PM */
1462 #ifdef CONFIG_PM_SLEEP
1463 static int dwc3_suspend(struct device
*dev
)
1465 struct dwc3
*dwc
= dev_get_drvdata(dev
);
1468 ret
= dwc3_suspend_common(dwc
, PMSG_SUSPEND
);
1472 pinctrl_pm_select_sleep_state(dev
);
1477 static int dwc3_resume(struct device
*dev
)
1479 struct dwc3
*dwc
= dev_get_drvdata(dev
);
1482 pinctrl_pm_select_default_state(dev
);
1484 ret
= dwc3_resume_common(dwc
, PMSG_RESUME
);
1488 pm_runtime_disable(dev
);
1489 pm_runtime_set_active(dev
);
1490 pm_runtime_enable(dev
);
1494 #endif /* CONFIG_PM_SLEEP */
1496 static const struct dev_pm_ops dwc3_dev_pm_ops
= {
1497 SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend
, dwc3_resume
)
1498 SET_RUNTIME_PM_OPS(dwc3_runtime_suspend
, dwc3_runtime_resume
,
1503 static const struct of_device_id of_dwc3_match
[] = {
1505 .compatible
= "snps,dwc3"
1508 .compatible
= "synopsys,dwc3"
1512 MODULE_DEVICE_TABLE(of
, of_dwc3_match
);
1517 #define ACPI_ID_INTEL_BSW "808622B7"
1519 static const struct acpi_device_id dwc3_acpi_match
[] = {
1520 { ACPI_ID_INTEL_BSW
, 0 },
1523 MODULE_DEVICE_TABLE(acpi
, dwc3_acpi_match
);
1526 static struct platform_driver dwc3_driver
= {
1527 .probe
= dwc3_probe
,
1528 .remove
= dwc3_remove
,
1531 .of_match_table
= of_match_ptr(of_dwc3_match
),
1532 .acpi_match_table
= ACPI_PTR(dwc3_acpi_match
),
1533 .pm
= &dwc3_dev_pm_ops
,
1537 module_platform_driver(dwc3_driver
);
1539 MODULE_ALIAS("platform:dwc3");
1540 MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
1541 MODULE_LICENSE("GPL v2");
1542 MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");