ohci-at91.c 17 KB

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