ohci-at91.c 17 KB

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