core.c 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222
  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/phy.h>
  65. #include <linux/regulator/consumer.h>
  66. #include <linux/usb/ehci_def.h>
  67. #include "ci.h"
  68. #include "udc.h"
  69. #include "bits.h"
  70. #include "host.h"
  71. #include "otg.h"
  72. #include "otg_fsm.h"
  73. /* Controller register map */
  74. static const u8 ci_regs_nolpm[] = {
  75. [CAP_CAPLENGTH] = 0x00U,
  76. [CAP_HCCPARAMS] = 0x08U,
  77. [CAP_DCCPARAMS] = 0x24U,
  78. [CAP_TESTMODE] = 0x38U,
  79. [OP_USBCMD] = 0x00U,
  80. [OP_USBSTS] = 0x04U,
  81. [OP_USBINTR] = 0x08U,
  82. [OP_DEVICEADDR] = 0x14U,
  83. [OP_ENDPTLISTADDR] = 0x18U,
  84. [OP_TTCTRL] = 0x1CU,
  85. [OP_BURSTSIZE] = 0x20U,
  86. [OP_ULPI_VIEWPORT] = 0x30U,
  87. [OP_PORTSC] = 0x44U,
  88. [OP_DEVLC] = 0x84U,
  89. [OP_OTGSC] = 0x64U,
  90. [OP_USBMODE] = 0x68U,
  91. [OP_ENDPTSETUPSTAT] = 0x6CU,
  92. [OP_ENDPTPRIME] = 0x70U,
  93. [OP_ENDPTFLUSH] = 0x74U,
  94. [OP_ENDPTSTAT] = 0x78U,
  95. [OP_ENDPTCOMPLETE] = 0x7CU,
  96. [OP_ENDPTCTRL] = 0x80U,
  97. };
  98. static const u8 ci_regs_lpm[] = {
  99. [CAP_CAPLENGTH] = 0x00U,
  100. [CAP_HCCPARAMS] = 0x08U,
  101. [CAP_DCCPARAMS] = 0x24U,
  102. [CAP_TESTMODE] = 0xFCU,
  103. [OP_USBCMD] = 0x00U,
  104. [OP_USBSTS] = 0x04U,
  105. [OP_USBINTR] = 0x08U,
  106. [OP_DEVICEADDR] = 0x14U,
  107. [OP_ENDPTLISTADDR] = 0x18U,
  108. [OP_TTCTRL] = 0x1CU,
  109. [OP_BURSTSIZE] = 0x20U,
  110. [OP_ULPI_VIEWPORT] = 0x30U,
  111. [OP_PORTSC] = 0x44U,
  112. [OP_DEVLC] = 0x84U,
  113. [OP_OTGSC] = 0xC4U,
  114. [OP_USBMODE] = 0xC8U,
  115. [OP_ENDPTSETUPSTAT] = 0xD8U,
  116. [OP_ENDPTPRIME] = 0xDCU,
  117. [OP_ENDPTFLUSH] = 0xE0U,
  118. [OP_ENDPTSTAT] = 0xE4U,
  119. [OP_ENDPTCOMPLETE] = 0xE8U,
  120. [OP_ENDPTCTRL] = 0xECU,
  121. };
  122. static void hw_alloc_regmap(struct ci_hdrc *ci, bool is_lpm)
  123. {
  124. int i;
  125. for (i = 0; i < OP_ENDPTCTRL; i++)
  126. ci->hw_bank.regmap[i] =
  127. (i <= CAP_LAST ? ci->hw_bank.cap : ci->hw_bank.op) +
  128. (is_lpm ? ci_regs_lpm[i] : ci_regs_nolpm[i]);
  129. for (; i <= OP_LAST; i++)
  130. ci->hw_bank.regmap[i] = ci->hw_bank.op +
  131. 4 * (i - OP_ENDPTCTRL) +
  132. (is_lpm
  133. ? ci_regs_lpm[OP_ENDPTCTRL]
  134. : ci_regs_nolpm[OP_ENDPTCTRL]);
  135. }
  136. static enum ci_revision ci_get_revision(struct ci_hdrc *ci)
  137. {
  138. int ver = hw_read_id_reg(ci, ID_ID, VERSION) >> __ffs(VERSION);
  139. enum ci_revision rev = CI_REVISION_UNKNOWN;
  140. if (ver == 0x2) {
  141. rev = hw_read_id_reg(ci, ID_ID, REVISION)
  142. >> __ffs(REVISION);
  143. rev += CI_REVISION_20;
  144. } else if (ver == 0x0) {
  145. rev = CI_REVISION_1X;
  146. }
  147. return rev;
  148. }
  149. /**
  150. * hw_read_intr_enable: returns interrupt enable register
  151. *
  152. * @ci: the controller
  153. *
  154. * This function returns register data
  155. */
  156. u32 hw_read_intr_enable(struct ci_hdrc *ci)
  157. {
  158. return hw_read(ci, OP_USBINTR, ~0);
  159. }
  160. /**
  161. * hw_read_intr_status: returns interrupt status register
  162. *
  163. * @ci: the controller
  164. *
  165. * This function returns register data
  166. */
  167. u32 hw_read_intr_status(struct ci_hdrc *ci)
  168. {
  169. return hw_read(ci, OP_USBSTS, ~0);
  170. }
  171. /**
  172. * hw_port_test_set: writes port test mode (execute without interruption)
  173. * @mode: new value
  174. *
  175. * This function returns an error code
  176. */
  177. int hw_port_test_set(struct ci_hdrc *ci, u8 mode)
  178. {
  179. const u8 TEST_MODE_MAX = 7;
  180. if (mode > TEST_MODE_MAX)
  181. return -EINVAL;
  182. hw_write(ci, OP_PORTSC, PORTSC_PTC, mode << __ffs(PORTSC_PTC));
  183. return 0;
  184. }
  185. /**
  186. * hw_port_test_get: reads port test mode value
  187. *
  188. * @ci: the controller
  189. *
  190. * This function returns port test mode value
  191. */
  192. u8 hw_port_test_get(struct ci_hdrc *ci)
  193. {
  194. return hw_read(ci, OP_PORTSC, PORTSC_PTC) >> __ffs(PORTSC_PTC);
  195. }
  196. static void hw_wait_phy_stable(void)
  197. {
  198. /*
  199. * The phy needs some delay to output the stable status from low
  200. * power mode. And for OTGSC, the status inputs are debounced
  201. * using a 1 ms time constant, so, delay 2ms for controller to get
  202. * the stable status, like vbus and id when the phy leaves low power.
  203. */
  204. usleep_range(2000, 2500);
  205. }
  206. /* The PHY enters/leaves low power mode */
  207. static void ci_hdrc_enter_lpm(struct ci_hdrc *ci, bool enable)
  208. {
  209. enum ci_hw_regs reg = ci->hw_bank.lpm ? OP_DEVLC : OP_PORTSC;
  210. bool lpm = !!(hw_read(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm)));
  211. if (enable && !lpm)
  212. hw_write(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm),
  213. PORTSC_PHCD(ci->hw_bank.lpm));
  214. else if (!enable && lpm)
  215. hw_write(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm),
  216. 0);
  217. }
  218. static int hw_device_init(struct ci_hdrc *ci, void __iomem *base)
  219. {
  220. u32 reg;
  221. /* bank is a module variable */
  222. ci->hw_bank.abs = base;
  223. ci->hw_bank.cap = ci->hw_bank.abs;
  224. ci->hw_bank.cap += ci->platdata->capoffset;
  225. ci->hw_bank.op = ci->hw_bank.cap + (ioread32(ci->hw_bank.cap) & 0xff);
  226. hw_alloc_regmap(ci, false);
  227. reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) >>
  228. __ffs(HCCPARAMS_LEN);
  229. ci->hw_bank.lpm = reg;
  230. if (reg)
  231. hw_alloc_regmap(ci, !!reg);
  232. ci->hw_bank.size = ci->hw_bank.op - ci->hw_bank.abs;
  233. ci->hw_bank.size += OP_LAST;
  234. ci->hw_bank.size /= sizeof(u32);
  235. reg = hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DEN) >>
  236. __ffs(DCCPARAMS_DEN);
  237. ci->hw_ep_max = reg * 2; /* cache hw ENDPT_MAX */
  238. if (ci->hw_ep_max > ENDPT_MAX)
  239. return -ENODEV;
  240. ci_hdrc_enter_lpm(ci, false);
  241. /* Disable all interrupts bits */
  242. hw_write(ci, OP_USBINTR, 0xffffffff, 0);
  243. /* Clear all interrupts status bits*/
  244. hw_write(ci, OP_USBSTS, 0xffffffff, 0xffffffff);
  245. ci->rev = ci_get_revision(ci);
  246. dev_dbg(ci->dev,
  247. "ChipIdea HDRC found, revision: %d, lpm: %d; cap: %p op: %p\n",
  248. ci->rev, ci->hw_bank.lpm, ci->hw_bank.cap, ci->hw_bank.op);
  249. /* setup lock mode ? */
  250. /* ENDPTSETUPSTAT is '0' by default */
  251. /* HCSPARAMS.bf.ppc SHOULD BE zero for device */
  252. return 0;
  253. }
  254. void hw_phymode_configure(struct ci_hdrc *ci)
  255. {
  256. u32 portsc, lpm, sts = 0;
  257. switch (ci->platdata->phy_mode) {
  258. case USBPHY_INTERFACE_MODE_UTMI:
  259. portsc = PORTSC_PTS(PTS_UTMI);
  260. lpm = DEVLC_PTS(PTS_UTMI);
  261. break;
  262. case USBPHY_INTERFACE_MODE_UTMIW:
  263. portsc = PORTSC_PTS(PTS_UTMI) | PORTSC_PTW;
  264. lpm = DEVLC_PTS(PTS_UTMI) | DEVLC_PTW;
  265. break;
  266. case USBPHY_INTERFACE_MODE_ULPI:
  267. portsc = PORTSC_PTS(PTS_ULPI);
  268. lpm = DEVLC_PTS(PTS_ULPI);
  269. break;
  270. case USBPHY_INTERFACE_MODE_SERIAL:
  271. portsc = PORTSC_PTS(PTS_SERIAL);
  272. lpm = DEVLC_PTS(PTS_SERIAL);
  273. sts = 1;
  274. break;
  275. case USBPHY_INTERFACE_MODE_HSIC:
  276. portsc = PORTSC_PTS(PTS_HSIC);
  277. lpm = DEVLC_PTS(PTS_HSIC);
  278. break;
  279. default:
  280. return;
  281. }
  282. if (ci->hw_bank.lpm) {
  283. hw_write(ci, OP_DEVLC, DEVLC_PTS(7) | DEVLC_PTW, lpm);
  284. if (sts)
  285. hw_write(ci, OP_DEVLC, DEVLC_STS, DEVLC_STS);
  286. } else {
  287. hw_write(ci, OP_PORTSC, PORTSC_PTS(7) | PORTSC_PTW, portsc);
  288. if (sts)
  289. hw_write(ci, OP_PORTSC, PORTSC_STS, PORTSC_STS);
  290. }
  291. }
  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. ci->platdata->notify_event(ci,
  442. CI_HDRC_CONTROLLER_RESET_EVENT);
  443. /* USBMODE should be configured step by step */
  444. hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE);
  445. hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_DC);
  446. /* HW >= 2.3 */
  447. hw_write(ci, OP_USBMODE, USBMODE_SLOM, USBMODE_SLOM);
  448. if (hw_read(ci, OP_USBMODE, USBMODE_CM) != USBMODE_CM_DC) {
  449. pr_err("cannot enter in %s device mode", ci_role(ci)->name);
  450. pr_err("lpm = %i", ci->hw_bank.lpm);
  451. return -ENODEV;
  452. }
  453. ci_platform_configure(ci);
  454. return 0;
  455. }
  456. static irqreturn_t ci_irq(int irq, void *data)
  457. {
  458. struct ci_hdrc *ci = data;
  459. irqreturn_t ret = IRQ_NONE;
  460. u32 otgsc = 0;
  461. if (ci->in_lpm) {
  462. disable_irq_nosync(irq);
  463. ci->wakeup_int = true;
  464. pm_runtime_get(ci->dev);
  465. return IRQ_HANDLED;
  466. }
  467. if (ci->is_otg) {
  468. otgsc = hw_read_otgsc(ci, ~0);
  469. if (ci_otg_is_fsm_mode(ci)) {
  470. ret = ci_otg_fsm_irq(ci);
  471. if (ret == IRQ_HANDLED)
  472. return ret;
  473. }
  474. }
  475. /*
  476. * Handle id change interrupt, it indicates device/host function
  477. * switch.
  478. */
  479. if (ci->is_otg && (otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS)) {
  480. ci->id_event = true;
  481. /* Clear ID change irq status */
  482. hw_write_otgsc(ci, OTGSC_IDIS, OTGSC_IDIS);
  483. ci_otg_queue_work(ci);
  484. return IRQ_HANDLED;
  485. }
  486. /*
  487. * Handle vbus change interrupt, it indicates device connection
  488. * and disconnection events.
  489. */
  490. if (ci->is_otg && (otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS)) {
  491. ci->b_sess_valid_event = true;
  492. /* Clear BSV irq */
  493. hw_write_otgsc(ci, OTGSC_BSVIS, OTGSC_BSVIS);
  494. ci_otg_queue_work(ci);
  495. return IRQ_HANDLED;
  496. }
  497. /* Handle device/host interrupt */
  498. if (ci->role != CI_ROLE_END)
  499. ret = ci_role(ci)->irq(ci);
  500. return ret;
  501. }
  502. static int ci_cable_notifier(struct notifier_block *nb, unsigned long event,
  503. void *ptr)
  504. {
  505. struct ci_hdrc_cable *cbl = container_of(nb, struct ci_hdrc_cable, nb);
  506. struct ci_hdrc *ci = cbl->ci;
  507. cbl->connected = event;
  508. cbl->changed = true;
  509. ci_irq(ci->irq, ci);
  510. return NOTIFY_DONE;
  511. }
  512. static int ci_get_platdata(struct device *dev,
  513. struct ci_hdrc_platform_data *platdata)
  514. {
  515. struct extcon_dev *ext_vbus, *ext_id;
  516. struct ci_hdrc_cable *cable;
  517. int ret;
  518. if (!platdata->phy_mode)
  519. platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
  520. if (!platdata->dr_mode)
  521. platdata->dr_mode = usb_get_dr_mode(dev);
  522. if (platdata->dr_mode == USB_DR_MODE_UNKNOWN)
  523. platdata->dr_mode = USB_DR_MODE_OTG;
  524. if (platdata->dr_mode != USB_DR_MODE_PERIPHERAL) {
  525. /* Get the vbus regulator */
  526. platdata->reg_vbus = devm_regulator_get(dev, "vbus");
  527. if (PTR_ERR(platdata->reg_vbus) == -EPROBE_DEFER) {
  528. return -EPROBE_DEFER;
  529. } else if (PTR_ERR(platdata->reg_vbus) == -ENODEV) {
  530. /* no vbus regulator is needed */
  531. platdata->reg_vbus = NULL;
  532. } else if (IS_ERR(platdata->reg_vbus)) {
  533. dev_err(dev, "Getting regulator error: %ld\n",
  534. PTR_ERR(platdata->reg_vbus));
  535. return PTR_ERR(platdata->reg_vbus);
  536. }
  537. /* Get TPL support */
  538. if (!platdata->tpl_support)
  539. platdata->tpl_support =
  540. of_usb_host_tpl_support(dev->of_node);
  541. }
  542. if (platdata->dr_mode == USB_DR_MODE_OTG) {
  543. /* We can support HNP and SRP of OTG 2.0 */
  544. platdata->ci_otg_caps.otg_rev = 0x0200;
  545. platdata->ci_otg_caps.hnp_support = true;
  546. platdata->ci_otg_caps.srp_support = true;
  547. /* Update otg capabilities by DT properties */
  548. ret = of_usb_update_otg_caps(dev->of_node,
  549. &platdata->ci_otg_caps);
  550. if (ret)
  551. return ret;
  552. }
  553. if (usb_get_maximum_speed(dev) == USB_SPEED_FULL)
  554. platdata->flags |= CI_HDRC_FORCE_FULLSPEED;
  555. of_property_read_u32(dev->of_node, "phy-clkgate-delay-us",
  556. &platdata->phy_clkgate_delay_us);
  557. platdata->itc_setting = 1;
  558. of_property_read_u32(dev->of_node, "itc-setting",
  559. &platdata->itc_setting);
  560. ret = of_property_read_u32(dev->of_node, "ahb-burst-config",
  561. &platdata->ahb_burst_config);
  562. if (!ret) {
  563. platdata->flags |= CI_HDRC_OVERRIDE_AHB_BURST;
  564. } else if (ret != -EINVAL) {
  565. dev_err(dev, "failed to get ahb-burst-config\n");
  566. return ret;
  567. }
  568. ret = of_property_read_u32(dev->of_node, "tx-burst-size-dword",
  569. &platdata->tx_burst_size);
  570. if (!ret) {
  571. platdata->flags |= CI_HDRC_OVERRIDE_TX_BURST;
  572. } else if (ret != -EINVAL) {
  573. dev_err(dev, "failed to get tx-burst-size-dword\n");
  574. return ret;
  575. }
  576. ret = of_property_read_u32(dev->of_node, "rx-burst-size-dword",
  577. &platdata->rx_burst_size);
  578. if (!ret) {
  579. platdata->flags |= CI_HDRC_OVERRIDE_RX_BURST;
  580. } else if (ret != -EINVAL) {
  581. dev_err(dev, "failed to get rx-burst-size-dword\n");
  582. return ret;
  583. }
  584. if (of_find_property(dev->of_node, "non-zero-ttctrl-ttha", NULL))
  585. platdata->flags |= CI_HDRC_SET_NON_ZERO_TTHA;
  586. ext_id = ERR_PTR(-ENODEV);
  587. ext_vbus = ERR_PTR(-ENODEV);
  588. if (of_property_read_bool(dev->of_node, "extcon")) {
  589. /* Each one of them is not mandatory */
  590. ext_vbus = extcon_get_edev_by_phandle(dev, 0);
  591. if (IS_ERR(ext_vbus) && PTR_ERR(ext_vbus) != -ENODEV)
  592. return PTR_ERR(ext_vbus);
  593. ext_id = extcon_get_edev_by_phandle(dev, 1);
  594. if (IS_ERR(ext_id) && PTR_ERR(ext_id) != -ENODEV)
  595. return PTR_ERR(ext_id);
  596. }
  597. cable = &platdata->vbus_extcon;
  598. cable->nb.notifier_call = ci_cable_notifier;
  599. cable->edev = ext_vbus;
  600. if (!IS_ERR(ext_vbus)) {
  601. ret = extcon_get_state(cable->edev, EXTCON_USB);
  602. if (ret)
  603. cable->connected = true;
  604. else
  605. cable->connected = false;
  606. }
  607. cable = &platdata->id_extcon;
  608. cable->nb.notifier_call = ci_cable_notifier;
  609. cable->edev = ext_id;
  610. if (!IS_ERR(ext_id)) {
  611. ret = extcon_get_state(cable->edev, EXTCON_USB_HOST);
  612. if (ret)
  613. cable->connected = true;
  614. else
  615. cable->connected = false;
  616. }
  617. return 0;
  618. }
  619. static int ci_extcon_register(struct ci_hdrc *ci)
  620. {
  621. struct ci_hdrc_cable *id, *vbus;
  622. int ret;
  623. id = &ci->platdata->id_extcon;
  624. id->ci = ci;
  625. if (!IS_ERR(id->edev)) {
  626. ret = devm_extcon_register_notifier(ci->dev, id->edev,
  627. EXTCON_USB_HOST, &id->nb);
  628. if (ret < 0) {
  629. dev_err(ci->dev, "register ID failed\n");
  630. return ret;
  631. }
  632. }
  633. vbus = &ci->platdata->vbus_extcon;
  634. vbus->ci = ci;
  635. if (!IS_ERR(vbus->edev)) {
  636. ret = devm_extcon_register_notifier(ci->dev, vbus->edev,
  637. EXTCON_USB, &vbus->nb);
  638. if (ret < 0) {
  639. dev_err(ci->dev, "register VBUS failed\n");
  640. return ret;
  641. }
  642. }
  643. return 0;
  644. }
  645. static DEFINE_IDA(ci_ida);
  646. struct platform_device *ci_hdrc_add_device(struct device *dev,
  647. struct resource *res, int nres,
  648. struct ci_hdrc_platform_data *platdata)
  649. {
  650. struct platform_device *pdev;
  651. int id, ret;
  652. ret = ci_get_platdata(dev, platdata);
  653. if (ret)
  654. return ERR_PTR(ret);
  655. id = ida_simple_get(&ci_ida, 0, 0, GFP_KERNEL);
  656. if (id < 0)
  657. return ERR_PTR(id);
  658. pdev = platform_device_alloc("ci_hdrc", id);
  659. if (!pdev) {
  660. ret = -ENOMEM;
  661. goto put_id;
  662. }
  663. pdev->dev.parent = dev;
  664. pdev->dev.dma_mask = dev->dma_mask;
  665. pdev->dev.dma_parms = dev->dma_parms;
  666. dma_set_coherent_mask(&pdev->dev, dev->coherent_dma_mask);
  667. ret = platform_device_add_resources(pdev, res, nres);
  668. if (ret)
  669. goto err;
  670. ret = platform_device_add_data(pdev, platdata, sizeof(*platdata));
  671. if (ret)
  672. goto err;
  673. ret = platform_device_add(pdev);
  674. if (ret)
  675. goto err;
  676. return pdev;
  677. err:
  678. platform_device_put(pdev);
  679. put_id:
  680. ida_simple_remove(&ci_ida, id);
  681. return ERR_PTR(ret);
  682. }
  683. EXPORT_SYMBOL_GPL(ci_hdrc_add_device);
  684. void ci_hdrc_remove_device(struct platform_device *pdev)
  685. {
  686. int id = pdev->id;
  687. platform_device_unregister(pdev);
  688. ida_simple_remove(&ci_ida, id);
  689. }
  690. EXPORT_SYMBOL_GPL(ci_hdrc_remove_device);
  691. static inline void ci_role_destroy(struct ci_hdrc *ci)
  692. {
  693. ci_hdrc_gadget_destroy(ci);
  694. ci_hdrc_host_destroy(ci);
  695. if (ci->is_otg)
  696. ci_hdrc_otg_destroy(ci);
  697. }
  698. static void ci_get_otg_capable(struct ci_hdrc *ci)
  699. {
  700. if (ci->platdata->flags & CI_HDRC_DUAL_ROLE_NOT_OTG)
  701. ci->is_otg = false;
  702. else
  703. ci->is_otg = (hw_read(ci, CAP_DCCPARAMS,
  704. DCCPARAMS_DC | DCCPARAMS_HC)
  705. == (DCCPARAMS_DC | DCCPARAMS_HC));
  706. if (ci->is_otg) {
  707. dev_dbg(ci->dev, "It is OTG capable controller\n");
  708. /* Disable and clear all OTG irq */
  709. hw_write_otgsc(ci, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS,
  710. OTGSC_INT_STATUS_BITS);
  711. }
  712. }
  713. static int ci_hdrc_probe(struct platform_device *pdev)
  714. {
  715. struct device *dev = &pdev->dev;
  716. struct ci_hdrc *ci;
  717. struct resource *res;
  718. void __iomem *base;
  719. int ret;
  720. enum usb_dr_mode dr_mode;
  721. if (!dev_get_platdata(dev)) {
  722. dev_err(dev, "platform data missing\n");
  723. return -ENODEV;
  724. }
  725. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  726. base = devm_ioremap_resource(dev, res);
  727. if (IS_ERR(base))
  728. return PTR_ERR(base);
  729. ci = devm_kzalloc(dev, sizeof(*ci), GFP_KERNEL);
  730. if (!ci)
  731. return -ENOMEM;
  732. spin_lock_init(&ci->lock);
  733. ci->dev = dev;
  734. ci->platdata = dev_get_platdata(dev);
  735. ci->imx28_write_fix = !!(ci->platdata->flags &
  736. CI_HDRC_IMX28_WRITE_FIX);
  737. ci->supports_runtime_pm = !!(ci->platdata->flags &
  738. CI_HDRC_SUPPORTS_RUNTIME_PM);
  739. platform_set_drvdata(pdev, ci);
  740. ret = hw_device_init(ci, base);
  741. if (ret < 0) {
  742. dev_err(dev, "can't initialize hardware\n");
  743. return -ENODEV;
  744. }
  745. ret = ci_ulpi_init(ci);
  746. if (ret)
  747. return ret;
  748. if (ci->platdata->phy) {
  749. ci->phy = ci->platdata->phy;
  750. } else if (ci->platdata->usb_phy) {
  751. ci->usb_phy = ci->platdata->usb_phy;
  752. } else {
  753. ci->phy = devm_phy_get(dev->parent, "usb-phy");
  754. ci->usb_phy = devm_usb_get_phy(dev->parent, USB_PHY_TYPE_USB2);
  755. /* if both generic PHY and USB PHY layers aren't enabled */
  756. if (PTR_ERR(ci->phy) == -ENOSYS &&
  757. PTR_ERR(ci->usb_phy) == -ENXIO) {
  758. ret = -ENXIO;
  759. goto ulpi_exit;
  760. }
  761. if (IS_ERR(ci->phy) && IS_ERR(ci->usb_phy)) {
  762. ret = -EPROBE_DEFER;
  763. goto ulpi_exit;
  764. }
  765. if (IS_ERR(ci->phy))
  766. ci->phy = NULL;
  767. else if (IS_ERR(ci->usb_phy))
  768. ci->usb_phy = NULL;
  769. }
  770. ret = ci_usb_phy_init(ci);
  771. if (ret) {
  772. dev_err(dev, "unable to init phy: %d\n", ret);
  773. return ret;
  774. }
  775. ci->hw_bank.phys = res->start;
  776. ci->irq = platform_get_irq(pdev, 0);
  777. if (ci->irq < 0) {
  778. dev_err(dev, "missing IRQ\n");
  779. ret = ci->irq;
  780. goto deinit_phy;
  781. }
  782. ci_get_otg_capable(ci);
  783. dr_mode = ci->platdata->dr_mode;
  784. /* initialize role(s) before the interrupt is requested */
  785. if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
  786. ret = ci_hdrc_host_init(ci);
  787. if (ret)
  788. dev_info(dev, "doesn't support host\n");
  789. }
  790. if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) {
  791. ret = ci_hdrc_gadget_init(ci);
  792. if (ret)
  793. dev_info(dev, "doesn't support gadget\n");
  794. }
  795. if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) {
  796. dev_err(dev, "no supported roles\n");
  797. ret = -ENODEV;
  798. goto deinit_phy;
  799. }
  800. if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) {
  801. ret = ci_hdrc_otg_init(ci);
  802. if (ret) {
  803. dev_err(dev, "init otg fails, ret = %d\n", ret);
  804. goto stop;
  805. }
  806. }
  807. if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) {
  808. if (ci->is_otg) {
  809. ci->role = ci_otg_role(ci);
  810. /* Enable ID change irq */
  811. hw_write_otgsc(ci, OTGSC_IDIE, OTGSC_IDIE);
  812. } else {
  813. /*
  814. * If the controller is not OTG capable, but support
  815. * role switch, the defalt role is gadget, and the
  816. * user can switch it through debugfs.
  817. */
  818. ci->role = CI_ROLE_GADGET;
  819. }
  820. } else {
  821. ci->role = ci->roles[CI_ROLE_HOST]
  822. ? CI_ROLE_HOST
  823. : CI_ROLE_GADGET;
  824. }
  825. if (!ci_otg_is_fsm_mode(ci)) {
  826. /* only update vbus status for peripheral */
  827. if (ci->role == CI_ROLE_GADGET)
  828. ci_handle_vbus_change(ci);
  829. ret = ci_role_start(ci, ci->role);
  830. if (ret) {
  831. dev_err(dev, "can't start %s role\n",
  832. ci_role(ci)->name);
  833. goto stop;
  834. }
  835. }
  836. ret = devm_request_irq(dev, ci->irq, ci_irq, IRQF_SHARED,
  837. ci->platdata->name, ci);
  838. if (ret)
  839. goto stop;
  840. ret = ci_extcon_register(ci);
  841. if (ret)
  842. goto stop;
  843. if (ci->supports_runtime_pm) {
  844. pm_runtime_set_active(&pdev->dev);
  845. pm_runtime_enable(&pdev->dev);
  846. pm_runtime_set_autosuspend_delay(&pdev->dev, 2000);
  847. pm_runtime_mark_last_busy(ci->dev);
  848. pm_runtime_use_autosuspend(&pdev->dev);
  849. }
  850. if (ci_otg_is_fsm_mode(ci))
  851. ci_hdrc_otg_fsm_start(ci);
  852. device_set_wakeup_capable(&pdev->dev, true);
  853. ret = dbg_create_files(ci);
  854. if (!ret)
  855. return 0;
  856. stop:
  857. ci_role_destroy(ci);
  858. deinit_phy:
  859. ci_usb_phy_exit(ci);
  860. ulpi_exit:
  861. ci_ulpi_exit(ci);
  862. return ret;
  863. }
  864. static int ci_hdrc_remove(struct platform_device *pdev)
  865. {
  866. struct ci_hdrc *ci = platform_get_drvdata(pdev);
  867. if (ci->supports_runtime_pm) {
  868. pm_runtime_get_sync(&pdev->dev);
  869. pm_runtime_disable(&pdev->dev);
  870. pm_runtime_put_noidle(&pdev->dev);
  871. }
  872. dbg_remove_files(ci);
  873. ci_role_destroy(ci);
  874. ci_hdrc_enter_lpm(ci, true);
  875. ci_usb_phy_exit(ci);
  876. ci_ulpi_exit(ci);
  877. return 0;
  878. }
  879. #ifdef CONFIG_PM
  880. /* Prepare wakeup by SRP before suspend */
  881. static void ci_otg_fsm_suspend_for_srp(struct ci_hdrc *ci)
  882. {
  883. if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) &&
  884. !hw_read_otgsc(ci, OTGSC_ID)) {
  885. hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_PP,
  886. PORTSC_PP);
  887. hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_WKCN,
  888. PORTSC_WKCN);
  889. }
  890. }
  891. /* Handle SRP when wakeup by data pulse */
  892. static void ci_otg_fsm_wakeup_by_srp(struct ci_hdrc *ci)
  893. {
  894. if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) &&
  895. (ci->fsm.a_bus_drop == 1) && (ci->fsm.a_bus_req == 0)) {
  896. if (!hw_read_otgsc(ci, OTGSC_ID)) {
  897. ci->fsm.a_srp_det = 1;
  898. ci->fsm.a_bus_drop = 0;
  899. } else {
  900. ci->fsm.id = 1;
  901. }
  902. ci_otg_queue_work(ci);
  903. }
  904. }
  905. static void ci_controller_suspend(struct ci_hdrc *ci)
  906. {
  907. disable_irq(ci->irq);
  908. ci_hdrc_enter_lpm(ci, true);
  909. if (ci->platdata->phy_clkgate_delay_us)
  910. usleep_range(ci->platdata->phy_clkgate_delay_us,
  911. ci->platdata->phy_clkgate_delay_us + 50);
  912. usb_phy_set_suspend(ci->usb_phy, 1);
  913. ci->in_lpm = true;
  914. enable_irq(ci->irq);
  915. }
  916. static int ci_controller_resume(struct device *dev)
  917. {
  918. struct ci_hdrc *ci = dev_get_drvdata(dev);
  919. int ret;
  920. dev_dbg(dev, "at %s\n", __func__);
  921. if (!ci->in_lpm) {
  922. WARN_ON(1);
  923. return 0;
  924. }
  925. ci_hdrc_enter_lpm(ci, false);
  926. ret = ci_ulpi_resume(ci);
  927. if (ret)
  928. return ret;
  929. if (ci->usb_phy) {
  930. usb_phy_set_suspend(ci->usb_phy, 0);
  931. usb_phy_set_wakeup(ci->usb_phy, false);
  932. hw_wait_phy_stable();
  933. }
  934. ci->in_lpm = false;
  935. if (ci->wakeup_int) {
  936. ci->wakeup_int = false;
  937. pm_runtime_mark_last_busy(ci->dev);
  938. pm_runtime_put_autosuspend(ci->dev);
  939. enable_irq(ci->irq);
  940. if (ci_otg_is_fsm_mode(ci))
  941. ci_otg_fsm_wakeup_by_srp(ci);
  942. }
  943. return 0;
  944. }
  945. #ifdef CONFIG_PM_SLEEP
  946. static int ci_suspend(struct device *dev)
  947. {
  948. struct ci_hdrc *ci = dev_get_drvdata(dev);
  949. if (ci->wq)
  950. flush_workqueue(ci->wq);
  951. /*
  952. * Controller needs to be active during suspend, otherwise the core
  953. * may run resume when the parent is at suspend if other driver's
  954. * suspend fails, it occurs before parent's suspend has not started,
  955. * but the core suspend has finished.
  956. */
  957. if (ci->in_lpm)
  958. pm_runtime_resume(dev);
  959. if (ci->in_lpm) {
  960. WARN_ON(1);
  961. return 0;
  962. }
  963. if (device_may_wakeup(dev)) {
  964. if (ci_otg_is_fsm_mode(ci))
  965. ci_otg_fsm_suspend_for_srp(ci);
  966. usb_phy_set_wakeup(ci->usb_phy, true);
  967. enable_irq_wake(ci->irq);
  968. }
  969. ci_controller_suspend(ci);
  970. return 0;
  971. }
  972. static int ci_resume(struct device *dev)
  973. {
  974. struct ci_hdrc *ci = dev_get_drvdata(dev);
  975. int ret;
  976. if (device_may_wakeup(dev))
  977. disable_irq_wake(ci->irq);
  978. ret = ci_controller_resume(dev);
  979. if (ret)
  980. return ret;
  981. if (ci->supports_runtime_pm) {
  982. pm_runtime_disable(dev);
  983. pm_runtime_set_active(dev);
  984. pm_runtime_enable(dev);
  985. }
  986. return ret;
  987. }
  988. #endif /* CONFIG_PM_SLEEP */
  989. static int ci_runtime_suspend(struct device *dev)
  990. {
  991. struct ci_hdrc *ci = dev_get_drvdata(dev);
  992. dev_dbg(dev, "at %s\n", __func__);
  993. if (ci->in_lpm) {
  994. WARN_ON(1);
  995. return 0;
  996. }
  997. if (ci_otg_is_fsm_mode(ci))
  998. ci_otg_fsm_suspend_for_srp(ci);
  999. usb_phy_set_wakeup(ci->usb_phy, true);
  1000. ci_controller_suspend(ci);
  1001. return 0;
  1002. }
  1003. static int ci_runtime_resume(struct device *dev)
  1004. {
  1005. return ci_controller_resume(dev);
  1006. }
  1007. #endif /* CONFIG_PM */
  1008. static const struct dev_pm_ops ci_pm_ops = {
  1009. SET_SYSTEM_SLEEP_PM_OPS(ci_suspend, ci_resume)
  1010. SET_RUNTIME_PM_OPS(ci_runtime_suspend, ci_runtime_resume, NULL)
  1011. };
  1012. static struct platform_driver ci_hdrc_driver = {
  1013. .probe = ci_hdrc_probe,
  1014. .remove = ci_hdrc_remove,
  1015. .driver = {
  1016. .name = "ci_hdrc",
  1017. .pm = &ci_pm_ops,
  1018. },
  1019. };
  1020. static int __init ci_hdrc_platform_register(void)
  1021. {
  1022. ci_hdrc_host_driver_init();
  1023. return platform_driver_register(&ci_hdrc_driver);
  1024. }
  1025. module_init(ci_hdrc_platform_register);
  1026. static void __exit ci_hdrc_platform_unregister(void)
  1027. {
  1028. platform_driver_unregister(&ci_hdrc_driver);
  1029. }
  1030. module_exit(ci_hdrc_platform_unregister);
  1031. MODULE_ALIAS("platform:ci_hdrc");
  1032. MODULE_LICENSE("GPL v2");
  1033. MODULE_AUTHOR("David Lopo <dlopo@chipidea.mips.com>");
  1034. MODULE_DESCRIPTION("ChipIdea HDRC Driver");