omap2430.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. /*
  2. * Copyright (C) 2005-2007 by Texas Instruments
  3. * Some code has been taken from tusb6010.c
  4. * Copyrights for that are attributable to:
  5. * Copyright (C) 2006 Nokia Corporation
  6. * Tony Lindgren <tony@atomide.com>
  7. *
  8. * This file is part of the Inventra Controller Driver for Linux.
  9. *
  10. * The Inventra Controller Driver for Linux is free software; you
  11. * can redistribute it and/or modify it under the terms of the GNU
  12. * General Public License version 2 as published by the Free Software
  13. * Foundation.
  14. *
  15. * The Inventra Controller Driver for Linux is distributed in
  16. * the hope that it will be useful, but WITHOUT ANY WARRANTY;
  17. * without even the implied warranty of MERCHANTABILITY or
  18. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  19. * License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with The Inventra Controller Driver for Linux ; if not,
  23. * write to the Free Software Foundation, Inc., 59 Temple Place,
  24. * Suite 330, Boston, MA 02111-1307 USA
  25. *
  26. */
  27. #include <linux/module.h>
  28. #include <linux/kernel.h>
  29. #include <linux/sched.h>
  30. #include <linux/init.h>
  31. #include <linux/list.h>
  32. #include <linux/io.h>
  33. #include <linux/of.h>
  34. #include <linux/platform_device.h>
  35. #include <linux/dma-mapping.h>
  36. #include <linux/pm_runtime.h>
  37. #include <linux/err.h>
  38. #include <linux/delay.h>
  39. #include <linux/usb/musb-omap.h>
  40. #include <linux/usb/omap_control_usb.h>
  41. #include "musb_core.h"
  42. #include "omap2430.h"
  43. struct omap2430_glue {
  44. struct device *dev;
  45. struct platform_device *musb;
  46. enum omap_musb_vbus_id_status status;
  47. struct work_struct omap_musb_mailbox_work;
  48. struct device *control_otghs;
  49. };
  50. #define glue_to_musb(g) platform_get_drvdata(g->musb)
  51. struct omap2430_glue *_glue;
  52. static struct timer_list musb_idle_timer;
  53. static void musb_do_idle(unsigned long _musb)
  54. {
  55. struct musb *musb = (void *)_musb;
  56. unsigned long flags;
  57. u8 power;
  58. u8 devctl;
  59. spin_lock_irqsave(&musb->lock, flags);
  60. switch (musb->xceiv->state) {
  61. case OTG_STATE_A_WAIT_BCON:
  62. devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
  63. if (devctl & MUSB_DEVCTL_BDEVICE) {
  64. musb->xceiv->state = OTG_STATE_B_IDLE;
  65. MUSB_DEV_MODE(musb);
  66. } else {
  67. musb->xceiv->state = OTG_STATE_A_IDLE;
  68. MUSB_HST_MODE(musb);
  69. }
  70. break;
  71. case OTG_STATE_A_SUSPEND:
  72. /* finish RESUME signaling? */
  73. if (musb->port1_status & MUSB_PORT_STAT_RESUME) {
  74. power = musb_readb(musb->mregs, MUSB_POWER);
  75. power &= ~MUSB_POWER_RESUME;
  76. dev_dbg(musb->controller, "root port resume stopped, power %02x\n", power);
  77. musb_writeb(musb->mregs, MUSB_POWER, power);
  78. musb->is_active = 1;
  79. musb->port1_status &= ~(USB_PORT_STAT_SUSPEND
  80. | MUSB_PORT_STAT_RESUME);
  81. musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
  82. usb_hcd_poll_rh_status(musb_to_hcd(musb));
  83. /* NOTE: it might really be A_WAIT_BCON ... */
  84. musb->xceiv->state = OTG_STATE_A_HOST;
  85. }
  86. break;
  87. case OTG_STATE_A_HOST:
  88. devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
  89. if (devctl & MUSB_DEVCTL_BDEVICE)
  90. musb->xceiv->state = OTG_STATE_B_IDLE;
  91. else
  92. musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
  93. default:
  94. break;
  95. }
  96. spin_unlock_irqrestore(&musb->lock, flags);
  97. }
  98. static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
  99. {
  100. unsigned long default_timeout = jiffies + msecs_to_jiffies(3);
  101. static unsigned long last_timer;
  102. if (timeout == 0)
  103. timeout = default_timeout;
  104. /* Never idle if active, or when VBUS timeout is not set as host */
  105. if (musb->is_active || ((musb->a_wait_bcon == 0)
  106. && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
  107. dev_dbg(musb->controller, "%s active, deleting timer\n",
  108. otg_state_string(musb->xceiv->state));
  109. del_timer(&musb_idle_timer);
  110. last_timer = jiffies;
  111. return;
  112. }
  113. if (time_after(last_timer, timeout)) {
  114. if (!timer_pending(&musb_idle_timer))
  115. last_timer = timeout;
  116. else {
  117. dev_dbg(musb->controller, "Longer idle timer already pending, ignoring\n");
  118. return;
  119. }
  120. }
  121. last_timer = timeout;
  122. dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
  123. otg_state_string(musb->xceiv->state),
  124. (unsigned long)jiffies_to_msecs(timeout - jiffies));
  125. mod_timer(&musb_idle_timer, timeout);
  126. }
  127. static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
  128. {
  129. struct usb_otg *otg = musb->xceiv->otg;
  130. u8 devctl;
  131. unsigned long timeout = jiffies + msecs_to_jiffies(1000);
  132. /* HDRC controls CPEN, but beware current surges during device
  133. * connect. They can trigger transient overcurrent conditions
  134. * that must be ignored.
  135. */
  136. devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
  137. if (is_on) {
  138. if (musb->xceiv->state == OTG_STATE_A_IDLE) {
  139. int loops = 100;
  140. /* start the session */
  141. devctl |= MUSB_DEVCTL_SESSION;
  142. musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
  143. /*
  144. * Wait for the musb to set as A device to enable the
  145. * VBUS
  146. */
  147. while (musb_readb(musb->mregs, MUSB_DEVCTL) & 0x80) {
  148. mdelay(5);
  149. cpu_relax();
  150. if (time_after(jiffies, timeout)
  151. || loops-- <= 0) {
  152. dev_err(musb->controller,
  153. "configured as A device timeout");
  154. break;
  155. }
  156. }
  157. if (otg->set_vbus)
  158. otg_set_vbus(otg, 1);
  159. } else {
  160. musb->is_active = 1;
  161. otg->default_a = 1;
  162. musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
  163. devctl |= MUSB_DEVCTL_SESSION;
  164. MUSB_HST_MODE(musb);
  165. }
  166. } else {
  167. musb->is_active = 0;
  168. /* NOTE: we're skipping A_WAIT_VFALL -> A_IDLE and
  169. * jumping right to B_IDLE...
  170. */
  171. otg->default_a = 0;
  172. musb->xceiv->state = OTG_STATE_B_IDLE;
  173. devctl &= ~MUSB_DEVCTL_SESSION;
  174. MUSB_DEV_MODE(musb);
  175. }
  176. musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
  177. dev_dbg(musb->controller, "VBUS %s, devctl %02x "
  178. /* otg %3x conf %08x prcm %08x */ "\n",
  179. otg_state_string(musb->xceiv->state),
  180. musb_readb(musb->mregs, MUSB_DEVCTL));
  181. }
  182. static int omap2430_musb_set_mode(struct musb *musb, u8 musb_mode)
  183. {
  184. u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
  185. devctl |= MUSB_DEVCTL_SESSION;
  186. musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
  187. return 0;
  188. }
  189. static inline void omap2430_low_level_exit(struct musb *musb)
  190. {
  191. u32 l;
  192. /* in any role */
  193. l = musb_readl(musb->mregs, OTG_FORCESTDBY);
  194. l |= ENABLEFORCE; /* enable MSTANDBY */
  195. musb_writel(musb->mregs, OTG_FORCESTDBY, l);
  196. }
  197. static inline void omap2430_low_level_init(struct musb *musb)
  198. {
  199. u32 l;
  200. l = musb_readl(musb->mregs, OTG_FORCESTDBY);
  201. l &= ~ENABLEFORCE; /* disable MSTANDBY */
  202. musb_writel(musb->mregs, OTG_FORCESTDBY, l);
  203. }
  204. void omap_musb_mailbox(enum omap_musb_vbus_id_status status)
  205. {
  206. struct omap2430_glue *glue = _glue;
  207. struct musb *musb = glue_to_musb(glue);
  208. glue->status = status;
  209. if (!musb) {
  210. dev_err(glue->dev, "musb core is not yet ready\n");
  211. return;
  212. }
  213. schedule_work(&glue->omap_musb_mailbox_work);
  214. }
  215. EXPORT_SYMBOL_GPL(omap_musb_mailbox);
  216. static void omap_musb_set_mailbox(struct omap2430_glue *glue)
  217. {
  218. struct musb *musb = glue_to_musb(glue);
  219. struct device *dev = musb->controller;
  220. struct musb_hdrc_platform_data *pdata = dev->platform_data;
  221. struct omap_musb_board_data *data = pdata->board_data;
  222. struct usb_otg *otg = musb->xceiv->otg;
  223. switch (glue->status) {
  224. case OMAP_MUSB_ID_GROUND:
  225. dev_dbg(dev, "ID GND\n");
  226. otg->default_a = true;
  227. musb->xceiv->state = OTG_STATE_A_IDLE;
  228. musb->xceiv->last_event = USB_EVENT_ID;
  229. if (musb->gadget_driver) {
  230. pm_runtime_get_sync(dev);
  231. omap_control_usb_set_mode(glue->control_otghs,
  232. USB_MODE_HOST);
  233. omap2430_musb_set_vbus(musb, 1);
  234. }
  235. break;
  236. case OMAP_MUSB_VBUS_VALID:
  237. dev_dbg(dev, "VBUS Connect\n");
  238. otg->default_a = false;
  239. musb->xceiv->state = OTG_STATE_B_IDLE;
  240. musb->xceiv->last_event = USB_EVENT_VBUS;
  241. if (musb->gadget_driver)
  242. pm_runtime_get_sync(dev);
  243. omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
  244. break;
  245. case OMAP_MUSB_ID_FLOAT:
  246. case OMAP_MUSB_VBUS_OFF:
  247. dev_dbg(dev, "VBUS Disconnect\n");
  248. musb->xceiv->last_event = USB_EVENT_NONE;
  249. if (musb->gadget_driver) {
  250. pm_runtime_mark_last_busy(dev);
  251. pm_runtime_put_autosuspend(dev);
  252. }
  253. if (data->interface_type == MUSB_INTERFACE_UTMI) {
  254. if (musb->xceiv->otg->set_vbus)
  255. otg_set_vbus(musb->xceiv->otg, 0);
  256. }
  257. omap_control_usb_set_mode(glue->control_otghs,
  258. USB_MODE_DISCONNECT);
  259. break;
  260. default:
  261. dev_dbg(dev, "ID float\n");
  262. }
  263. }
  264. static void omap_musb_mailbox_work(struct work_struct *mailbox_work)
  265. {
  266. struct omap2430_glue *glue = container_of(mailbox_work,
  267. struct omap2430_glue, omap_musb_mailbox_work);
  268. omap_musb_set_mailbox(glue);
  269. }
  270. static irqreturn_t omap2430_musb_interrupt(int irq, void *__hci)
  271. {
  272. unsigned long flags;
  273. irqreturn_t retval = IRQ_NONE;
  274. struct musb *musb = __hci;
  275. spin_lock_irqsave(&musb->lock, flags);
  276. musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB);
  277. musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX);
  278. musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX);
  279. if (musb->int_usb || musb->int_tx || musb->int_rx)
  280. retval = musb_interrupt(musb);
  281. spin_unlock_irqrestore(&musb->lock, flags);
  282. return retval;
  283. }
  284. static int omap2430_musb_init(struct musb *musb)
  285. {
  286. u32 l;
  287. int status = 0;
  288. struct device *dev = musb->controller;
  289. struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
  290. struct musb_hdrc_platform_data *plat = dev->platform_data;
  291. struct omap_musb_board_data *data = plat->board_data;
  292. /* We require some kind of external transceiver, hooked
  293. * up through ULPI. TWL4030-family PMICs include one,
  294. * which needs a driver, drivers aren't always needed.
  295. */
  296. musb->xceiv = devm_usb_get_phy_dev(dev, 0);
  297. if (IS_ERR_OR_NULL(musb->xceiv)) {
  298. pr_err("HS USB OTG: no transceiver configured\n");
  299. return -ENODEV;
  300. }
  301. musb->isr = omap2430_musb_interrupt;
  302. status = pm_runtime_get_sync(dev);
  303. if (status < 0) {
  304. dev_err(dev, "pm_runtime_get_sync FAILED %d\n", status);
  305. goto err1;
  306. }
  307. l = musb_readl(musb->mregs, OTG_INTERFSEL);
  308. if (data->interface_type == MUSB_INTERFACE_UTMI) {
  309. /* OMAP4 uses Internal PHY GS70 which uses UTMI interface */
  310. l &= ~ULPI_12PIN; /* Disable ULPI */
  311. l |= UTMI_8BIT; /* Enable UTMI */
  312. } else {
  313. l |= ULPI_12PIN;
  314. }
  315. musb_writel(musb->mregs, OTG_INTERFSEL, l);
  316. pr_debug("HS USB OTG: revision 0x%x, sysconfig 0x%02x, "
  317. "sysstatus 0x%x, intrfsel 0x%x, simenable 0x%x\n",
  318. musb_readl(musb->mregs, OTG_REVISION),
  319. musb_readl(musb->mregs, OTG_SYSCONFIG),
  320. musb_readl(musb->mregs, OTG_SYSSTATUS),
  321. musb_readl(musb->mregs, OTG_INTERFSEL),
  322. musb_readl(musb->mregs, OTG_SIMENABLE));
  323. setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb);
  324. if (glue->status != OMAP_MUSB_UNKNOWN)
  325. omap_musb_set_mailbox(glue);
  326. pm_runtime_put_noidle(musb->controller);
  327. return 0;
  328. err1:
  329. return status;
  330. }
  331. static void omap2430_musb_enable(struct musb *musb)
  332. {
  333. u8 devctl;
  334. unsigned long timeout = jiffies + msecs_to_jiffies(1000);
  335. struct device *dev = musb->controller;
  336. struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
  337. struct musb_hdrc_platform_data *pdata = dev->platform_data;
  338. struct omap_musb_board_data *data = pdata->board_data;
  339. switch (glue->status) {
  340. case OMAP_MUSB_ID_GROUND:
  341. omap_control_usb_set_mode(glue->control_otghs, USB_MODE_HOST);
  342. if (data->interface_type != MUSB_INTERFACE_UTMI)
  343. break;
  344. devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
  345. /* start the session */
  346. devctl |= MUSB_DEVCTL_SESSION;
  347. musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
  348. while (musb_readb(musb->mregs, MUSB_DEVCTL) &
  349. MUSB_DEVCTL_BDEVICE) {
  350. cpu_relax();
  351. if (time_after(jiffies, timeout)) {
  352. dev_err(dev, "configured as A device timeout");
  353. break;
  354. }
  355. }
  356. break;
  357. case OMAP_MUSB_VBUS_VALID:
  358. omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
  359. break;
  360. default:
  361. break;
  362. }
  363. }
  364. static void omap2430_musb_disable(struct musb *musb)
  365. {
  366. struct device *dev = musb->controller;
  367. struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
  368. if (glue->status != OMAP_MUSB_UNKNOWN)
  369. omap_control_usb_set_mode(glue->control_otghs,
  370. USB_MODE_DISCONNECT);
  371. }
  372. static int omap2430_musb_exit(struct musb *musb)
  373. {
  374. del_timer_sync(&musb_idle_timer);
  375. omap2430_low_level_exit(musb);
  376. return 0;
  377. }
  378. static const struct musb_platform_ops omap2430_ops = {
  379. .init = omap2430_musb_init,
  380. .exit = omap2430_musb_exit,
  381. .set_mode = omap2430_musb_set_mode,
  382. .try_idle = omap2430_musb_try_idle,
  383. .set_vbus = omap2430_musb_set_vbus,
  384. .enable = omap2430_musb_enable,
  385. .disable = omap2430_musb_disable,
  386. };
  387. static u64 omap2430_dmamask = DMA_BIT_MASK(32);
  388. static int omap2430_probe(struct platform_device *pdev)
  389. {
  390. struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
  391. struct omap_musb_board_data *data;
  392. struct platform_device *musb;
  393. struct omap2430_glue *glue;
  394. struct device_node *np = pdev->dev.of_node;
  395. struct musb_hdrc_config *config;
  396. int ret = -ENOMEM;
  397. glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
  398. if (!glue) {
  399. dev_err(&pdev->dev, "failed to allocate glue context\n");
  400. goto err0;
  401. }
  402. musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
  403. if (!musb) {
  404. dev_err(&pdev->dev, "failed to allocate musb device\n");
  405. goto err0;
  406. }
  407. musb->dev.parent = &pdev->dev;
  408. musb->dev.dma_mask = &omap2430_dmamask;
  409. musb->dev.coherent_dma_mask = omap2430_dmamask;
  410. glue->dev = &pdev->dev;
  411. glue->musb = musb;
  412. glue->status = OMAP_MUSB_UNKNOWN;
  413. if (np) {
  414. pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
  415. if (!pdata) {
  416. dev_err(&pdev->dev,
  417. "failed to allocate musb platfrom data\n");
  418. ret = -ENOMEM;
  419. goto err2;
  420. }
  421. data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
  422. if (!data) {
  423. dev_err(&pdev->dev,
  424. "failed to allocate musb board data\n");
  425. ret = -ENOMEM;
  426. goto err2;
  427. }
  428. config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
  429. if (!data) {
  430. dev_err(&pdev->dev,
  431. "failed to allocate musb hdrc config\n");
  432. goto err2;
  433. }
  434. of_property_read_u32(np, "mode", (u32 *)&pdata->mode);
  435. of_property_read_u32(np, "interface_type",
  436. (u32 *)&data->interface_type);
  437. of_property_read_u32(np, "num_eps", (u32 *)&config->num_eps);
  438. of_property_read_u32(np, "ram_bits", (u32 *)&config->ram_bits);
  439. of_property_read_u32(np, "power", (u32 *)&pdata->power);
  440. config->multipoint = of_property_read_bool(np, "multipoint");
  441. pdata->has_mailbox = of_property_read_bool(np,
  442. "ti,has-mailbox");
  443. pdata->board_data = data;
  444. pdata->config = config;
  445. }
  446. if (pdata->has_mailbox) {
  447. glue->control_otghs = omap_get_control_dev();
  448. if (IS_ERR(glue->control_otghs)) {
  449. dev_vdbg(&pdev->dev, "Failed to get control device\n");
  450. return -ENODEV;
  451. }
  452. } else {
  453. glue->control_otghs = ERR_PTR(-ENODEV);
  454. }
  455. pdata->platform_ops = &omap2430_ops;
  456. platform_set_drvdata(pdev, glue);
  457. /*
  458. * REVISIT if we ever have two instances of the wrapper, we will be
  459. * in big trouble
  460. */
  461. _glue = glue;
  462. INIT_WORK(&glue->omap_musb_mailbox_work, omap_musb_mailbox_work);
  463. ret = platform_device_add_resources(musb, pdev->resource,
  464. pdev->num_resources);
  465. if (ret) {
  466. dev_err(&pdev->dev, "failed to add resources\n");
  467. goto err2;
  468. }
  469. ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
  470. if (ret) {
  471. dev_err(&pdev->dev, "failed to add platform_data\n");
  472. goto err2;
  473. }
  474. pm_runtime_enable(&pdev->dev);
  475. ret = platform_device_add(musb);
  476. if (ret) {
  477. dev_err(&pdev->dev, "failed to register musb device\n");
  478. goto err2;
  479. }
  480. return 0;
  481. err2:
  482. platform_device_put(musb);
  483. err0:
  484. return ret;
  485. }
  486. static int omap2430_remove(struct platform_device *pdev)
  487. {
  488. struct omap2430_glue *glue = platform_get_drvdata(pdev);
  489. cancel_work_sync(&glue->omap_musb_mailbox_work);
  490. platform_device_unregister(glue->musb);
  491. return 0;
  492. }
  493. #ifdef CONFIG_PM
  494. static int omap2430_runtime_suspend(struct device *dev)
  495. {
  496. struct omap2430_glue *glue = dev_get_drvdata(dev);
  497. struct musb *musb = glue_to_musb(glue);
  498. if (musb) {
  499. musb->context.otg_interfsel = musb_readl(musb->mregs,
  500. OTG_INTERFSEL);
  501. omap2430_low_level_exit(musb);
  502. usb_phy_set_suspend(musb->xceiv, 1);
  503. }
  504. return 0;
  505. }
  506. static int omap2430_runtime_resume(struct device *dev)
  507. {
  508. struct omap2430_glue *glue = dev_get_drvdata(dev);
  509. struct musb *musb = glue_to_musb(glue);
  510. if (musb) {
  511. omap2430_low_level_init(musb);
  512. musb_writel(musb->mregs, OTG_INTERFSEL,
  513. musb->context.otg_interfsel);
  514. usb_phy_set_suspend(musb->xceiv, 0);
  515. }
  516. return 0;
  517. }
  518. static struct dev_pm_ops omap2430_pm_ops = {
  519. .runtime_suspend = omap2430_runtime_suspend,
  520. .runtime_resume = omap2430_runtime_resume,
  521. };
  522. #define DEV_PM_OPS (&omap2430_pm_ops)
  523. #else
  524. #define DEV_PM_OPS NULL
  525. #endif
  526. #ifdef CONFIG_OF
  527. static const struct of_device_id omap2430_id_table[] = {
  528. {
  529. .compatible = "ti,omap4-musb"
  530. },
  531. {
  532. .compatible = "ti,omap3-musb"
  533. },
  534. {},
  535. };
  536. MODULE_DEVICE_TABLE(of, omap2430_id_table);
  537. #endif
  538. static struct platform_driver omap2430_driver = {
  539. .probe = omap2430_probe,
  540. .remove = omap2430_remove,
  541. .driver = {
  542. .name = "musb-omap2430",
  543. .pm = DEV_PM_OPS,
  544. .of_match_table = of_match_ptr(omap2430_id_table),
  545. },
  546. };
  547. MODULE_DESCRIPTION("OMAP2PLUS MUSB Glue Layer");
  548. MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
  549. MODULE_LICENSE("GPL v2");
  550. static int __init omap2430_init(void)
  551. {
  552. return platform_driver_register(&omap2430_driver);
  553. }
  554. subsys_initcall(omap2430_init);
  555. static void __exit omap2430_exit(void)
  556. {
  557. platform_driver_unregister(&omap2430_driver);
  558. }
  559. module_exit(omap2430_exit);