core.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. /**
  2. * core.c - DesignWare USB3 DRD Controller Core file
  3. *
  4. * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
  5. *
  6. * Authors: Felipe Balbi <balbi@ti.com>,
  7. * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions, and the following disclaimer,
  14. * without modification.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * 3. The names of the above-listed copyright holders may not be used
  19. * to endorse or promote products derived from this software without
  20. * specific prior written permission.
  21. *
  22. * ALTERNATIVELY, this software may be distributed under the terms of the
  23. * GNU General Public License ("GPL") version 2, as published by the Free
  24. * Software Foundation.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  27. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  28. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  29. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  30. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  31. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  32. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  33. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  34. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  35. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  36. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. */
  38. #include <linux/module.h>
  39. #include <linux/kernel.h>
  40. #include <linux/slab.h>
  41. #include <linux/spinlock.h>
  42. #include <linux/platform_device.h>
  43. #include <linux/pm_runtime.h>
  44. #include <linux/interrupt.h>
  45. #include <linux/ioport.h>
  46. #include <linux/io.h>
  47. #include <linux/list.h>
  48. #include <linux/delay.h>
  49. #include <linux/dma-mapping.h>
  50. #include <linux/of.h>
  51. #include <linux/usb/ch9.h>
  52. #include <linux/usb/gadget.h>
  53. #include "core.h"
  54. #include "gadget.h"
  55. #include "io.h"
  56. #include "debug.h"
  57. static char *maximum_speed = "super";
  58. module_param(maximum_speed, charp, 0);
  59. MODULE_PARM_DESC(maximum_speed, "Maximum supported speed.");
  60. /* -------------------------------------------------------------------------- */
  61. #define DWC3_DEVS_POSSIBLE 32
  62. static DECLARE_BITMAP(dwc3_devs, DWC3_DEVS_POSSIBLE);
  63. int dwc3_get_device_id(void)
  64. {
  65. int id;
  66. again:
  67. id = find_first_zero_bit(dwc3_devs, DWC3_DEVS_POSSIBLE);
  68. if (id < DWC3_DEVS_POSSIBLE) {
  69. int old;
  70. old = test_and_set_bit(id, dwc3_devs);
  71. if (old)
  72. goto again;
  73. } else {
  74. pr_err("dwc3: no space for new device\n");
  75. id = -ENOMEM;
  76. }
  77. return id;
  78. }
  79. EXPORT_SYMBOL_GPL(dwc3_get_device_id);
  80. void dwc3_put_device_id(int id)
  81. {
  82. int ret;
  83. if (id < 0)
  84. return;
  85. ret = test_bit(id, dwc3_devs);
  86. WARN(!ret, "dwc3: ID %d not in use\n", id);
  87. clear_bit(id, dwc3_devs);
  88. }
  89. EXPORT_SYMBOL_GPL(dwc3_put_device_id);
  90. void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
  91. {
  92. u32 reg;
  93. reg = dwc3_readl(dwc->regs, DWC3_GCTL);
  94. reg &= ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG));
  95. reg |= DWC3_GCTL_PRTCAPDIR(mode);
  96. dwc3_writel(dwc->regs, DWC3_GCTL, reg);
  97. }
  98. /**
  99. * dwc3_core_soft_reset - Issues core soft reset and PHY reset
  100. * @dwc: pointer to our context structure
  101. */
  102. static void dwc3_core_soft_reset(struct dwc3 *dwc)
  103. {
  104. u32 reg;
  105. /* Before Resetting PHY, put Core in Reset */
  106. reg = dwc3_readl(dwc->regs, DWC3_GCTL);
  107. reg |= DWC3_GCTL_CORESOFTRESET;
  108. dwc3_writel(dwc->regs, DWC3_GCTL, reg);
  109. /* Assert USB3 PHY reset */
  110. reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
  111. reg |= DWC3_GUSB3PIPECTL_PHYSOFTRST;
  112. dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
  113. /* Assert USB2 PHY reset */
  114. reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
  115. reg |= DWC3_GUSB2PHYCFG_PHYSOFTRST;
  116. dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
  117. mdelay(100);
  118. /* Clear USB3 PHY reset */
  119. reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
  120. reg &= ~DWC3_GUSB3PIPECTL_PHYSOFTRST;
  121. dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
  122. /* Clear USB2 PHY reset */
  123. reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
  124. reg &= ~DWC3_GUSB2PHYCFG_PHYSOFTRST;
  125. dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
  126. mdelay(100);
  127. /* After PHYs are stable we can take Core out of reset state */
  128. reg = dwc3_readl(dwc->regs, DWC3_GCTL);
  129. reg &= ~DWC3_GCTL_CORESOFTRESET;
  130. dwc3_writel(dwc->regs, DWC3_GCTL, reg);
  131. }
  132. /**
  133. * dwc3_free_one_event_buffer - Frees one event buffer
  134. * @dwc: Pointer to our controller context structure
  135. * @evt: Pointer to event buffer to be freed
  136. */
  137. static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
  138. struct dwc3_event_buffer *evt)
  139. {
  140. dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma);
  141. kfree(evt);
  142. }
  143. /**
  144. * dwc3_alloc_one_event_buffer - Allocates one event buffer structure
  145. * @dwc: Pointer to our controller context structure
  146. * @length: size of the event buffer
  147. *
  148. * Returns a pointer to the allocated event buffer structure on success
  149. * otherwise ERR_PTR(errno).
  150. */
  151. static struct dwc3_event_buffer *__devinit
  152. dwc3_alloc_one_event_buffer(struct dwc3 *dwc, unsigned length)
  153. {
  154. struct dwc3_event_buffer *evt;
  155. evt = kzalloc(sizeof(*evt), GFP_KERNEL);
  156. if (!evt)
  157. return ERR_PTR(-ENOMEM);
  158. evt->dwc = dwc;
  159. evt->length = length;
  160. evt->buf = dma_alloc_coherent(dwc->dev, length,
  161. &evt->dma, GFP_KERNEL);
  162. if (!evt->buf) {
  163. kfree(evt);
  164. return ERR_PTR(-ENOMEM);
  165. }
  166. return evt;
  167. }
  168. /**
  169. * dwc3_free_event_buffers - frees all allocated event buffers
  170. * @dwc: Pointer to our controller context structure
  171. */
  172. static void dwc3_free_event_buffers(struct dwc3 *dwc)
  173. {
  174. struct dwc3_event_buffer *evt;
  175. int i;
  176. for (i = 0; i < dwc->num_event_buffers; i++) {
  177. evt = dwc->ev_buffs[i];
  178. if (evt)
  179. dwc3_free_one_event_buffer(dwc, evt);
  180. }
  181. kfree(dwc->ev_buffs);
  182. }
  183. /**
  184. * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length
  185. * @dwc: pointer to our controller context structure
  186. * @length: size of event buffer
  187. *
  188. * Returns 0 on success otherwise negative errno. In the error case, dwc
  189. * may contain some buffers allocated but not all which were requested.
  190. */
  191. static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
  192. {
  193. int num;
  194. int i;
  195. num = DWC3_NUM_INT(dwc->hwparams.hwparams1);
  196. dwc->num_event_buffers = num;
  197. dwc->ev_buffs = kzalloc(sizeof(*dwc->ev_buffs) * num, GFP_KERNEL);
  198. if (!dwc->ev_buffs) {
  199. dev_err(dwc->dev, "can't allocate event buffers array\n");
  200. return -ENOMEM;
  201. }
  202. for (i = 0; i < num; i++) {
  203. struct dwc3_event_buffer *evt;
  204. evt = dwc3_alloc_one_event_buffer(dwc, length);
  205. if (IS_ERR(evt)) {
  206. dev_err(dwc->dev, "can't allocate event buffer\n");
  207. return PTR_ERR(evt);
  208. }
  209. dwc->ev_buffs[i] = evt;
  210. }
  211. return 0;
  212. }
  213. /**
  214. * dwc3_event_buffers_setup - setup our allocated event buffers
  215. * @dwc: pointer to our controller context structure
  216. *
  217. * Returns 0 on success otherwise negative errno.
  218. */
  219. static int dwc3_event_buffers_setup(struct dwc3 *dwc)
  220. {
  221. struct dwc3_event_buffer *evt;
  222. int n;
  223. for (n = 0; n < dwc->num_event_buffers; n++) {
  224. evt = dwc->ev_buffs[n];
  225. dev_dbg(dwc->dev, "Event buf %p dma %08llx length %d\n",
  226. evt->buf, (unsigned long long) evt->dma,
  227. evt->length);
  228. evt->lpos = 0;
  229. dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n),
  230. lower_32_bits(evt->dma));
  231. dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n),
  232. upper_32_bits(evt->dma));
  233. dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n),
  234. evt->length & 0xffff);
  235. dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0);
  236. }
  237. return 0;
  238. }
  239. static void dwc3_event_buffers_cleanup(struct dwc3 *dwc)
  240. {
  241. struct dwc3_event_buffer *evt;
  242. int n;
  243. for (n = 0; n < dwc->num_event_buffers; n++) {
  244. evt = dwc->ev_buffs[n];
  245. evt->lpos = 0;
  246. dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), 0);
  247. dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), 0);
  248. dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), 0);
  249. dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0);
  250. }
  251. }
  252. static void __devinit dwc3_cache_hwparams(struct dwc3 *dwc)
  253. {
  254. struct dwc3_hwparams *parms = &dwc->hwparams;
  255. parms->hwparams0 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS0);
  256. parms->hwparams1 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS1);
  257. parms->hwparams2 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS2);
  258. parms->hwparams3 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS3);
  259. parms->hwparams4 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS4);
  260. parms->hwparams5 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS5);
  261. parms->hwparams6 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS6);
  262. parms->hwparams7 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS7);
  263. parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8);
  264. }
  265. /**
  266. * dwc3_core_init - Low-level initialization of DWC3 Core
  267. * @dwc: Pointer to our controller context structure
  268. *
  269. * Returns 0 on success otherwise negative errno.
  270. */
  271. static int __devinit dwc3_core_init(struct dwc3 *dwc)
  272. {
  273. unsigned long timeout;
  274. u32 reg;
  275. int ret;
  276. reg = dwc3_readl(dwc->regs, DWC3_GSNPSID);
  277. /* This should read as U3 followed by revision number */
  278. if ((reg & DWC3_GSNPSID_MASK) != 0x55330000) {
  279. dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n");
  280. ret = -ENODEV;
  281. goto err0;
  282. }
  283. dwc->revision = reg;
  284. /* issue device SoftReset too */
  285. timeout = jiffies + msecs_to_jiffies(500);
  286. dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST);
  287. do {
  288. reg = dwc3_readl(dwc->regs, DWC3_DCTL);
  289. if (!(reg & DWC3_DCTL_CSFTRST))
  290. break;
  291. if (time_after(jiffies, timeout)) {
  292. dev_err(dwc->dev, "Reset Timed Out\n");
  293. ret = -ETIMEDOUT;
  294. goto err0;
  295. }
  296. cpu_relax();
  297. } while (true);
  298. dwc3_core_soft_reset(dwc);
  299. dwc3_cache_hwparams(dwc);
  300. reg = dwc3_readl(dwc->regs, DWC3_GCTL);
  301. reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
  302. reg &= ~DWC3_GCTL_DISSCRAMBLE;
  303. switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) {
  304. case DWC3_GHWPARAMS1_EN_PWROPT_CLK:
  305. reg &= ~DWC3_GCTL_DSBLCLKGTNG;
  306. break;
  307. default:
  308. dev_dbg(dwc->dev, "No power optimization available\n");
  309. }
  310. /*
  311. * WORKAROUND: DWC3 revisions <1.90a have a bug
  312. * where the device can fail to connect at SuperSpeed
  313. * and falls back to high-speed mode which causes
  314. * the device to enter a Connect/Disconnect loop
  315. */
  316. if (dwc->revision < DWC3_REVISION_190A)
  317. reg |= DWC3_GCTL_U2RSTECN;
  318. dwc3_writel(dwc->regs, DWC3_GCTL, reg);
  319. ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
  320. if (ret) {
  321. dev_err(dwc->dev, "failed to allocate event buffers\n");
  322. ret = -ENOMEM;
  323. goto err1;
  324. }
  325. ret = dwc3_event_buffers_setup(dwc);
  326. if (ret) {
  327. dev_err(dwc->dev, "failed to setup event buffers\n");
  328. goto err1;
  329. }
  330. return 0;
  331. err1:
  332. dwc3_free_event_buffers(dwc);
  333. err0:
  334. return ret;
  335. }
  336. static void dwc3_core_exit(struct dwc3 *dwc)
  337. {
  338. dwc3_event_buffers_cleanup(dwc);
  339. dwc3_free_event_buffers(dwc);
  340. }
  341. #define DWC3_ALIGN_MASK (16 - 1)
  342. static int __devinit dwc3_probe(struct platform_device *pdev)
  343. {
  344. struct device_node *node = pdev->dev.of_node;
  345. struct resource *res;
  346. struct dwc3 *dwc;
  347. struct device *dev = &pdev->dev;
  348. int ret = -ENOMEM;
  349. void __iomem *regs;
  350. void *mem;
  351. u8 mode;
  352. mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL);
  353. if (!mem) {
  354. dev_err(dev, "not enough memory\n");
  355. return -ENOMEM;
  356. }
  357. dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1);
  358. dwc->mem = mem;
  359. res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  360. if (!res) {
  361. dev_err(dev, "missing IRQ\n");
  362. return -ENODEV;
  363. }
  364. dwc->xhci_resources[1] = *res;
  365. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  366. if (!res) {
  367. dev_err(dev, "missing memory resource\n");
  368. return -ENODEV;
  369. }
  370. dwc->xhci_resources[0] = *res;
  371. dwc->xhci_resources[0].end = dwc->xhci_resources[0].start +
  372. DWC3_XHCI_REGS_END;
  373. /*
  374. * Request memory region but exclude xHCI regs,
  375. * since it will be requested by the xhci-plat driver.
  376. */
  377. res = devm_request_mem_region(dev, res->start + DWC3_GLOBALS_REGS_START,
  378. resource_size(res) - DWC3_GLOBALS_REGS_START,
  379. dev_name(dev));
  380. if (!res) {
  381. dev_err(dev, "can't request mem region\n");
  382. return -ENOMEM;
  383. }
  384. regs = devm_ioremap(dev, res->start, resource_size(res));
  385. if (!regs) {
  386. dev_err(dev, "ioremap failed\n");
  387. return -ENOMEM;
  388. }
  389. spin_lock_init(&dwc->lock);
  390. platform_set_drvdata(pdev, dwc);
  391. dwc->regs = regs;
  392. dwc->regs_size = resource_size(res);
  393. dwc->dev = dev;
  394. if (!strncmp("super", maximum_speed, 5))
  395. dwc->maximum_speed = DWC3_DCFG_SUPERSPEED;
  396. else if (!strncmp("high", maximum_speed, 4))
  397. dwc->maximum_speed = DWC3_DCFG_HIGHSPEED;
  398. else if (!strncmp("full", maximum_speed, 4))
  399. dwc->maximum_speed = DWC3_DCFG_FULLSPEED1;
  400. else if (!strncmp("low", maximum_speed, 3))
  401. dwc->maximum_speed = DWC3_DCFG_LOWSPEED;
  402. else
  403. dwc->maximum_speed = DWC3_DCFG_SUPERSPEED;
  404. if (of_get_property(node, "tx-fifo-resize", NULL))
  405. dwc->needs_fifo_resize = true;
  406. pm_runtime_enable(dev);
  407. pm_runtime_get_sync(dev);
  408. pm_runtime_forbid(dev);
  409. ret = dwc3_core_init(dwc);
  410. if (ret) {
  411. dev_err(dev, "failed to initialize core\n");
  412. return ret;
  413. }
  414. mode = DWC3_MODE(dwc->hwparams.hwparams0);
  415. switch (mode) {
  416. case DWC3_MODE_DEVICE:
  417. dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
  418. ret = dwc3_gadget_init(dwc);
  419. if (ret) {
  420. dev_err(dev, "failed to initialize gadget\n");
  421. goto err1;
  422. }
  423. break;
  424. case DWC3_MODE_HOST:
  425. dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
  426. ret = dwc3_host_init(dwc);
  427. if (ret) {
  428. dev_err(dev, "failed to initialize host\n");
  429. goto err1;
  430. }
  431. break;
  432. case DWC3_MODE_DRD:
  433. dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
  434. ret = dwc3_host_init(dwc);
  435. if (ret) {
  436. dev_err(dev, "failed to initialize host\n");
  437. goto err1;
  438. }
  439. ret = dwc3_gadget_init(dwc);
  440. if (ret) {
  441. dev_err(dev, "failed to initialize gadget\n");
  442. goto err1;
  443. }
  444. break;
  445. default:
  446. dev_err(dev, "Unsupported mode of operation %d\n", mode);
  447. goto err1;
  448. }
  449. dwc->mode = mode;
  450. ret = dwc3_debugfs_init(dwc);
  451. if (ret) {
  452. dev_err(dev, "failed to initialize debugfs\n");
  453. goto err2;
  454. }
  455. pm_runtime_allow(dev);
  456. return 0;
  457. err2:
  458. switch (mode) {
  459. case DWC3_MODE_DEVICE:
  460. dwc3_gadget_exit(dwc);
  461. break;
  462. case DWC3_MODE_HOST:
  463. dwc3_host_exit(dwc);
  464. break;
  465. case DWC3_MODE_DRD:
  466. dwc3_host_exit(dwc);
  467. dwc3_gadget_exit(dwc);
  468. break;
  469. default:
  470. /* do nothing */
  471. break;
  472. }
  473. err1:
  474. dwc3_core_exit(dwc);
  475. return ret;
  476. }
  477. static int __devexit dwc3_remove(struct platform_device *pdev)
  478. {
  479. struct dwc3 *dwc = platform_get_drvdata(pdev);
  480. struct resource *res;
  481. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  482. pm_runtime_put(&pdev->dev);
  483. pm_runtime_disable(&pdev->dev);
  484. dwc3_debugfs_exit(dwc);
  485. switch (dwc->mode) {
  486. case DWC3_MODE_DEVICE:
  487. dwc3_gadget_exit(dwc);
  488. break;
  489. case DWC3_MODE_HOST:
  490. dwc3_host_exit(dwc);
  491. break;
  492. case DWC3_MODE_DRD:
  493. dwc3_host_exit(dwc);
  494. dwc3_gadget_exit(dwc);
  495. break;
  496. default:
  497. /* do nothing */
  498. break;
  499. }
  500. dwc3_core_exit(dwc);
  501. return 0;
  502. }
  503. static struct platform_driver dwc3_driver = {
  504. .probe = dwc3_probe,
  505. .remove = __devexit_p(dwc3_remove),
  506. .driver = {
  507. .name = "dwc3",
  508. },
  509. };
  510. module_platform_driver(dwc3_driver);
  511. MODULE_ALIAS("platform:dwc3");
  512. MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
  513. MODULE_LICENSE("Dual BSD/GPL");
  514. MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");