omap2430.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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.h>
  40. #include <linux/phy/omap_control_phy.h>
  41. #include <linux/of_platform.h>
  42. #include "musb_core.h"
  43. #include "omap2430.h"
  44. struct omap2430_glue {
  45. struct device *dev;
  46. struct platform_device *musb;
  47. enum musb_vbus_id_status status;
  48. struct work_struct omap_musb_mailbox_work;
  49. struct device *control_otghs;
  50. bool cable_connected;
  51. bool enabled;
  52. bool powered;
  53. };
  54. #define glue_to_musb(g) platform_get_drvdata(g->musb)
  55. static struct omap2430_glue *_glue;
  56. static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
  57. {
  58. struct usb_otg *otg = musb->xceiv->otg;
  59. u8 devctl;
  60. unsigned long timeout = jiffies + msecs_to_jiffies(1000);
  61. /* HDRC controls CPEN, but beware current surges during device
  62. * connect. They can trigger transient overcurrent conditions
  63. * that must be ignored.
  64. */
  65. devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
  66. if (is_on) {
  67. if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
  68. int loops = 100;
  69. /* start the session */
  70. devctl |= MUSB_DEVCTL_SESSION;
  71. musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
  72. /*
  73. * Wait for the musb to set as A device to enable the
  74. * VBUS
  75. */
  76. while (musb_readb(musb->mregs, MUSB_DEVCTL) &
  77. MUSB_DEVCTL_BDEVICE) {
  78. mdelay(5);
  79. cpu_relax();
  80. if (time_after(jiffies, timeout)
  81. || loops-- <= 0) {
  82. dev_err(musb->controller,
  83. "configured as A device timeout");
  84. break;
  85. }
  86. }
  87. otg_set_vbus(otg, 1);
  88. } else {
  89. musb->is_active = 1;
  90. otg->default_a = 1;
  91. musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
  92. devctl |= MUSB_DEVCTL_SESSION;
  93. MUSB_HST_MODE(musb);
  94. }
  95. } else {
  96. musb->is_active = 0;
  97. /* NOTE: we're skipping A_WAIT_VFALL -> A_IDLE and
  98. * jumping right to B_IDLE...
  99. */
  100. otg->default_a = 0;
  101. musb->xceiv->otg->state = OTG_STATE_B_IDLE;
  102. devctl &= ~MUSB_DEVCTL_SESSION;
  103. MUSB_DEV_MODE(musb);
  104. }
  105. musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
  106. dev_dbg(musb->controller, "VBUS %s, devctl %02x "
  107. /* otg %3x conf %08x prcm %08x */ "\n",
  108. usb_otg_state_string(musb->xceiv->otg->state),
  109. musb_readb(musb->mregs, MUSB_DEVCTL));
  110. }
  111. static inline void omap2430_low_level_exit(struct musb *musb)
  112. {
  113. u32 l;
  114. /* in any role */
  115. l = musb_readl(musb->mregs, OTG_FORCESTDBY);
  116. l |= ENABLEFORCE; /* enable MSTANDBY */
  117. musb_writel(musb->mregs, OTG_FORCESTDBY, l);
  118. }
  119. static inline void omap2430_low_level_init(struct musb *musb)
  120. {
  121. u32 l;
  122. l = musb_readl(musb->mregs, OTG_FORCESTDBY);
  123. l &= ~ENABLEFORCE; /* disable MSTANDBY */
  124. musb_writel(musb->mregs, OTG_FORCESTDBY, l);
  125. }
  126. /*
  127. * We can get multiple cable events so we need to keep track
  128. * of the power state. Only keep power enabled if USB cable is
  129. * connected and a gadget is started.
  130. */
  131. static void omap2430_set_power(struct musb *musb, bool enabled, bool cable)
  132. {
  133. struct device *dev = musb->controller;
  134. struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
  135. bool power_up;
  136. int res;
  137. if (glue->enabled != enabled)
  138. glue->enabled = enabled;
  139. if (glue->cable_connected != cable)
  140. glue->cable_connected = cable;
  141. power_up = glue->enabled && glue->cable_connected;
  142. if (power_up == glue->powered) {
  143. dev_warn(musb->controller, "power state already %i\n",
  144. power_up);
  145. return;
  146. }
  147. glue->powered = power_up;
  148. if (power_up) {
  149. res = pm_runtime_get_sync(musb->controller);
  150. if (res < 0) {
  151. dev_err(musb->controller, "could not enable: %i", res);
  152. glue->powered = false;
  153. }
  154. } else {
  155. pm_runtime_mark_last_busy(musb->controller);
  156. pm_runtime_put_autosuspend(musb->controller);
  157. }
  158. }
  159. static int omap2430_musb_mailbox(enum musb_vbus_id_status status)
  160. {
  161. struct omap2430_glue *glue = _glue;
  162. if (!glue) {
  163. pr_err("%s: musb core is not yet initialized\n", __func__);
  164. return -EPROBE_DEFER;
  165. }
  166. glue->status = status;
  167. if (!glue_to_musb(glue)) {
  168. pr_err("%s: musb core is not yet ready\n", __func__);
  169. return -EPROBE_DEFER;
  170. }
  171. schedule_work(&glue->omap_musb_mailbox_work);
  172. return 0;
  173. }
  174. static void omap_musb_set_mailbox(struct omap2430_glue *glue)
  175. {
  176. struct musb *musb = glue_to_musb(glue);
  177. struct device *dev = musb->controller;
  178. struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev);
  179. struct omap_musb_board_data *data = pdata->board_data;
  180. struct usb_otg *otg = musb->xceiv->otg;
  181. bool cable_connected;
  182. cable_connected = ((glue->status == MUSB_ID_GROUND) ||
  183. (glue->status == MUSB_VBUS_VALID));
  184. if (cable_connected)
  185. omap2430_set_power(musb, glue->enabled, cable_connected);
  186. switch (glue->status) {
  187. case MUSB_ID_GROUND:
  188. dev_dbg(dev, "ID GND\n");
  189. otg->default_a = true;
  190. musb->xceiv->otg->state = OTG_STATE_A_IDLE;
  191. musb->xceiv->last_event = USB_EVENT_ID;
  192. if (musb->gadget_driver) {
  193. omap_control_usb_set_mode(glue->control_otghs,
  194. USB_MODE_HOST);
  195. omap2430_musb_set_vbus(musb, 1);
  196. }
  197. break;
  198. case MUSB_VBUS_VALID:
  199. dev_dbg(dev, "VBUS Connect\n");
  200. otg->default_a = false;
  201. musb->xceiv->otg->state = OTG_STATE_B_IDLE;
  202. musb->xceiv->last_event = USB_EVENT_VBUS;
  203. omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
  204. break;
  205. case MUSB_ID_FLOAT:
  206. case MUSB_VBUS_OFF:
  207. dev_dbg(dev, "VBUS Disconnect\n");
  208. musb->xceiv->last_event = USB_EVENT_NONE;
  209. if (musb->gadget_driver)
  210. omap2430_musb_set_vbus(musb, 0);
  211. if (data->interface_type == MUSB_INTERFACE_UTMI)
  212. otg_set_vbus(musb->xceiv->otg, 0);
  213. omap_control_usb_set_mode(glue->control_otghs,
  214. USB_MODE_DISCONNECT);
  215. break;
  216. default:
  217. dev_dbg(dev, "ID float\n");
  218. }
  219. if (!cable_connected)
  220. omap2430_set_power(musb, glue->enabled, cable_connected);
  221. atomic_notifier_call_chain(&musb->xceiv->notifier,
  222. musb->xceiv->last_event, NULL);
  223. }
  224. static void omap_musb_mailbox_work(struct work_struct *mailbox_work)
  225. {
  226. struct omap2430_glue *glue = container_of(mailbox_work,
  227. struct omap2430_glue, omap_musb_mailbox_work);
  228. omap_musb_set_mailbox(glue);
  229. }
  230. static irqreturn_t omap2430_musb_interrupt(int irq, void *__hci)
  231. {
  232. unsigned long flags;
  233. irqreturn_t retval = IRQ_NONE;
  234. struct musb *musb = __hci;
  235. spin_lock_irqsave(&musb->lock, flags);
  236. musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB);
  237. musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX);
  238. musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX);
  239. if (musb->int_usb || musb->int_tx || musb->int_rx)
  240. retval = musb_interrupt(musb);
  241. spin_unlock_irqrestore(&musb->lock, flags);
  242. return retval;
  243. }
  244. static int omap2430_musb_init(struct musb *musb)
  245. {
  246. u32 l;
  247. int status = 0;
  248. struct device *dev = musb->controller;
  249. struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
  250. struct musb_hdrc_platform_data *plat = dev_get_platdata(dev);
  251. struct omap_musb_board_data *data = plat->board_data;
  252. /* We require some kind of external transceiver, hooked
  253. * up through ULPI. TWL4030-family PMICs include one,
  254. * which needs a driver, drivers aren't always needed.
  255. */
  256. if (dev->parent->of_node) {
  257. musb->phy = devm_phy_get(dev->parent, "usb2-phy");
  258. /* We can't totally remove musb->xceiv as of now because
  259. * musb core uses xceiv.state and xceiv.otg. Once we have
  260. * a separate state machine to handle otg, these can be moved
  261. * out of xceiv and then we can start using the generic PHY
  262. * framework
  263. */
  264. musb->xceiv = devm_usb_get_phy_by_phandle(dev->parent,
  265. "usb-phy", 0);
  266. } else {
  267. musb->xceiv = devm_usb_get_phy_dev(dev, 0);
  268. musb->phy = devm_phy_get(dev, "usb");
  269. }
  270. if (IS_ERR(musb->xceiv)) {
  271. status = PTR_ERR(musb->xceiv);
  272. if (status == -ENXIO)
  273. return status;
  274. pr_err("HS USB OTG: no transceiver configured\n");
  275. return -EPROBE_DEFER;
  276. }
  277. if (IS_ERR(musb->phy)) {
  278. pr_err("HS USB OTG: no PHY configured\n");
  279. return PTR_ERR(musb->phy);
  280. }
  281. musb->isr = omap2430_musb_interrupt;
  282. phy_init(musb->phy);
  283. l = musb_readl(musb->mregs, OTG_INTERFSEL);
  284. if (data->interface_type == MUSB_INTERFACE_UTMI) {
  285. /* OMAP4 uses Internal PHY GS70 which uses UTMI interface */
  286. l &= ~ULPI_12PIN; /* Disable ULPI */
  287. l |= UTMI_8BIT; /* Enable UTMI */
  288. } else {
  289. l |= ULPI_12PIN;
  290. }
  291. musb_writel(musb->mregs, OTG_INTERFSEL, l);
  292. pr_debug("HS USB OTG: revision 0x%x, sysconfig 0x%02x, "
  293. "sysstatus 0x%x, intrfsel 0x%x, simenable 0x%x\n",
  294. musb_readl(musb->mregs, OTG_REVISION),
  295. musb_readl(musb->mregs, OTG_SYSCONFIG),
  296. musb_readl(musb->mregs, OTG_SYSSTATUS),
  297. musb_readl(musb->mregs, OTG_INTERFSEL),
  298. musb_readl(musb->mregs, OTG_SIMENABLE));
  299. if (glue->status != MUSB_UNKNOWN)
  300. omap_musb_set_mailbox(glue);
  301. return 0;
  302. }
  303. static void omap2430_musb_enable(struct musb *musb)
  304. {
  305. u8 devctl;
  306. unsigned long timeout = jiffies + msecs_to_jiffies(1000);
  307. struct device *dev = musb->controller;
  308. struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
  309. struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev);
  310. struct omap_musb_board_data *data = pdata->board_data;
  311. if (!WARN_ON(!musb->phy))
  312. phy_power_on(musb->phy);
  313. omap2430_set_power(musb, true, glue->cable_connected);
  314. switch (glue->status) {
  315. case MUSB_ID_GROUND:
  316. omap_control_usb_set_mode(glue->control_otghs, USB_MODE_HOST);
  317. if (data->interface_type != MUSB_INTERFACE_UTMI)
  318. break;
  319. devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
  320. /* start the session */
  321. devctl |= MUSB_DEVCTL_SESSION;
  322. musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
  323. while (musb_readb(musb->mregs, MUSB_DEVCTL) &
  324. MUSB_DEVCTL_BDEVICE) {
  325. cpu_relax();
  326. if (time_after(jiffies, timeout)) {
  327. dev_err(dev, "configured as A device timeout");
  328. break;
  329. }
  330. }
  331. break;
  332. case MUSB_VBUS_VALID:
  333. omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
  334. break;
  335. default:
  336. break;
  337. }
  338. }
  339. static void omap2430_musb_disable(struct musb *musb)
  340. {
  341. struct device *dev = musb->controller;
  342. struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
  343. if (!WARN_ON(!musb->phy))
  344. phy_power_off(musb->phy);
  345. if (glue->status != MUSB_UNKNOWN)
  346. omap_control_usb_set_mode(glue->control_otghs,
  347. USB_MODE_DISCONNECT);
  348. omap2430_set_power(musb, false, glue->cable_connected);
  349. }
  350. static int omap2430_musb_exit(struct musb *musb)
  351. {
  352. struct device *dev = musb->controller;
  353. struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
  354. omap2430_low_level_exit(musb);
  355. phy_exit(musb->phy);
  356. musb->phy = NULL;
  357. cancel_work_sync(&glue->omap_musb_mailbox_work);
  358. return 0;
  359. }
  360. static const struct musb_platform_ops omap2430_ops = {
  361. .quirks = MUSB_DMA_INVENTRA,
  362. #ifdef CONFIG_USB_INVENTRA_DMA
  363. .dma_init = musbhs_dma_controller_create,
  364. .dma_exit = musbhs_dma_controller_destroy,
  365. #endif
  366. .init = omap2430_musb_init,
  367. .exit = omap2430_musb_exit,
  368. .set_vbus = omap2430_musb_set_vbus,
  369. .enable = omap2430_musb_enable,
  370. .disable = omap2430_musb_disable,
  371. .phy_callback = omap2430_musb_mailbox,
  372. };
  373. static u64 omap2430_dmamask = DMA_BIT_MASK(32);
  374. static int omap2430_probe(struct platform_device *pdev)
  375. {
  376. struct resource musb_resources[3];
  377. struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev);
  378. struct omap_musb_board_data *data;
  379. struct platform_device *musb;
  380. struct omap2430_glue *glue;
  381. struct device_node *np = pdev->dev.of_node;
  382. struct musb_hdrc_config *config;
  383. int ret = -ENOMEM, val;
  384. glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
  385. if (!glue)
  386. goto err0;
  387. musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
  388. if (!musb) {
  389. dev_err(&pdev->dev, "failed to allocate musb device\n");
  390. goto err0;
  391. }
  392. musb->dev.parent = &pdev->dev;
  393. musb->dev.dma_mask = &omap2430_dmamask;
  394. musb->dev.coherent_dma_mask = omap2430_dmamask;
  395. glue->dev = &pdev->dev;
  396. glue->musb = musb;
  397. glue->status = MUSB_UNKNOWN;
  398. glue->control_otghs = ERR_PTR(-ENODEV);
  399. if (np) {
  400. struct device_node *control_node;
  401. struct platform_device *control_pdev;
  402. pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
  403. if (!pdata)
  404. goto err2;
  405. data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
  406. if (!data)
  407. goto err2;
  408. config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
  409. if (!config)
  410. goto err2;
  411. of_property_read_u32(np, "mode", (u32 *)&pdata->mode);
  412. of_property_read_u32(np, "interface-type",
  413. (u32 *)&data->interface_type);
  414. of_property_read_u32(np, "num-eps", (u32 *)&config->num_eps);
  415. of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits);
  416. of_property_read_u32(np, "power", (u32 *)&pdata->power);
  417. ret = of_property_read_u32(np, "multipoint", &val);
  418. if (!ret && val)
  419. config->multipoint = true;
  420. pdata->board_data = data;
  421. pdata->config = config;
  422. control_node = of_parse_phandle(np, "ctrl-module", 0);
  423. if (control_node) {
  424. control_pdev = of_find_device_by_node(control_node);
  425. if (!control_pdev) {
  426. dev_err(&pdev->dev, "Failed to get control device\n");
  427. ret = -EINVAL;
  428. goto err2;
  429. }
  430. glue->control_otghs = &control_pdev->dev;
  431. }
  432. }
  433. pdata->platform_ops = &omap2430_ops;
  434. platform_set_drvdata(pdev, glue);
  435. /*
  436. * REVISIT if we ever have two instances of the wrapper, we will be
  437. * in big trouble
  438. */
  439. _glue = glue;
  440. INIT_WORK(&glue->omap_musb_mailbox_work, omap_musb_mailbox_work);
  441. memset(musb_resources, 0x00, sizeof(*musb_resources) *
  442. ARRAY_SIZE(musb_resources));
  443. musb_resources[0].name = pdev->resource[0].name;
  444. musb_resources[0].start = pdev->resource[0].start;
  445. musb_resources[0].end = pdev->resource[0].end;
  446. musb_resources[0].flags = pdev->resource[0].flags;
  447. musb_resources[1].name = pdev->resource[1].name;
  448. musb_resources[1].start = pdev->resource[1].start;
  449. musb_resources[1].end = pdev->resource[1].end;
  450. musb_resources[1].flags = pdev->resource[1].flags;
  451. musb_resources[2].name = pdev->resource[2].name;
  452. musb_resources[2].start = pdev->resource[2].start;
  453. musb_resources[2].end = pdev->resource[2].end;
  454. musb_resources[2].flags = pdev->resource[2].flags;
  455. ret = platform_device_add_resources(musb, musb_resources,
  456. ARRAY_SIZE(musb_resources));
  457. if (ret) {
  458. dev_err(&pdev->dev, "failed to add resources\n");
  459. goto err2;
  460. }
  461. ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
  462. if (ret) {
  463. dev_err(&pdev->dev, "failed to add platform_data\n");
  464. goto err2;
  465. }
  466. pm_runtime_enable(glue->dev);
  467. pm_runtime_use_autosuspend(glue->dev);
  468. pm_runtime_set_autosuspend_delay(glue->dev, 500);
  469. ret = platform_device_add(musb);
  470. if (ret) {
  471. dev_err(&pdev->dev, "failed to register musb device\n");
  472. goto err2;
  473. }
  474. return 0;
  475. err2:
  476. platform_device_put(musb);
  477. err0:
  478. return ret;
  479. }
  480. static int omap2430_remove(struct platform_device *pdev)
  481. {
  482. struct omap2430_glue *glue = platform_get_drvdata(pdev);
  483. struct musb *musb = glue_to_musb(glue);
  484. pm_runtime_get_sync(glue->dev);
  485. platform_device_unregister(glue->musb);
  486. omap2430_set_power(musb, false, false);
  487. pm_runtime_put_sync(glue->dev);
  488. pm_runtime_dont_use_autosuspend(glue->dev);
  489. pm_runtime_disable(glue->dev);
  490. return 0;
  491. }
  492. #ifdef CONFIG_PM
  493. static int omap2430_runtime_suspend(struct device *dev)
  494. {
  495. struct omap2430_glue *glue = dev_get_drvdata(dev);
  496. struct musb *musb = glue_to_musb(glue);
  497. if (!musb)
  498. return 0;
  499. musb->context.otg_interfsel = musb_readl(musb->mregs,
  500. OTG_INTERFSEL);
  501. omap2430_low_level_exit(musb);
  502. return 0;
  503. }
  504. static int omap2430_runtime_resume(struct device *dev)
  505. {
  506. struct omap2430_glue *glue = dev_get_drvdata(dev);
  507. struct musb *musb = glue_to_musb(glue);
  508. if (!musb)
  509. return 0;
  510. omap2430_low_level_init(musb);
  511. musb_writel(musb->mregs, OTG_INTERFSEL,
  512. musb->context.otg_interfsel);
  513. return 0;
  514. }
  515. static struct dev_pm_ops omap2430_pm_ops = {
  516. .runtime_suspend = omap2430_runtime_suspend,
  517. .runtime_resume = omap2430_runtime_resume,
  518. };
  519. #define DEV_PM_OPS (&omap2430_pm_ops)
  520. #else
  521. #define DEV_PM_OPS NULL
  522. #endif
  523. #ifdef CONFIG_OF
  524. static const struct of_device_id omap2430_id_table[] = {
  525. {
  526. .compatible = "ti,omap4-musb"
  527. },
  528. {
  529. .compatible = "ti,omap3-musb"
  530. },
  531. {},
  532. };
  533. MODULE_DEVICE_TABLE(of, omap2430_id_table);
  534. #endif
  535. static struct platform_driver omap2430_driver = {
  536. .probe = omap2430_probe,
  537. .remove = omap2430_remove,
  538. .driver = {
  539. .name = "musb-omap2430",
  540. .pm = DEV_PM_OPS,
  541. .of_match_table = of_match_ptr(omap2430_id_table),
  542. },
  543. };
  544. module_platform_driver(omap2430_driver);
  545. MODULE_DESCRIPTION("OMAP2PLUS MUSB Glue Layer");
  546. MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
  547. MODULE_LICENSE("GPL v2");