core.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  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/usb/ch9.h>
  51. #include <linux/usb/gadget.h>
  52. #include <linux/module.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 0;
  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. /* After PHYs are stable we can take Core out of reset state */
  127. reg = dwc3_readl(dwc->regs, DWC3_GCTL);
  128. reg &= ~DWC3_GCTL_CORESOFTRESET;
  129. dwc3_writel(dwc->regs, DWC3_GCTL, reg);
  130. }
  131. /**
  132. * dwc3_free_one_event_buffer - Frees one event buffer
  133. * @dwc: Pointer to our controller context structure
  134. * @evt: Pointer to event buffer to be freed
  135. */
  136. static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
  137. struct dwc3_event_buffer *evt)
  138. {
  139. dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma);
  140. kfree(evt);
  141. }
  142. /**
  143. * dwc3_alloc_one_event_buffer - Allocated one event buffer structure
  144. * @dwc: Pointer to our controller context structure
  145. * @length: size of the event buffer
  146. *
  147. * Returns a pointer to the allocated event buffer structure on succes
  148. * otherwise ERR_PTR(errno).
  149. */
  150. static struct dwc3_event_buffer *__devinit
  151. dwc3_alloc_one_event_buffer(struct dwc3 *dwc, unsigned length)
  152. {
  153. struct dwc3_event_buffer *evt;
  154. evt = kzalloc(sizeof(*evt), GFP_KERNEL);
  155. if (!evt)
  156. return ERR_PTR(-ENOMEM);
  157. evt->dwc = dwc;
  158. evt->length = length;
  159. evt->buf = dma_alloc_coherent(dwc->dev, length,
  160. &evt->dma, GFP_KERNEL);
  161. if (!evt->buf) {
  162. kfree(evt);
  163. return ERR_PTR(-ENOMEM);
  164. }
  165. return evt;
  166. }
  167. /**
  168. * dwc3_free_event_buffers - frees all allocated event buffers
  169. * @dwc: Pointer to our controller context structure
  170. */
  171. static void dwc3_free_event_buffers(struct dwc3 *dwc)
  172. {
  173. struct dwc3_event_buffer *evt;
  174. int i;
  175. for (i = 0; i < dwc->num_event_buffers; i++) {
  176. evt = dwc->ev_buffs[i];
  177. if (evt) {
  178. dwc3_free_one_event_buffer(dwc, evt);
  179. dwc->ev_buffs[i] = NULL;
  180. }
  181. }
  182. }
  183. /**
  184. * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length
  185. * @dwc: Pointer to out controller context structure
  186. * @length: size of event buffer
  187. *
  188. * Returns 0 on success otherwise negative errno. In error the 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 out controller context structure
  216. *
  217. * Returns 0 on success otherwise negative errno.
  218. */
  219. static int __devinit 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. dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n),
  229. lower_32_bits(evt->dma));
  230. dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n),
  231. upper_32_bits(evt->dma));
  232. dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n),
  233. evt->length & 0xffff);
  234. dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0);
  235. }
  236. return 0;
  237. }
  238. static void dwc3_event_buffers_cleanup(struct dwc3 *dwc)
  239. {
  240. struct dwc3_event_buffer *evt;
  241. int n;
  242. for (n = 0; n < dwc->num_event_buffers; n++) {
  243. evt = dwc->ev_buffs[n];
  244. dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), 0);
  245. dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), 0);
  246. dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), 0);
  247. dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0);
  248. }
  249. }
  250. static void __devinit dwc3_cache_hwparams(struct dwc3 *dwc)
  251. {
  252. struct dwc3_hwparams *parms = &dwc->hwparams;
  253. parms->hwparams0 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS0);
  254. parms->hwparams1 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS1);
  255. parms->hwparams2 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS2);
  256. parms->hwparams3 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS3);
  257. parms->hwparams4 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS4);
  258. parms->hwparams5 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS5);
  259. parms->hwparams6 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS6);
  260. parms->hwparams7 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS7);
  261. parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8);
  262. }
  263. /**
  264. * dwc3_core_init - Low-level initialization of DWC3 Core
  265. * @dwc: Pointer to our controller context structure
  266. *
  267. * Returns 0 on success otherwise negative errno.
  268. */
  269. static int __devinit dwc3_core_init(struct dwc3 *dwc)
  270. {
  271. unsigned long timeout;
  272. u32 reg;
  273. int ret;
  274. reg = dwc3_readl(dwc->regs, DWC3_GSNPSID);
  275. /* This should read as U3 followed by revision number */
  276. if ((reg & DWC3_GSNPSID_MASK) != 0x55330000) {
  277. dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n");
  278. ret = -ENODEV;
  279. goto err0;
  280. }
  281. dwc->revision = reg;
  282. dwc3_core_soft_reset(dwc);
  283. /* issue device SoftReset too */
  284. timeout = jiffies + msecs_to_jiffies(500);
  285. dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST);
  286. do {
  287. reg = dwc3_readl(dwc->regs, DWC3_DCTL);
  288. if (!(reg & DWC3_DCTL_CSFTRST))
  289. break;
  290. if (time_after(jiffies, timeout)) {
  291. dev_err(dwc->dev, "Reset Timed Out\n");
  292. ret = -ETIMEDOUT;
  293. goto err0;
  294. }
  295. cpu_relax();
  296. } while (true);
  297. dwc3_cache_hwparams(dwc);
  298. reg = dwc3_readl(dwc->regs, DWC3_GCTL);
  299. reg &= ~DWC3_GCTL_SCALEDOWN(3);
  300. reg &= ~DWC3_GCTL_DISSCRAMBLE;
  301. switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) {
  302. case DWC3_GHWPARAMS1_EN_PWROPT_CLK:
  303. reg &= ~DWC3_GCTL_DSBLCLKGTNG;
  304. break;
  305. default:
  306. dev_dbg(dwc->dev, "No power optimization available\n");
  307. }
  308. /*
  309. * WORKAROUND: DWC3 revisions <1.90a have a bug
  310. * when The device fails to connect at SuperSpeed
  311. * and falls back to high-speed mode which causes
  312. * the device to enter in a Connect/Disconnect loop
  313. */
  314. if (dwc->revision < DWC3_REVISION_190A)
  315. reg |= DWC3_GCTL_U2RSTECN;
  316. dwc3_writel(dwc->regs, DWC3_GCTL, reg);
  317. ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
  318. if (ret) {
  319. dev_err(dwc->dev, "failed to allocate event buffers\n");
  320. ret = -ENOMEM;
  321. goto err1;
  322. }
  323. ret = dwc3_event_buffers_setup(dwc);
  324. if (ret) {
  325. dev_err(dwc->dev, "failed to setup event buffers\n");
  326. goto err1;
  327. }
  328. return 0;
  329. err1:
  330. dwc3_free_event_buffers(dwc);
  331. err0:
  332. return ret;
  333. }
  334. static void dwc3_core_exit(struct dwc3 *dwc)
  335. {
  336. dwc3_event_buffers_cleanup(dwc);
  337. dwc3_free_event_buffers(dwc);
  338. }
  339. #define DWC3_ALIGN_MASK (16 - 1)
  340. static int __devinit dwc3_probe(struct platform_device *pdev)
  341. {
  342. struct resource *res;
  343. struct dwc3 *dwc;
  344. int ret = -ENOMEM;
  345. int irq;
  346. void __iomem *regs;
  347. void *mem;
  348. u8 mode;
  349. mem = kzalloc(sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL);
  350. if (!mem) {
  351. dev_err(&pdev->dev, "not enough memory\n");
  352. goto err0;
  353. }
  354. dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1);
  355. dwc->mem = mem;
  356. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  357. if (!res) {
  358. dev_err(&pdev->dev, "missing resource\n");
  359. goto err1;
  360. }
  361. dwc->res = res;
  362. res = request_mem_region(res->start, resource_size(res),
  363. dev_name(&pdev->dev));
  364. if (!res) {
  365. dev_err(&pdev->dev, "can't request mem region\n");
  366. goto err1;
  367. }
  368. regs = ioremap(res->start, resource_size(res));
  369. if (!regs) {
  370. dev_err(&pdev->dev, "ioremap failed\n");
  371. goto err2;
  372. }
  373. irq = platform_get_irq(pdev, 0);
  374. if (irq < 0) {
  375. dev_err(&pdev->dev, "missing IRQ\n");
  376. goto err3;
  377. }
  378. spin_lock_init(&dwc->lock);
  379. platform_set_drvdata(pdev, dwc);
  380. dwc->regs = regs;
  381. dwc->regs_size = resource_size(res);
  382. dwc->dev = &pdev->dev;
  383. dwc->irq = irq;
  384. if (!strncmp("super", maximum_speed, 5))
  385. dwc->maximum_speed = DWC3_DCFG_SUPERSPEED;
  386. else if (!strncmp("high", maximum_speed, 4))
  387. dwc->maximum_speed = DWC3_DCFG_HIGHSPEED;
  388. else if (!strncmp("full", maximum_speed, 4))
  389. dwc->maximum_speed = DWC3_DCFG_FULLSPEED1;
  390. else if (!strncmp("low", maximum_speed, 3))
  391. dwc->maximum_speed = DWC3_DCFG_LOWSPEED;
  392. else
  393. dwc->maximum_speed = DWC3_DCFG_SUPERSPEED;
  394. pm_runtime_enable(&pdev->dev);
  395. pm_runtime_get_sync(&pdev->dev);
  396. pm_runtime_forbid(&pdev->dev);
  397. ret = dwc3_core_init(dwc);
  398. if (ret) {
  399. dev_err(&pdev->dev, "failed to initialize core\n");
  400. goto err3;
  401. }
  402. mode = DWC3_MODE(dwc->hwparams.hwparams0);
  403. switch (mode) {
  404. case DWC3_MODE_DEVICE:
  405. dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
  406. ret = dwc3_gadget_init(dwc);
  407. if (ret) {
  408. dev_err(&pdev->dev, "failed to initialize gadget\n");
  409. goto err4;
  410. }
  411. break;
  412. case DWC3_MODE_HOST:
  413. dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
  414. ret = dwc3_host_init(dwc);
  415. if (ret) {
  416. dev_err(&pdev->dev, "failed to initialize host\n");
  417. goto err4;
  418. }
  419. break;
  420. case DWC3_MODE_DRD:
  421. dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
  422. ret = dwc3_host_init(dwc);
  423. if (ret) {
  424. dev_err(&pdev->dev, "failed to initialize host\n");
  425. goto err4;
  426. }
  427. ret = dwc3_gadget_init(dwc);
  428. if (ret) {
  429. dev_err(&pdev->dev, "failed to initialize gadget\n");
  430. goto err4;
  431. }
  432. break;
  433. default:
  434. dev_err(&pdev->dev, "Unsupported mode of operation %d\n", mode);
  435. goto err4;
  436. }
  437. dwc->mode = mode;
  438. ret = dwc3_debugfs_init(dwc);
  439. if (ret) {
  440. dev_err(&pdev->dev, "failed to initialize debugfs\n");
  441. goto err5;
  442. }
  443. pm_runtime_allow(&pdev->dev);
  444. return 0;
  445. err5:
  446. switch (mode) {
  447. case DWC3_MODE_DEVICE:
  448. dwc3_gadget_exit(dwc);
  449. break;
  450. case DWC3_MODE_HOST:
  451. dwc3_host_exit(dwc);
  452. break;
  453. case DWC3_MODE_DRD:
  454. dwc3_host_exit(dwc);
  455. dwc3_gadget_exit(dwc);
  456. break;
  457. default:
  458. /* do nothing */
  459. break;
  460. }
  461. err4:
  462. dwc3_core_exit(dwc);
  463. err3:
  464. iounmap(regs);
  465. err2:
  466. release_mem_region(res->start, resource_size(res));
  467. err1:
  468. kfree(dwc->mem);
  469. err0:
  470. return ret;
  471. }
  472. static int __devexit dwc3_remove(struct platform_device *pdev)
  473. {
  474. struct dwc3 *dwc = platform_get_drvdata(pdev);
  475. struct resource *res;
  476. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  477. pm_runtime_put(&pdev->dev);
  478. pm_runtime_disable(&pdev->dev);
  479. dwc3_debugfs_exit(dwc);
  480. switch (dwc->mode) {
  481. case DWC3_MODE_DEVICE:
  482. dwc3_gadget_exit(dwc);
  483. break;
  484. case DWC3_MODE_HOST:
  485. dwc3_host_exit(dwc);
  486. break;
  487. case DWC3_MODE_DRD:
  488. dwc3_host_exit(dwc);
  489. dwc3_gadget_exit(dwc);
  490. break;
  491. default:
  492. /* do nothing */
  493. break;
  494. }
  495. dwc3_core_exit(dwc);
  496. release_mem_region(res->start, resource_size(res));
  497. iounmap(dwc->regs);
  498. kfree(dwc->mem);
  499. return 0;
  500. }
  501. static struct platform_driver dwc3_driver = {
  502. .probe = dwc3_probe,
  503. .remove = __devexit_p(dwc3_remove),
  504. .driver = {
  505. .name = "dwc3",
  506. },
  507. };
  508. MODULE_ALIAS("platform:dwc3");
  509. MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
  510. MODULE_LICENSE("Dual BSD/GPL");
  511. MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");
  512. static int __devinit dwc3_init(void)
  513. {
  514. return platform_driver_register(&dwc3_driver);
  515. }
  516. module_init(dwc3_init);
  517. static void __exit dwc3_exit(void)
  518. {
  519. platform_driver_unregister(&dwc3_driver);
  520. }
  521. module_exit(dwc3_exit);