2 * core.c - DesignWare USB3 DRD Controller Core file
4 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
6 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 of
11 * the License as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <linux/version.h>
23 #include <linux/module.h>
24 #include <linux/kernel.h>
25 #include <linux/slab.h>
26 #include <linux/spinlock.h>
27 #include <linux/platform_device.h>
28 #include <linux/pm_runtime.h>
29 #include <linux/interrupt.h>
30 #include <linux/ioport.h>
32 #include <linux/list.h>
33 #include <linux/delay.h>
34 #include <linux/dma-mapping.h>
35 #include <linux/extcon.h>
37 #include <linux/acpi.h>
38 #include <linux/pinctrl/consumer.h>
40 #include <linux/usb/ch9.h>
41 #include <linux/usb/gadget.h>
42 #include <linux/usb/of.h>
43 #include <linux/usb/otg.h>
45 #include "platform_data.h"
52 /* -------------------------------------------------------------------------- */
54 void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
58 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
59 reg &= ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG));
60 reg |= DWC3_GCTL_PRTCAPDIR(mode);
61 dwc3_writel(dwc->regs, DWC3_GCTL, reg);
65 * dwc3_core_soft_reset - Issues core soft reset and PHY reset
66 * @dwc: pointer to our context structure
68 static int dwc3_core_soft_reset(struct dwc3 *dwc)
74 usb_phy_init(dwc->usb2_phy);
75 usb_phy_init(dwc->usb3_phy);
76 ret = phy_init(dwc->usb2_generic_phy);
80 ret = phy_init(dwc->usb3_generic_phy);
82 phy_exit(dwc->usb2_generic_phy);
87 * We're resetting only the device side because, if we're in host mode,
88 * XHCI driver will reset the host block. If dwc3 was configured for
89 * host-only mode, then we can return early.
91 if (dwc->dr_mode == USB_DR_MODE_HOST)
94 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
95 reg |= DWC3_DCTL_CSFTRST;
96 dwc3_writel(dwc->regs, DWC3_DCTL, reg);
99 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
100 if (!(reg & DWC3_DCTL_CSFTRST))
110 * dwc3_soft_reset - Issue soft reset
111 * @dwc: Pointer to our controller context structure
113 int dwc3_soft_reset(struct dwc3 *dwc)
115 unsigned long timeout;
118 timeout = jiffies + msecs_to_jiffies(500);
119 dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST);
121 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
122 if (!(reg & DWC3_DCTL_CSFTRST))
125 if (time_after(jiffies, timeout)) {
126 dev_err(dwc->dev, "Reset Timed Out\n");
137 * dwc3_frame_length_adjustment - Adjusts frame length if required
138 * @dwc3: Pointer to our controller context structure
139 * @fladj: Value of GFLADJ_30MHZ to adjust frame length
141 static void dwc3_frame_length_adjustment(struct dwc3 *dwc, u32 fladj)
146 if (dwc->revision < DWC3_REVISION_250A)
152 reg = dwc3_readl(dwc->regs, DWC3_GFLADJ);
153 dft = reg & DWC3_GFLADJ_30MHZ_MASK;
154 if (!dev_WARN_ONCE(dwc->dev, dft == fladj,
155 "request value same as default, ignoring\n")) {
156 reg &= ~DWC3_GFLADJ_30MHZ_MASK;
157 reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | fladj;
158 dwc3_writel(dwc->regs, DWC3_GFLADJ, reg);
163 * dwc3_free_one_event_buffer - Frees one event buffer
164 * @dwc: Pointer to our controller context structure
165 * @evt: Pointer to event buffer to be freed
167 static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
168 struct dwc3_event_buffer *evt)
170 dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma);
174 * dwc3_alloc_one_event_buffer - Allocates one event buffer structure
175 * @dwc: Pointer to our controller context structure
176 * @length: size of the event buffer
178 * Returns a pointer to the allocated event buffer structure on success
179 * otherwise ERR_PTR(errno).
181 static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc,
184 struct dwc3_event_buffer *evt;
186 evt = devm_kzalloc(dwc->dev, sizeof(*evt), GFP_KERNEL);
188 return ERR_PTR(-ENOMEM);
191 evt->length = length;
192 evt->buf = dma_alloc_coherent(dwc->dev, length,
193 &evt->dma, GFP_KERNEL);
195 return ERR_PTR(-ENOMEM);
201 * dwc3_free_event_buffers - frees all allocated event buffers
202 * @dwc: Pointer to our controller context structure
204 static void dwc3_free_event_buffers(struct dwc3 *dwc)
206 struct dwc3_event_buffer *evt;
209 for (i = 0; i < dwc->num_event_buffers; i++) {
210 evt = dwc->ev_buffs[i];
212 dwc3_free_one_event_buffer(dwc, evt);
217 * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length
218 * @dwc: pointer to our controller context structure
219 * @length: size of event buffer
221 * Returns 0 on success otherwise negative errno. In the error case, dwc
222 * may contain some buffers allocated but not all which were requested.
224 static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
229 num = DWC3_NUM_INT(dwc->hwparams.hwparams1);
230 dwc->num_event_buffers = num;
232 dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num,
237 for (i = 0; i < num; i++) {
238 struct dwc3_event_buffer *evt;
240 evt = dwc3_alloc_one_event_buffer(dwc, length);
242 dev_err(dwc->dev, "can't allocate event buffer\n");
245 dwc->ev_buffs[i] = evt;
252 * dwc3_event_buffers_setup - setup our allocated event buffers
253 * @dwc: pointer to our controller context structure
255 * Returns 0 on success otherwise negative errno.
257 int dwc3_event_buffers_setup(struct dwc3 *dwc)
259 struct dwc3_event_buffer *evt;
262 for (n = 0; n < dwc->num_event_buffers; n++) {
263 evt = dwc->ev_buffs[n];
264 dwc3_trace(trace_dwc3_core,
265 "Event buf %p dma %08llx length %d\n",
266 evt->buf, (unsigned long long) evt->dma,
271 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n),
272 lower_32_bits(evt->dma));
273 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n),
274 upper_32_bits(evt->dma));
275 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n),
276 DWC3_GEVNTSIZ_SIZE(evt->length));
277 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0);
283 void dwc3_event_buffers_cleanup(struct dwc3 *dwc)
285 struct dwc3_event_buffer *evt;
288 for (n = 0; n < dwc->num_event_buffers; n++) {
289 evt = dwc->ev_buffs[n];
293 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), 0);
294 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), 0);
295 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), DWC3_GEVNTSIZ_INTMASK
296 | DWC3_GEVNTSIZ_SIZE(0));
297 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0);
301 static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc)
303 if (!dwc->has_hibernation)
306 if (!dwc->nr_scratch)
309 dwc->scratchbuf = kmalloc_array(dwc->nr_scratch,
310 DWC3_SCRATCHBUF_SIZE, GFP_KERNEL);
311 if (!dwc->scratchbuf)
317 static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)
319 dma_addr_t scratch_addr;
323 if (!dwc->has_hibernation)
326 if (!dwc->nr_scratch)
329 /* should never fall here */
330 if (!WARN_ON(dwc->scratchbuf))
333 scratch_addr = dma_map_single(dwc->dev, dwc->scratchbuf,
334 dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE,
336 if (dma_mapping_error(dwc->dev, scratch_addr)) {
337 dev_err(dwc->dev, "failed to map scratch buffer\n");
342 dwc->scratch_addr = scratch_addr;
344 param = lower_32_bits(scratch_addr);
346 ret = dwc3_send_gadget_generic_command(dwc,
347 DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO, param);
351 param = upper_32_bits(scratch_addr);
353 ret = dwc3_send_gadget_generic_command(dwc,
354 DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI, param);
361 dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch *
362 DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
368 static void dwc3_free_scratch_buffers(struct dwc3 *dwc)
370 if (!dwc->has_hibernation)
373 if (!dwc->nr_scratch)
376 /* should never fall here */
377 if (!WARN_ON(dwc->scratchbuf))
380 dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch *
381 DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
382 kfree(dwc->scratchbuf);
385 static void dwc3_core_num_eps(struct dwc3 *dwc)
387 struct dwc3_hwparams *parms = &dwc->hwparams;
389 dwc->num_in_eps = DWC3_NUM_IN_EPS(parms);
390 dwc->num_out_eps = DWC3_NUM_EPS(parms) - dwc->num_in_eps;
392 dwc3_trace(trace_dwc3_core, "found %d IN and %d OUT endpoints",
393 dwc->num_in_eps, dwc->num_out_eps);
396 static void dwc3_cache_hwparams(struct dwc3 *dwc)
398 struct dwc3_hwparams *parms = &dwc->hwparams;
400 parms->hwparams0 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS0);
401 parms->hwparams1 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS1);
402 parms->hwparams2 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS2);
403 parms->hwparams3 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS3);
404 parms->hwparams4 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS4);
405 parms->hwparams5 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS5);
406 parms->hwparams6 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS6);
407 parms->hwparams7 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS7);
408 parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8);
412 * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core
413 * @dwc: Pointer to our controller context structure
415 * Returns 0 on success. The USB PHY interfaces are configured but not
416 * initialized. The PHY interfaces and the PHYs get initialized together with
417 * the core in dwc3_core_init.
419 static int dwc3_phy_setup(struct dwc3 *dwc)
425 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
428 * Above 1.94a, it is recommended to set DWC3_GUSB3PIPECTL_SUSPHY
429 * to '0' during coreConsultant configuration. So default value
430 * will be '0' when the core is reset. Application needs to set it
431 * to '1' after the core initialization is completed.
433 if (dwc->revision > DWC3_REVISION_194A)
434 reg |= DWC3_GUSB3PIPECTL_SUSPHY;
436 if (dwc->u2ss_inp3_quirk)
437 reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK;
439 if (dwc->req_p1p2p3_quirk)
440 reg |= DWC3_GUSB3PIPECTL_REQP1P2P3;
442 if (dwc->del_p1p2p3_quirk)
443 reg |= DWC3_GUSB3PIPECTL_DEP1P2P3_EN;
445 if (dwc->del_phy_power_chg_quirk)
446 reg |= DWC3_GUSB3PIPECTL_DEPOCHANGE;
448 if (dwc->lfps_filter_quirk)
449 reg |= DWC3_GUSB3PIPECTL_LFPSFILT;
451 if (dwc->rx_detect_poll_quirk)
452 reg |= DWC3_GUSB3PIPECTL_RX_DETOPOLL;
454 if (dwc->tx_de_emphasis_quirk)
455 reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis);
457 if (dwc->dis_u3_susphy_quirk)
458 reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
460 if (dwc->dis_del_phy_power_chg_quirk)
461 reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE;
463 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
465 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
467 /* Select the HS PHY interface */
468 switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) {
469 case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI:
470 if (dwc->hsphy_interface &&
471 !strncmp(dwc->hsphy_interface, "utmi", 4)) {
472 reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI;
474 } else if (dwc->hsphy_interface &&
475 !strncmp(dwc->hsphy_interface, "ulpi", 4)) {
476 reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI;
477 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
479 /* Relying on default value. */
480 if (!(reg & DWC3_GUSB2PHYCFG_ULPI_UTMI))
484 case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI:
485 /* Making sure the interface and PHY are operational */
486 ret = dwc3_soft_reset(dwc);
492 ret = dwc3_ulpi_init(dwc);
501 * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to
502 * '0' during coreConsultant configuration. So default value will
503 * be '0' when the core is reset. Application needs to set it to
504 * '1' after the core initialization is completed.
506 if (dwc->revision > DWC3_REVISION_194A)
507 reg |= DWC3_GUSB2PHYCFG_SUSPHY;
509 if (dwc->dis_u2_susphy_quirk)
510 reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
512 if (dwc->dis_enblslpm_quirk)
513 reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
515 if (dwc->dis_u2_freeclk_exists_quirk)
516 reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS;
518 if (dwc->phyif_utmi_16_bits)
519 reg |= DWC3_GUSB2PHYCFG_PHYIF;
521 usbtrdtim = (reg & DWC3_GUSB2PHYCFG_PHYIF) ?
522 USBTRDTIM_UTMI_16_BIT : USBTRDTIM_UTMI_8_BIT;
524 reg &= ~DWC3_GUSB2PHYCFG_USBTRDTIM_MASK;
525 reg |= (usbtrdtim << DWC3_GUSB2PHYCFG_USBTRDTIM_SHIFT);
527 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
533 * dwc3_core_init - Low-level initialization of DWC3 Core
534 * @dwc: Pointer to our controller context structure
536 * Returns 0 on success otherwise negative errno.
538 static int dwc3_core_init(struct dwc3 *dwc)
540 u32 hwparams4 = dwc->hwparams.hwparams4;
544 reg = dwc3_readl(dwc->regs, DWC3_GSNPSID);
545 /* This should read as U3 followed by revision number */
546 if ((reg & DWC3_GSNPSID_MASK) == 0x55330000) {
547 /* Detected DWC_usb3 IP */
549 } else if ((reg & DWC3_GSNPSID_MASK) == 0x33310000) {
550 /* Detected DWC_usb31 IP */
551 dwc->revision = dwc3_readl(dwc->regs, DWC3_VER_NUMBER);
552 dwc->revision |= DWC3_REVISION_IS_DWC31;
554 dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n");
560 * Write Linux Version Code to our GUID register so it's easy to figure
561 * out which kernel version a bug was found.
563 dwc3_writel(dwc->regs, DWC3_GUID, LINUX_VERSION_CODE);
565 /* Handle USB2.0-only core configuration */
566 if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
567 DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
568 if (dwc->maximum_speed == USB_SPEED_SUPER)
569 dwc->maximum_speed = USB_SPEED_HIGH;
572 /* issue device SoftReset too */
573 ret = dwc3_soft_reset(dwc);
577 ret = dwc3_core_soft_reset(dwc);
581 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
582 reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
584 switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) {
585 case DWC3_GHWPARAMS1_EN_PWROPT_CLK:
587 * WORKAROUND: DWC3 revisions between 2.10a and 2.50a have an
588 * issue which would cause xHCI compliance tests to fail.
590 * Because of that we cannot enable clock gating on such
595 * STAR#9000588375: Clock Gating, SOF Issues when ref_clk-Based
598 if ((dwc->dr_mode == USB_DR_MODE_HOST ||
599 dwc->dr_mode == USB_DR_MODE_OTG) &&
600 (dwc->revision >= DWC3_REVISION_210A &&
601 dwc->revision <= DWC3_REVISION_250A))
602 reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC;
604 reg &= ~DWC3_GCTL_DSBLCLKGTNG;
606 case DWC3_GHWPARAMS1_EN_PWROPT_HIB:
607 /* enable hibernation here */
608 dwc->nr_scratch = DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4);
611 * REVISIT Enabling this bit so that host-mode hibernation
612 * will work. Device-mode hibernation is not yet implemented.
614 reg |= DWC3_GCTL_GBLHIBERNATIONEN;
617 dwc3_trace(trace_dwc3_core, "No power optimization available\n");
620 /* check if current dwc3 is on simulation board */
621 if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) {
622 dwc3_trace(trace_dwc3_core,
623 "running on FPGA platform\n");
627 WARN_ONCE(dwc->disable_scramble_quirk && !dwc->is_fpga,
628 "disable_scramble cannot be used on non-FPGA builds\n");
630 if (dwc->disable_scramble_quirk && dwc->is_fpga)
631 reg |= DWC3_GCTL_DISSCRAMBLE;
633 reg &= ~DWC3_GCTL_DISSCRAMBLE;
635 if (dwc->u2exit_lfps_quirk)
636 reg |= DWC3_GCTL_U2EXIT_LFPS;
639 * WORKAROUND: DWC3 revisions <1.90a have a bug
640 * where the device can fail to connect at SuperSpeed
641 * and falls back to high-speed mode which causes
642 * the device to enter a Connect/Disconnect loop
644 if (dwc->revision < DWC3_REVISION_190A)
645 reg |= DWC3_GCTL_U2RSTECN;
647 dwc3_core_num_eps(dwc);
649 dwc3_writel(dwc->regs, DWC3_GCTL, reg);
651 ret = dwc3_alloc_scratch_buffers(dwc);
655 ret = dwc3_setup_scratch_buffers(dwc);
662 dwc3_free_scratch_buffers(dwc);
665 usb_phy_shutdown(dwc->usb2_phy);
666 usb_phy_shutdown(dwc->usb3_phy);
667 phy_exit(dwc->usb2_generic_phy);
668 phy_exit(dwc->usb3_generic_phy);
674 static void dwc3_core_exit(struct dwc3 *dwc)
676 dwc3_free_scratch_buffers(dwc);
677 usb_phy_shutdown(dwc->usb2_phy);
678 usb_phy_shutdown(dwc->usb3_phy);
679 phy_exit(dwc->usb2_generic_phy);
680 phy_exit(dwc->usb3_generic_phy);
683 static int dwc3_core_get_phy(struct dwc3 *dwc)
685 struct device *dev = dwc->dev;
686 struct device_node *node = dev->of_node;
690 dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0);
691 dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1);
693 dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
694 dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
697 if (IS_ERR(dwc->usb2_phy)) {
698 ret = PTR_ERR(dwc->usb2_phy);
699 if (ret == -ENXIO || ret == -ENODEV) {
700 dwc->usb2_phy = NULL;
701 } else if (ret == -EPROBE_DEFER) {
704 dev_err(dev, "no usb2 phy configured\n");
709 if (IS_ERR(dwc->usb3_phy)) {
710 ret = PTR_ERR(dwc->usb3_phy);
711 if (ret == -ENXIO || ret == -ENODEV) {
712 dwc->usb3_phy = NULL;
713 } else if (ret == -EPROBE_DEFER) {
716 dev_err(dev, "no usb3 phy configured\n");
721 dwc->usb2_generic_phy = devm_phy_get(dev, "usb2-phy");
722 if (IS_ERR(dwc->usb2_generic_phy)) {
723 ret = PTR_ERR(dwc->usb2_generic_phy);
724 if (ret == -ENOSYS || ret == -ENODEV) {
725 dwc->usb2_generic_phy = NULL;
726 } else if (ret == -EPROBE_DEFER) {
729 dev_err(dev, "no usb2 phy configured\n");
734 dwc->usb3_generic_phy = devm_phy_get(dev, "usb3-phy");
735 if (IS_ERR(dwc->usb3_generic_phy)) {
736 ret = PTR_ERR(dwc->usb3_generic_phy);
737 if (ret == -ENOSYS || ret == -ENODEV) {
738 dwc->usb3_generic_phy = NULL;
739 } else if (ret == -EPROBE_DEFER) {
742 dev_err(dev, "no usb3 phy configured\n");
750 static int dwc3_core_init_mode(struct dwc3 *dwc)
752 struct device *dev = dwc->dev;
755 switch (dwc->dr_mode) {
756 case USB_DR_MODE_PERIPHERAL:
757 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
758 ret = dwc3_gadget_init(dwc);
760 dev_err(dev, "failed to initialize gadget\n");
764 case USB_DR_MODE_HOST:
765 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
766 ret = dwc3_host_init(dwc);
768 dev_err(dev, "failed to initialize host\n");
772 case USB_DR_MODE_OTG:
773 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
774 ret = dwc3_host_init(dwc);
776 dev_err(dev, "failed to initialize host\n");
780 ret = dwc3_gadget_init(dwc);
782 dev_err(dev, "failed to initialize gadget\n");
787 dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode);
794 static void dwc3_core_exit_mode(struct dwc3 *dwc)
796 switch (dwc->dr_mode) {
797 case USB_DR_MODE_PERIPHERAL:
798 dwc3_gadget_exit(dwc);
800 case USB_DR_MODE_HOST:
803 case USB_DR_MODE_OTG:
805 dwc3_gadget_exit(dwc);
813 /* Returns true if the controller is capable of DRD. */
814 bool dwc3_hw_is_drd(struct dwc3 *dwc)
816 u32 op_mode = DWC3_GHWPARAMS0_USB3_MODE(dwc->hwparams.hwparams0);
818 return (op_mode == DWC3_GHWPARAMS0_USB3_DRD);
821 bool dwc3_force_mode(struct dwc3 *dwc, u32 mode)
828 * Force mode has no effect if the hardware is not drd mode.
830 if (!dwc3_hw_is_drd(dwc))
833 * If dr_mode is either peripheral or host only, there is no
834 * need to ever force the mode to the opposite mode.
836 if (WARN_ON(mode == DWC3_GCTL_PRTCAP_DEVICE &&
837 dwc->dr_mode == USB_DR_MODE_HOST))
840 if (WARN_ON(mode == DWC3_GCTL_PRTCAP_HOST &&
841 dwc->dr_mode == USB_DR_MODE_PERIPHERAL))
844 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
845 if (DWC3_GCTL_PRTCAP(reg) == mode)
848 hcd = dev_get_drvdata(&dwc->xhci->dev);
851 case DWC3_GCTL_PRTCAP_DEVICE:
852 if (hcd->state != HC_STATE_HALT) {
853 usb_remove_hcd(hcd->shared_hcd);
857 spin_lock_irqsave(&dwc->lock, flags);
858 dwc3_set_mode(dwc, mode);
859 dwc3_gadget_restart(dwc, true);
860 spin_unlock_irqrestore(&dwc->lock, flags);
863 case DWC3_GCTL_PRTCAP_HOST:
864 spin_lock_irqsave(&dwc->lock, flags);
865 dwc3_gadget_restart(dwc, false);
866 dwc3_set_mode(dwc, mode);
867 spin_unlock_irqrestore(&dwc->lock, flags);
869 if (hcd->state == HC_STATE_HALT) {
870 usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
871 usb_add_hcd(hcd->shared_hcd, hcd->irq, IRQF_SHARED);
883 static void rockchip_otg_extcon_evt_worker(struct work_struct *work)
886 container_of(work, struct dwc3, cable.otg_work.work);
887 struct extcon_dev *edev = dwc->cable.edev;
893 if (extcon_get_cable_state_(edev, EXTCON_USB) > 0) {
894 dev_info(dwc->dev, "USB peripheral connected\n");
896 if (dwc->cable.connected) {
897 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
899 if (DWC3_GCTL_PRTCAP(reg) != DWC3_GCTL_PRTCAP_DEVICE) {
900 spin_lock_irqsave(&dwc->lock, flags);
901 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
902 spin_unlock_irqrestore(&dwc->lock, flags);
909 * If dr_mode is host only, never to set
910 * the mode to the peripheral mode.
912 if (WARN_ON(dwc->dr_mode == USB_DR_MODE_HOST))
915 ret = phy_power_on(dwc->usb2_generic_phy);
919 ret = phy_power_on(dwc->usb3_generic_phy);
923 spin_lock_irqsave(&dwc->lock, flags);
925 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
926 dwc3_gadget_restart(dwc, true);
928 spin_unlock_irqrestore(&dwc->lock, flags);
930 dwc->cable.connected = true;
931 } else if (extcon_get_cable_state_(edev, EXTCON_USB_HOST) > 0) {
932 dev_info(dwc->dev, "USB HOST connected\n");
934 if (dwc->cable.connected) {
935 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
937 if (DWC3_GCTL_PRTCAP(reg) != DWC3_GCTL_PRTCAP_HOST) {
938 spin_lock_irqsave(&dwc->lock, flags);
939 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
940 spin_unlock_irqrestore(&dwc->lock, flags);
947 * If dr_mode is device only, never to
948 * set the mode to the host mode.
950 if (WARN_ON(dwc->dr_mode == USB_DR_MODE_PERIPHERAL))
953 ret = phy_power_on(dwc->usb2_generic_phy);
957 ret = phy_power_on(dwc->usb3_generic_phy);
961 hcd = dev_get_drvdata(&dwc->xhci->dev);
963 spin_lock_irqsave(&dwc->lock, flags);
965 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
967 spin_unlock_irqrestore(&dwc->lock, flags);
969 if (hcd->state == HC_STATE_HALT) {
970 usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
971 usb_add_hcd(hcd->shared_hcd, hcd->irq, IRQF_SHARED);
974 dwc->cable.connected = true;
976 dev_info(dwc->dev, "USB unconnected\n");
978 if (!dwc->cable.connected)
981 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
983 if (DWC3_GCTL_PRTCAP(reg) == DWC3_GCTL_PRTCAP_DEVICE ||
984 DWC3_GCTL_PRTCAP(reg) == DWC3_GCTL_PRTCAP_OTG) {
985 spin_lock_irqsave(&dwc->lock, flags);
986 dwc3_gadget_restart(dwc, false);
987 spin_unlock_irqrestore(&dwc->lock, flags);
990 if (DWC3_GCTL_PRTCAP(reg) == DWC3_GCTL_PRTCAP_HOST ||
991 DWC3_GCTL_PRTCAP(reg) == DWC3_GCTL_PRTCAP_OTG) {
992 hcd = dev_get_drvdata(&dwc->xhci->dev);
994 if (hcd->state != HC_STATE_HALT) {
995 usb_remove_hcd(hcd->shared_hcd);
1000 spin_lock_irqsave(&dwc->lock, flags);
1002 switch (dwc->dr_mode) {
1003 case USB_DR_MODE_PERIPHERAL:
1004 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
1006 case USB_DR_MODE_HOST:
1007 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
1009 case USB_DR_MODE_OTG:
1010 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
1016 spin_unlock_irqrestore(&dwc->lock, flags);
1018 phy_power_off(dwc->usb2_generic_phy);
1019 phy_power_off(dwc->usb3_generic_phy);
1021 dwc->cable.connected = false;
1025 static int dwc3_rockchip_device_notifier(struct notifier_block *nb,
1026 unsigned long event, void *ptr)
1029 container_of(nb, struct dwc3, cable.device_nb);
1031 schedule_delayed_work(&dwc->cable.otg_work, 0);
1036 static int dwc3_rockchip_host_notifier(struct notifier_block *nb,
1037 unsigned long event, void *ptr)
1040 container_of(nb, struct dwc3, cable.host_nb);
1042 schedule_delayed_work(&dwc->cable.otg_work, 0);
1047 #define DWC3_ALIGN_MASK (16 - 1)
1049 static int dwc3_probe(struct platform_device *pdev)
1051 struct device *dev = &pdev->dev;
1052 struct dwc3_platform_data *pdata = dev_get_platdata(dev);
1053 struct resource *res;
1055 u8 lpm_nyet_threshold;
1059 struct extcon_dev *edev;
1066 mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL);
1070 dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1);
1074 /* Try to set 64-bit DMA first */
1075 if (!pdev->dev.dma_mask)
1076 /* Platform did not initialize dma_mask */
1077 ret = dma_coerce_mask_and_coherent(&pdev->dev,
1080 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
1082 /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */
1084 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
1089 if (device_property_read_bool(dev, "extcon")) {
1090 edev = extcon_get_edev_by_phandle(dev, 0);
1092 if (PTR_ERR(edev) != -EPROBE_DEFER)
1093 dev_err(dev, "couldn't get extcon device\n");
1094 return PTR_ERR(edev);
1097 /* Register for extcon notification */
1098 INIT_DELAYED_WORK(&dwc->cable.otg_work,
1099 rockchip_otg_extcon_evt_worker);
1100 dwc->cable.device_nb.notifier_call =
1101 dwc3_rockchip_device_notifier;
1102 dwc->cable.host_nb.notifier_call =
1103 dwc3_rockchip_host_notifier;
1105 ret = extcon_register_notifier(edev, EXTCON_USB,
1106 &dwc->cable.device_nb);
1108 dev_err(dev, "failed to register notifier for USB\n");
1112 ret = extcon_register_notifier(edev, EXTCON_USB_HOST,
1113 &dwc->cable.host_nb);
1115 dev_err(dev, "failed to register notifier for USB HOST\n");
1116 extcon_unregister_notifier(edev, EXTCON_USB,
1117 &dwc->cable.device_nb);
1122 * cable.connected flag is used for otg device/host
1123 * connect status, true means connection and false
1124 * means disconnection. However, we initialize the
1125 * cable.connected with true, though nothing connect
1126 * with the usb port. It aims to do phy power off
1127 * and disable controller in cable.work.
1129 dwc->cable.connected = true;
1130 dwc->cable.edev = edev;
1133 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1135 dev_err(dev, "missing IRQ\n");
1138 dwc->xhci_resources[1].start = res->start;
1139 dwc->xhci_resources[1].end = res->end;
1140 dwc->xhci_resources[1].flags = res->flags;
1141 dwc->xhci_resources[1].name = res->name;
1143 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1145 dev_err(dev, "missing memory resource\n");
1149 dwc->xhci_resources[0].start = res->start;
1150 dwc->xhci_resources[0].end = dwc->xhci_resources[0].start +
1152 dwc->xhci_resources[0].flags = res->flags;
1153 dwc->xhci_resources[0].name = res->name;
1155 res->start += DWC3_GLOBALS_REGS_START;
1158 * Request memory region but exclude xHCI regs,
1159 * since it will be requested by the xhci-plat driver.
1161 regs = devm_ioremap_resource(dev, res);
1163 ret = PTR_ERR(regs);
1168 dwc->regs_size = resource_size(res);
1170 /* default to highest possible threshold */
1171 lpm_nyet_threshold = 0xff;
1173 /* default to -3.5dB de-emphasis */
1177 * default to assert utmi_sleep_n and use maximum allowed HIRD
1178 * threshold value of 0b1100
1180 hird_threshold = 12;
1182 dwc->maximum_speed = usb_get_maximum_speed(dev);
1183 dwc->dr_mode = usb_get_dr_mode(dev);
1185 dwc->has_lpm_erratum = device_property_read_bool(dev,
1186 "snps,has-lpm-erratum");
1187 device_property_read_u8(dev, "snps,lpm-nyet-threshold",
1188 &lpm_nyet_threshold);
1189 dwc->is_utmi_l1_suspend = device_property_read_bool(dev,
1190 "snps,is-utmi-l1-suspend");
1191 device_property_read_u8(dev, "snps,hird-threshold",
1193 dwc->usb3_lpm_capable = device_property_read_bool(dev,
1194 "snps,usb3_lpm_capable");
1196 dwc->disable_scramble_quirk = device_property_read_bool(dev,
1197 "snps,disable_scramble_quirk");
1198 dwc->u2exit_lfps_quirk = device_property_read_bool(dev,
1199 "snps,u2exit_lfps_quirk");
1200 dwc->u2ss_inp3_quirk = device_property_read_bool(dev,
1201 "snps,u2ss_inp3_quirk");
1202 dwc->req_p1p2p3_quirk = device_property_read_bool(dev,
1203 "snps,req_p1p2p3_quirk");
1204 dwc->del_p1p2p3_quirk = device_property_read_bool(dev,
1205 "snps,del_p1p2p3_quirk");
1206 dwc->del_phy_power_chg_quirk = device_property_read_bool(dev,
1207 "snps,del_phy_power_chg_quirk");
1208 dwc->lfps_filter_quirk = device_property_read_bool(dev,
1209 "snps,lfps_filter_quirk");
1210 dwc->rx_detect_poll_quirk = device_property_read_bool(dev,
1211 "snps,rx_detect_poll_quirk");
1212 dwc->dis_u3_susphy_quirk = device_property_read_bool(dev,
1213 "snps,dis_u3_susphy_quirk");
1214 dwc->dis_u2_susphy_quirk = device_property_read_bool(dev,
1215 "snps,dis_u2_susphy_quirk");
1216 dwc->dis_enblslpm_quirk = device_property_read_bool(dev,
1217 "snps,dis_enblslpm_quirk");
1218 dwc->dis_u2_freeclk_exists_quirk = device_property_read_bool(dev,
1219 "snps,dis_u2_freeclk_exists_quirk");
1220 dwc->dis_del_phy_power_chg_quirk = device_property_read_bool(dev,
1221 "snps,dis_del_phy_power_chg_quirk");
1222 dwc->xhci_slow_suspend_quirk = device_property_read_bool(dev,
1223 "snps,xhci_slow_suspend_quirk");
1224 dwc->phyif_utmi_16_bits = device_property_read_bool(dev,
1225 "snps,phyif_utmi_16_bits");
1227 dwc->tx_de_emphasis_quirk = device_property_read_bool(dev,
1228 "snps,tx_de_emphasis_quirk");
1229 device_property_read_u8(dev, "snps,tx_de_emphasis",
1231 device_property_read_string(dev, "snps,hsphy_interface",
1232 &dwc->hsphy_interface);
1233 device_property_read_u32(dev, "snps,quirk-frame-length-adjustment",
1237 dwc->maximum_speed = pdata->maximum_speed;
1238 dwc->has_lpm_erratum = pdata->has_lpm_erratum;
1239 if (pdata->lpm_nyet_threshold)
1240 lpm_nyet_threshold = pdata->lpm_nyet_threshold;
1241 dwc->is_utmi_l1_suspend = pdata->is_utmi_l1_suspend;
1242 if (pdata->hird_threshold)
1243 hird_threshold = pdata->hird_threshold;
1245 dwc->usb3_lpm_capable = pdata->usb3_lpm_capable;
1246 dwc->dr_mode = pdata->dr_mode;
1248 dwc->disable_scramble_quirk = pdata->disable_scramble_quirk;
1249 dwc->u2exit_lfps_quirk = pdata->u2exit_lfps_quirk;
1250 dwc->u2ss_inp3_quirk = pdata->u2ss_inp3_quirk;
1251 dwc->req_p1p2p3_quirk = pdata->req_p1p2p3_quirk;
1252 dwc->del_p1p2p3_quirk = pdata->del_p1p2p3_quirk;
1253 dwc->del_phy_power_chg_quirk = pdata->del_phy_power_chg_quirk;
1254 dwc->lfps_filter_quirk = pdata->lfps_filter_quirk;
1255 dwc->rx_detect_poll_quirk = pdata->rx_detect_poll_quirk;
1256 dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk;
1257 dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk;
1258 dwc->dis_enblslpm_quirk = pdata->dis_enblslpm_quirk;
1259 dwc->dis_u2_freeclk_exists_quirk =
1260 pdata->dis_u2_freeclk_exists_quirk;
1261 dwc->dis_del_phy_power_chg_quirk =
1262 pdata->dis_del_phy_power_chg_quirk;
1263 dwc->xhci_slow_suspend_quirk =
1264 pdata->xhci_slow_suspend_quirk;
1265 dwc->phyif_utmi_16_bits = pdata->phyif_utmi_16_bits;
1267 dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk;
1268 if (pdata->tx_de_emphasis)
1269 tx_de_emphasis = pdata->tx_de_emphasis;
1271 dwc->hsphy_interface = pdata->hsphy_interface;
1272 fladj = pdata->fladj_value;
1275 /* default to superspeed if no maximum_speed passed */
1276 if (dwc->maximum_speed == USB_SPEED_UNKNOWN)
1277 dwc->maximum_speed = USB_SPEED_SUPER;
1279 dwc->lpm_nyet_threshold = lpm_nyet_threshold;
1280 dwc->tx_de_emphasis = tx_de_emphasis;
1282 dwc->hird_threshold = hird_threshold
1283 | (dwc->is_utmi_l1_suspend << 4);
1285 platform_set_drvdata(pdev, dwc);
1286 dwc3_cache_hwparams(dwc);
1288 ret = dwc3_phy_setup(dwc);
1292 ret = dwc3_core_get_phy(dwc);
1296 spin_lock_init(&dwc->lock);
1298 if (!dev->dma_mask) {
1299 dev->dma_mask = dev->parent->dma_mask;
1300 dev->dma_parms = dev->parent->dma_parms;
1301 dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask);
1304 pm_runtime_enable(dev);
1305 pm_runtime_get_sync(dev);
1306 pm_runtime_forbid(dev);
1308 ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
1310 dev_err(dwc->dev, "failed to allocate event buffers\n");
1315 if (IS_ENABLED(CONFIG_USB_DWC3_HOST))
1316 dwc->dr_mode = USB_DR_MODE_HOST;
1317 else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET))
1318 dwc->dr_mode = USB_DR_MODE_PERIPHERAL;
1320 if (dwc->dr_mode == USB_DR_MODE_UNKNOWN)
1321 dwc->dr_mode = USB_DR_MODE_OTG;
1323 ret = dwc3_core_init(dwc);
1325 dev_err(dev, "failed to initialize core\n");
1329 /* Adjust Frame Length */
1330 dwc3_frame_length_adjustment(dwc, fladj);
1332 usb_phy_set_suspend(dwc->usb2_phy, 0);
1333 usb_phy_set_suspend(dwc->usb3_phy, 0);
1335 ret = phy_power_on(dwc->usb2_generic_phy);
1339 ret = phy_power_on(dwc->usb3_generic_phy);
1343 ret = dwc3_event_buffers_setup(dwc);
1345 dev_err(dwc->dev, "failed to setup event buffers\n");
1349 ret = dwc3_core_init_mode(dwc);
1353 ret = dwc3_debugfs_init(dwc);
1355 dev_err(dev, "failed to initialize debugfs\n");
1359 if (dwc->cable.edev)
1360 schedule_delayed_work(&dwc->cable.otg_work, (2 * HZ));
1362 pm_runtime_allow(dev);
1367 dwc3_core_exit_mode(dwc);
1370 dwc3_event_buffers_cleanup(dwc);
1373 phy_power_off(dwc->usb3_generic_phy);
1376 phy_power_off(dwc->usb2_generic_phy);
1379 usb_phy_set_suspend(dwc->usb2_phy, 1);
1380 usb_phy_set_suspend(dwc->usb3_phy, 1);
1381 dwc3_core_exit(dwc);
1384 dwc3_free_event_buffers(dwc);
1385 dwc3_ulpi_exit(dwc);
1389 * restore res->start back to its original value so that, in case the
1390 * probe is deferred, we don't end up getting error in request the
1391 * memory region the next time probe is called.
1393 res->start -= DWC3_GLOBALS_REGS_START;
1398 static int dwc3_remove(struct platform_device *pdev)
1400 struct dwc3 *dwc = platform_get_drvdata(pdev);
1401 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1404 * restore res->start back to its original value so that, in case the
1405 * probe is deferred, we don't end up getting error in request the
1406 * memory region the next time probe is called.
1408 res->start -= DWC3_GLOBALS_REGS_START;
1410 dwc3_debugfs_exit(dwc);
1411 dwc3_core_exit_mode(dwc);
1412 dwc3_event_buffers_cleanup(dwc);
1413 dwc3_free_event_buffers(dwc);
1415 usb_phy_set_suspend(dwc->usb2_phy, 1);
1416 usb_phy_set_suspend(dwc->usb3_phy, 1);
1417 phy_power_off(dwc->usb2_generic_phy);
1418 phy_power_off(dwc->usb3_generic_phy);
1420 dwc3_core_exit(dwc);
1421 dwc3_ulpi_exit(dwc);
1423 pm_runtime_put_sync(&pdev->dev);
1424 pm_runtime_disable(&pdev->dev);
1429 #ifdef CONFIG_PM_SLEEP
1430 static int dwc3_suspend(struct device *dev)
1432 struct dwc3 *dwc = dev_get_drvdata(dev);
1433 unsigned long flags;
1435 spin_lock_irqsave(&dwc->lock, flags);
1437 switch (dwc->dr_mode) {
1438 case USB_DR_MODE_PERIPHERAL:
1439 case USB_DR_MODE_OTG:
1440 dwc3_gadget_suspend(dwc);
1442 case USB_DR_MODE_HOST:
1444 dwc3_event_buffers_cleanup(dwc);
1448 dwc->gctl = dwc3_readl(dwc->regs, DWC3_GCTL);
1449 spin_unlock_irqrestore(&dwc->lock, flags);
1451 usb_phy_shutdown(dwc->usb3_phy);
1452 usb_phy_shutdown(dwc->usb2_phy);
1453 phy_exit(dwc->usb2_generic_phy);
1454 phy_exit(dwc->usb3_generic_phy);
1456 pinctrl_pm_select_sleep_state(dev);
1461 static int dwc3_resume(struct device *dev)
1463 struct dwc3 *dwc = dev_get_drvdata(dev);
1464 unsigned long flags;
1467 pinctrl_pm_select_default_state(dev);
1469 usb_phy_init(dwc->usb3_phy);
1470 usb_phy_init(dwc->usb2_phy);
1471 ret = phy_init(dwc->usb2_generic_phy);
1475 ret = phy_init(dwc->usb3_generic_phy);
1477 goto err_usb2phy_init;
1479 spin_lock_irqsave(&dwc->lock, flags);
1481 dwc3_event_buffers_setup(dwc);
1482 dwc3_writel(dwc->regs, DWC3_GCTL, dwc->gctl);
1484 switch (dwc->dr_mode) {
1485 case USB_DR_MODE_PERIPHERAL:
1486 case USB_DR_MODE_OTG:
1487 dwc3_gadget_resume(dwc);
1489 case USB_DR_MODE_HOST:
1495 spin_unlock_irqrestore(&dwc->lock, flags);
1497 pm_runtime_disable(dev);
1498 pm_runtime_set_active(dev);
1499 pm_runtime_enable(dev);
1504 phy_exit(dwc->usb2_generic_phy);
1509 static const struct dev_pm_ops dwc3_dev_pm_ops = {
1510 SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend, dwc3_resume)
1513 #define DWC3_PM_OPS &(dwc3_dev_pm_ops)
1515 #define DWC3_PM_OPS NULL
1519 static const struct of_device_id of_dwc3_match[] = {
1521 .compatible = "snps,dwc3"
1524 .compatible = "synopsys,dwc3"
1528 MODULE_DEVICE_TABLE(of, of_dwc3_match);
1533 #define ACPI_ID_INTEL_BSW "808622B7"
1535 static const struct acpi_device_id dwc3_acpi_match[] = {
1536 { ACPI_ID_INTEL_BSW, 0 },
1539 MODULE_DEVICE_TABLE(acpi, dwc3_acpi_match);
1542 static struct platform_driver dwc3_driver = {
1543 .probe = dwc3_probe,
1544 .remove = dwc3_remove,
1547 .of_match_table = of_match_ptr(of_dwc3_match),
1548 .acpi_match_table = ACPI_PTR(dwc3_acpi_match),
1553 module_platform_driver(dwc3_driver);
1555 MODULE_ALIAS("platform:dwc3");
1556 MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
1557 MODULE_LICENSE("GPL v2");
1558 MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");