ohci-at91.c 17 KB

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