ohci-at91.c 17 KB

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