ohci-at91.c 16 KB

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