ohci-at91.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. /*
  2. * OHCI HCD (Host Controller Driver) for USB.
  3. *
  4. * Copyright (C) 2004 SAN People (Pty) Ltd.
  5. * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org>
  6. *
  7. * AT91 Bus Glue
  8. *
  9. * Based on fragments of 2.4 driver by Rick Bronson.
  10. * Based on ohci-omap.c
  11. *
  12. * This file is licenced under the GPL.
  13. */
  14. #include <linux/clk.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/of_platform.h>
  17. #include <linux/of_gpio.h>
  18. #include <mach/hardware.h>
  19. #include <asm/gpio.h>
  20. #include <mach/board.h>
  21. #include <mach/cpu.h>
  22. #ifndef CONFIG_ARCH_AT91
  23. #error "CONFIG_ARCH_AT91 must be defined."
  24. #endif
  25. /* interface and function clocks; sometimes also an AHB clock */
  26. static struct clk *iclk, *fclk, *hclk;
  27. static int clocked;
  28. extern int usb_disabled(void);
  29. /*-------------------------------------------------------------------------*/
  30. static void at91_start_clock(void)
  31. {
  32. clk_enable(hclk);
  33. clk_enable(iclk);
  34. clk_enable(fclk);
  35. clocked = 1;
  36. }
  37. static void at91_stop_clock(void)
  38. {
  39. clk_disable(fclk);
  40. clk_disable(iclk);
  41. clk_disable(hclk);
  42. clocked = 0;
  43. }
  44. static void at91_start_hc(struct platform_device *pdev)
  45. {
  46. struct usb_hcd *hcd = platform_get_drvdata(pdev);
  47. struct ohci_regs __iomem *regs = hcd->regs;
  48. dev_dbg(&pdev->dev, "start\n");
  49. /*
  50. * Start the USB clocks.
  51. */
  52. at91_start_clock();
  53. /*
  54. * The USB host controller must remain in reset.
  55. */
  56. writel(0, &regs->control);
  57. }
  58. static void at91_stop_hc(struct platform_device *pdev)
  59. {
  60. struct usb_hcd *hcd = platform_get_drvdata(pdev);
  61. struct ohci_regs __iomem *regs = hcd->regs;
  62. dev_dbg(&pdev->dev, "stop\n");
  63. /*
  64. * Put the USB host controller into reset.
  65. */
  66. writel(0, &regs->control);
  67. /*
  68. * Stop the USB clocks.
  69. */
  70. at91_stop_clock();
  71. }
  72. /*-------------------------------------------------------------------------*/
  73. static void usb_hcd_at91_remove (struct usb_hcd *, struct platform_device *);
  74. /* configure so an HC device and id are always provided */
  75. /* always called with process context; sleeping is OK */
  76. /**
  77. * usb_hcd_at91_probe - initialize AT91-based HCDs
  78. * Context: !in_interrupt()
  79. *
  80. * Allocates basic resources for this USB host controller, and
  81. * then invokes the start() method for the HCD associated with it
  82. * through the hotplug entry's driver_data.
  83. */
  84. static int usb_hcd_at91_probe(const struct hc_driver *driver,
  85. struct platform_device *pdev)
  86. {
  87. int retval;
  88. struct usb_hcd *hcd = NULL;
  89. if (pdev->num_resources != 2) {
  90. pr_debug("hcd probe: invalid num_resources");
  91. return -ENODEV;
  92. }
  93. if ((pdev->resource[0].flags != IORESOURCE_MEM)
  94. || (pdev->resource[1].flags != IORESOURCE_IRQ)) {
  95. pr_debug("hcd probe: invalid resource type\n");
  96. return -ENODEV;
  97. }
  98. hcd = usb_create_hcd(driver, &pdev->dev, "at91");
  99. if (!hcd)
  100. return -ENOMEM;
  101. hcd->rsrc_start = pdev->resource[0].start;
  102. hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1;
  103. if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
  104. pr_debug("request_mem_region failed\n");
  105. retval = -EBUSY;
  106. goto err1;
  107. }
  108. hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
  109. if (!hcd->regs) {
  110. pr_debug("ioremap failed\n");
  111. retval = -EIO;
  112. goto err2;
  113. }
  114. iclk = clk_get(&pdev->dev, "ohci_clk");
  115. if (IS_ERR(iclk)) {
  116. dev_err(&pdev->dev, "failed to get ohci_clk\n");
  117. retval = PTR_ERR(iclk);
  118. goto err3;
  119. }
  120. fclk = clk_get(&pdev->dev, "uhpck");
  121. if (IS_ERR(fclk)) {
  122. dev_err(&pdev->dev, "failed to get uhpck\n");
  123. retval = PTR_ERR(fclk);
  124. goto err4;
  125. }
  126. hclk = clk_get(&pdev->dev, "hclk");
  127. if (IS_ERR(hclk)) {
  128. dev_err(&pdev->dev, "failed to get hclk\n");
  129. retval = PTR_ERR(hclk);
  130. goto err5;
  131. }
  132. at91_start_hc(pdev);
  133. ohci_hcd_init(hcd_to_ohci(hcd));
  134. retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED);
  135. if (retval == 0)
  136. return retval;
  137. /* Error handling */
  138. at91_stop_hc(pdev);
  139. clk_put(hclk);
  140. err5:
  141. clk_put(fclk);
  142. err4:
  143. clk_put(iclk);
  144. err3:
  145. iounmap(hcd->regs);
  146. err2:
  147. release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  148. err1:
  149. usb_put_hcd(hcd);
  150. return retval;
  151. }
  152. /* may be called with controller, bus, and devices active */
  153. /**
  154. * usb_hcd_at91_remove - shutdown processing for AT91-based HCDs
  155. * @dev: USB Host Controller being removed
  156. * Context: !in_interrupt()
  157. *
  158. * Reverses the effect of usb_hcd_at91_probe(), first invoking
  159. * the HCD's stop() method. It is always called from a thread
  160. * context, "rmmod" or something similar.
  161. *
  162. */
  163. static void usb_hcd_at91_remove(struct usb_hcd *hcd,
  164. struct platform_device *pdev)
  165. {
  166. usb_remove_hcd(hcd);
  167. at91_stop_hc(pdev);
  168. iounmap(hcd->regs);
  169. release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  170. usb_put_hcd(hcd);
  171. clk_put(hclk);
  172. clk_put(fclk);
  173. clk_put(iclk);
  174. fclk = iclk = hclk = NULL;
  175. dev_set_drvdata(&pdev->dev, NULL);
  176. }
  177. /*-------------------------------------------------------------------------*/
  178. static int __devinit
  179. ohci_at91_start (struct usb_hcd *hcd)
  180. {
  181. struct at91_usbh_data *board = hcd->self.controller->platform_data;
  182. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  183. int ret;
  184. if ((ret = ohci_init(ohci)) < 0)
  185. return ret;
  186. ohci->num_ports = board->ports;
  187. if ((ret = ohci_run(ohci)) < 0) {
  188. err("can't start %s", hcd->self.bus_name);
  189. ohci_stop(hcd);
  190. return ret;
  191. }
  192. return 0;
  193. }
  194. static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int enable)
  195. {
  196. if (port < 0 || port >= 2)
  197. return;
  198. if (!gpio_is_valid(pdata->vbus_pin[port]))
  199. return;
  200. gpio_set_value(pdata->vbus_pin[port],
  201. !pdata->vbus_pin_active_low[port] ^ enable);
  202. }
  203. static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)
  204. {
  205. if (port < 0 || port >= 2)
  206. return -EINVAL;
  207. if (!gpio_is_valid(pdata->vbus_pin[port]))
  208. return -EINVAL;
  209. return gpio_get_value(pdata->vbus_pin[port]) ^
  210. !pdata->vbus_pin_active_low[port];
  211. }
  212. /*
  213. * Update the status data from the hub with the over-current indicator change.
  214. */
  215. static int ohci_at91_hub_status_data(struct usb_hcd *hcd, char *buf)
  216. {
  217. struct at91_usbh_data *pdata = hcd->self.controller->platform_data;
  218. int length = ohci_hub_status_data(hcd, buf);
  219. int port;
  220. for (port = 0; port < ARRAY_SIZE(pdata->overcurrent_pin); port++) {
  221. if (pdata->overcurrent_changed[port]) {
  222. if (! length)
  223. length = 1;
  224. buf[0] |= 1 << (port + 1);
  225. }
  226. }
  227. return length;
  228. }
  229. /*
  230. * Look at the control requests to the root hub and see if we need to override.
  231. */
  232. static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
  233. u16 wIndex, char *buf, u16 wLength)
  234. {
  235. struct at91_usbh_data *pdata = hcd->self.controller->platform_data;
  236. struct usb_hub_descriptor *desc;
  237. int ret = -EINVAL;
  238. u32 *data = (u32 *)buf;
  239. dev_dbg(hcd->self.controller,
  240. "ohci_at91_hub_control(%p,0x%04x,0x%04x,0x%04x,%p,%04x)\n",
  241. hcd, typeReq, wValue, wIndex, buf, wLength);
  242. switch (typeReq) {
  243. case SetPortFeature:
  244. if (wValue == USB_PORT_FEAT_POWER) {
  245. dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n");
  246. ohci_at91_usb_set_power(pdata, wIndex - 1, 1);
  247. goto out;
  248. }
  249. break;
  250. case ClearPortFeature:
  251. switch (wValue) {
  252. case USB_PORT_FEAT_C_OVER_CURRENT:
  253. dev_dbg(hcd->self.controller,
  254. "ClearPortFeature: C_OVER_CURRENT\n");
  255. if (wIndex == 1 || wIndex == 2) {
  256. pdata->overcurrent_changed[wIndex-1] = 0;
  257. pdata->overcurrent_status[wIndex-1] = 0;
  258. }
  259. goto out;
  260. case USB_PORT_FEAT_OVER_CURRENT:
  261. dev_dbg(hcd->self.controller,
  262. "ClearPortFeature: OVER_CURRENT\n");
  263. if (wIndex == 1 || wIndex == 2) {
  264. pdata->overcurrent_status[wIndex-1] = 0;
  265. }
  266. goto out;
  267. case USB_PORT_FEAT_POWER:
  268. dev_dbg(hcd->self.controller,
  269. "ClearPortFeature: POWER\n");
  270. if (wIndex == 1 || wIndex == 2) {
  271. ohci_at91_usb_set_power(pdata, wIndex - 1, 0);
  272. return 0;
  273. }
  274. }
  275. break;
  276. }
  277. ret = ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
  278. if (ret)
  279. goto out;
  280. switch (typeReq) {
  281. case GetHubDescriptor:
  282. /* update the hub's descriptor */
  283. desc = (struct usb_hub_descriptor *)buf;
  284. dev_dbg(hcd->self.controller, "wHubCharacteristics 0x%04x\n",
  285. desc->wHubCharacteristics);
  286. /* remove the old configurations for power-switching, and
  287. * over-current protection, and insert our new configuration
  288. */
  289. desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM);
  290. desc->wHubCharacteristics |= cpu_to_le16(0x0001);
  291. if (pdata->overcurrent_supported) {
  292. desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_OCPM);
  293. desc->wHubCharacteristics |= cpu_to_le16(0x0008|0x0001);
  294. }
  295. dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n",
  296. desc->wHubCharacteristics);
  297. return ret;
  298. case GetPortStatus:
  299. /* check port status */
  300. dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex);
  301. if (wIndex == 1 || wIndex == 2) {
  302. if (! ohci_at91_usb_get_power(pdata, wIndex-1)) {
  303. *data &= ~cpu_to_le32(RH_PS_PPS);
  304. }
  305. if (pdata->overcurrent_changed[wIndex-1]) {
  306. *data |= cpu_to_le32(RH_PS_OCIC);
  307. }
  308. if (pdata->overcurrent_status[wIndex-1]) {
  309. *data |= cpu_to_le32(RH_PS_POCI);
  310. }
  311. }
  312. }
  313. out:
  314. return ret;
  315. }
  316. /*-------------------------------------------------------------------------*/
  317. static const struct hc_driver ohci_at91_hc_driver = {
  318. .description = hcd_name,
  319. .product_desc = "AT91 OHCI",
  320. .hcd_priv_size = sizeof(struct ohci_hcd),
  321. /*
  322. * generic hardware linkage
  323. */
  324. .irq = ohci_irq,
  325. .flags = HCD_USB11 | HCD_MEMORY,
  326. /*
  327. * basic lifecycle operations
  328. */
  329. .start = ohci_at91_start,
  330. .stop = ohci_stop,
  331. .shutdown = ohci_shutdown,
  332. /*
  333. * managing i/o requests and associated device resources
  334. */
  335. .urb_enqueue = ohci_urb_enqueue,
  336. .urb_dequeue = ohci_urb_dequeue,
  337. .endpoint_disable = ohci_endpoint_disable,
  338. /*
  339. * scheduling support
  340. */
  341. .get_frame_number = ohci_get_frame,
  342. /*
  343. * root hub support
  344. */
  345. .hub_status_data = ohci_at91_hub_status_data,
  346. .hub_control = ohci_at91_hub_control,
  347. #ifdef CONFIG_PM
  348. .bus_suspend = ohci_bus_suspend,
  349. .bus_resume = ohci_bus_resume,
  350. #endif
  351. .start_port_reset = ohci_start_port_reset,
  352. };
  353. /*-------------------------------------------------------------------------*/
  354. static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data)
  355. {
  356. struct platform_device *pdev = data;
  357. struct at91_usbh_data *pdata = pdev->dev.platform_data;
  358. int val, gpio, port;
  359. /* From the GPIO notifying the over-current situation, find
  360. * out the corresponding port */
  361. for (port = 0; port < ARRAY_SIZE(pdata->overcurrent_pin); port++) {
  362. if (gpio_to_irq(pdata->overcurrent_pin[port]) == irq) {
  363. gpio = pdata->overcurrent_pin[port];
  364. break;
  365. }
  366. }
  367. if (port == ARRAY_SIZE(pdata->overcurrent_pin)) {
  368. dev_err(& pdev->dev, "overcurrent interrupt from unknown GPIO\n");
  369. return IRQ_HANDLED;
  370. }
  371. val = gpio_get_value(gpio);
  372. /* When notified of an over-current situation, disable power
  373. on the corresponding port, and mark this port in
  374. over-current. */
  375. if (! val) {
  376. ohci_at91_usb_set_power(pdata, port, 0);
  377. pdata->overcurrent_status[port] = 1;
  378. pdata->overcurrent_changed[port] = 1;
  379. }
  380. dev_dbg(& pdev->dev, "overcurrent situation %s\n",
  381. val ? "exited" : "notified");
  382. return IRQ_HANDLED;
  383. }
  384. #ifdef CONFIG_OF
  385. static const struct of_device_id at91_ohci_dt_ids[] = {
  386. { .compatible = "atmel,at91rm9200-ohci" },
  387. { /* sentinel */ }
  388. };
  389. MODULE_DEVICE_TABLE(of, at91_ohci_dt_ids);
  390. static u64 at91_ohci_dma_mask = DMA_BIT_MASK(32);
  391. static int __devinit ohci_at91_of_init(struct platform_device *pdev)
  392. {
  393. struct device_node *np = pdev->dev.of_node;
  394. int i, ret, gpio;
  395. enum of_gpio_flags flags;
  396. struct at91_usbh_data *pdata;
  397. u32 ports;
  398. if (!np)
  399. return 0;
  400. /* Right now device-tree probed devices don't get dma_mask set.
  401. * Since shared usb code relies on it, set it here for now.
  402. * Once we have dma capability bindings this can go away.
  403. */
  404. if (!pdev->dev.dma_mask)
  405. pdev->dev.dma_mask = &at91_ohci_dma_mask;
  406. pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
  407. if (!pdata)
  408. return -ENOMEM;
  409. if (!of_property_read_u32(np, "num-ports", &ports))
  410. pdata->ports = ports;
  411. for (i = 0; i < 2; i++) {
  412. gpio = of_get_named_gpio_flags(np, "atmel,vbus-gpio", i, &flags);
  413. pdata->vbus_pin[i] = gpio;
  414. if (!gpio_is_valid(gpio))
  415. continue;
  416. pdata->vbus_pin_active_low[i] = flags & OF_GPIO_ACTIVE_LOW;
  417. ret = gpio_request(gpio, "ohci_vbus");
  418. if (ret) {
  419. dev_warn(&pdev->dev, "can't request vbus gpio %d", gpio);
  420. continue;
  421. }
  422. ret = gpio_direction_output(gpio, !(flags & OF_GPIO_ACTIVE_LOW) ^ 1);
  423. if (ret)
  424. dev_warn(&pdev->dev, "can't put vbus gpio %d as output %d",
  425. !(flags & OF_GPIO_ACTIVE_LOW) ^ 1, gpio);
  426. }
  427. for (i = 0; i < 2; i++) {
  428. gpio = of_get_named_gpio_flags(np, "atmel,oc-gpio", i, &flags);
  429. pdata->overcurrent_pin[i] = gpio;
  430. if (!gpio_is_valid(gpio))
  431. continue;
  432. ret = gpio_request(gpio, "ohci_overcurrent");
  433. if (ret) {
  434. dev_err(&pdev->dev, "can't request overcurrent gpio %d", gpio);
  435. continue;
  436. }
  437. ret = gpio_direction_input(gpio);
  438. if (ret) {
  439. dev_err(&pdev->dev, "can't configure overcurrent gpio %d as input", gpio);
  440. continue;
  441. }
  442. ret = request_irq(gpio_to_irq(gpio),
  443. ohci_hcd_at91_overcurrent_irq,
  444. IRQF_SHARED, "ohci_overcurrent", pdev);
  445. if (ret) {
  446. gpio_free(gpio);
  447. dev_warn(& pdev->dev, "cannot get GPIO IRQ for overcurrent\n");
  448. }
  449. }
  450. pdev->dev.platform_data = pdata;
  451. return 0;
  452. }
  453. #else
  454. static int __devinit ohci_at91_of_init(struct platform_device *pdev)
  455. {
  456. return 0;
  457. }
  458. #endif
  459. /*-------------------------------------------------------------------------*/
  460. static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
  461. {
  462. struct at91_usbh_data *pdata;
  463. int i;
  464. i = ohci_at91_of_init(pdev);
  465. if (i)
  466. return i;
  467. pdata = pdev->dev.platform_data;
  468. if (pdata) {
  469. for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) {
  470. if (!gpio_is_valid(pdata->vbus_pin[i]))
  471. continue;
  472. gpio_request(pdata->vbus_pin[i], "ohci_vbus");
  473. ohci_at91_usb_set_power(pdata, i, 1);
  474. }
  475. for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) {
  476. int ret;
  477. if (!gpio_is_valid(pdata->overcurrent_pin[i]))
  478. continue;
  479. gpio_request(pdata->overcurrent_pin[i], "ohci_overcurrent");
  480. ret = request_irq(gpio_to_irq(pdata->overcurrent_pin[i]),
  481. ohci_hcd_at91_overcurrent_irq,
  482. IRQF_SHARED, "ohci_overcurrent", pdev);
  483. if (ret) {
  484. gpio_free(pdata->overcurrent_pin[i]);
  485. dev_warn(& pdev->dev, "cannot get GPIO IRQ for overcurrent\n");
  486. }
  487. }
  488. }
  489. device_init_wakeup(&pdev->dev, 1);
  490. return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev);
  491. }
  492. static int ohci_hcd_at91_drv_remove(struct platform_device *pdev)
  493. {
  494. struct at91_usbh_data *pdata = pdev->dev.platform_data;
  495. int i;
  496. if (pdata) {
  497. for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) {
  498. if (!gpio_is_valid(pdata->vbus_pin[i]))
  499. continue;
  500. ohci_at91_usb_set_power(pdata, i, 0);
  501. gpio_free(pdata->vbus_pin[i]);
  502. }
  503. for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) {
  504. if (!gpio_is_valid(pdata->overcurrent_pin[i]))
  505. continue;
  506. free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev);
  507. gpio_free(pdata->overcurrent_pin[i]);
  508. }
  509. }
  510. device_init_wakeup(&pdev->dev, 0);
  511. usb_hcd_at91_remove(platform_get_drvdata(pdev), pdev);
  512. return 0;
  513. }
  514. #ifdef CONFIG_PM
  515. static int
  516. ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
  517. {
  518. struct usb_hcd *hcd = platform_get_drvdata(pdev);
  519. struct ohci_hcd *ohci = hcd_to_ohci(hcd);
  520. if (device_may_wakeup(&pdev->dev))
  521. enable_irq_wake(hcd->irq);
  522. /*
  523. * The integrated transceivers seem unable to notice disconnect,
  524. * reconnect, or wakeup without the 48 MHz clock active. so for
  525. * correctness, always discard connection state (using reset).
  526. *
  527. * REVISIT: some boards will be able to turn VBUS off...
  528. */
  529. if (at91_suspend_entering_slow_clock()) {
  530. ohci_usb_reset (ohci);
  531. /* flush the writes */
  532. (void) ohci_readl (ohci, &ohci->regs->control);
  533. at91_stop_clock();
  534. }
  535. return 0;
  536. }
  537. static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
  538. {
  539. struct usb_hcd *hcd = platform_get_drvdata(pdev);
  540. if (device_may_wakeup(&pdev->dev))
  541. disable_irq_wake(hcd->irq);
  542. if (!clocked)
  543. at91_start_clock();
  544. ohci_finish_controller_resume(hcd);
  545. return 0;
  546. }
  547. #else
  548. #define ohci_hcd_at91_drv_suspend NULL
  549. #define ohci_hcd_at91_drv_resume NULL
  550. #endif
  551. MODULE_ALIAS("platform:at91_ohci");
  552. static struct platform_driver ohci_hcd_at91_driver = {
  553. .probe = ohci_hcd_at91_drv_probe,
  554. .remove = ohci_hcd_at91_drv_remove,
  555. .shutdown = usb_hcd_platform_shutdown,
  556. .suspend = ohci_hcd_at91_drv_suspend,
  557. .resume = ohci_hcd_at91_drv_resume,
  558. .driver = {
  559. .name = "at91_ohci",
  560. .owner = THIS_MODULE,
  561. .of_match_table = of_match_ptr(at91_ohci_dt_ids),
  562. },
  563. };