da8xx.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. /*
  2. * Texas Instruments DA8xx/OMAP-L1x "glue layer"
  3. *
  4. * Copyright (c) 2008-2009 MontaVista Software, Inc. <source@mvista.com>
  5. *
  6. * Based on the DaVinci "glue layer" code.
  7. * Copyright (C) 2005-2006 by Texas Instruments
  8. *
  9. * DT support
  10. * Copyright (c) 2016 Petr Kulhavy <petr@barix.com>
  11. *
  12. * This file is part of the Inventra Controller Driver for Linux.
  13. *
  14. * The Inventra Controller Driver for Linux is free software; you
  15. * can redistribute it and/or modify it under the terms of the GNU
  16. * General Public License version 2 as published by the Free Software
  17. * Foundation.
  18. *
  19. * The Inventra Controller Driver for Linux is distributed in
  20. * the hope that it will be useful, but WITHOUT ANY WARRANTY;
  21. * without even the implied warranty of MERCHANTABILITY or
  22. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  23. * License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with The Inventra Controller Driver for Linux ; if not,
  27. * write to the Free Software Foundation, Inc., 59 Temple Place,
  28. * Suite 330, Boston, MA 02111-1307 USA
  29. *
  30. */
  31. #include <linux/module.h>
  32. #include <linux/clk.h>
  33. #include <linux/err.h>
  34. #include <linux/io.h>
  35. #include <linux/phy/phy.h>
  36. #include <linux/platform_device.h>
  37. #include <linux/dma-mapping.h>
  38. #include <linux/usb/usb_phy_generic.h>
  39. #include "musb_core.h"
  40. /*
  41. * DA8XX specific definitions
  42. */
  43. /* USB 2.0 OTG module registers */
  44. #define DA8XX_USB_REVISION_REG 0x00
  45. #define DA8XX_USB_CTRL_REG 0x04
  46. #define DA8XX_USB_STAT_REG 0x08
  47. #define DA8XX_USB_EMULATION_REG 0x0c
  48. #define DA8XX_USB_MODE_REG 0x10 /* Transparent, CDC, [Generic] RNDIS */
  49. #define DA8XX_USB_AUTOREQ_REG 0x14
  50. #define DA8XX_USB_SRP_FIX_TIME_REG 0x18
  51. #define DA8XX_USB_TEARDOWN_REG 0x1c
  52. #define DA8XX_USB_INTR_SRC_REG 0x20
  53. #define DA8XX_USB_INTR_SRC_SET_REG 0x24
  54. #define DA8XX_USB_INTR_SRC_CLEAR_REG 0x28
  55. #define DA8XX_USB_INTR_MASK_REG 0x2c
  56. #define DA8XX_USB_INTR_MASK_SET_REG 0x30
  57. #define DA8XX_USB_INTR_MASK_CLEAR_REG 0x34
  58. #define DA8XX_USB_INTR_SRC_MASKED_REG 0x38
  59. #define DA8XX_USB_END_OF_INTR_REG 0x3c
  60. #define DA8XX_USB_GENERIC_RNDIS_EP_SIZE_REG(n) (0x50 + (((n) - 1) << 2))
  61. /* Control register bits */
  62. #define DA8XX_SOFT_RESET_MASK 1
  63. #define DA8XX_USB_TX_EP_MASK 0x1f /* EP0 + 4 Tx EPs */
  64. #define DA8XX_USB_RX_EP_MASK 0x1e /* 4 Rx EPs */
  65. /* USB interrupt register bits */
  66. #define DA8XX_INTR_USB_SHIFT 16
  67. #define DA8XX_INTR_USB_MASK (0x1ff << DA8XX_INTR_USB_SHIFT) /* 8 Mentor */
  68. /* interrupts and DRVVBUS interrupt */
  69. #define DA8XX_INTR_DRVVBUS 0x100
  70. #define DA8XX_INTR_RX_SHIFT 8
  71. #define DA8XX_INTR_RX_MASK (DA8XX_USB_RX_EP_MASK << DA8XX_INTR_RX_SHIFT)
  72. #define DA8XX_INTR_TX_SHIFT 0
  73. #define DA8XX_INTR_TX_MASK (DA8XX_USB_TX_EP_MASK << DA8XX_INTR_TX_SHIFT)
  74. #define DA8XX_MENTOR_CORE_OFFSET 0x400
  75. struct da8xx_glue {
  76. struct device *dev;
  77. struct platform_device *musb;
  78. struct platform_device *usb_phy;
  79. struct clk *clk;
  80. struct phy *phy;
  81. };
  82. /*
  83. * Because we don't set CTRL.UINT, it's "important" to:
  84. * - not read/write INTRUSB/INTRUSBE (except during
  85. * initial setup, as a workaround);
  86. * - use INTSET/INTCLR instead.
  87. */
  88. /**
  89. * da8xx_musb_enable - enable interrupts
  90. */
  91. static void da8xx_musb_enable(struct musb *musb)
  92. {
  93. void __iomem *reg_base = musb->ctrl_base;
  94. u32 mask;
  95. /* Workaround: setup IRQs through both register sets. */
  96. mask = ((musb->epmask & DA8XX_USB_TX_EP_MASK) << DA8XX_INTR_TX_SHIFT) |
  97. ((musb->epmask & DA8XX_USB_RX_EP_MASK) << DA8XX_INTR_RX_SHIFT) |
  98. DA8XX_INTR_USB_MASK;
  99. musb_writel(reg_base, DA8XX_USB_INTR_MASK_SET_REG, mask);
  100. /* Force the DRVVBUS IRQ so we can start polling for ID change. */
  101. musb_writel(reg_base, DA8XX_USB_INTR_SRC_SET_REG,
  102. DA8XX_INTR_DRVVBUS << DA8XX_INTR_USB_SHIFT);
  103. }
  104. /**
  105. * da8xx_musb_disable - disable HDRC and flush interrupts
  106. */
  107. static void da8xx_musb_disable(struct musb *musb)
  108. {
  109. void __iomem *reg_base = musb->ctrl_base;
  110. musb_writel(reg_base, DA8XX_USB_INTR_MASK_CLEAR_REG,
  111. DA8XX_INTR_USB_MASK |
  112. DA8XX_INTR_TX_MASK | DA8XX_INTR_RX_MASK);
  113. musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
  114. musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
  115. }
  116. #define portstate(stmt) stmt
  117. static void da8xx_musb_set_vbus(struct musb *musb, int is_on)
  118. {
  119. WARN_ON(is_on && is_peripheral_active(musb));
  120. }
  121. #define POLL_SECONDS 2
  122. static struct timer_list otg_workaround;
  123. static void otg_timer(unsigned long _musb)
  124. {
  125. struct musb *musb = (void *)_musb;
  126. void __iomem *mregs = musb->mregs;
  127. u8 devctl;
  128. unsigned long flags;
  129. /*
  130. * We poll because DaVinci's won't expose several OTG-critical
  131. * status change events (from the transceiver) otherwise.
  132. */
  133. devctl = musb_readb(mregs, MUSB_DEVCTL);
  134. dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
  135. usb_otg_state_string(musb->xceiv->otg->state));
  136. spin_lock_irqsave(&musb->lock, flags);
  137. switch (musb->xceiv->otg->state) {
  138. case OTG_STATE_A_WAIT_BCON:
  139. devctl &= ~MUSB_DEVCTL_SESSION;
  140. musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
  141. devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
  142. if (devctl & MUSB_DEVCTL_BDEVICE) {
  143. musb->xceiv->otg->state = OTG_STATE_B_IDLE;
  144. MUSB_DEV_MODE(musb);
  145. } else {
  146. musb->xceiv->otg->state = OTG_STATE_A_IDLE;
  147. MUSB_HST_MODE(musb);
  148. }
  149. break;
  150. case OTG_STATE_A_WAIT_VFALL:
  151. /*
  152. * Wait till VBUS falls below SessionEnd (~0.2 V); the 1.3
  153. * RTL seems to mis-handle session "start" otherwise (or in
  154. * our case "recover"), in routine "VBUS was valid by the time
  155. * VBUSERR got reported during enumeration" cases.
  156. */
  157. if (devctl & MUSB_DEVCTL_VBUS) {
  158. mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
  159. break;
  160. }
  161. musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
  162. musb_writel(musb->ctrl_base, DA8XX_USB_INTR_SRC_SET_REG,
  163. MUSB_INTR_VBUSERROR << DA8XX_INTR_USB_SHIFT);
  164. break;
  165. case OTG_STATE_B_IDLE:
  166. /*
  167. * There's no ID-changed IRQ, so we have no good way to tell
  168. * when to switch to the A-Default state machine (by setting
  169. * the DEVCTL.Session bit).
  170. *
  171. * Workaround: whenever we're in B_IDLE, try setting the
  172. * session flag every few seconds. If it works, ID was
  173. * grounded and we're now in the A-Default state machine.
  174. *
  175. * NOTE: setting the session flag is _supposed_ to trigger
  176. * SRP but clearly it doesn't.
  177. */
  178. musb_writeb(mregs, MUSB_DEVCTL, devctl | MUSB_DEVCTL_SESSION);
  179. devctl = musb_readb(mregs, MUSB_DEVCTL);
  180. if (devctl & MUSB_DEVCTL_BDEVICE)
  181. mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
  182. else
  183. musb->xceiv->otg->state = OTG_STATE_A_IDLE;
  184. break;
  185. default:
  186. break;
  187. }
  188. spin_unlock_irqrestore(&musb->lock, flags);
  189. }
  190. static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
  191. {
  192. static unsigned long last_timer;
  193. if (timeout == 0)
  194. timeout = jiffies + msecs_to_jiffies(3);
  195. /* Never idle if active, or when VBUS timeout is not set as host */
  196. if (musb->is_active || (musb->a_wait_bcon == 0 &&
  197. musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
  198. dev_dbg(musb->controller, "%s active, deleting timer\n",
  199. usb_otg_state_string(musb->xceiv->otg->state));
  200. del_timer(&otg_workaround);
  201. last_timer = jiffies;
  202. return;
  203. }
  204. if (time_after(last_timer, timeout) && timer_pending(&otg_workaround)) {
  205. dev_dbg(musb->controller, "Longer idle timer already pending, ignoring...\n");
  206. return;
  207. }
  208. last_timer = timeout;
  209. dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
  210. usb_otg_state_string(musb->xceiv->otg->state),
  211. jiffies_to_msecs(timeout - jiffies));
  212. mod_timer(&otg_workaround, timeout);
  213. }
  214. static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
  215. {
  216. struct musb *musb = hci;
  217. void __iomem *reg_base = musb->ctrl_base;
  218. struct usb_otg *otg = musb->xceiv->otg;
  219. unsigned long flags;
  220. irqreturn_t ret = IRQ_NONE;
  221. u32 status;
  222. spin_lock_irqsave(&musb->lock, flags);
  223. /*
  224. * NOTE: DA8XX shadows the Mentor IRQs. Don't manage them through
  225. * the Mentor registers (except for setup), use the TI ones and EOI.
  226. */
  227. /* Acknowledge and handle non-CPPI interrupts */
  228. status = musb_readl(reg_base, DA8XX_USB_INTR_SRC_MASKED_REG);
  229. if (!status)
  230. goto eoi;
  231. musb_writel(reg_base, DA8XX_USB_INTR_SRC_CLEAR_REG, status);
  232. dev_dbg(musb->controller, "USB IRQ %08x\n", status);
  233. musb->int_rx = (status & DA8XX_INTR_RX_MASK) >> DA8XX_INTR_RX_SHIFT;
  234. musb->int_tx = (status & DA8XX_INTR_TX_MASK) >> DA8XX_INTR_TX_SHIFT;
  235. musb->int_usb = (status & DA8XX_INTR_USB_MASK) >> DA8XX_INTR_USB_SHIFT;
  236. /*
  237. * DRVVBUS IRQs are the only proxy we have (a very poor one!) for
  238. * DA8xx's missing ID change IRQ. We need an ID change IRQ to
  239. * switch appropriately between halves of the OTG state machine.
  240. * Managing DEVCTL.Session per Mentor docs requires that we know its
  241. * value but DEVCTL.BDevice is invalid without DEVCTL.Session set.
  242. * Also, DRVVBUS pulses for SRP (but not at 5 V)...
  243. */
  244. if (status & (DA8XX_INTR_DRVVBUS << DA8XX_INTR_USB_SHIFT)) {
  245. int drvvbus = musb_readl(reg_base, DA8XX_USB_STAT_REG);
  246. void __iomem *mregs = musb->mregs;
  247. u8 devctl = musb_readb(mregs, MUSB_DEVCTL);
  248. int err;
  249. err = musb->int_usb & MUSB_INTR_VBUSERROR;
  250. if (err) {
  251. /*
  252. * The Mentor core doesn't debounce VBUS as needed
  253. * to cope with device connect current spikes. This
  254. * means it's not uncommon for bus-powered devices
  255. * to get VBUS errors during enumeration.
  256. *
  257. * This is a workaround, but newer RTL from Mentor
  258. * seems to allow a better one: "re"-starting sessions
  259. * without waiting for VBUS to stop registering in
  260. * devctl.
  261. */
  262. musb->int_usb &= ~MUSB_INTR_VBUSERROR;
  263. musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
  264. mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
  265. WARNING("VBUS error workaround (delay coming)\n");
  266. } else if (drvvbus) {
  267. MUSB_HST_MODE(musb);
  268. otg->default_a = 1;
  269. musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
  270. portstate(musb->port1_status |= USB_PORT_STAT_POWER);
  271. del_timer(&otg_workaround);
  272. } else {
  273. musb->is_active = 0;
  274. MUSB_DEV_MODE(musb);
  275. otg->default_a = 0;
  276. musb->xceiv->otg->state = OTG_STATE_B_IDLE;
  277. portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
  278. }
  279. dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
  280. drvvbus ? "on" : "off",
  281. usb_otg_state_string(musb->xceiv->otg->state),
  282. err ? " ERROR" : "",
  283. devctl);
  284. ret = IRQ_HANDLED;
  285. }
  286. if (musb->int_tx || musb->int_rx || musb->int_usb)
  287. ret |= musb_interrupt(musb);
  288. eoi:
  289. /* EOI needs to be written for the IRQ to be re-asserted. */
  290. if (ret == IRQ_HANDLED || status)
  291. musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
  292. /* Poll for ID change */
  293. if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
  294. mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
  295. spin_unlock_irqrestore(&musb->lock, flags);
  296. return ret;
  297. }
  298. static int da8xx_musb_set_mode(struct musb *musb, u8 musb_mode)
  299. {
  300. struct da8xx_glue *glue = dev_get_drvdata(musb->controller->parent);
  301. enum phy_mode phy_mode;
  302. /*
  303. * The PHY has some issues when it is forced in device or host mode.
  304. * Unless the user request another mode, configure the PHY in OTG mode.
  305. */
  306. if (!musb->is_initialized)
  307. return phy_set_mode(glue->phy, PHY_MODE_USB_OTG);
  308. switch (musb_mode) {
  309. case MUSB_HOST: /* Force VBUS valid, ID = 0 */
  310. phy_mode = PHY_MODE_USB_HOST;
  311. break;
  312. case MUSB_PERIPHERAL: /* Force VBUS valid, ID = 1 */
  313. phy_mode = PHY_MODE_USB_DEVICE;
  314. break;
  315. case MUSB_OTG: /* Don't override the VBUS/ID comparators */
  316. phy_mode = PHY_MODE_USB_OTG;
  317. break;
  318. default:
  319. return -EINVAL;
  320. }
  321. return phy_set_mode(glue->phy, phy_mode);
  322. }
  323. static int da8xx_musb_init(struct musb *musb)
  324. {
  325. struct da8xx_glue *glue = dev_get_drvdata(musb->controller->parent);
  326. void __iomem *reg_base = musb->ctrl_base;
  327. u32 rev;
  328. int ret = -ENODEV;
  329. musb->mregs += DA8XX_MENTOR_CORE_OFFSET;
  330. ret = clk_prepare_enable(glue->clk);
  331. if (ret) {
  332. dev_err(glue->dev, "failed to enable clock\n");
  333. return ret;
  334. }
  335. /* Returns zero if e.g. not clocked */
  336. rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG);
  337. if (!rev)
  338. goto fail;
  339. musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
  340. if (IS_ERR_OR_NULL(musb->xceiv)) {
  341. ret = -EPROBE_DEFER;
  342. goto fail;
  343. }
  344. setup_timer(&otg_workaround, otg_timer, (unsigned long)musb);
  345. /* Reset the controller */
  346. musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK);
  347. /* Start the on-chip PHY and its PLL. */
  348. ret = phy_init(glue->phy);
  349. if (ret) {
  350. dev_err(glue->dev, "Failed to init phy.\n");
  351. goto fail;
  352. }
  353. ret = phy_power_on(glue->phy);
  354. if (ret) {
  355. dev_err(glue->dev, "Failed to power on phy.\n");
  356. goto err_phy_power_on;
  357. }
  358. msleep(5);
  359. /* NOTE: IRQs are in mixed mode, not bypass to pure MUSB */
  360. pr_debug("DA8xx OTG revision %08x, control %02x\n", rev,
  361. musb_readb(reg_base, DA8XX_USB_CTRL_REG));
  362. musb->isr = da8xx_musb_interrupt;
  363. return 0;
  364. err_phy_power_on:
  365. phy_exit(glue->phy);
  366. fail:
  367. clk_disable_unprepare(glue->clk);
  368. return ret;
  369. }
  370. static int da8xx_musb_exit(struct musb *musb)
  371. {
  372. struct da8xx_glue *glue = dev_get_drvdata(musb->controller->parent);
  373. del_timer_sync(&otg_workaround);
  374. phy_power_off(glue->phy);
  375. phy_exit(glue->phy);
  376. clk_disable_unprepare(glue->clk);
  377. usb_put_phy(musb->xceiv);
  378. return 0;
  379. }
  380. static inline u8 get_vbus_power(struct device *dev)
  381. {
  382. struct regulator *vbus_supply;
  383. int current_uA;
  384. vbus_supply = regulator_get_optional(dev, "vbus");
  385. if (IS_ERR(vbus_supply))
  386. return 255;
  387. current_uA = regulator_get_current_limit(vbus_supply);
  388. regulator_put(vbus_supply);
  389. if (current_uA <= 0 || current_uA > 510000)
  390. return 255;
  391. return current_uA / 1000 / 2;
  392. }
  393. static const struct musb_platform_ops da8xx_ops = {
  394. .quirks = MUSB_DMA_CPPI | MUSB_INDEXED_EP,
  395. .init = da8xx_musb_init,
  396. .exit = da8xx_musb_exit,
  397. .fifo_mode = 2,
  398. #ifdef CONFIG_USB_TI_CPPI_DMA
  399. .dma_init = cppi_dma_controller_create,
  400. .dma_exit = cppi_dma_controller_destroy,
  401. #endif
  402. .enable = da8xx_musb_enable,
  403. .disable = da8xx_musb_disable,
  404. .set_mode = da8xx_musb_set_mode,
  405. .try_idle = da8xx_musb_try_idle,
  406. .set_vbus = da8xx_musb_set_vbus,
  407. };
  408. static const struct platform_device_info da8xx_dev_info = {
  409. .name = "musb-hdrc",
  410. .id = PLATFORM_DEVID_AUTO,
  411. .dma_mask = DMA_BIT_MASK(32),
  412. };
  413. static const struct musb_hdrc_config da8xx_config = {
  414. .ram_bits = 10,
  415. .num_eps = 5,
  416. .multipoint = 1,
  417. };
  418. static int da8xx_probe(struct platform_device *pdev)
  419. {
  420. struct resource musb_resources[2];
  421. struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev);
  422. struct da8xx_glue *glue;
  423. struct platform_device_info pinfo;
  424. struct clk *clk;
  425. struct device_node *np = pdev->dev.of_node;
  426. int ret;
  427. glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
  428. if (!glue)
  429. return -ENOMEM;
  430. clk = devm_clk_get(&pdev->dev, "usb20");
  431. if (IS_ERR(clk)) {
  432. dev_err(&pdev->dev, "failed to get clock\n");
  433. return PTR_ERR(clk);
  434. }
  435. glue->phy = devm_phy_get(&pdev->dev, "usb-phy");
  436. if (IS_ERR(glue->phy)) {
  437. if (PTR_ERR(glue->phy) != -EPROBE_DEFER)
  438. dev_err(&pdev->dev, "failed to get phy\n");
  439. return PTR_ERR(glue->phy);
  440. }
  441. glue->dev = &pdev->dev;
  442. glue->clk = clk;
  443. if (IS_ENABLED(CONFIG_OF) && np) {
  444. pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
  445. if (!pdata)
  446. return -ENOMEM;
  447. pdata->config = &da8xx_config;
  448. pdata->mode = musb_get_mode(&pdev->dev);
  449. pdata->power = get_vbus_power(&pdev->dev);
  450. }
  451. pdata->platform_ops = &da8xx_ops;
  452. glue->usb_phy = usb_phy_generic_register();
  453. ret = PTR_ERR_OR_ZERO(glue->usb_phy);
  454. if (ret) {
  455. dev_err(&pdev->dev, "failed to register usb_phy\n");
  456. return ret;
  457. }
  458. platform_set_drvdata(pdev, glue);
  459. memset(musb_resources, 0x00, sizeof(*musb_resources) *
  460. ARRAY_SIZE(musb_resources));
  461. musb_resources[0].name = pdev->resource[0].name;
  462. musb_resources[0].start = pdev->resource[0].start;
  463. musb_resources[0].end = pdev->resource[0].end;
  464. musb_resources[0].flags = pdev->resource[0].flags;
  465. musb_resources[1].name = pdev->resource[1].name;
  466. musb_resources[1].start = pdev->resource[1].start;
  467. musb_resources[1].end = pdev->resource[1].end;
  468. musb_resources[1].flags = pdev->resource[1].flags;
  469. pinfo = da8xx_dev_info;
  470. pinfo.parent = &pdev->dev;
  471. pinfo.res = musb_resources;
  472. pinfo.num_res = ARRAY_SIZE(musb_resources);
  473. pinfo.data = pdata;
  474. pinfo.size_data = sizeof(*pdata);
  475. glue->musb = platform_device_register_full(&pinfo);
  476. ret = PTR_ERR_OR_ZERO(glue->musb);
  477. if (ret) {
  478. dev_err(&pdev->dev, "failed to register musb device: %d\n", ret);
  479. usb_phy_generic_unregister(glue->usb_phy);
  480. }
  481. return ret;
  482. }
  483. static int da8xx_remove(struct platform_device *pdev)
  484. {
  485. struct da8xx_glue *glue = platform_get_drvdata(pdev);
  486. platform_device_unregister(glue->musb);
  487. usb_phy_generic_unregister(glue->usb_phy);
  488. return 0;
  489. }
  490. #ifdef CONFIG_OF
  491. static const struct of_device_id da8xx_id_table[] = {
  492. {
  493. .compatible = "ti,da830-musb",
  494. },
  495. {},
  496. };
  497. MODULE_DEVICE_TABLE(of, da8xx_id_table);
  498. #endif
  499. static struct platform_driver da8xx_driver = {
  500. .probe = da8xx_probe,
  501. .remove = da8xx_remove,
  502. .driver = {
  503. .name = "musb-da8xx",
  504. .of_match_table = of_match_ptr(da8xx_id_table),
  505. },
  506. };
  507. MODULE_DESCRIPTION("DA8xx/OMAP-L1x MUSB Glue Layer");
  508. MODULE_AUTHOR("Sergei Shtylyov <sshtylyov@ru.mvista.com>");
  509. MODULE_LICENSE("GPL v2");
  510. module_platform_driver(da8xx_driver);