core.c 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225
  1. /*
  2. * core.c - ChipIdea USB IP core family device controller
  3. *
  4. * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
  5. *
  6. * Author: David Lopo
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. /*
  13. * Description: ChipIdea USB IP core family device controller
  14. *
  15. * This driver is composed of several blocks:
  16. * - HW: hardware interface
  17. * - DBG: debug facilities (optional)
  18. * - UTIL: utilities
  19. * - ISR: interrupts handling
  20. * - ENDPT: endpoint operations (Gadget API)
  21. * - GADGET: gadget operations (Gadget API)
  22. * - BUS: bus glue code, bus abstraction layer
  23. *
  24. * Compile Options
  25. * - STALL_IN: non-empty bulk-in pipes cannot be halted
  26. * if defined mass storage compliance succeeds but with warnings
  27. * => case 4: Hi > Dn
  28. * => case 5: Hi > Di
  29. * => case 8: Hi <> Do
  30. * if undefined usbtest 13 fails
  31. * - TRACE: enable function tracing (depends on DEBUG)
  32. *
  33. * Main Features
  34. * - Chapter 9 & Mass Storage Compliance with Gadget File Storage
  35. * - Chapter 9 Compliance with Gadget Zero (STALL_IN undefined)
  36. * - Normal & LPM support
  37. *
  38. * USBTEST Report
  39. * - OK: 0-12, 13 (STALL_IN defined) & 14
  40. * - Not Supported: 15 & 16 (ISO)
  41. *
  42. * TODO List
  43. * - Suspend & Remote Wakeup
  44. */
  45. #include <linux/delay.h>
  46. #include <linux/device.h>
  47. #include <linux/dma-mapping.h>
  48. #include <linux/extcon.h>
  49. #include <linux/phy/phy.h>
  50. #include <linux/platform_device.h>
  51. #include <linux/module.h>
  52. #include <linux/idr.h>
  53. #include <linux/interrupt.h>
  54. #include <linux/io.h>
  55. #include <linux/kernel.h>
  56. #include <linux/slab.h>
  57. #include <linux/pm_runtime.h>
  58. #include <linux/usb/ch9.h>
  59. #include <linux/usb/gadget.h>
  60. #include <linux/usb/otg.h>
  61. #include <linux/usb/chipidea.h>
  62. #include <linux/usb/of.h>
  63. #include <linux/of.h>
  64. #include <linux/regulator/consumer.h>
  65. #include <linux/usb/ehci_def.h>
  66. #include "ci.h"
  67. #include "udc.h"
  68. #include "bits.h"
  69. #include "host.h"
  70. #include "otg.h"
  71. #include "otg_fsm.h"
  72. /* Controller register map */
  73. static const u8 ci_regs_nolpm[] = {
  74. [CAP_CAPLENGTH] = 0x00U,
  75. [CAP_HCCPARAMS] = 0x08U,
  76. [CAP_DCCPARAMS] = 0x24U,
  77. [CAP_TESTMODE] = 0x38U,
  78. [OP_USBCMD] = 0x00U,
  79. [OP_USBSTS] = 0x04U,
  80. [OP_USBINTR] = 0x08U,
  81. [OP_DEVICEADDR] = 0x14U,
  82. [OP_ENDPTLISTADDR] = 0x18U,
  83. [OP_TTCTRL] = 0x1CU,
  84. [OP_BURSTSIZE] = 0x20U,
  85. [OP_ULPI_VIEWPORT] = 0x30U,
  86. [OP_PORTSC] = 0x44U,
  87. [OP_DEVLC] = 0x84U,
  88. [OP_OTGSC] = 0x64U,
  89. [OP_USBMODE] = 0x68U,
  90. [OP_ENDPTSETUPSTAT] = 0x6CU,
  91. [OP_ENDPTPRIME] = 0x70U,
  92. [OP_ENDPTFLUSH] = 0x74U,
  93. [OP_ENDPTSTAT] = 0x78U,
  94. [OP_ENDPTCOMPLETE] = 0x7CU,
  95. [OP_ENDPTCTRL] = 0x80U,
  96. };
  97. static const u8 ci_regs_lpm[] = {
  98. [CAP_CAPLENGTH] = 0x00U,
  99. [CAP_HCCPARAMS] = 0x08U,
  100. [CAP_DCCPARAMS] = 0x24U,
  101. [CAP_TESTMODE] = 0xFCU,
  102. [OP_USBCMD] = 0x00U,
  103. [OP_USBSTS] = 0x04U,
  104. [OP_USBINTR] = 0x08U,
  105. [OP_DEVICEADDR] = 0x14U,
  106. [OP_ENDPTLISTADDR] = 0x18U,
  107. [OP_TTCTRL] = 0x1CU,
  108. [OP_BURSTSIZE] = 0x20U,
  109. [OP_ULPI_VIEWPORT] = 0x30U,
  110. [OP_PORTSC] = 0x44U,
  111. [OP_DEVLC] = 0x84U,
  112. [OP_OTGSC] = 0xC4U,
  113. [OP_USBMODE] = 0xC8U,
  114. [OP_ENDPTSETUPSTAT] = 0xD8U,
  115. [OP_ENDPTPRIME] = 0xDCU,
  116. [OP_ENDPTFLUSH] = 0xE0U,
  117. [OP_ENDPTSTAT] = 0xE4U,
  118. [OP_ENDPTCOMPLETE] = 0xE8U,
  119. [OP_ENDPTCTRL] = 0xECU,
  120. };
  121. static void hw_alloc_regmap(struct ci_hdrc *ci, bool is_lpm)
  122. {
  123. int i;
  124. for (i = 0; i < OP_ENDPTCTRL; i++)
  125. ci->hw_bank.regmap[i] =
  126. (i <= CAP_LAST ? ci->hw_bank.cap : ci->hw_bank.op) +
  127. (is_lpm ? ci_regs_lpm[i] : ci_regs_nolpm[i]);
  128. for (; i <= OP_LAST; i++)
  129. ci->hw_bank.regmap[i] = ci->hw_bank.op +
  130. 4 * (i - OP_ENDPTCTRL) +
  131. (is_lpm
  132. ? ci_regs_lpm[OP_ENDPTCTRL]
  133. : ci_regs_nolpm[OP_ENDPTCTRL]);
  134. }
  135. static enum ci_revision ci_get_revision(struct ci_hdrc *ci)
  136. {
  137. int ver = hw_read_id_reg(ci, ID_ID, VERSION) >> __ffs(VERSION);
  138. enum ci_revision rev = CI_REVISION_UNKNOWN;
  139. if (ver == 0x2) {
  140. rev = hw_read_id_reg(ci, ID_ID, REVISION)
  141. >> __ffs(REVISION);
  142. rev += CI_REVISION_20;
  143. } else if (ver == 0x0) {
  144. rev = CI_REVISION_1X;
  145. }
  146. return rev;
  147. }
  148. /**
  149. * hw_read_intr_enable: returns interrupt enable register
  150. *
  151. * @ci: the controller
  152. *
  153. * This function returns register data
  154. */
  155. u32 hw_read_intr_enable(struct ci_hdrc *ci)
  156. {
  157. return hw_read(ci, OP_USBINTR, ~0);
  158. }
  159. /**
  160. * hw_read_intr_status: returns interrupt status register
  161. *
  162. * @ci: the controller
  163. *
  164. * This function returns register data
  165. */
  166. u32 hw_read_intr_status(struct ci_hdrc *ci)
  167. {
  168. return hw_read(ci, OP_USBSTS, ~0);
  169. }
  170. /**
  171. * hw_port_test_set: writes port test mode (execute without interruption)
  172. * @mode: new value
  173. *
  174. * This function returns an error code
  175. */
  176. int hw_port_test_set(struct ci_hdrc *ci, u8 mode)
  177. {
  178. const u8 TEST_MODE_MAX = 7;
  179. if (mode > TEST_MODE_MAX)
  180. return -EINVAL;
  181. hw_write(ci, OP_PORTSC, PORTSC_PTC, mode << __ffs(PORTSC_PTC));
  182. return 0;
  183. }
  184. /**
  185. * hw_port_test_get: reads port test mode value
  186. *
  187. * @ci: the controller
  188. *
  189. * This function returns port test mode value
  190. */
  191. u8 hw_port_test_get(struct ci_hdrc *ci)
  192. {
  193. return hw_read(ci, OP_PORTSC, PORTSC_PTC) >> __ffs(PORTSC_PTC);
  194. }
  195. static void hw_wait_phy_stable(void)
  196. {
  197. /*
  198. * The phy needs some delay to output the stable status from low
  199. * power mode. And for OTGSC, the status inputs are debounced
  200. * using a 1 ms time constant, so, delay 2ms for controller to get
  201. * the stable status, like vbus and id when the phy leaves low power.
  202. */
  203. usleep_range(2000, 2500);
  204. }
  205. /* The PHY enters/leaves low power mode */
  206. static void ci_hdrc_enter_lpm(struct ci_hdrc *ci, bool enable)
  207. {
  208. enum ci_hw_regs reg = ci->hw_bank.lpm ? OP_DEVLC : OP_PORTSC;
  209. bool lpm = !!(hw_read(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm)));
  210. if (enable && !lpm)
  211. hw_write(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm),
  212. PORTSC_PHCD(ci->hw_bank.lpm));
  213. else if (!enable && lpm)
  214. hw_write(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm),
  215. 0);
  216. }
  217. static int hw_device_init(struct ci_hdrc *ci, void __iomem *base)
  218. {
  219. u32 reg;
  220. /* bank is a module variable */
  221. ci->hw_bank.abs = base;
  222. ci->hw_bank.cap = ci->hw_bank.abs;
  223. ci->hw_bank.cap += ci->platdata->capoffset;
  224. ci->hw_bank.op = ci->hw_bank.cap + (ioread32(ci->hw_bank.cap) & 0xff);
  225. hw_alloc_regmap(ci, false);
  226. reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) >>
  227. __ffs(HCCPARAMS_LEN);
  228. ci->hw_bank.lpm = reg;
  229. if (reg)
  230. hw_alloc_regmap(ci, !!reg);
  231. ci->hw_bank.size = ci->hw_bank.op - ci->hw_bank.abs;
  232. ci->hw_bank.size += OP_LAST;
  233. ci->hw_bank.size /= sizeof(u32);
  234. reg = hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DEN) >>
  235. __ffs(DCCPARAMS_DEN);
  236. ci->hw_ep_max = reg * 2; /* cache hw ENDPT_MAX */
  237. if (ci->hw_ep_max > ENDPT_MAX)
  238. return -ENODEV;
  239. ci_hdrc_enter_lpm(ci, false);
  240. /* Disable all interrupts bits */
  241. hw_write(ci, OP_USBINTR, 0xffffffff, 0);
  242. /* Clear all interrupts status bits*/
  243. hw_write(ci, OP_USBSTS, 0xffffffff, 0xffffffff);
  244. ci->rev = ci_get_revision(ci);
  245. dev_dbg(ci->dev,
  246. "ChipIdea HDRC found, revision: %d, lpm: %d; cap: %p op: %p\n",
  247. ci->rev, ci->hw_bank.lpm, ci->hw_bank.cap, ci->hw_bank.op);
  248. /* setup lock mode ? */
  249. /* ENDPTSETUPSTAT is '0' by default */
  250. /* HCSPARAMS.bf.ppc SHOULD BE zero for device */
  251. return 0;
  252. }
  253. void hw_phymode_configure(struct ci_hdrc *ci)
  254. {
  255. u32 portsc, lpm, sts = 0;
  256. switch (ci->platdata->phy_mode) {
  257. case USBPHY_INTERFACE_MODE_UTMI:
  258. portsc = PORTSC_PTS(PTS_UTMI);
  259. lpm = DEVLC_PTS(PTS_UTMI);
  260. break;
  261. case USBPHY_INTERFACE_MODE_UTMIW:
  262. portsc = PORTSC_PTS(PTS_UTMI) | PORTSC_PTW;
  263. lpm = DEVLC_PTS(PTS_UTMI) | DEVLC_PTW;
  264. break;
  265. case USBPHY_INTERFACE_MODE_ULPI:
  266. portsc = PORTSC_PTS(PTS_ULPI);
  267. lpm = DEVLC_PTS(PTS_ULPI);
  268. break;
  269. case USBPHY_INTERFACE_MODE_SERIAL:
  270. portsc = PORTSC_PTS(PTS_SERIAL);
  271. lpm = DEVLC_PTS(PTS_SERIAL);
  272. sts = 1;
  273. break;
  274. case USBPHY_INTERFACE_MODE_HSIC:
  275. portsc = PORTSC_PTS(PTS_HSIC);
  276. lpm = DEVLC_PTS(PTS_HSIC);
  277. break;
  278. default:
  279. return;
  280. }
  281. if (ci->hw_bank.lpm) {
  282. hw_write(ci, OP_DEVLC, DEVLC_PTS(7) | DEVLC_PTW, lpm);
  283. if (sts)
  284. hw_write(ci, OP_DEVLC, DEVLC_STS, DEVLC_STS);
  285. } else {
  286. hw_write(ci, OP_PORTSC, PORTSC_PTS(7) | PORTSC_PTW, portsc);
  287. if (sts)
  288. hw_write(ci, OP_PORTSC, PORTSC_STS, PORTSC_STS);
  289. }
  290. }
  291. EXPORT_SYMBOL_GPL(hw_phymode_configure);
  292. /**
  293. * _ci_usb_phy_init: initialize phy taking in account both phy and usb_phy
  294. * interfaces
  295. * @ci: the controller
  296. *
  297. * This function returns an error code if the phy failed to init
  298. */
  299. static int _ci_usb_phy_init(struct ci_hdrc *ci)
  300. {
  301. int ret;
  302. if (ci->phy) {
  303. ret = phy_init(ci->phy);
  304. if (ret)
  305. return ret;
  306. ret = phy_power_on(ci->phy);
  307. if (ret) {
  308. phy_exit(ci->phy);
  309. return ret;
  310. }
  311. } else {
  312. ret = usb_phy_init(ci->usb_phy);
  313. }
  314. return ret;
  315. }
  316. /**
  317. * _ci_usb_phy_exit: deinitialize phy taking in account both phy and usb_phy
  318. * interfaces
  319. * @ci: the controller
  320. */
  321. static void ci_usb_phy_exit(struct ci_hdrc *ci)
  322. {
  323. if (ci->platdata->flags & CI_HDRC_OVERRIDE_PHY_CONTROL)
  324. return;
  325. if (ci->phy) {
  326. phy_power_off(ci->phy);
  327. phy_exit(ci->phy);
  328. } else {
  329. usb_phy_shutdown(ci->usb_phy);
  330. }
  331. }
  332. /**
  333. * ci_usb_phy_init: initialize phy according to different phy type
  334. * @ci: the controller
  335. *
  336. * This function returns an error code if usb_phy_init has failed
  337. */
  338. static int ci_usb_phy_init(struct ci_hdrc *ci)
  339. {
  340. int ret;
  341. if (ci->platdata->flags & CI_HDRC_OVERRIDE_PHY_CONTROL)
  342. return 0;
  343. switch (ci->platdata->phy_mode) {
  344. case USBPHY_INTERFACE_MODE_UTMI:
  345. case USBPHY_INTERFACE_MODE_UTMIW:
  346. case USBPHY_INTERFACE_MODE_HSIC:
  347. ret = _ci_usb_phy_init(ci);
  348. if (!ret)
  349. hw_wait_phy_stable();
  350. else
  351. return ret;
  352. hw_phymode_configure(ci);
  353. break;
  354. case USBPHY_INTERFACE_MODE_ULPI:
  355. case USBPHY_INTERFACE_MODE_SERIAL:
  356. hw_phymode_configure(ci);
  357. ret = _ci_usb_phy_init(ci);
  358. if (ret)
  359. return ret;
  360. break;
  361. default:
  362. ret = _ci_usb_phy_init(ci);
  363. if (!ret)
  364. hw_wait_phy_stable();
  365. }
  366. return ret;
  367. }
  368. /**
  369. * ci_platform_configure: do controller configure
  370. * @ci: the controller
  371. *
  372. */
  373. void ci_platform_configure(struct ci_hdrc *ci)
  374. {
  375. bool is_device_mode, is_host_mode;
  376. is_device_mode = hw_read(ci, OP_USBMODE, USBMODE_CM) == USBMODE_CM_DC;
  377. is_host_mode = hw_read(ci, OP_USBMODE, USBMODE_CM) == USBMODE_CM_HC;
  378. if (is_device_mode &&
  379. (ci->platdata->flags & CI_HDRC_DISABLE_DEVICE_STREAMING))
  380. hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
  381. if (is_host_mode &&
  382. (ci->platdata->flags & CI_HDRC_DISABLE_HOST_STREAMING))
  383. hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
  384. if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) {
  385. if (ci->hw_bank.lpm)
  386. hw_write(ci, OP_DEVLC, DEVLC_PFSC, DEVLC_PFSC);
  387. else
  388. hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC);
  389. }
  390. if (ci->platdata->flags & CI_HDRC_SET_NON_ZERO_TTHA)
  391. hw_write(ci, OP_TTCTRL, TTCTRL_TTHA_MASK, TTCTRL_TTHA);
  392. hw_write(ci, OP_USBCMD, 0xff0000, ci->platdata->itc_setting << 16);
  393. if (ci->platdata->flags & CI_HDRC_OVERRIDE_AHB_BURST)
  394. hw_write_id_reg(ci, ID_SBUSCFG, AHBBRST_MASK,
  395. ci->platdata->ahb_burst_config);
  396. /* override burst size, take effect only when ahb_burst_config is 0 */
  397. if (!hw_read_id_reg(ci, ID_SBUSCFG, AHBBRST_MASK)) {
  398. if (ci->platdata->flags & CI_HDRC_OVERRIDE_TX_BURST)
  399. hw_write(ci, OP_BURSTSIZE, TX_BURST_MASK,
  400. ci->platdata->tx_burst_size << __ffs(TX_BURST_MASK));
  401. if (ci->platdata->flags & CI_HDRC_OVERRIDE_RX_BURST)
  402. hw_write(ci, OP_BURSTSIZE, RX_BURST_MASK,
  403. ci->platdata->rx_burst_size);
  404. }
  405. }
  406. /**
  407. * hw_controller_reset: do controller reset
  408. * @ci: the controller
  409. *
  410. * This function returns an error code
  411. */
  412. static int hw_controller_reset(struct ci_hdrc *ci)
  413. {
  414. int count = 0;
  415. hw_write(ci, OP_USBCMD, USBCMD_RST, USBCMD_RST);
  416. while (hw_read(ci, OP_USBCMD, USBCMD_RST)) {
  417. udelay(10);
  418. if (count++ > 1000)
  419. return -ETIMEDOUT;
  420. }
  421. return 0;
  422. }
  423. /**
  424. * hw_device_reset: resets chip (execute without interruption)
  425. * @ci: the controller
  426. *
  427. * This function returns an error code
  428. */
  429. int hw_device_reset(struct ci_hdrc *ci)
  430. {
  431. int ret;
  432. /* should flush & stop before reset */
  433. hw_write(ci, OP_ENDPTFLUSH, ~0, ~0);
  434. hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
  435. ret = hw_controller_reset(ci);
  436. if (ret) {
  437. dev_err(ci->dev, "error resetting controller, ret=%d\n", ret);
  438. return ret;
  439. }
  440. if (ci->platdata->notify_event) {
  441. ret = ci->platdata->notify_event(ci,
  442. CI_HDRC_CONTROLLER_RESET_EVENT);
  443. if (ret)
  444. return ret;
  445. }
  446. /* USBMODE should be configured step by step */
  447. hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE);
  448. hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_DC);
  449. /* HW >= 2.3 */
  450. hw_write(ci, OP_USBMODE, USBMODE_SLOM, USBMODE_SLOM);
  451. if (hw_read(ci, OP_USBMODE, USBMODE_CM) != USBMODE_CM_DC) {
  452. pr_err("cannot enter in %s device mode", ci_role(ci)->name);
  453. pr_err("lpm = %i", ci->hw_bank.lpm);
  454. return -ENODEV;
  455. }
  456. ci_platform_configure(ci);
  457. return 0;
  458. }
  459. static irqreturn_t ci_irq(int irq, void *data)
  460. {
  461. struct ci_hdrc *ci = data;
  462. irqreturn_t ret = IRQ_NONE;
  463. u32 otgsc = 0;
  464. if (ci->in_lpm) {
  465. disable_irq_nosync(irq);
  466. ci->wakeup_int = true;
  467. pm_runtime_get(ci->dev);
  468. return IRQ_HANDLED;
  469. }
  470. if (ci->is_otg) {
  471. otgsc = hw_read_otgsc(ci, ~0);
  472. if (ci_otg_is_fsm_mode(ci)) {
  473. ret = ci_otg_fsm_irq(ci);
  474. if (ret == IRQ_HANDLED)
  475. return ret;
  476. }
  477. }
  478. /*
  479. * Handle id change interrupt, it indicates device/host function
  480. * switch.
  481. */
  482. if (ci->is_otg && (otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS)) {
  483. ci->id_event = true;
  484. /* Clear ID change irq status */
  485. hw_write_otgsc(ci, OTGSC_IDIS, OTGSC_IDIS);
  486. ci_otg_queue_work(ci);
  487. return IRQ_HANDLED;
  488. }
  489. /*
  490. * Handle vbus change interrupt, it indicates device connection
  491. * and disconnection events.
  492. */
  493. if (ci->is_otg && (otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS)) {
  494. ci->b_sess_valid_event = true;
  495. /* Clear BSV irq */
  496. hw_write_otgsc(ci, OTGSC_BSVIS, OTGSC_BSVIS);
  497. ci_otg_queue_work(ci);
  498. return IRQ_HANDLED;
  499. }
  500. /* Handle device/host interrupt */
  501. if (ci->role != CI_ROLE_END)
  502. ret = ci_role(ci)->irq(ci);
  503. return ret;
  504. }
  505. static int ci_cable_notifier(struct notifier_block *nb, unsigned long event,
  506. void *ptr)
  507. {
  508. struct ci_hdrc_cable *cbl = container_of(nb, struct ci_hdrc_cable, nb);
  509. struct ci_hdrc *ci = cbl->ci;
  510. cbl->connected = event;
  511. cbl->changed = true;
  512. ci_irq(ci->irq, ci);
  513. return NOTIFY_DONE;
  514. }
  515. static int ci_get_platdata(struct device *dev,
  516. struct ci_hdrc_platform_data *platdata)
  517. {
  518. struct extcon_dev *ext_vbus, *ext_id;
  519. struct ci_hdrc_cable *cable;
  520. int ret;
  521. if (!platdata->phy_mode)
  522. platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
  523. if (!platdata->dr_mode)
  524. platdata->dr_mode = usb_get_dr_mode(dev);
  525. if (platdata->dr_mode == USB_DR_MODE_UNKNOWN)
  526. platdata->dr_mode = USB_DR_MODE_OTG;
  527. if (platdata->dr_mode != USB_DR_MODE_PERIPHERAL) {
  528. /* Get the vbus regulator */
  529. platdata->reg_vbus = devm_regulator_get(dev, "vbus");
  530. if (PTR_ERR(platdata->reg_vbus) == -EPROBE_DEFER) {
  531. return -EPROBE_DEFER;
  532. } else if (PTR_ERR(platdata->reg_vbus) == -ENODEV) {
  533. /* no vbus regulator is needed */
  534. platdata->reg_vbus = NULL;
  535. } else if (IS_ERR(platdata->reg_vbus)) {
  536. dev_err(dev, "Getting regulator error: %ld\n",
  537. PTR_ERR(platdata->reg_vbus));
  538. return PTR_ERR(platdata->reg_vbus);
  539. }
  540. /* Get TPL support */
  541. if (!platdata->tpl_support)
  542. platdata->tpl_support =
  543. of_usb_host_tpl_support(dev->of_node);
  544. }
  545. if (platdata->dr_mode == USB_DR_MODE_OTG) {
  546. /* We can support HNP and SRP of OTG 2.0 */
  547. platdata->ci_otg_caps.otg_rev = 0x0200;
  548. platdata->ci_otg_caps.hnp_support = true;
  549. platdata->ci_otg_caps.srp_support = true;
  550. /* Update otg capabilities by DT properties */
  551. ret = of_usb_update_otg_caps(dev->of_node,
  552. &platdata->ci_otg_caps);
  553. if (ret)
  554. return ret;
  555. }
  556. if (usb_get_maximum_speed(dev) == USB_SPEED_FULL)
  557. platdata->flags |= CI_HDRC_FORCE_FULLSPEED;
  558. of_property_read_u32(dev->of_node, "phy-clkgate-delay-us",
  559. &platdata->phy_clkgate_delay_us);
  560. platdata->itc_setting = 1;
  561. of_property_read_u32(dev->of_node, "itc-setting",
  562. &platdata->itc_setting);
  563. ret = of_property_read_u32(dev->of_node, "ahb-burst-config",
  564. &platdata->ahb_burst_config);
  565. if (!ret) {
  566. platdata->flags |= CI_HDRC_OVERRIDE_AHB_BURST;
  567. } else if (ret != -EINVAL) {
  568. dev_err(dev, "failed to get ahb-burst-config\n");
  569. return ret;
  570. }
  571. ret = of_property_read_u32(dev->of_node, "tx-burst-size-dword",
  572. &platdata->tx_burst_size);
  573. if (!ret) {
  574. platdata->flags |= CI_HDRC_OVERRIDE_TX_BURST;
  575. } else if (ret != -EINVAL) {
  576. dev_err(dev, "failed to get tx-burst-size-dword\n");
  577. return ret;
  578. }
  579. ret = of_property_read_u32(dev->of_node, "rx-burst-size-dword",
  580. &platdata->rx_burst_size);
  581. if (!ret) {
  582. platdata->flags |= CI_HDRC_OVERRIDE_RX_BURST;
  583. } else if (ret != -EINVAL) {
  584. dev_err(dev, "failed to get rx-burst-size-dword\n");
  585. return ret;
  586. }
  587. if (of_find_property(dev->of_node, "non-zero-ttctrl-ttha", NULL))
  588. platdata->flags |= CI_HDRC_SET_NON_ZERO_TTHA;
  589. ext_id = ERR_PTR(-ENODEV);
  590. ext_vbus = ERR_PTR(-ENODEV);
  591. if (of_property_read_bool(dev->of_node, "extcon")) {
  592. /* Each one of them is not mandatory */
  593. ext_vbus = extcon_get_edev_by_phandle(dev, 0);
  594. if (IS_ERR(ext_vbus) && PTR_ERR(ext_vbus) != -ENODEV)
  595. return PTR_ERR(ext_vbus);
  596. ext_id = extcon_get_edev_by_phandle(dev, 1);
  597. if (IS_ERR(ext_id) && PTR_ERR(ext_id) != -ENODEV)
  598. return PTR_ERR(ext_id);
  599. }
  600. cable = &platdata->vbus_extcon;
  601. cable->nb.notifier_call = ci_cable_notifier;
  602. cable->edev = ext_vbus;
  603. if (!IS_ERR(ext_vbus)) {
  604. ret = extcon_get_state(cable->edev, EXTCON_USB);
  605. if (ret)
  606. cable->connected = true;
  607. else
  608. cable->connected = false;
  609. }
  610. cable = &platdata->id_extcon;
  611. cable->nb.notifier_call = ci_cable_notifier;
  612. cable->edev = ext_id;
  613. if (!IS_ERR(ext_id)) {
  614. ret = extcon_get_state(cable->edev, EXTCON_USB_HOST);
  615. if (ret)
  616. cable->connected = true;
  617. else
  618. cable->connected = false;
  619. }
  620. return 0;
  621. }
  622. static int ci_extcon_register(struct ci_hdrc *ci)
  623. {
  624. struct ci_hdrc_cable *id, *vbus;
  625. int ret;
  626. id = &ci->platdata->id_extcon;
  627. id->ci = ci;
  628. if (!IS_ERR(id->edev)) {
  629. ret = devm_extcon_register_notifier(ci->dev, id->edev,
  630. EXTCON_USB_HOST, &id->nb);
  631. if (ret < 0) {
  632. dev_err(ci->dev, "register ID failed\n");
  633. return ret;
  634. }
  635. }
  636. vbus = &ci->platdata->vbus_extcon;
  637. vbus->ci = ci;
  638. if (!IS_ERR(vbus->edev)) {
  639. ret = devm_extcon_register_notifier(ci->dev, vbus->edev,
  640. EXTCON_USB, &vbus->nb);
  641. if (ret < 0) {
  642. dev_err(ci->dev, "register VBUS failed\n");
  643. return ret;
  644. }
  645. }
  646. return 0;
  647. }
  648. static DEFINE_IDA(ci_ida);
  649. struct platform_device *ci_hdrc_add_device(struct device *dev,
  650. struct resource *res, int nres,
  651. struct ci_hdrc_platform_data *platdata)
  652. {
  653. struct platform_device *pdev;
  654. int id, ret;
  655. ret = ci_get_platdata(dev, platdata);
  656. if (ret)
  657. return ERR_PTR(ret);
  658. id = ida_simple_get(&ci_ida, 0, 0, GFP_KERNEL);
  659. if (id < 0)
  660. return ERR_PTR(id);
  661. pdev = platform_device_alloc("ci_hdrc", id);
  662. if (!pdev) {
  663. ret = -ENOMEM;
  664. goto put_id;
  665. }
  666. pdev->dev.parent = dev;
  667. pdev->dev.dma_mask = dev->dma_mask;
  668. pdev->dev.dma_parms = dev->dma_parms;
  669. dma_set_coherent_mask(&pdev->dev, dev->coherent_dma_mask);
  670. ret = platform_device_add_resources(pdev, res, nres);
  671. if (ret)
  672. goto err;
  673. ret = platform_device_add_data(pdev, platdata, sizeof(*platdata));
  674. if (ret)
  675. goto err;
  676. ret = platform_device_add(pdev);
  677. if (ret)
  678. goto err;
  679. return pdev;
  680. err:
  681. platform_device_put(pdev);
  682. put_id:
  683. ida_simple_remove(&ci_ida, id);
  684. return ERR_PTR(ret);
  685. }
  686. EXPORT_SYMBOL_GPL(ci_hdrc_add_device);
  687. void ci_hdrc_remove_device(struct platform_device *pdev)
  688. {
  689. int id = pdev->id;
  690. platform_device_unregister(pdev);
  691. ida_simple_remove(&ci_ida, id);
  692. }
  693. EXPORT_SYMBOL_GPL(ci_hdrc_remove_device);
  694. static inline void ci_role_destroy(struct ci_hdrc *ci)
  695. {
  696. ci_hdrc_gadget_destroy(ci);
  697. ci_hdrc_host_destroy(ci);
  698. if (ci->is_otg)
  699. ci_hdrc_otg_destroy(ci);
  700. }
  701. static void ci_get_otg_capable(struct ci_hdrc *ci)
  702. {
  703. if (ci->platdata->flags & CI_HDRC_DUAL_ROLE_NOT_OTG)
  704. ci->is_otg = false;
  705. else
  706. ci->is_otg = (hw_read(ci, CAP_DCCPARAMS,
  707. DCCPARAMS_DC | DCCPARAMS_HC)
  708. == (DCCPARAMS_DC | DCCPARAMS_HC));
  709. if (ci->is_otg) {
  710. dev_dbg(ci->dev, "It is OTG capable controller\n");
  711. /* Disable and clear all OTG irq */
  712. hw_write_otgsc(ci, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS,
  713. OTGSC_INT_STATUS_BITS);
  714. }
  715. }
  716. static int ci_hdrc_probe(struct platform_device *pdev)
  717. {
  718. struct device *dev = &pdev->dev;
  719. struct ci_hdrc *ci;
  720. struct resource *res;
  721. void __iomem *base;
  722. int ret;
  723. enum usb_dr_mode dr_mode;
  724. if (!dev_get_platdata(dev)) {
  725. dev_err(dev, "platform data missing\n");
  726. return -ENODEV;
  727. }
  728. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  729. base = devm_ioremap_resource(dev, res);
  730. if (IS_ERR(base))
  731. return PTR_ERR(base);
  732. ci = devm_kzalloc(dev, sizeof(*ci), GFP_KERNEL);
  733. if (!ci)
  734. return -ENOMEM;
  735. spin_lock_init(&ci->lock);
  736. ci->dev = dev;
  737. ci->platdata = dev_get_platdata(dev);
  738. ci->imx28_write_fix = !!(ci->platdata->flags &
  739. CI_HDRC_IMX28_WRITE_FIX);
  740. ci->supports_runtime_pm = !!(ci->platdata->flags &
  741. CI_HDRC_SUPPORTS_RUNTIME_PM);
  742. platform_set_drvdata(pdev, ci);
  743. ret = hw_device_init(ci, base);
  744. if (ret < 0) {
  745. dev_err(dev, "can't initialize hardware\n");
  746. return -ENODEV;
  747. }
  748. ret = ci_ulpi_init(ci);
  749. if (ret)
  750. return ret;
  751. if (ci->platdata->phy) {
  752. ci->phy = ci->platdata->phy;
  753. } else if (ci->platdata->usb_phy) {
  754. ci->usb_phy = ci->platdata->usb_phy;
  755. } else {
  756. ci->phy = devm_phy_get(dev->parent, "usb-phy");
  757. ci->usb_phy = devm_usb_get_phy(dev->parent, USB_PHY_TYPE_USB2);
  758. /* if both generic PHY and USB PHY layers aren't enabled */
  759. if (PTR_ERR(ci->phy) == -ENOSYS &&
  760. PTR_ERR(ci->usb_phy) == -ENXIO) {
  761. ret = -ENXIO;
  762. goto ulpi_exit;
  763. }
  764. if (IS_ERR(ci->phy) && IS_ERR(ci->usb_phy)) {
  765. ret = -EPROBE_DEFER;
  766. goto ulpi_exit;
  767. }
  768. if (IS_ERR(ci->phy))
  769. ci->phy = NULL;
  770. else if (IS_ERR(ci->usb_phy))
  771. ci->usb_phy = NULL;
  772. }
  773. ret = ci_usb_phy_init(ci);
  774. if (ret) {
  775. dev_err(dev, "unable to init phy: %d\n", ret);
  776. return ret;
  777. }
  778. ci->hw_bank.phys = res->start;
  779. ci->irq = platform_get_irq(pdev, 0);
  780. if (ci->irq < 0) {
  781. dev_err(dev, "missing IRQ\n");
  782. ret = ci->irq;
  783. goto deinit_phy;
  784. }
  785. ci_get_otg_capable(ci);
  786. dr_mode = ci->platdata->dr_mode;
  787. /* initialize role(s) before the interrupt is requested */
  788. if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
  789. ret = ci_hdrc_host_init(ci);
  790. if (ret)
  791. dev_info(dev, "doesn't support host\n");
  792. }
  793. if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) {
  794. ret = ci_hdrc_gadget_init(ci);
  795. if (ret)
  796. dev_info(dev, "doesn't support gadget\n");
  797. }
  798. if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) {
  799. dev_err(dev, "no supported roles\n");
  800. ret = -ENODEV;
  801. goto deinit_phy;
  802. }
  803. if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) {
  804. ret = ci_hdrc_otg_init(ci);
  805. if (ret) {
  806. dev_err(dev, "init otg fails, ret = %d\n", ret);
  807. goto stop;
  808. }
  809. }
  810. if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) {
  811. if (ci->is_otg) {
  812. ci->role = ci_otg_role(ci);
  813. /* Enable ID change irq */
  814. hw_write_otgsc(ci, OTGSC_IDIE, OTGSC_IDIE);
  815. } else {
  816. /*
  817. * If the controller is not OTG capable, but support
  818. * role switch, the defalt role is gadget, and the
  819. * user can switch it through debugfs.
  820. */
  821. ci->role = CI_ROLE_GADGET;
  822. }
  823. } else {
  824. ci->role = ci->roles[CI_ROLE_HOST]
  825. ? CI_ROLE_HOST
  826. : CI_ROLE_GADGET;
  827. }
  828. if (!ci_otg_is_fsm_mode(ci)) {
  829. /* only update vbus status for peripheral */
  830. if (ci->role == CI_ROLE_GADGET)
  831. ci_handle_vbus_change(ci);
  832. ret = ci_role_start(ci, ci->role);
  833. if (ret) {
  834. dev_err(dev, "can't start %s role\n",
  835. ci_role(ci)->name);
  836. goto stop;
  837. }
  838. }
  839. ret = devm_request_irq(dev, ci->irq, ci_irq, IRQF_SHARED,
  840. ci->platdata->name, ci);
  841. if (ret)
  842. goto stop;
  843. ret = ci_extcon_register(ci);
  844. if (ret)
  845. goto stop;
  846. if (ci->supports_runtime_pm) {
  847. pm_runtime_set_active(&pdev->dev);
  848. pm_runtime_enable(&pdev->dev);
  849. pm_runtime_set_autosuspend_delay(&pdev->dev, 2000);
  850. pm_runtime_mark_last_busy(ci->dev);
  851. pm_runtime_use_autosuspend(&pdev->dev);
  852. }
  853. if (ci_otg_is_fsm_mode(ci))
  854. ci_hdrc_otg_fsm_start(ci);
  855. device_set_wakeup_capable(&pdev->dev, true);
  856. ret = dbg_create_files(ci);
  857. if (!ret)
  858. return 0;
  859. stop:
  860. ci_role_destroy(ci);
  861. deinit_phy:
  862. ci_usb_phy_exit(ci);
  863. ulpi_exit:
  864. ci_ulpi_exit(ci);
  865. return ret;
  866. }
  867. static int ci_hdrc_remove(struct platform_device *pdev)
  868. {
  869. struct ci_hdrc *ci = platform_get_drvdata(pdev);
  870. if (ci->supports_runtime_pm) {
  871. pm_runtime_get_sync(&pdev->dev);
  872. pm_runtime_disable(&pdev->dev);
  873. pm_runtime_put_noidle(&pdev->dev);
  874. }
  875. dbg_remove_files(ci);
  876. ci_role_destroy(ci);
  877. ci_hdrc_enter_lpm(ci, true);
  878. ci_usb_phy_exit(ci);
  879. ci_ulpi_exit(ci);
  880. return 0;
  881. }
  882. #ifdef CONFIG_PM
  883. /* Prepare wakeup by SRP before suspend */
  884. static void ci_otg_fsm_suspend_for_srp(struct ci_hdrc *ci)
  885. {
  886. if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) &&
  887. !hw_read_otgsc(ci, OTGSC_ID)) {
  888. hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_PP,
  889. PORTSC_PP);
  890. hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_WKCN,
  891. PORTSC_WKCN);
  892. }
  893. }
  894. /* Handle SRP when wakeup by data pulse */
  895. static void ci_otg_fsm_wakeup_by_srp(struct ci_hdrc *ci)
  896. {
  897. if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) &&
  898. (ci->fsm.a_bus_drop == 1) && (ci->fsm.a_bus_req == 0)) {
  899. if (!hw_read_otgsc(ci, OTGSC_ID)) {
  900. ci->fsm.a_srp_det = 1;
  901. ci->fsm.a_bus_drop = 0;
  902. } else {
  903. ci->fsm.id = 1;
  904. }
  905. ci_otg_queue_work(ci);
  906. }
  907. }
  908. static void ci_controller_suspend(struct ci_hdrc *ci)
  909. {
  910. disable_irq(ci->irq);
  911. ci_hdrc_enter_lpm(ci, true);
  912. if (ci->platdata->phy_clkgate_delay_us)
  913. usleep_range(ci->platdata->phy_clkgate_delay_us,
  914. ci->platdata->phy_clkgate_delay_us + 50);
  915. usb_phy_set_suspend(ci->usb_phy, 1);
  916. ci->in_lpm = true;
  917. enable_irq(ci->irq);
  918. }
  919. static int ci_controller_resume(struct device *dev)
  920. {
  921. struct ci_hdrc *ci = dev_get_drvdata(dev);
  922. int ret;
  923. dev_dbg(dev, "at %s\n", __func__);
  924. if (!ci->in_lpm) {
  925. WARN_ON(1);
  926. return 0;
  927. }
  928. ci_hdrc_enter_lpm(ci, false);
  929. ret = ci_ulpi_resume(ci);
  930. if (ret)
  931. return ret;
  932. if (ci->usb_phy) {
  933. usb_phy_set_suspend(ci->usb_phy, 0);
  934. usb_phy_set_wakeup(ci->usb_phy, false);
  935. hw_wait_phy_stable();
  936. }
  937. ci->in_lpm = false;
  938. if (ci->wakeup_int) {
  939. ci->wakeup_int = false;
  940. pm_runtime_mark_last_busy(ci->dev);
  941. pm_runtime_put_autosuspend(ci->dev);
  942. enable_irq(ci->irq);
  943. if (ci_otg_is_fsm_mode(ci))
  944. ci_otg_fsm_wakeup_by_srp(ci);
  945. }
  946. return 0;
  947. }
  948. #ifdef CONFIG_PM_SLEEP
  949. static int ci_suspend(struct device *dev)
  950. {
  951. struct ci_hdrc *ci = dev_get_drvdata(dev);
  952. if (ci->wq)
  953. flush_workqueue(ci->wq);
  954. /*
  955. * Controller needs to be active during suspend, otherwise the core
  956. * may run resume when the parent is at suspend if other driver's
  957. * suspend fails, it occurs before parent's suspend has not started,
  958. * but the core suspend has finished.
  959. */
  960. if (ci->in_lpm)
  961. pm_runtime_resume(dev);
  962. if (ci->in_lpm) {
  963. WARN_ON(1);
  964. return 0;
  965. }
  966. if (device_may_wakeup(dev)) {
  967. if (ci_otg_is_fsm_mode(ci))
  968. ci_otg_fsm_suspend_for_srp(ci);
  969. usb_phy_set_wakeup(ci->usb_phy, true);
  970. enable_irq_wake(ci->irq);
  971. }
  972. ci_controller_suspend(ci);
  973. return 0;
  974. }
  975. static int ci_resume(struct device *dev)
  976. {
  977. struct ci_hdrc *ci = dev_get_drvdata(dev);
  978. int ret;
  979. if (device_may_wakeup(dev))
  980. disable_irq_wake(ci->irq);
  981. ret = ci_controller_resume(dev);
  982. if (ret)
  983. return ret;
  984. if (ci->supports_runtime_pm) {
  985. pm_runtime_disable(dev);
  986. pm_runtime_set_active(dev);
  987. pm_runtime_enable(dev);
  988. }
  989. return ret;
  990. }
  991. #endif /* CONFIG_PM_SLEEP */
  992. static int ci_runtime_suspend(struct device *dev)
  993. {
  994. struct ci_hdrc *ci = dev_get_drvdata(dev);
  995. dev_dbg(dev, "at %s\n", __func__);
  996. if (ci->in_lpm) {
  997. WARN_ON(1);
  998. return 0;
  999. }
  1000. if (ci_otg_is_fsm_mode(ci))
  1001. ci_otg_fsm_suspend_for_srp(ci);
  1002. usb_phy_set_wakeup(ci->usb_phy, true);
  1003. ci_controller_suspend(ci);
  1004. return 0;
  1005. }
  1006. static int ci_runtime_resume(struct device *dev)
  1007. {
  1008. return ci_controller_resume(dev);
  1009. }
  1010. #endif /* CONFIG_PM */
  1011. static const struct dev_pm_ops ci_pm_ops = {
  1012. SET_SYSTEM_SLEEP_PM_OPS(ci_suspend, ci_resume)
  1013. SET_RUNTIME_PM_OPS(ci_runtime_suspend, ci_runtime_resume, NULL)
  1014. };
  1015. static struct platform_driver ci_hdrc_driver = {
  1016. .probe = ci_hdrc_probe,
  1017. .remove = ci_hdrc_remove,
  1018. .driver = {
  1019. .name = "ci_hdrc",
  1020. .pm = &ci_pm_ops,
  1021. },
  1022. };
  1023. static int __init ci_hdrc_platform_register(void)
  1024. {
  1025. ci_hdrc_host_driver_init();
  1026. return platform_driver_register(&ci_hdrc_driver);
  1027. }
  1028. module_init(ci_hdrc_platform_register);
  1029. static void __exit ci_hdrc_platform_unregister(void)
  1030. {
  1031. platform_driver_unregister(&ci_hdrc_driver);
  1032. }
  1033. module_exit(ci_hdrc_platform_unregister);
  1034. MODULE_ALIAS("platform:ci_hdrc");
  1035. MODULE_LICENSE("GPL v2");
  1036. MODULE_AUTHOR("David Lopo <dlopo@chipidea.mips.com>");
  1037. MODULE_DESCRIPTION("ChipIdea HDRC Driver");