ohci-at91.c 17 KB

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