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 <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. #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 __devexit 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 __devinit 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 = pdev->resource[0].end - pdev->resource[0].start + 1;
  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 __devexit 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 __devinit
  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 __devinit
  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. err("can't start %s", hcd->self.bus_name);
  199. ohci_stop(hcd);
  200. return ret;
  201. }
  202. return 0;
  203. }
  204. static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int enable)
  205. {
  206. if (!valid_port(port))
  207. return;
  208. if (!gpio_is_valid(pdata->vbus_pin[port]))
  209. return;
  210. gpio_set_value(pdata->vbus_pin[port],
  211. pdata->vbus_pin_active_low[port] ^ enable);
  212. }
  213. static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)
  214. {
  215. if (!valid_port(port))
  216. return -EINVAL;
  217. if (!gpio_is_valid(pdata->vbus_pin[port]))
  218. return -EINVAL;
  219. return gpio_get_value(pdata->vbus_pin[port]) ^
  220. pdata->vbus_pin_active_low[port];
  221. }
  222. /*
  223. * Update the status data from the hub with the over-current indicator change.
  224. */
  225. static int ohci_at91_hub_status_data(struct usb_hcd *hcd, char *buf)
  226. {
  227. struct at91_usbh_data *pdata = hcd->self.controller->platform_data;
  228. int length = ohci_hub_status_data(hcd, buf);
  229. int port;
  230. at91_for_each_port(port) {
  231. if (pdata->overcurrent_changed[port]) {
  232. if (!length)
  233. length = 1;
  234. buf[0] |= 1 << (port + 1);
  235. }
  236. }
  237. return length;
  238. }
  239. /*
  240. * Look at the control requests to the root hub and see if we need to override.
  241. */
  242. static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
  243. u16 wIndex, char *buf, u16 wLength)
  244. {
  245. struct at91_usbh_data *pdata = hcd->self.controller->platform_data;
  246. struct usb_hub_descriptor *desc;
  247. int ret = -EINVAL;
  248. u32 *data = (u32 *)buf;
  249. dev_dbg(hcd->self.controller,
  250. "ohci_at91_hub_control(%pK,0x%04x,0x%04x,0x%04x,%pK,%04x)\n",
  251. hcd, typeReq, wValue, wIndex, buf, wLength);
  252. wIndex--;
  253. switch (typeReq) {
  254. case SetPortFeature:
  255. if (wValue == USB_PORT_FEAT_POWER) {
  256. dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n");
  257. if (valid_port(wIndex)) {
  258. ohci_at91_usb_set_power(pdata, wIndex, 1);
  259. ret = 0;
  260. }
  261. goto out;
  262. }
  263. break;
  264. case ClearPortFeature:
  265. switch (wValue) {
  266. case USB_PORT_FEAT_C_OVER_CURRENT:
  267. dev_dbg(hcd->self.controller,
  268. "ClearPortFeature: C_OVER_CURRENT\n");
  269. if (valid_port(wIndex)) {
  270. pdata->overcurrent_changed[wIndex] = 0;
  271. pdata->overcurrent_status[wIndex] = 0;
  272. }
  273. goto out;
  274. case USB_PORT_FEAT_OVER_CURRENT:
  275. dev_dbg(hcd->self.controller,
  276. "ClearPortFeature: OVER_CURRENT\n");
  277. if (valid_port(wIndex))
  278. pdata->overcurrent_status[wIndex] = 0;
  279. goto out;
  280. case USB_PORT_FEAT_POWER:
  281. dev_dbg(hcd->self.controller,
  282. "ClearPortFeature: POWER\n");
  283. if (valid_port(wIndex)) {
  284. ohci_at91_usb_set_power(pdata, wIndex, 0);
  285. return 0;
  286. }
  287. }
  288. break;
  289. }
  290. ret = ohci_hub_control(hcd, typeReq, wValue, wIndex + 1, buf, wLength);
  291. if (ret)
  292. goto out;
  293. switch (typeReq) {
  294. case GetHubDescriptor:
  295. /* update the hub's descriptor */
  296. desc = (struct usb_hub_descriptor *)buf;
  297. dev_dbg(hcd->self.controller, "wHubCharacteristics 0x%04x\n",
  298. desc->wHubCharacteristics);
  299. /* remove the old configurations for power-switching, and
  300. * over-current protection, and insert our new configuration
  301. */
  302. desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM);
  303. desc->wHubCharacteristics |= cpu_to_le16(0x0001);
  304. if (pdata->overcurrent_supported) {
  305. desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_OCPM);
  306. desc->wHubCharacteristics |= cpu_to_le16(0x0008|0x0001);
  307. }
  308. dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n",
  309. desc->wHubCharacteristics);
  310. return ret;
  311. case GetPortStatus:
  312. /* check port status */
  313. dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex);
  314. if (valid_port(wIndex)) {
  315. if (!ohci_at91_usb_get_power(pdata, wIndex))
  316. *data &= ~cpu_to_le32(RH_PS_PPS);
  317. if (pdata->overcurrent_changed[wIndex])
  318. *data |= cpu_to_le32(RH_PS_OCIC);
  319. if (pdata->overcurrent_status[wIndex])
  320. *data |= cpu_to_le32(RH_PS_POCI);
  321. }
  322. }
  323. out:
  324. return ret;
  325. }
  326. /*-------------------------------------------------------------------------*/
  327. static const struct hc_driver ohci_at91_hc_driver = {
  328. .description = hcd_name,
  329. .product_desc = "AT91 OHCI",
  330. .hcd_priv_size = sizeof(struct ohci_hcd),
  331. /*
  332. * generic hardware linkage
  333. */
  334. .irq = ohci_irq,
  335. .flags = HCD_USB11 | HCD_MEMORY,
  336. /*
  337. * basic lifecycle operations
  338. */
  339. .reset = ohci_at91_reset,
  340. .start = ohci_at91_start,
  341. .stop = ohci_stop,
  342. .shutdown = ohci_shutdown,
  343. /*
  344. * managing i/o requests and associated device resources
  345. */
  346. .urb_enqueue = ohci_urb_enqueue,
  347. .urb_dequeue = ohci_urb_dequeue,
  348. .endpoint_disable = ohci_endpoint_disable,
  349. /*
  350. * scheduling support
  351. */
  352. .get_frame_number = ohci_get_frame,
  353. /*
  354. * root hub support
  355. */
  356. .hub_status_data = ohci_at91_hub_status_data,
  357. .hub_control = ohci_at91_hub_control,
  358. #ifdef CONFIG_PM
  359. .bus_suspend = ohci_bus_suspend,
  360. .bus_resume = ohci_bus_resume,
  361. #endif
  362. .start_port_reset = ohci_start_port_reset,
  363. };
  364. /*-------------------------------------------------------------------------*/
  365. static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data)
  366. {
  367. struct platform_device *pdev = data;
  368. struct at91_usbh_data *pdata = pdev->dev.platform_data;
  369. int val, gpio, port;
  370. /* From the GPIO notifying the over-current situation, find
  371. * out the corresponding port */
  372. at91_for_each_port(port) {
  373. if (gpio_is_valid(pdata->overcurrent_pin[port]) &&
  374. gpio_to_irq(pdata->overcurrent_pin[port]) == irq) {
  375. gpio = pdata->overcurrent_pin[port];
  376. break;
  377. }
  378. }
  379. if (port == AT91_MAX_USBH_PORTS) {
  380. dev_err(& pdev->dev, "overcurrent interrupt from unknown GPIO\n");
  381. return IRQ_HANDLED;
  382. }
  383. val = gpio_get_value(gpio);
  384. /* When notified of an over-current situation, disable power
  385. on the corresponding port, and mark this port in
  386. over-current. */
  387. if (!val) {
  388. ohci_at91_usb_set_power(pdata, port, 0);
  389. pdata->overcurrent_status[port] = 1;
  390. pdata->overcurrent_changed[port] = 1;
  391. }
  392. dev_dbg(& pdev->dev, "overcurrent situation %s\n",
  393. val ? "exited" : "notified");
  394. return IRQ_HANDLED;
  395. }
  396. #ifdef CONFIG_OF
  397. static const struct of_device_id at91_ohci_dt_ids[] = {
  398. { .compatible = "atmel,at91rm9200-ohci" },
  399. { /* sentinel */ }
  400. };
  401. MODULE_DEVICE_TABLE(of, at91_ohci_dt_ids);
  402. static u64 at91_ohci_dma_mask = DMA_BIT_MASK(32);
  403. static int __devinit ohci_at91_of_init(struct platform_device *pdev)
  404. {
  405. struct device_node *np = pdev->dev.of_node;
  406. int i, gpio;
  407. enum of_gpio_flags flags;
  408. struct at91_usbh_data *pdata;
  409. u32 ports;
  410. if (!np)
  411. return 0;
  412. /* Right now device-tree probed devices don't get dma_mask set.
  413. * Since shared usb code relies on it, set it here for now.
  414. * Once we have dma capability bindings this can go away.
  415. */
  416. if (!pdev->dev.dma_mask)
  417. pdev->dev.dma_mask = &at91_ohci_dma_mask;
  418. pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
  419. if (!pdata)
  420. return -ENOMEM;
  421. if (!of_property_read_u32(np, "num-ports", &ports))
  422. pdata->ports = ports;
  423. at91_for_each_port(i) {
  424. gpio = of_get_named_gpio_flags(np, "atmel,vbus-gpio", i, &flags);
  425. pdata->vbus_pin[i] = gpio;
  426. if (!gpio_is_valid(gpio))
  427. continue;
  428. pdata->vbus_pin_active_low[i] = flags & OF_GPIO_ACTIVE_LOW;
  429. }
  430. at91_for_each_port(i)
  431. pdata->overcurrent_pin[i] =
  432. of_get_named_gpio_flags(np, "atmel,oc-gpio", i, &flags);
  433. pdev->dev.platform_data = pdata;
  434. return 0;
  435. }
  436. #else
  437. static int __devinit ohci_at91_of_init(struct platform_device *pdev)
  438. {
  439. return 0;
  440. }
  441. #endif
  442. /*-------------------------------------------------------------------------*/
  443. static int __devinit ohci_hcd_at91_drv_probe(struct platform_device *pdev)
  444. {
  445. struct at91_usbh_data *pdata;
  446. int i;
  447. int gpio;
  448. int ret;
  449. ret = ohci_at91_of_init(pdev);
  450. if (ret)
  451. return ret;
  452. pdata = pdev->dev.platform_data;
  453. if (pdata) {
  454. at91_for_each_port(i) {
  455. /*
  456. * do not configure PIO if not in relation with
  457. * real USB port on board
  458. */
  459. if (i >= pdata->ports) {
  460. pdata->vbus_pin[i] = -EINVAL;
  461. pdata->overcurrent_pin[i] = -EINVAL;
  462. break;
  463. }
  464. if (!gpio_is_valid(pdata->vbus_pin[i]))
  465. continue;
  466. gpio = pdata->vbus_pin[i];
  467. ret = gpio_request(gpio, "ohci_vbus");
  468. if (ret) {
  469. dev_err(&pdev->dev,
  470. "can't request vbus gpio %d\n", gpio);
  471. continue;
  472. }
  473. ret = gpio_direction_output(gpio,
  474. !pdata->vbus_pin_active_low[i]);
  475. if (ret) {
  476. dev_err(&pdev->dev,
  477. "can't put vbus gpio %d as output %d\n",
  478. gpio, !pdata->vbus_pin_active_low[i]);
  479. gpio_free(gpio);
  480. continue;
  481. }
  482. ohci_at91_usb_set_power(pdata, i, 1);
  483. }
  484. at91_for_each_port(i) {
  485. if (!gpio_is_valid(pdata->overcurrent_pin[i]))
  486. continue;
  487. gpio = pdata->overcurrent_pin[i];
  488. ret = gpio_request(gpio, "ohci_overcurrent");
  489. if (ret) {
  490. dev_err(&pdev->dev,
  491. "can't request overcurrent gpio %d\n",
  492. gpio);
  493. continue;
  494. }
  495. ret = gpio_direction_input(gpio);
  496. if (ret) {
  497. dev_err(&pdev->dev,
  498. "can't configure overcurrent gpio %d as input\n",
  499. gpio);
  500. gpio_free(gpio);
  501. continue;
  502. }
  503. ret = request_irq(gpio_to_irq(gpio),
  504. ohci_hcd_at91_overcurrent_irq,
  505. IRQF_SHARED, "ohci_overcurrent", pdev);
  506. if (ret) {
  507. gpio_free(gpio);
  508. dev_err(&pdev->dev,
  509. "can't get gpio IRQ for overcurrent\n");
  510. }
  511. }
  512. }
  513. device_init_wakeup(&pdev->dev, 1);
  514. return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev);
  515. }
  516. static int __devexit ohci_hcd_at91_drv_remove(struct platform_device *pdev)
  517. {
  518. struct at91_usbh_data *pdata = pdev->dev.platform_data;
  519. int i;
  520. if (pdata) {
  521. at91_for_each_port(i) {
  522. if (!gpio_is_valid(pdata->vbus_pin[i]))
  523. continue;
  524. ohci_at91_usb_set_power(pdata, i, 0);
  525. gpio_free(pdata->vbus_pin[i]);
  526. }
  527. at91_for_each_port(i) {
  528. if (!gpio_is_valid(pdata->overcurrent_pin[i]))
  529. continue;
  530. free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev);
  531. gpio_free(pdata->overcurrent_pin[i]);
  532. }
  533. }
  534. device_init_wakeup(&pdev->dev, 0);
  535. usb_hcd_at91_remove(platform_get_drvdata(pdev), pdev);
  536. return 0;
  537. }
  538. #ifdef CONFIG_PM
  539. static int
  540. ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
  541. {
  542. struct usb_hcd *hcd = platform_get_drvdata(pdev);
  543. struct ohci_hcd *ohci = hcd_to_ohci(hcd);
  544. if (device_may_wakeup(&pdev->dev))
  545. enable_irq_wake(hcd->irq);
  546. /*
  547. * The integrated transceivers seem unable to notice disconnect,
  548. * reconnect, or wakeup without the 48 MHz clock active. so for
  549. * correctness, always discard connection state (using reset).
  550. *
  551. * REVISIT: some boards will be able to turn VBUS off...
  552. */
  553. if (at91_suspend_entering_slow_clock()) {
  554. ohci_usb_reset (ohci);
  555. /* flush the writes */
  556. (void) ohci_readl (ohci, &ohci->regs->control);
  557. at91_stop_clock();
  558. }
  559. return 0;
  560. }
  561. static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
  562. {
  563. struct usb_hcd *hcd = platform_get_drvdata(pdev);
  564. if (device_may_wakeup(&pdev->dev))
  565. disable_irq_wake(hcd->irq);
  566. if (!clocked)
  567. at91_start_clock();
  568. ohci_finish_controller_resume(hcd);
  569. return 0;
  570. }
  571. #else
  572. #define ohci_hcd_at91_drv_suspend NULL
  573. #define ohci_hcd_at91_drv_resume NULL
  574. #endif
  575. MODULE_ALIAS("platform:at91_ohci");
  576. static struct platform_driver ohci_hcd_at91_driver = {
  577. .probe = ohci_hcd_at91_drv_probe,
  578. .remove = __devexit_p(ohci_hcd_at91_drv_remove),
  579. .shutdown = usb_hcd_platform_shutdown,
  580. .suspend = ohci_hcd_at91_drv_suspend,
  581. .resume = ohci_hcd_at91_drv_resume,
  582. .driver = {
  583. .name = "at91_ohci",
  584. .owner = THIS_MODULE,
  585. .of_match_table = of_match_ptr(at91_ohci_dt_ids),
  586. },
  587. };