am35x.c 16 KB

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