core.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233
  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. phy_set_mode(ci->phy, PHY_MODE_USB_DEVICE);
  380. if (ci->platdata->flags & CI_HDRC_DISABLE_DEVICE_STREAMING)
  381. hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS,
  382. USBMODE_CI_SDIS);
  383. }
  384. if (is_host_mode) {
  385. phy_set_mode(ci->phy, PHY_MODE_USB_HOST);
  386. if (ci->platdata->flags & CI_HDRC_DISABLE_HOST_STREAMING)
  387. hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS,
  388. USBMODE_CI_SDIS);
  389. }
  390. if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) {
  391. if (ci->hw_bank.lpm)
  392. hw_write(ci, OP_DEVLC, DEVLC_PFSC, DEVLC_PFSC);
  393. else
  394. hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC);
  395. }
  396. if (ci->platdata->flags & CI_HDRC_SET_NON_ZERO_TTHA)
  397. hw_write(ci, OP_TTCTRL, TTCTRL_TTHA_MASK, TTCTRL_TTHA);
  398. hw_write(ci, OP_USBCMD, 0xff0000, ci->platdata->itc_setting << 16);
  399. if (ci->platdata->flags & CI_HDRC_OVERRIDE_AHB_BURST)
  400. hw_write_id_reg(ci, ID_SBUSCFG, AHBBRST_MASK,
  401. ci->platdata->ahb_burst_config);
  402. /* override burst size, take effect only when ahb_burst_config is 0 */
  403. if (!hw_read_id_reg(ci, ID_SBUSCFG, AHBBRST_MASK)) {
  404. if (ci->platdata->flags & CI_HDRC_OVERRIDE_TX_BURST)
  405. hw_write(ci, OP_BURSTSIZE, TX_BURST_MASK,
  406. ci->platdata->tx_burst_size << __ffs(TX_BURST_MASK));
  407. if (ci->platdata->flags & CI_HDRC_OVERRIDE_RX_BURST)
  408. hw_write(ci, OP_BURSTSIZE, RX_BURST_MASK,
  409. ci->platdata->rx_burst_size);
  410. }
  411. }
  412. /**
  413. * hw_controller_reset: do controller reset
  414. * @ci: the controller
  415. *
  416. * This function returns an error code
  417. */
  418. static int hw_controller_reset(struct ci_hdrc *ci)
  419. {
  420. int count = 0;
  421. hw_write(ci, OP_USBCMD, USBCMD_RST, USBCMD_RST);
  422. while (hw_read(ci, OP_USBCMD, USBCMD_RST)) {
  423. udelay(10);
  424. if (count++ > 1000)
  425. return -ETIMEDOUT;
  426. }
  427. return 0;
  428. }
  429. /**
  430. * hw_device_reset: resets chip (execute without interruption)
  431. * @ci: the controller
  432. *
  433. * This function returns an error code
  434. */
  435. int hw_device_reset(struct ci_hdrc *ci)
  436. {
  437. int ret;
  438. /* should flush & stop before reset */
  439. hw_write(ci, OP_ENDPTFLUSH, ~0, ~0);
  440. hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
  441. ret = hw_controller_reset(ci);
  442. if (ret) {
  443. dev_err(ci->dev, "error resetting controller, ret=%d\n", ret);
  444. return ret;
  445. }
  446. if (ci->platdata->notify_event) {
  447. ret = ci->platdata->notify_event(ci,
  448. CI_HDRC_CONTROLLER_RESET_EVENT);
  449. if (ret)
  450. return ret;
  451. }
  452. /* USBMODE should be configured step by step */
  453. hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE);
  454. hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_DC);
  455. /* HW >= 2.3 */
  456. hw_write(ci, OP_USBMODE, USBMODE_SLOM, USBMODE_SLOM);
  457. if (hw_read(ci, OP_USBMODE, USBMODE_CM) != USBMODE_CM_DC) {
  458. pr_err("cannot enter in %s device mode", ci_role(ci)->name);
  459. pr_err("lpm = %i", ci->hw_bank.lpm);
  460. return -ENODEV;
  461. }
  462. ci_platform_configure(ci);
  463. return 0;
  464. }
  465. static irqreturn_t ci_irq(int irq, void *data)
  466. {
  467. struct ci_hdrc *ci = data;
  468. irqreturn_t ret = IRQ_NONE;
  469. u32 otgsc = 0;
  470. if (ci->in_lpm) {
  471. disable_irq_nosync(irq);
  472. ci->wakeup_int = true;
  473. pm_runtime_get(ci->dev);
  474. return IRQ_HANDLED;
  475. }
  476. if (ci->is_otg) {
  477. otgsc = hw_read_otgsc(ci, ~0);
  478. if (ci_otg_is_fsm_mode(ci)) {
  479. ret = ci_otg_fsm_irq(ci);
  480. if (ret == IRQ_HANDLED)
  481. return ret;
  482. }
  483. }
  484. /*
  485. * Handle id change interrupt, it indicates device/host function
  486. * switch.
  487. */
  488. if (ci->is_otg && (otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS)) {
  489. ci->id_event = true;
  490. /* Clear ID change irq status */
  491. hw_write_otgsc(ci, OTGSC_IDIS, OTGSC_IDIS);
  492. ci_otg_queue_work(ci);
  493. return IRQ_HANDLED;
  494. }
  495. /*
  496. * Handle vbus change interrupt, it indicates device connection
  497. * and disconnection events.
  498. */
  499. if (ci->is_otg && (otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS)) {
  500. ci->b_sess_valid_event = true;
  501. /* Clear BSV irq */
  502. hw_write_otgsc(ci, OTGSC_BSVIS, OTGSC_BSVIS);
  503. ci_otg_queue_work(ci);
  504. return IRQ_HANDLED;
  505. }
  506. /* Handle device/host interrupt */
  507. if (ci->role != CI_ROLE_END)
  508. ret = ci_role(ci)->irq(ci);
  509. return ret;
  510. }
  511. static int ci_cable_notifier(struct notifier_block *nb, unsigned long event,
  512. void *ptr)
  513. {
  514. struct ci_hdrc_cable *cbl = container_of(nb, struct ci_hdrc_cable, nb);
  515. struct ci_hdrc *ci = cbl->ci;
  516. cbl->connected = event;
  517. cbl->changed = true;
  518. ci_irq(ci->irq, ci);
  519. return NOTIFY_DONE;
  520. }
  521. static int ci_get_platdata(struct device *dev,
  522. struct ci_hdrc_platform_data *platdata)
  523. {
  524. struct extcon_dev *ext_vbus, *ext_id;
  525. struct ci_hdrc_cable *cable;
  526. int ret;
  527. if (!platdata->phy_mode)
  528. platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
  529. if (!platdata->dr_mode)
  530. platdata->dr_mode = usb_get_dr_mode(dev);
  531. if (platdata->dr_mode == USB_DR_MODE_UNKNOWN)
  532. platdata->dr_mode = USB_DR_MODE_OTG;
  533. if (platdata->dr_mode != USB_DR_MODE_PERIPHERAL) {
  534. /* Get the vbus regulator */
  535. platdata->reg_vbus = devm_regulator_get(dev, "vbus");
  536. if (PTR_ERR(platdata->reg_vbus) == -EPROBE_DEFER) {
  537. return -EPROBE_DEFER;
  538. } else if (PTR_ERR(platdata->reg_vbus) == -ENODEV) {
  539. /* no vbus regulator is needed */
  540. platdata->reg_vbus = NULL;
  541. } else if (IS_ERR(platdata->reg_vbus)) {
  542. dev_err(dev, "Getting regulator error: %ld\n",
  543. PTR_ERR(platdata->reg_vbus));
  544. return PTR_ERR(platdata->reg_vbus);
  545. }
  546. /* Get TPL support */
  547. if (!platdata->tpl_support)
  548. platdata->tpl_support =
  549. of_usb_host_tpl_support(dev->of_node);
  550. }
  551. if (platdata->dr_mode == USB_DR_MODE_OTG) {
  552. /* We can support HNP and SRP of OTG 2.0 */
  553. platdata->ci_otg_caps.otg_rev = 0x0200;
  554. platdata->ci_otg_caps.hnp_support = true;
  555. platdata->ci_otg_caps.srp_support = true;
  556. /* Update otg capabilities by DT properties */
  557. ret = of_usb_update_otg_caps(dev->of_node,
  558. &platdata->ci_otg_caps);
  559. if (ret)
  560. return ret;
  561. }
  562. if (usb_get_maximum_speed(dev) == USB_SPEED_FULL)
  563. platdata->flags |= CI_HDRC_FORCE_FULLSPEED;
  564. of_property_read_u32(dev->of_node, "phy-clkgate-delay-us",
  565. &platdata->phy_clkgate_delay_us);
  566. platdata->itc_setting = 1;
  567. of_property_read_u32(dev->of_node, "itc-setting",
  568. &platdata->itc_setting);
  569. ret = of_property_read_u32(dev->of_node, "ahb-burst-config",
  570. &platdata->ahb_burst_config);
  571. if (!ret) {
  572. platdata->flags |= CI_HDRC_OVERRIDE_AHB_BURST;
  573. } else if (ret != -EINVAL) {
  574. dev_err(dev, "failed to get ahb-burst-config\n");
  575. return ret;
  576. }
  577. ret = of_property_read_u32(dev->of_node, "tx-burst-size-dword",
  578. &platdata->tx_burst_size);
  579. if (!ret) {
  580. platdata->flags |= CI_HDRC_OVERRIDE_TX_BURST;
  581. } else if (ret != -EINVAL) {
  582. dev_err(dev, "failed to get tx-burst-size-dword\n");
  583. return ret;
  584. }
  585. ret = of_property_read_u32(dev->of_node, "rx-burst-size-dword",
  586. &platdata->rx_burst_size);
  587. if (!ret) {
  588. platdata->flags |= CI_HDRC_OVERRIDE_RX_BURST;
  589. } else if (ret != -EINVAL) {
  590. dev_err(dev, "failed to get rx-burst-size-dword\n");
  591. return ret;
  592. }
  593. if (of_find_property(dev->of_node, "non-zero-ttctrl-ttha", NULL))
  594. platdata->flags |= CI_HDRC_SET_NON_ZERO_TTHA;
  595. ext_id = ERR_PTR(-ENODEV);
  596. ext_vbus = ERR_PTR(-ENODEV);
  597. if (of_property_read_bool(dev->of_node, "extcon")) {
  598. /* Each one of them is not mandatory */
  599. ext_vbus = extcon_get_edev_by_phandle(dev, 0);
  600. if (IS_ERR(ext_vbus) && PTR_ERR(ext_vbus) != -ENODEV)
  601. return PTR_ERR(ext_vbus);
  602. ext_id = extcon_get_edev_by_phandle(dev, 1);
  603. if (IS_ERR(ext_id) && PTR_ERR(ext_id) != -ENODEV)
  604. return PTR_ERR(ext_id);
  605. }
  606. cable = &platdata->vbus_extcon;
  607. cable->nb.notifier_call = ci_cable_notifier;
  608. cable->edev = ext_vbus;
  609. if (!IS_ERR(ext_vbus)) {
  610. ret = extcon_get_state(cable->edev, EXTCON_USB);
  611. if (ret)
  612. cable->connected = true;
  613. else
  614. cable->connected = false;
  615. }
  616. cable = &platdata->id_extcon;
  617. cable->nb.notifier_call = ci_cable_notifier;
  618. cable->edev = ext_id;
  619. if (!IS_ERR(ext_id)) {
  620. ret = extcon_get_state(cable->edev, EXTCON_USB_HOST);
  621. if (ret)
  622. cable->connected = true;
  623. else
  624. cable->connected = false;
  625. }
  626. return 0;
  627. }
  628. static int ci_extcon_register(struct ci_hdrc *ci)
  629. {
  630. struct ci_hdrc_cable *id, *vbus;
  631. int ret;
  632. id = &ci->platdata->id_extcon;
  633. id->ci = ci;
  634. if (!IS_ERR(id->edev)) {
  635. ret = devm_extcon_register_notifier(ci->dev, id->edev,
  636. EXTCON_USB_HOST, &id->nb);
  637. if (ret < 0) {
  638. dev_err(ci->dev, "register ID failed\n");
  639. return ret;
  640. }
  641. }
  642. vbus = &ci->platdata->vbus_extcon;
  643. vbus->ci = ci;
  644. if (!IS_ERR(vbus->edev)) {
  645. ret = devm_extcon_register_notifier(ci->dev, vbus->edev,
  646. EXTCON_USB, &vbus->nb);
  647. if (ret < 0) {
  648. dev_err(ci->dev, "register VBUS failed\n");
  649. return ret;
  650. }
  651. }
  652. return 0;
  653. }
  654. static DEFINE_IDA(ci_ida);
  655. struct platform_device *ci_hdrc_add_device(struct device *dev,
  656. struct resource *res, int nres,
  657. struct ci_hdrc_platform_data *platdata)
  658. {
  659. struct platform_device *pdev;
  660. int id, ret;
  661. ret = ci_get_platdata(dev, platdata);
  662. if (ret)
  663. return ERR_PTR(ret);
  664. id = ida_simple_get(&ci_ida, 0, 0, GFP_KERNEL);
  665. if (id < 0)
  666. return ERR_PTR(id);
  667. pdev = platform_device_alloc("ci_hdrc", id);
  668. if (!pdev) {
  669. ret = -ENOMEM;
  670. goto put_id;
  671. }
  672. pdev->dev.parent = dev;
  673. pdev->dev.dma_mask = dev->dma_mask;
  674. pdev->dev.dma_parms = dev->dma_parms;
  675. dma_set_coherent_mask(&pdev->dev, dev->coherent_dma_mask);
  676. ret = platform_device_add_resources(pdev, res, nres);
  677. if (ret)
  678. goto err;
  679. ret = platform_device_add_data(pdev, platdata, sizeof(*platdata));
  680. if (ret)
  681. goto err;
  682. ret = platform_device_add(pdev);
  683. if (ret)
  684. goto err;
  685. return pdev;
  686. err:
  687. platform_device_put(pdev);
  688. put_id:
  689. ida_simple_remove(&ci_ida, id);
  690. return ERR_PTR(ret);
  691. }
  692. EXPORT_SYMBOL_GPL(ci_hdrc_add_device);
  693. void ci_hdrc_remove_device(struct platform_device *pdev)
  694. {
  695. int id = pdev->id;
  696. platform_device_unregister(pdev);
  697. ida_simple_remove(&ci_ida, id);
  698. }
  699. EXPORT_SYMBOL_GPL(ci_hdrc_remove_device);
  700. static inline void ci_role_destroy(struct ci_hdrc *ci)
  701. {
  702. ci_hdrc_gadget_destroy(ci);
  703. ci_hdrc_host_destroy(ci);
  704. if (ci->is_otg)
  705. ci_hdrc_otg_destroy(ci);
  706. }
  707. static void ci_get_otg_capable(struct ci_hdrc *ci)
  708. {
  709. if (ci->platdata->flags & CI_HDRC_DUAL_ROLE_NOT_OTG)
  710. ci->is_otg = false;
  711. else
  712. ci->is_otg = (hw_read(ci, CAP_DCCPARAMS,
  713. DCCPARAMS_DC | DCCPARAMS_HC)
  714. == (DCCPARAMS_DC | DCCPARAMS_HC));
  715. if (ci->is_otg) {
  716. dev_dbg(ci->dev, "It is OTG capable controller\n");
  717. /* Disable and clear all OTG irq */
  718. hw_write_otgsc(ci, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS,
  719. OTGSC_INT_STATUS_BITS);
  720. }
  721. }
  722. static int ci_hdrc_probe(struct platform_device *pdev)
  723. {
  724. struct device *dev = &pdev->dev;
  725. struct ci_hdrc *ci;
  726. struct resource *res;
  727. void __iomem *base;
  728. int ret;
  729. enum usb_dr_mode dr_mode;
  730. if (!dev_get_platdata(dev)) {
  731. dev_err(dev, "platform data missing\n");
  732. return -ENODEV;
  733. }
  734. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  735. base = devm_ioremap_resource(dev, res);
  736. if (IS_ERR(base))
  737. return PTR_ERR(base);
  738. ci = devm_kzalloc(dev, sizeof(*ci), GFP_KERNEL);
  739. if (!ci)
  740. return -ENOMEM;
  741. spin_lock_init(&ci->lock);
  742. ci->dev = dev;
  743. ci->platdata = dev_get_platdata(dev);
  744. ci->imx28_write_fix = !!(ci->platdata->flags &
  745. CI_HDRC_IMX28_WRITE_FIX);
  746. ci->supports_runtime_pm = !!(ci->platdata->flags &
  747. CI_HDRC_SUPPORTS_RUNTIME_PM);
  748. platform_set_drvdata(pdev, ci);
  749. ret = hw_device_init(ci, base);
  750. if (ret < 0) {
  751. dev_err(dev, "can't initialize hardware\n");
  752. return -ENODEV;
  753. }
  754. ret = ci_ulpi_init(ci);
  755. if (ret)
  756. return ret;
  757. if (ci->platdata->phy) {
  758. ci->phy = ci->platdata->phy;
  759. } else if (ci->platdata->usb_phy) {
  760. ci->usb_phy = ci->platdata->usb_phy;
  761. } else {
  762. ci->phy = devm_phy_get(dev->parent, "usb-phy");
  763. ci->usb_phy = devm_usb_get_phy(dev->parent, USB_PHY_TYPE_USB2);
  764. /* if both generic PHY and USB PHY layers aren't enabled */
  765. if (PTR_ERR(ci->phy) == -ENOSYS &&
  766. PTR_ERR(ci->usb_phy) == -ENXIO) {
  767. ret = -ENXIO;
  768. goto ulpi_exit;
  769. }
  770. if (IS_ERR(ci->phy) && IS_ERR(ci->usb_phy)) {
  771. ret = -EPROBE_DEFER;
  772. goto ulpi_exit;
  773. }
  774. if (IS_ERR(ci->phy))
  775. ci->phy = NULL;
  776. else if (IS_ERR(ci->usb_phy))
  777. ci->usb_phy = NULL;
  778. }
  779. ret = ci_usb_phy_init(ci);
  780. if (ret) {
  781. dev_err(dev, "unable to init phy: %d\n", ret);
  782. return ret;
  783. }
  784. ci->hw_bank.phys = res->start;
  785. ci->irq = platform_get_irq(pdev, 0);
  786. if (ci->irq < 0) {
  787. dev_err(dev, "missing IRQ\n");
  788. ret = ci->irq;
  789. goto deinit_phy;
  790. }
  791. ci_get_otg_capable(ci);
  792. dr_mode = ci->platdata->dr_mode;
  793. /* initialize role(s) before the interrupt is requested */
  794. if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
  795. ret = ci_hdrc_host_init(ci);
  796. if (ret)
  797. dev_info(dev, "doesn't support host\n");
  798. }
  799. if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) {
  800. ret = ci_hdrc_gadget_init(ci);
  801. if (ret)
  802. dev_info(dev, "doesn't support gadget\n");
  803. }
  804. if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) {
  805. dev_err(dev, "no supported roles\n");
  806. ret = -ENODEV;
  807. goto deinit_phy;
  808. }
  809. if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) {
  810. ret = ci_hdrc_otg_init(ci);
  811. if (ret) {
  812. dev_err(dev, "init otg fails, ret = %d\n", ret);
  813. goto stop;
  814. }
  815. }
  816. if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) {
  817. if (ci->is_otg) {
  818. ci->role = ci_otg_role(ci);
  819. /* Enable ID change irq */
  820. hw_write_otgsc(ci, OTGSC_IDIE, OTGSC_IDIE);
  821. } else {
  822. /*
  823. * If the controller is not OTG capable, but support
  824. * role switch, the defalt role is gadget, and the
  825. * user can switch it through debugfs.
  826. */
  827. ci->role = CI_ROLE_GADGET;
  828. }
  829. } else {
  830. ci->role = ci->roles[CI_ROLE_HOST]
  831. ? CI_ROLE_HOST
  832. : CI_ROLE_GADGET;
  833. }
  834. if (!ci_otg_is_fsm_mode(ci)) {
  835. /* only update vbus status for peripheral */
  836. if (ci->role == CI_ROLE_GADGET)
  837. ci_handle_vbus_change(ci);
  838. ret = ci_role_start(ci, ci->role);
  839. if (ret) {
  840. dev_err(dev, "can't start %s role\n",
  841. ci_role(ci)->name);
  842. goto stop;
  843. }
  844. }
  845. ret = devm_request_irq(dev, ci->irq, ci_irq, IRQF_SHARED,
  846. ci->platdata->name, ci);
  847. if (ret)
  848. goto stop;
  849. ret = ci_extcon_register(ci);
  850. if (ret)
  851. goto stop;
  852. if (ci->supports_runtime_pm) {
  853. pm_runtime_set_active(&pdev->dev);
  854. pm_runtime_enable(&pdev->dev);
  855. pm_runtime_set_autosuspend_delay(&pdev->dev, 2000);
  856. pm_runtime_mark_last_busy(ci->dev);
  857. pm_runtime_use_autosuspend(&pdev->dev);
  858. }
  859. if (ci_otg_is_fsm_mode(ci))
  860. ci_hdrc_otg_fsm_start(ci);
  861. device_set_wakeup_capable(&pdev->dev, true);
  862. ret = dbg_create_files(ci);
  863. if (!ret)
  864. return 0;
  865. stop:
  866. ci_role_destroy(ci);
  867. deinit_phy:
  868. ci_usb_phy_exit(ci);
  869. ulpi_exit:
  870. ci_ulpi_exit(ci);
  871. return ret;
  872. }
  873. static int ci_hdrc_remove(struct platform_device *pdev)
  874. {
  875. struct ci_hdrc *ci = platform_get_drvdata(pdev);
  876. if (ci->supports_runtime_pm) {
  877. pm_runtime_get_sync(&pdev->dev);
  878. pm_runtime_disable(&pdev->dev);
  879. pm_runtime_put_noidle(&pdev->dev);
  880. }
  881. dbg_remove_files(ci);
  882. ci_role_destroy(ci);
  883. ci_hdrc_enter_lpm(ci, true);
  884. ci_usb_phy_exit(ci);
  885. ci_ulpi_exit(ci);
  886. return 0;
  887. }
  888. #ifdef CONFIG_PM
  889. /* Prepare wakeup by SRP before suspend */
  890. static void ci_otg_fsm_suspend_for_srp(struct ci_hdrc *ci)
  891. {
  892. if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) &&
  893. !hw_read_otgsc(ci, OTGSC_ID)) {
  894. hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_PP,
  895. PORTSC_PP);
  896. hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_WKCN,
  897. PORTSC_WKCN);
  898. }
  899. }
  900. /* Handle SRP when wakeup by data pulse */
  901. static void ci_otg_fsm_wakeup_by_srp(struct ci_hdrc *ci)
  902. {
  903. if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) &&
  904. (ci->fsm.a_bus_drop == 1) && (ci->fsm.a_bus_req == 0)) {
  905. if (!hw_read_otgsc(ci, OTGSC_ID)) {
  906. ci->fsm.a_srp_det = 1;
  907. ci->fsm.a_bus_drop = 0;
  908. } else {
  909. ci->fsm.id = 1;
  910. }
  911. ci_otg_queue_work(ci);
  912. }
  913. }
  914. static void ci_controller_suspend(struct ci_hdrc *ci)
  915. {
  916. disable_irq(ci->irq);
  917. ci_hdrc_enter_lpm(ci, true);
  918. if (ci->platdata->phy_clkgate_delay_us)
  919. usleep_range(ci->platdata->phy_clkgate_delay_us,
  920. ci->platdata->phy_clkgate_delay_us + 50);
  921. usb_phy_set_suspend(ci->usb_phy, 1);
  922. ci->in_lpm = true;
  923. enable_irq(ci->irq);
  924. }
  925. static int ci_controller_resume(struct device *dev)
  926. {
  927. struct ci_hdrc *ci = dev_get_drvdata(dev);
  928. int ret;
  929. dev_dbg(dev, "at %s\n", __func__);
  930. if (!ci->in_lpm) {
  931. WARN_ON(1);
  932. return 0;
  933. }
  934. ci_hdrc_enter_lpm(ci, false);
  935. ret = ci_ulpi_resume(ci);
  936. if (ret)
  937. return ret;
  938. if (ci->usb_phy) {
  939. usb_phy_set_suspend(ci->usb_phy, 0);
  940. usb_phy_set_wakeup(ci->usb_phy, false);
  941. hw_wait_phy_stable();
  942. }
  943. ci->in_lpm = false;
  944. if (ci->wakeup_int) {
  945. ci->wakeup_int = false;
  946. pm_runtime_mark_last_busy(ci->dev);
  947. pm_runtime_put_autosuspend(ci->dev);
  948. enable_irq(ci->irq);
  949. if (ci_otg_is_fsm_mode(ci))
  950. ci_otg_fsm_wakeup_by_srp(ci);
  951. }
  952. return 0;
  953. }
  954. #ifdef CONFIG_PM_SLEEP
  955. static int ci_suspend(struct device *dev)
  956. {
  957. struct ci_hdrc *ci = dev_get_drvdata(dev);
  958. if (ci->wq)
  959. flush_workqueue(ci->wq);
  960. /*
  961. * Controller needs to be active during suspend, otherwise the core
  962. * may run resume when the parent is at suspend if other driver's
  963. * suspend fails, it occurs before parent's suspend has not started,
  964. * but the core suspend has finished.
  965. */
  966. if (ci->in_lpm)
  967. pm_runtime_resume(dev);
  968. if (ci->in_lpm) {
  969. WARN_ON(1);
  970. return 0;
  971. }
  972. if (device_may_wakeup(dev)) {
  973. if (ci_otg_is_fsm_mode(ci))
  974. ci_otg_fsm_suspend_for_srp(ci);
  975. usb_phy_set_wakeup(ci->usb_phy, true);
  976. enable_irq_wake(ci->irq);
  977. }
  978. ci_controller_suspend(ci);
  979. return 0;
  980. }
  981. static int ci_resume(struct device *dev)
  982. {
  983. struct ci_hdrc *ci = dev_get_drvdata(dev);
  984. int ret;
  985. if (device_may_wakeup(dev))
  986. disable_irq_wake(ci->irq);
  987. ret = ci_controller_resume(dev);
  988. if (ret)
  989. return ret;
  990. if (ci->supports_runtime_pm) {
  991. pm_runtime_disable(dev);
  992. pm_runtime_set_active(dev);
  993. pm_runtime_enable(dev);
  994. }
  995. return ret;
  996. }
  997. #endif /* CONFIG_PM_SLEEP */
  998. static int ci_runtime_suspend(struct device *dev)
  999. {
  1000. struct ci_hdrc *ci = dev_get_drvdata(dev);
  1001. dev_dbg(dev, "at %s\n", __func__);
  1002. if (ci->in_lpm) {
  1003. WARN_ON(1);
  1004. return 0;
  1005. }
  1006. if (ci_otg_is_fsm_mode(ci))
  1007. ci_otg_fsm_suspend_for_srp(ci);
  1008. usb_phy_set_wakeup(ci->usb_phy, true);
  1009. ci_controller_suspend(ci);
  1010. return 0;
  1011. }
  1012. static int ci_runtime_resume(struct device *dev)
  1013. {
  1014. return ci_controller_resume(dev);
  1015. }
  1016. #endif /* CONFIG_PM */
  1017. static const struct dev_pm_ops ci_pm_ops = {
  1018. SET_SYSTEM_SLEEP_PM_OPS(ci_suspend, ci_resume)
  1019. SET_RUNTIME_PM_OPS(ci_runtime_suspend, ci_runtime_resume, NULL)
  1020. };
  1021. static struct platform_driver ci_hdrc_driver = {
  1022. .probe = ci_hdrc_probe,
  1023. .remove = ci_hdrc_remove,
  1024. .driver = {
  1025. .name = "ci_hdrc",
  1026. .pm = &ci_pm_ops,
  1027. },
  1028. };
  1029. static int __init ci_hdrc_platform_register(void)
  1030. {
  1031. ci_hdrc_host_driver_init();
  1032. return platform_driver_register(&ci_hdrc_driver);
  1033. }
  1034. module_init(ci_hdrc_platform_register);
  1035. static void __exit ci_hdrc_platform_unregister(void)
  1036. {
  1037. platform_driver_unregister(&ci_hdrc_driver);
  1038. }
  1039. module_exit(ci_hdrc_platform_unregister);
  1040. MODULE_ALIAS("platform:ci_hdrc");
  1041. MODULE_LICENSE("GPL v2");
  1042. MODULE_AUTHOR("David Lopo <dlopo@chipidea.mips.com>");
  1043. MODULE_DESCRIPTION("ChipIdea HDRC Driver");