ohci-at91.c 17 KB

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