am35x.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /*
  2. * Texas Instruments AM35x "glue layer"
  3. *
  4. * Copyright (c) 2010, by Texas Instruments
  5. *
  6. * Based on the DA8xx "glue layer" code.
  7. * Copyright (c) 2008-2009, MontaVista Software, Inc. <source@mvista.com>
  8. *
  9. * This file is part of the Inventra Controller Driver for Linux.
  10. *
  11. * The Inventra Controller Driver for Linux is free software; you
  12. * can redistribute it and/or modify it under the terms of the GNU
  13. * General Public License version 2 as published by the Free Software
  14. * Foundation.
  15. *
  16. * The Inventra Controller Driver for Linux is distributed in
  17. * the hope that it will be useful, but WITHOUT ANY WARRANTY;
  18. * without even the implied warranty of MERCHANTABILITY or
  19. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  20. * License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with The Inventra Controller Driver for Linux ; if not,
  24. * write to the Free Software Foundation, Inc., 59 Temple Place,
  25. * Suite 330, Boston, MA 02111-1307 USA
  26. *
  27. */
  28. #include <linux/module.h>
  29. #include <linux/clk.h>
  30. #include <linux/err.h>
  31. #include <linux/io.h>
  32. #include <linux/platform_device.h>
  33. #include <linux/dma-mapping.h>
  34. #include <linux/usb/usb_phy_generic.h>
  35. #include <linux/platform_data/usb-omap.h>
  36. #include "musb_core.h"
  37. /*
  38. * AM35x specific definitions
  39. */
  40. /* USB 2.0 OTG module registers */
  41. #define USB_REVISION_REG 0x00
  42. #define USB_CTRL_REG 0x04
  43. #define USB_STAT_REG 0x08
  44. #define USB_EMULATION_REG 0x0c
  45. /* 0x10 Reserved */
  46. #define USB_AUTOREQ_REG 0x14
  47. #define USB_SRP_FIX_TIME_REG 0x18
  48. #define USB_TEARDOWN_REG 0x1c
  49. #define EP_INTR_SRC_REG 0x20
  50. #define EP_INTR_SRC_SET_REG 0x24
  51. #define EP_INTR_SRC_CLEAR_REG 0x28
  52. #define EP_INTR_MASK_REG 0x2c
  53. #define EP_INTR_MASK_SET_REG 0x30
  54. #define EP_INTR_MASK_CLEAR_REG 0x34
  55. #define EP_INTR_SRC_MASKED_REG 0x38
  56. #define CORE_INTR_SRC_REG 0x40
  57. #define CORE_INTR_SRC_SET_REG 0x44
  58. #define CORE_INTR_SRC_CLEAR_REG 0x48
  59. #define CORE_INTR_MASK_REG 0x4c
  60. #define CORE_INTR_MASK_SET_REG 0x50
  61. #define CORE_INTR_MASK_CLEAR_REG 0x54
  62. #define CORE_INTR_SRC_MASKED_REG 0x58
  63. /* 0x5c Reserved */
  64. #define USB_END_OF_INTR_REG 0x60
  65. /* Control register bits */
  66. #define AM35X_SOFT_RESET_MASK 1
  67. /* USB interrupt register bits */
  68. #define AM35X_INTR_USB_SHIFT 16
  69. #define AM35X_INTR_USB_MASK (0x1ff << AM35X_INTR_USB_SHIFT)
  70. #define AM35X_INTR_DRVVBUS 0x100
  71. #define AM35X_INTR_RX_SHIFT 16
  72. #define AM35X_INTR_TX_SHIFT 0
  73. #define AM35X_TX_EP_MASK 0xffff /* EP0 + 15 Tx EPs */
  74. #define AM35X_RX_EP_MASK 0xfffe /* 15 Rx EPs */
  75. #define AM35X_TX_INTR_MASK (AM35X_TX_EP_MASK << AM35X_INTR_TX_SHIFT)
  76. #define AM35X_RX_INTR_MASK (AM35X_RX_EP_MASK << AM35X_INTR_RX_SHIFT)
  77. #define USB_MENTOR_CORE_OFFSET 0x400
  78. struct am35x_glue {
  79. struct device *dev;
  80. struct platform_device *musb;
  81. struct platform_device *phy;
  82. struct clk *phy_clk;
  83. struct clk *clk;
  84. };
  85. /*
  86. * am35x_musb_enable - enable interrupts
  87. */
  88. static void am35x_musb_enable(struct musb *musb)
  89. {
  90. void __iomem *reg_base = musb->ctrl_base;
  91. u32 epmask;
  92. /* Workaround: setup IRQs through both register sets. */
  93. epmask = ((musb->epmask & AM35X_TX_EP_MASK) << AM35X_INTR_TX_SHIFT) |
  94. ((musb->epmask & AM35X_RX_EP_MASK) << AM35X_INTR_RX_SHIFT);
  95. musb_writel(reg_base, EP_INTR_MASK_SET_REG, epmask);
  96. musb_writel(reg_base, CORE_INTR_MASK_SET_REG, AM35X_INTR_USB_MASK);
  97. /* Force the DRVVBUS IRQ so we can start polling for ID change. */
  98. musb_writel(reg_base, CORE_INTR_SRC_SET_REG,
  99. AM35X_INTR_DRVVBUS << AM35X_INTR_USB_SHIFT);
  100. }
  101. /*
  102. * am35x_musb_disable - disable HDRC and flush interrupts
  103. */
  104. static void am35x_musb_disable(struct musb *musb)
  105. {
  106. void __iomem *reg_base = musb->ctrl_base;
  107. musb_writel(reg_base, CORE_INTR_MASK_CLEAR_REG, AM35X_INTR_USB_MASK);
  108. musb_writel(reg_base, EP_INTR_MASK_CLEAR_REG,
  109. AM35X_TX_INTR_MASK | AM35X_RX_INTR_MASK);
  110. musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
  111. musb_writel(reg_base, USB_END_OF_INTR_REG, 0);
  112. }
  113. #define portstate(stmt) stmt
  114. static void am35x_musb_set_vbus(struct musb *musb, int is_on)
  115. {
  116. WARN_ON(is_on && is_peripheral_active(musb));
  117. }
  118. #define POLL_SECONDS 2
  119. static struct timer_list otg_workaround;
  120. static void otg_timer(unsigned long _musb)
  121. {
  122. struct musb *musb = (void *)_musb;
  123. void __iomem *mregs = musb->mregs;
  124. u8 devctl;
  125. unsigned long flags;
  126. /*
  127. * We poll because AM35x's won't expose several OTG-critical
  128. * status change events (from the transceiver) otherwise.
  129. */
  130. devctl = musb_readb(mregs, MUSB_DEVCTL);
  131. dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
  132. usb_otg_state_string(musb->xceiv->otg->state));
  133. spin_lock_irqsave(&musb->lock, flags);
  134. switch (musb->xceiv->otg->state) {
  135. case OTG_STATE_A_WAIT_BCON:
  136. devctl &= ~MUSB_DEVCTL_SESSION;
  137. musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
  138. devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
  139. if (devctl & MUSB_DEVCTL_BDEVICE) {
  140. musb->xceiv->otg->state = OTG_STATE_B_IDLE;
  141. MUSB_DEV_MODE(musb);
  142. } else {
  143. musb->xceiv->otg->state = OTG_STATE_A_IDLE;
  144. MUSB_HST_MODE(musb);
  145. }
  146. break;
  147. case OTG_STATE_A_WAIT_VFALL:
  148. musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
  149. musb_writel(musb->ctrl_base, CORE_INTR_SRC_SET_REG,
  150. MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT);
  151. break;
  152. case OTG_STATE_B_IDLE:
  153. devctl = musb_readb(mregs, MUSB_DEVCTL);
  154. if (devctl & MUSB_DEVCTL_BDEVICE)
  155. mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
  156. else
  157. musb->xceiv->otg->state = OTG_STATE_A_IDLE;
  158. break;
  159. default:
  160. break;
  161. }
  162. spin_unlock_irqrestore(&musb->lock, flags);
  163. }
  164. static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
  165. {
  166. static unsigned long last_timer;
  167. if (timeout == 0)
  168. timeout = jiffies + msecs_to_jiffies(3);
  169. /* Never idle if active, or when VBUS timeout is not set as host */
  170. if (musb->is_active || (musb->a_wait_bcon == 0 &&
  171. musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
  172. dev_dbg(musb->controller, "%s active, deleting timer\n",
  173. usb_otg_state_string(musb->xceiv->otg->state));
  174. del_timer(&otg_workaround);
  175. last_timer = jiffies;
  176. return;
  177. }
  178. if (time_after(last_timer, timeout) && timer_pending(&otg_workaround)) {
  179. dev_dbg(musb->controller, "Longer idle timer already pending, ignoring...\n");
  180. return;
  181. }
  182. last_timer = timeout;
  183. dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
  184. usb_otg_state_string(musb->xceiv->otg->state),
  185. jiffies_to_msecs(timeout - jiffies));
  186. mod_timer(&otg_workaround, timeout);
  187. }
  188. static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
  189. {
  190. struct musb *musb = hci;
  191. void __iomem *reg_base = musb->ctrl_base;
  192. struct device *dev = musb->controller;
  193. struct musb_hdrc_platform_data *plat = dev_get_platdata(dev);
  194. struct omap_musb_board_data *data = plat->board_data;
  195. struct usb_otg *otg = musb->xceiv->otg;
  196. unsigned long flags;
  197. irqreturn_t ret = IRQ_NONE;
  198. u32 epintr, usbintr;
  199. spin_lock_irqsave(&musb->lock, flags);
  200. /* Get endpoint interrupts */
  201. epintr = musb_readl(reg_base, EP_INTR_SRC_MASKED_REG);
  202. if (epintr) {
  203. musb_writel(reg_base, EP_INTR_SRC_CLEAR_REG, epintr);
  204. musb->int_rx =
  205. (epintr & AM35X_RX_INTR_MASK) >> AM35X_INTR_RX_SHIFT;
  206. musb->int_tx =
  207. (epintr & AM35X_TX_INTR_MASK) >> AM35X_INTR_TX_SHIFT;
  208. }
  209. /* Get usb core interrupts */
  210. usbintr = musb_readl(reg_base, CORE_INTR_SRC_MASKED_REG);
  211. if (!usbintr && !epintr)
  212. goto eoi;
  213. if (usbintr) {
  214. musb_writel(reg_base, CORE_INTR_SRC_CLEAR_REG, usbintr);
  215. musb->int_usb =
  216. (usbintr & AM35X_INTR_USB_MASK) >> AM35X_INTR_USB_SHIFT;
  217. }
  218. /*
  219. * DRVVBUS IRQs are the only proxy we have (a very poor one!) for
  220. * AM35x's missing ID change IRQ. We need an ID change IRQ to
  221. * switch appropriately between halves of the OTG state machine.
  222. * Managing DEVCTL.SESSION per Mentor docs requires that we know its
  223. * value but DEVCTL.BDEVICE is invalid without DEVCTL.SESSION set.
  224. * Also, DRVVBUS pulses for SRP (but not at 5V) ...
  225. */
  226. if (usbintr & (AM35X_INTR_DRVVBUS << AM35X_INTR_USB_SHIFT)) {
  227. int drvvbus = musb_readl(reg_base, USB_STAT_REG);
  228. void __iomem *mregs = musb->mregs;
  229. u8 devctl = musb_readb(mregs, MUSB_DEVCTL);
  230. int err;
  231. err = musb->int_usb & MUSB_INTR_VBUSERROR;
  232. if (err) {
  233. /*
  234. * The Mentor core doesn't debounce VBUS as needed
  235. * to cope with device connect current spikes. This
  236. * means it's not uncommon for bus-powered devices
  237. * to get VBUS errors during enumeration.
  238. *
  239. * This is a workaround, but newer RTL from Mentor
  240. * seems to allow a better one: "re"-starting sessions
  241. * without waiting for VBUS to stop registering in
  242. * devctl.
  243. */
  244. musb->int_usb &= ~MUSB_INTR_VBUSERROR;
  245. musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
  246. mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
  247. WARNING("VBUS error workaround (delay coming)\n");
  248. } else if (drvvbus) {
  249. MUSB_HST_MODE(musb);
  250. otg->default_a = 1;
  251. musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
  252. portstate(musb->port1_status |= USB_PORT_STAT_POWER);
  253. del_timer(&otg_workaround);
  254. } else {
  255. musb->is_active = 0;
  256. MUSB_DEV_MODE(musb);
  257. otg->default_a = 0;
  258. musb->xceiv->otg->state = OTG_STATE_B_IDLE;
  259. portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
  260. }
  261. /* NOTE: this must complete power-on within 100 ms. */
  262. dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
  263. drvvbus ? "on" : "off",
  264. usb_otg_state_string(musb->xceiv->otg->state),
  265. err ? " ERROR" : "",
  266. devctl);
  267. ret = IRQ_HANDLED;
  268. }
  269. /* Drop spurious RX and TX if device is disconnected */
  270. if (musb->int_usb & MUSB_INTR_DISCONNECT) {
  271. musb->int_tx = 0;
  272. musb->int_rx = 0;
  273. }
  274. if (musb->int_tx || musb->int_rx || musb->int_usb)
  275. ret |= musb_interrupt(musb);
  276. eoi:
  277. /* EOI needs to be written for the IRQ to be re-asserted. */
  278. if (ret == IRQ_HANDLED || epintr || usbintr) {
  279. /* clear level interrupt */
  280. if (data->clear_irq)
  281. data->clear_irq();
  282. /* write EOI */
  283. musb_writel(reg_base, USB_END_OF_INTR_REG, 0);
  284. }
  285. /* Poll for ID change */
  286. if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
  287. mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
  288. spin_unlock_irqrestore(&musb->lock, flags);
  289. return ret;
  290. }
  291. static int am35x_musb_set_mode(struct musb *musb, u8 musb_mode)
  292. {
  293. struct device *dev = musb->controller;
  294. struct musb_hdrc_platform_data *plat = dev_get_platdata(dev);
  295. struct omap_musb_board_data *data = plat->board_data;
  296. int retval = 0;
  297. if (data->set_mode)
  298. data->set_mode(musb_mode);
  299. else
  300. retval = -EIO;
  301. return retval;
  302. }
  303. static int am35x_musb_init(struct musb *musb)
  304. {
  305. struct device *dev = musb->controller;
  306. struct musb_hdrc_platform_data *plat = dev_get_platdata(dev);
  307. struct omap_musb_board_data *data = plat->board_data;
  308. void __iomem *reg_base = musb->ctrl_base;
  309. u32 rev;
  310. musb->mregs += USB_MENTOR_CORE_OFFSET;
  311. /* Returns zero if e.g. not clocked */
  312. rev = musb_readl(reg_base, USB_REVISION_REG);
  313. if (!rev)
  314. return -ENODEV;
  315. musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
  316. if (IS_ERR_OR_NULL(musb->xceiv))
  317. return -EPROBE_DEFER;
  318. setup_timer(&otg_workaround, otg_timer, (unsigned long) musb);
  319. /* Reset the musb */
  320. if (data->reset)
  321. data->reset();
  322. /* Reset the controller */
  323. musb_writel(reg_base, USB_CTRL_REG, AM35X_SOFT_RESET_MASK);
  324. /* Start the on-chip PHY and its PLL. */
  325. if (data->set_phy_power)
  326. data->set_phy_power(1);
  327. msleep(5);
  328. musb->isr = am35x_musb_interrupt;
  329. /* clear level interrupt */
  330. if (data->clear_irq)
  331. data->clear_irq();
  332. return 0;
  333. }
  334. static int am35x_musb_exit(struct musb *musb)
  335. {
  336. struct device *dev = musb->controller;
  337. struct musb_hdrc_platform_data *plat = dev_get_platdata(dev);
  338. struct omap_musb_board_data *data = plat->board_data;
  339. del_timer_sync(&otg_workaround);
  340. /* Shutdown the on-chip PHY and its PLL. */
  341. if (data->set_phy_power)
  342. data->set_phy_power(0);
  343. usb_put_phy(musb->xceiv);
  344. return 0;
  345. }
  346. /* AM35x supports only 32bit read operation */
  347. static void am35x_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
  348. {
  349. void __iomem *fifo = hw_ep->fifo;
  350. u32 val;
  351. int i;
  352. /* Read for 32bit-aligned destination address */
  353. if (likely((0x03 & (unsigned long) dst) == 0) && len >= 4) {
  354. readsl(fifo, dst, len >> 2);
  355. dst += len & ~0x03;
  356. len &= 0x03;
  357. }
  358. /*
  359. * Now read the remaining 1 to 3 byte or complete length if
  360. * unaligned address.
  361. */
  362. if (len > 4) {
  363. for (i = 0; i < (len >> 2); i++) {
  364. *(u32 *) dst = musb_readl(fifo, 0);
  365. dst += 4;
  366. }
  367. len &= 0x03;
  368. }
  369. if (len > 0) {
  370. val = musb_readl(fifo, 0);
  371. memcpy(dst, &val, len);
  372. }
  373. }
  374. static const struct musb_platform_ops am35x_ops = {
  375. .quirks = MUSB_DMA_INVENTRA | MUSB_INDEXED_EP,
  376. .init = am35x_musb_init,
  377. .exit = am35x_musb_exit,
  378. .read_fifo = am35x_read_fifo,
  379. #ifdef CONFIG_USB_INVENTRA_DMA
  380. .dma_init = musbhs_dma_controller_create,
  381. .dma_exit = musbhs_dma_controller_destroy,
  382. #endif
  383. .enable = am35x_musb_enable,
  384. .disable = am35x_musb_disable,
  385. .set_mode = am35x_musb_set_mode,
  386. .try_idle = am35x_musb_try_idle,
  387. .set_vbus = am35x_musb_set_vbus,
  388. };
  389. static const struct platform_device_info am35x_dev_info = {
  390. .name = "musb-hdrc",
  391. .id = PLATFORM_DEVID_AUTO,
  392. .dma_mask = DMA_BIT_MASK(32),
  393. };
  394. static int am35x_probe(struct platform_device *pdev)
  395. {
  396. struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev);
  397. struct platform_device *musb;
  398. struct am35x_glue *glue;
  399. struct platform_device_info pinfo;
  400. struct clk *phy_clk;
  401. struct clk *clk;
  402. int ret = -ENOMEM;
  403. glue = kzalloc(sizeof(*glue), GFP_KERNEL);
  404. if (!glue) {
  405. dev_err(&pdev->dev, "failed to allocate glue context\n");
  406. goto err0;
  407. }
  408. phy_clk = clk_get(&pdev->dev, "fck");
  409. if (IS_ERR(phy_clk)) {
  410. dev_err(&pdev->dev, "failed to get PHY clock\n");
  411. ret = PTR_ERR(phy_clk);
  412. goto err3;
  413. }
  414. clk = clk_get(&pdev->dev, "ick");
  415. if (IS_ERR(clk)) {
  416. dev_err(&pdev->dev, "failed to get clock\n");
  417. ret = PTR_ERR(clk);
  418. goto err4;
  419. }
  420. ret = clk_enable(phy_clk);
  421. if (ret) {
  422. dev_err(&pdev->dev, "failed to enable PHY clock\n");
  423. goto err5;
  424. }
  425. ret = clk_enable(clk);
  426. if (ret) {
  427. dev_err(&pdev->dev, "failed to enable clock\n");
  428. goto err6;
  429. }
  430. glue->dev = &pdev->dev;
  431. glue->phy_clk = phy_clk;
  432. glue->clk = clk;
  433. pdata->platform_ops = &am35x_ops;
  434. glue->phy = usb_phy_generic_register();
  435. if (IS_ERR(glue->phy))
  436. goto err7;
  437. platform_set_drvdata(pdev, glue);
  438. pinfo = am35x_dev_info;
  439. pinfo.parent = &pdev->dev;
  440. pinfo.res = pdev->resource;
  441. pinfo.num_res = pdev->num_resources;
  442. pinfo.data = pdata;
  443. pinfo.size_data = sizeof(*pdata);
  444. glue->musb = musb = platform_device_register_full(&pinfo);
  445. if (IS_ERR(musb)) {
  446. ret = PTR_ERR(musb);
  447. dev_err(&pdev->dev, "failed to register musb device: %d\n", ret);
  448. goto err8;
  449. }
  450. return 0;
  451. err8:
  452. usb_phy_generic_unregister(glue->phy);
  453. err7:
  454. clk_disable(clk);
  455. err6:
  456. clk_disable(phy_clk);
  457. err5:
  458. clk_put(clk);
  459. err4:
  460. clk_put(phy_clk);
  461. err3:
  462. kfree(glue);
  463. err0:
  464. return ret;
  465. }
  466. static int am35x_remove(struct platform_device *pdev)
  467. {
  468. struct am35x_glue *glue = platform_get_drvdata(pdev);
  469. platform_device_unregister(glue->musb);
  470. usb_phy_generic_unregister(glue->phy);
  471. clk_disable(glue->clk);
  472. clk_disable(glue->phy_clk);
  473. clk_put(glue->clk);
  474. clk_put(glue->phy_clk);
  475. kfree(glue);
  476. return 0;
  477. }
  478. #ifdef CONFIG_PM_SLEEP
  479. static int am35x_suspend(struct device *dev)
  480. {
  481. struct am35x_glue *glue = dev_get_drvdata(dev);
  482. struct musb_hdrc_platform_data *plat = dev_get_platdata(dev);
  483. struct omap_musb_board_data *data = plat->board_data;
  484. /* Shutdown the on-chip PHY and its PLL. */
  485. if (data->set_phy_power)
  486. data->set_phy_power(0);
  487. clk_disable(glue->phy_clk);
  488. clk_disable(glue->clk);
  489. return 0;
  490. }
  491. static int am35x_resume(struct device *dev)
  492. {
  493. struct am35x_glue *glue = dev_get_drvdata(dev);
  494. struct musb_hdrc_platform_data *plat = dev_get_platdata(dev);
  495. struct omap_musb_board_data *data = plat->board_data;
  496. int ret;
  497. /* Start the on-chip PHY and its PLL. */
  498. if (data->set_phy_power)
  499. data->set_phy_power(1);
  500. ret = clk_enable(glue->phy_clk);
  501. if (ret) {
  502. dev_err(dev, "failed to enable PHY clock\n");
  503. return ret;
  504. }
  505. ret = clk_enable(glue->clk);
  506. if (ret) {
  507. dev_err(dev, "failed to enable clock\n");
  508. return ret;
  509. }
  510. return 0;
  511. }
  512. #endif
  513. static SIMPLE_DEV_PM_OPS(am35x_pm_ops, am35x_suspend, am35x_resume);
  514. static struct platform_driver am35x_driver = {
  515. .probe = am35x_probe,
  516. .remove = am35x_remove,
  517. .driver = {
  518. .name = "musb-am35x",
  519. .pm = &am35x_pm_ops,
  520. },
  521. };
  522. MODULE_DESCRIPTION("AM35x MUSB Glue Layer");
  523. MODULE_AUTHOR("Ajay Kumar Gupta <ajay.gupta@ti.com>");
  524. MODULE_LICENSE("GPL v2");
  525. module_platform_driver(am35x_driver);