ohci-pxa27x.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. /*
  2. * OHCI HCD (Host Controller Driver) for USB.
  3. *
  4. * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
  5. * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
  6. * (C) Copyright 2002 Hewlett-Packard Company
  7. *
  8. * Bus Glue for pxa27x
  9. *
  10. * Written by Christopher Hoover <ch@hpl.hp.com>
  11. * Based on fragments of previous driver by Russell King et al.
  12. *
  13. * Modified for LH7A404 from ohci-sa1111.c
  14. * by Durgesh Pattamatta <pattamattad@sharpsec.com>
  15. *
  16. * Modified for pxa27x from ohci-lh7a404.c
  17. * by Nick Bane <nick@cecomputing.co.uk> 26-8-2004
  18. *
  19. * This file is licenced under the GPL.
  20. */
  21. #include <linux/clk.h>
  22. #include <linux/device.h>
  23. #include <linux/io.h>
  24. #include <linux/kernel.h>
  25. #include <linux/module.h>
  26. #include <linux/of_platform.h>
  27. #include <linux/of_gpio.h>
  28. #include <linux/platform_data/usb-ohci-pxa27x.h>
  29. #include <linux/platform_data/usb-pxa3xx-ulpi.h>
  30. #include <linux/platform_device.h>
  31. #include <linux/signal.h>
  32. #include <linux/usb.h>
  33. #include <linux/usb/hcd.h>
  34. #include <linux/usb/otg.h>
  35. #include <mach/hardware.h>
  36. #include "ohci.h"
  37. #define DRIVER_DESC "OHCI PXA27x/PXA3x driver"
  38. /*
  39. * UHC: USB Host Controller (OHCI-like) register definitions
  40. */
  41. #define UHCREV (0x0000) /* UHC HCI Spec Revision */
  42. #define UHCHCON (0x0004) /* UHC Host Control Register */
  43. #define UHCCOMS (0x0008) /* UHC Command Status Register */
  44. #define UHCINTS (0x000C) /* UHC Interrupt Status Register */
  45. #define UHCINTE (0x0010) /* UHC Interrupt Enable */
  46. #define UHCINTD (0x0014) /* UHC Interrupt Disable */
  47. #define UHCHCCA (0x0018) /* UHC Host Controller Comm. Area */
  48. #define UHCPCED (0x001C) /* UHC Period Current Endpt Descr */
  49. #define UHCCHED (0x0020) /* UHC Control Head Endpt Descr */
  50. #define UHCCCED (0x0024) /* UHC Control Current Endpt Descr */
  51. #define UHCBHED (0x0028) /* UHC Bulk Head Endpt Descr */
  52. #define UHCBCED (0x002C) /* UHC Bulk Current Endpt Descr */
  53. #define UHCDHEAD (0x0030) /* UHC Done Head */
  54. #define UHCFMI (0x0034) /* UHC Frame Interval */
  55. #define UHCFMR (0x0038) /* UHC Frame Remaining */
  56. #define UHCFMN (0x003C) /* UHC Frame Number */
  57. #define UHCPERS (0x0040) /* UHC Periodic Start */
  58. #define UHCLS (0x0044) /* UHC Low Speed Threshold */
  59. #define UHCRHDA (0x0048) /* UHC Root Hub Descriptor A */
  60. #define UHCRHDA_NOCP (1 << 12) /* No over current protection */
  61. #define UHCRHDA_OCPM (1 << 11) /* Over Current Protection Mode */
  62. #define UHCRHDA_POTPGT(x) \
  63. (((x) & 0xff) << 24) /* Power On To Power Good Time */
  64. #define UHCRHDB (0x004C) /* UHC Root Hub Descriptor B */
  65. #define UHCRHS (0x0050) /* UHC Root Hub Status */
  66. #define UHCRHPS1 (0x0054) /* UHC Root Hub Port 1 Status */
  67. #define UHCRHPS2 (0x0058) /* UHC Root Hub Port 2 Status */
  68. #define UHCRHPS3 (0x005C) /* UHC Root Hub Port 3 Status */
  69. #define UHCSTAT (0x0060) /* UHC Status Register */
  70. #define UHCSTAT_UPS3 (1 << 16) /* USB Power Sense Port3 */
  71. #define UHCSTAT_SBMAI (1 << 15) /* System Bus Master Abort Interrupt*/
  72. #define UHCSTAT_SBTAI (1 << 14) /* System Bus Target Abort Interrupt*/
  73. #define UHCSTAT_UPRI (1 << 13) /* USB Port Resume Interrupt */
  74. #define UHCSTAT_UPS2 (1 << 12) /* USB Power Sense Port 2 */
  75. #define UHCSTAT_UPS1 (1 << 11) /* USB Power Sense Port 1 */
  76. #define UHCSTAT_HTA (1 << 10) /* HCI Target Abort */
  77. #define UHCSTAT_HBA (1 << 8) /* HCI Buffer Active */
  78. #define UHCSTAT_RWUE (1 << 7) /* HCI Remote Wake Up Event */
  79. #define UHCHR (0x0064) /* UHC Reset Register */
  80. #define UHCHR_SSEP3 (1 << 11) /* Sleep Standby Enable for Port3 */
  81. #define UHCHR_SSEP2 (1 << 10) /* Sleep Standby Enable for Port2 */
  82. #define UHCHR_SSEP1 (1 << 9) /* Sleep Standby Enable for Port1 */
  83. #define UHCHR_PCPL (1 << 7) /* Power control polarity low */
  84. #define UHCHR_PSPL (1 << 6) /* Power sense polarity low */
  85. #define UHCHR_SSE (1 << 5) /* Sleep Standby Enable */
  86. #define UHCHR_UIT (1 << 4) /* USB Interrupt Test */
  87. #define UHCHR_SSDC (1 << 3) /* Simulation Scale Down Clock */
  88. #define UHCHR_CGR (1 << 2) /* Clock Generation Reset */
  89. #define UHCHR_FHR (1 << 1) /* Force Host Controller Reset */
  90. #define UHCHR_FSBIR (1 << 0) /* Force System Bus Iface Reset */
  91. #define UHCHIE (0x0068) /* UHC Interrupt Enable Register*/
  92. #define UHCHIE_UPS3IE (1 << 14) /* Power Sense Port3 IntEn */
  93. #define UHCHIE_UPRIE (1 << 13) /* Port Resume IntEn */
  94. #define UHCHIE_UPS2IE (1 << 12) /* Power Sense Port2 IntEn */
  95. #define UHCHIE_UPS1IE (1 << 11) /* Power Sense Port1 IntEn */
  96. #define UHCHIE_TAIE (1 << 10) /* HCI Interface Transfer Abort
  97. Interrupt Enable*/
  98. #define UHCHIE_HBAIE (1 << 8) /* HCI Buffer Active IntEn */
  99. #define UHCHIE_RWIE (1 << 7) /* Remote Wake-up IntEn */
  100. #define UHCHIT (0x006C) /* UHC Interrupt Test register */
  101. #define PXA_UHC_MAX_PORTNUM 3
  102. static const char hcd_name[] = "ohci-pxa27x";
  103. static struct hc_driver __read_mostly ohci_pxa27x_hc_driver;
  104. struct pxa27x_ohci {
  105. struct clk *clk;
  106. void __iomem *mmio_base;
  107. };
  108. #define to_pxa27x_ohci(hcd) (struct pxa27x_ohci *)(hcd_to_ohci(hcd)->priv)
  109. /*
  110. PMM_NPS_MODE -- PMM Non-power switching mode
  111. Ports are powered continuously.
  112. PMM_GLOBAL_MODE -- PMM global switching mode
  113. All ports are powered at the same time.
  114. PMM_PERPORT_MODE -- PMM per port switching mode
  115. Ports are powered individually.
  116. */
  117. static int pxa27x_ohci_select_pmm(struct pxa27x_ohci *pxa_ohci, int mode)
  118. {
  119. uint32_t uhcrhda = __raw_readl(pxa_ohci->mmio_base + UHCRHDA);
  120. uint32_t uhcrhdb = __raw_readl(pxa_ohci->mmio_base + UHCRHDB);
  121. switch (mode) {
  122. case PMM_NPS_MODE:
  123. uhcrhda |= RH_A_NPS;
  124. break;
  125. case PMM_GLOBAL_MODE:
  126. uhcrhda &= ~(RH_A_NPS & RH_A_PSM);
  127. break;
  128. case PMM_PERPORT_MODE:
  129. uhcrhda &= ~(RH_A_NPS);
  130. uhcrhda |= RH_A_PSM;
  131. /* Set port power control mask bits, only 3 ports. */
  132. uhcrhdb |= (0x7<<17);
  133. break;
  134. default:
  135. printk( KERN_ERR
  136. "Invalid mode %d, set to non-power switch mode.\n",
  137. mode );
  138. uhcrhda |= RH_A_NPS;
  139. }
  140. __raw_writel(uhcrhda, pxa_ohci->mmio_base + UHCRHDA);
  141. __raw_writel(uhcrhdb, pxa_ohci->mmio_base + UHCRHDB);
  142. return 0;
  143. }
  144. /*-------------------------------------------------------------------------*/
  145. static inline void pxa27x_setup_hc(struct pxa27x_ohci *pxa_ohci,
  146. struct pxaohci_platform_data *inf)
  147. {
  148. uint32_t uhchr = __raw_readl(pxa_ohci->mmio_base + UHCHR);
  149. uint32_t uhcrhda = __raw_readl(pxa_ohci->mmio_base + UHCRHDA);
  150. if (inf->flags & ENABLE_PORT1)
  151. uhchr &= ~UHCHR_SSEP1;
  152. if (inf->flags & ENABLE_PORT2)
  153. uhchr &= ~UHCHR_SSEP2;
  154. if (inf->flags & ENABLE_PORT3)
  155. uhchr &= ~UHCHR_SSEP3;
  156. if (inf->flags & POWER_CONTROL_LOW)
  157. uhchr |= UHCHR_PCPL;
  158. if (inf->flags & POWER_SENSE_LOW)
  159. uhchr |= UHCHR_PSPL;
  160. if (inf->flags & NO_OC_PROTECTION)
  161. uhcrhda |= UHCRHDA_NOCP;
  162. else
  163. uhcrhda &= ~UHCRHDA_NOCP;
  164. if (inf->flags & OC_MODE_PERPORT)
  165. uhcrhda |= UHCRHDA_OCPM;
  166. else
  167. uhcrhda &= ~UHCRHDA_OCPM;
  168. if (inf->power_on_delay) {
  169. uhcrhda &= ~UHCRHDA_POTPGT(0xff);
  170. uhcrhda |= UHCRHDA_POTPGT(inf->power_on_delay / 2);
  171. }
  172. __raw_writel(uhchr, pxa_ohci->mmio_base + UHCHR);
  173. __raw_writel(uhcrhda, pxa_ohci->mmio_base + UHCRHDA);
  174. }
  175. static inline void pxa27x_reset_hc(struct pxa27x_ohci *pxa_ohci)
  176. {
  177. uint32_t uhchr = __raw_readl(pxa_ohci->mmio_base + UHCHR);
  178. __raw_writel(uhchr | UHCHR_FHR, pxa_ohci->mmio_base + UHCHR);
  179. udelay(11);
  180. __raw_writel(uhchr & ~UHCHR_FHR, pxa_ohci->mmio_base + UHCHR);
  181. }
  182. #ifdef CONFIG_PXA27x
  183. extern void pxa27x_clear_otgph(void);
  184. #else
  185. #define pxa27x_clear_otgph() do {} while (0)
  186. #endif
  187. static int pxa27x_start_hc(struct pxa27x_ohci *pxa_ohci, struct device *dev)
  188. {
  189. int retval = 0;
  190. struct pxaohci_platform_data *inf;
  191. uint32_t uhchr;
  192. struct usb_hcd *hcd = dev_get_drvdata(dev);
  193. inf = dev_get_platdata(dev);
  194. clk_prepare_enable(pxa_ohci->clk);
  195. pxa27x_reset_hc(pxa_ohci);
  196. uhchr = __raw_readl(pxa_ohci->mmio_base + UHCHR) | UHCHR_FSBIR;
  197. __raw_writel(uhchr, pxa_ohci->mmio_base + UHCHR);
  198. while (__raw_readl(pxa_ohci->mmio_base + UHCHR) & UHCHR_FSBIR)
  199. cpu_relax();
  200. pxa27x_setup_hc(pxa_ohci, inf);
  201. if (inf->init)
  202. retval = inf->init(dev);
  203. if (retval < 0)
  204. return retval;
  205. if (cpu_is_pxa3xx())
  206. pxa3xx_u2d_start_hc(&hcd->self);
  207. uhchr = __raw_readl(pxa_ohci->mmio_base + UHCHR) & ~UHCHR_SSE;
  208. __raw_writel(uhchr, pxa_ohci->mmio_base + UHCHR);
  209. __raw_writel(UHCHIE_UPRIE | UHCHIE_RWIE, pxa_ohci->mmio_base + UHCHIE);
  210. /* Clear any OTG Pin Hold */
  211. pxa27x_clear_otgph();
  212. return 0;
  213. }
  214. static void pxa27x_stop_hc(struct pxa27x_ohci *pxa_ohci, struct device *dev)
  215. {
  216. struct pxaohci_platform_data *inf;
  217. struct usb_hcd *hcd = dev_get_drvdata(dev);
  218. uint32_t uhccoms;
  219. inf = dev_get_platdata(dev);
  220. if (cpu_is_pxa3xx())
  221. pxa3xx_u2d_stop_hc(&hcd->self);
  222. if (inf->exit)
  223. inf->exit(dev);
  224. pxa27x_reset_hc(pxa_ohci);
  225. /* Host Controller Reset */
  226. uhccoms = __raw_readl(pxa_ohci->mmio_base + UHCCOMS) | 0x01;
  227. __raw_writel(uhccoms, pxa_ohci->mmio_base + UHCCOMS);
  228. udelay(10);
  229. clk_disable_unprepare(pxa_ohci->clk);
  230. }
  231. #ifdef CONFIG_OF
  232. static const struct of_device_id pxa_ohci_dt_ids[] = {
  233. { .compatible = "marvell,pxa-ohci" },
  234. { }
  235. };
  236. MODULE_DEVICE_TABLE(of, pxa_ohci_dt_ids);
  237. static int ohci_pxa_of_init(struct platform_device *pdev)
  238. {
  239. struct device_node *np = pdev->dev.of_node;
  240. struct pxaohci_platform_data *pdata;
  241. u32 tmp;
  242. if (!np)
  243. return 0;
  244. /* Right now device-tree probed devices don't get dma_mask set.
  245. * Since shared usb code relies on it, set it here for now.
  246. * Once we have dma capability bindings this can go away.
  247. */
  248. if (!pdev->dev.dma_mask)
  249. pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
  250. if (!pdev->dev.coherent_dma_mask)
  251. pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
  252. pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
  253. if (!pdata)
  254. return -ENOMEM;
  255. if (of_get_property(np, "marvell,enable-port1", NULL))
  256. pdata->flags |= ENABLE_PORT1;
  257. if (of_get_property(np, "marvell,enable-port2", NULL))
  258. pdata->flags |= ENABLE_PORT2;
  259. if (of_get_property(np, "marvell,enable-port3", NULL))
  260. pdata->flags |= ENABLE_PORT3;
  261. if (of_get_property(np, "marvell,port-sense-low", NULL))
  262. pdata->flags |= POWER_SENSE_LOW;
  263. if (of_get_property(np, "marvell,power-control-low", NULL))
  264. pdata->flags |= POWER_CONTROL_LOW;
  265. if (of_get_property(np, "marvell,no-oc-protection", NULL))
  266. pdata->flags |= NO_OC_PROTECTION;
  267. if (of_get_property(np, "marvell,oc-mode-perport", NULL))
  268. pdata->flags |= OC_MODE_PERPORT;
  269. if (!of_property_read_u32(np, "marvell,power-on-delay", &tmp))
  270. pdata->power_on_delay = tmp;
  271. if (!of_property_read_u32(np, "marvell,port-mode", &tmp))
  272. pdata->port_mode = tmp;
  273. if (!of_property_read_u32(np, "marvell,power-budget", &tmp))
  274. pdata->power_budget = tmp;
  275. pdev->dev.platform_data = pdata;
  276. return 0;
  277. }
  278. #else
  279. static int ohci_pxa_of_init(struct platform_device *pdev)
  280. {
  281. return 0;
  282. }
  283. #endif
  284. /*-------------------------------------------------------------------------*/
  285. /* configure so an HC device and id are always provided */
  286. /* always called with process context; sleeping is OK */
  287. /**
  288. * usb_hcd_pxa27x_probe - initialize pxa27x-based HCDs
  289. * Context: !in_interrupt()
  290. *
  291. * Allocates basic resources for this USB host controller, and
  292. * then invokes the start() method for the HCD associated with it
  293. * through the hotplug entry's driver_data.
  294. *
  295. */
  296. int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device *pdev)
  297. {
  298. int retval, irq;
  299. struct usb_hcd *hcd;
  300. struct pxaohci_platform_data *inf;
  301. struct pxa27x_ohci *pxa_ohci;
  302. struct ohci_hcd *ohci;
  303. struct resource *r;
  304. struct clk *usb_clk;
  305. retval = ohci_pxa_of_init(pdev);
  306. if (retval)
  307. return retval;
  308. inf = dev_get_platdata(&pdev->dev);
  309. if (!inf)
  310. return -ENODEV;
  311. irq = platform_get_irq(pdev, 0);
  312. if (irq < 0) {
  313. pr_err("no resource of IORESOURCE_IRQ");
  314. return -ENXIO;
  315. }
  316. usb_clk = clk_get(&pdev->dev, NULL);
  317. if (IS_ERR(usb_clk))
  318. return PTR_ERR(usb_clk);
  319. hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x");
  320. if (!hcd) {
  321. retval = -ENOMEM;
  322. goto err0;
  323. }
  324. r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  325. if (!r) {
  326. pr_err("no resource of IORESOURCE_MEM");
  327. retval = -ENXIO;
  328. goto err1;
  329. }
  330. hcd->rsrc_start = r->start;
  331. hcd->rsrc_len = resource_size(r);
  332. if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
  333. pr_debug("request_mem_region failed");
  334. retval = -EBUSY;
  335. goto err1;
  336. }
  337. hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
  338. if (!hcd->regs) {
  339. pr_debug("ioremap failed");
  340. retval = -ENOMEM;
  341. goto err2;
  342. }
  343. /* initialize "struct pxa27x_ohci" */
  344. pxa_ohci = to_pxa27x_ohci(hcd);
  345. pxa_ohci->clk = usb_clk;
  346. pxa_ohci->mmio_base = (void __iomem *)hcd->regs;
  347. retval = pxa27x_start_hc(pxa_ohci, &pdev->dev);
  348. if (retval < 0) {
  349. pr_debug("pxa27x_start_hc failed");
  350. goto err3;
  351. }
  352. /* Select Power Management Mode */
  353. pxa27x_ohci_select_pmm(pxa_ohci, inf->port_mode);
  354. if (inf->power_budget)
  355. hcd->power_budget = inf->power_budget;
  356. /* The value of NDP in roothub_a is incorrect on this hardware */
  357. ohci = hcd_to_ohci(hcd);
  358. ohci->num_ports = 3;
  359. retval = usb_add_hcd(hcd, irq, 0);
  360. if (retval == 0)
  361. return retval;
  362. pxa27x_stop_hc(pxa_ohci, &pdev->dev);
  363. err3:
  364. iounmap(hcd->regs);
  365. err2:
  366. release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  367. err1:
  368. usb_put_hcd(hcd);
  369. err0:
  370. clk_put(usb_clk);
  371. return retval;
  372. }
  373. /* may be called without controller electrically present */
  374. /* may be called with controller, bus, and devices active */
  375. /**
  376. * usb_hcd_pxa27x_remove - shutdown processing for pxa27x-based HCDs
  377. * @dev: USB Host Controller being removed
  378. * Context: !in_interrupt()
  379. *
  380. * Reverses the effect of usb_hcd_pxa27x_probe(), first invoking
  381. * the HCD's stop() method. It is always called from a thread
  382. * context, normally "rmmod", "apmd", or something similar.
  383. *
  384. */
  385. void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev)
  386. {
  387. struct pxa27x_ohci *pxa_ohci = to_pxa27x_ohci(hcd);
  388. usb_remove_hcd(hcd);
  389. pxa27x_stop_hc(pxa_ohci, &pdev->dev);
  390. iounmap(hcd->regs);
  391. release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  392. clk_put(pxa_ohci->clk);
  393. usb_put_hcd(hcd);
  394. }
  395. /*-------------------------------------------------------------------------*/
  396. static int ohci_hcd_pxa27x_drv_probe(struct platform_device *pdev)
  397. {
  398. pr_debug ("In ohci_hcd_pxa27x_drv_probe");
  399. if (usb_disabled())
  400. return -ENODEV;
  401. return usb_hcd_pxa27x_probe(&ohci_pxa27x_hc_driver, pdev);
  402. }
  403. static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev)
  404. {
  405. struct usb_hcd *hcd = platform_get_drvdata(pdev);
  406. usb_hcd_pxa27x_remove(hcd, pdev);
  407. return 0;
  408. }
  409. #ifdef CONFIG_PM
  410. static int ohci_hcd_pxa27x_drv_suspend(struct device *dev)
  411. {
  412. struct usb_hcd *hcd = dev_get_drvdata(dev);
  413. struct pxa27x_ohci *pxa_ohci = to_pxa27x_ohci(hcd);
  414. struct ohci_hcd *ohci = hcd_to_ohci(hcd);
  415. bool do_wakeup = device_may_wakeup(dev);
  416. int ret;
  417. if (time_before(jiffies, ohci->next_statechange))
  418. msleep(5);
  419. ohci->next_statechange = jiffies;
  420. ret = ohci_suspend(hcd, do_wakeup);
  421. if (ret)
  422. return ret;
  423. pxa27x_stop_hc(pxa_ohci, dev);
  424. return ret;
  425. }
  426. static int ohci_hcd_pxa27x_drv_resume(struct device *dev)
  427. {
  428. struct usb_hcd *hcd = dev_get_drvdata(dev);
  429. struct pxa27x_ohci *pxa_ohci = to_pxa27x_ohci(hcd);
  430. struct pxaohci_platform_data *inf = dev_get_platdata(dev);
  431. struct ohci_hcd *ohci = hcd_to_ohci(hcd);
  432. int status;
  433. if (time_before(jiffies, ohci->next_statechange))
  434. msleep(5);
  435. ohci->next_statechange = jiffies;
  436. status = pxa27x_start_hc(pxa_ohci, dev);
  437. if (status < 0)
  438. return status;
  439. /* Select Power Management Mode */
  440. pxa27x_ohci_select_pmm(pxa_ohci, inf->port_mode);
  441. ohci_resume(hcd, false);
  442. return 0;
  443. }
  444. static const struct dev_pm_ops ohci_hcd_pxa27x_pm_ops = {
  445. .suspend = ohci_hcd_pxa27x_drv_suspend,
  446. .resume = ohci_hcd_pxa27x_drv_resume,
  447. };
  448. #endif
  449. static struct platform_driver ohci_hcd_pxa27x_driver = {
  450. .probe = ohci_hcd_pxa27x_drv_probe,
  451. .remove = ohci_hcd_pxa27x_drv_remove,
  452. .shutdown = usb_hcd_platform_shutdown,
  453. .driver = {
  454. .name = "pxa27x-ohci",
  455. .owner = THIS_MODULE,
  456. .of_match_table = of_match_ptr(pxa_ohci_dt_ids),
  457. #ifdef CONFIG_PM
  458. .pm = &ohci_hcd_pxa27x_pm_ops,
  459. #endif
  460. },
  461. };
  462. static const struct ohci_driver_overrides pxa27x_overrides __initconst = {
  463. .extra_priv_size = sizeof(struct pxa27x_ohci),
  464. };
  465. static int __init ohci_pxa27x_init(void)
  466. {
  467. if (usb_disabled())
  468. return -ENODEV;
  469. pr_info("%s: " DRIVER_DESC "\n", hcd_name);
  470. ohci_init_driver(&ohci_pxa27x_hc_driver, &pxa27x_overrides);
  471. return platform_driver_register(&ohci_hcd_pxa27x_driver);
  472. }
  473. module_init(ohci_pxa27x_init);
  474. static void __exit ohci_pxa27x_cleanup(void)
  475. {
  476. platform_driver_unregister(&ohci_hcd_pxa27x_driver);
  477. }
  478. module_exit(ohci_pxa27x_cleanup);
  479. MODULE_DESCRIPTION(DRIVER_DESC);
  480. MODULE_LICENSE("GPL");
  481. MODULE_ALIAS("platform:pxa27x-ohci");