Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Generic platform ohci driver |
| 3 | * |
| 4 | * Copyright 2007 Michael Buesch <m@bues.ch> |
| 5 | * Copyright 2011-2012 Hauke Mehrtens <hauke@hauke-m.de> |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 6 | * Copyright 2014 Hans de Goede <hdegoede@redhat.com> |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 7 | * |
| 8 | * Derived from the OCHI-SSB driver |
| 9 | * Derived from the OHCI-PCI driver |
| 10 | * Copyright 1999 Roman Weissgaerber |
| 11 | * Copyright 2000-2002 David Brownell |
| 12 | * Copyright 1999 Linus Torvalds |
| 13 | * Copyright 1999 Gregory P. Smith |
| 14 | * |
| 15 | * Licensed under the GNU/GPL. See COPYING for details. |
| 16 | */ |
Manjunath Goudar | 928fb68 | 2013-06-03 20:46:08 +0530 | [diff] [blame] | 17 | |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 18 | #include <linux/clk.h> |
| 19 | #include <linux/dma-mapping.h> |
Manjunath Goudar | 928fb68 | 2013-06-03 20:46:08 +0530 | [diff] [blame] | 20 | #include <linux/hrtimer.h> |
| 21 | #include <linux/io.h> |
| 22 | #include <linux/kernel.h> |
| 23 | #include <linux/module.h> |
Thierry Reding | 148e113 | 2013-01-21 11:09:22 +0100 | [diff] [blame] | 24 | #include <linux/err.h> |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 25 | #include <linux/phy/phy.h> |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 26 | #include <linux/platform_device.h> |
Maxime Ripard | 4615f3b | 2014-05-13 17:44:20 +0200 | [diff] [blame] | 27 | #include <linux/reset.h> |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 28 | #include <linux/usb/ohci_pdriver.h> |
Manjunath Goudar | 928fb68 | 2013-06-03 20:46:08 +0530 | [diff] [blame] | 29 | #include <linux/usb.h> |
| 30 | #include <linux/usb/hcd.h> |
| 31 | |
| 32 | #include "ohci.h" |
| 33 | |
| 34 | #define DRIVER_DESC "OHCI generic platform driver" |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 35 | #define OHCI_MAX_CLKS 3 |
| 36 | #define hcd_to_ohci_priv(h) ((struct ohci_platform_priv *)hcd_to_ohci(h)->priv) |
| 37 | |
| 38 | struct ohci_platform_priv { |
| 39 | struct clk *clks[OHCI_MAX_CLKS]; |
Maxime Ripard | 4615f3b | 2014-05-13 17:44:20 +0200 | [diff] [blame] | 40 | struct reset_control *rst; |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 41 | struct phy *phy; |
| 42 | }; |
Manjunath Goudar | 928fb68 | 2013-06-03 20:46:08 +0530 | [diff] [blame] | 43 | |
| 44 | static const char hcd_name[] = "ohci-platform"; |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 45 | |
| 46 | static int ohci_platform_reset(struct usb_hcd *hcd) |
| 47 | { |
| 48 | struct platform_device *pdev = to_platform_device(hcd->self.controller); |
Jingoo Han | d4f09e2 | 2013-07-30 19:59:40 +0900 | [diff] [blame] | 49 | struct usb_ohci_pdata *pdata = dev_get_platdata(&pdev->dev); |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 50 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 51 | |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 52 | if (pdata->no_big_frame_no) |
| 53 | ohci->flags |= OHCI_QUIRK_FRAME_NO; |
Florian Fainelli | 2b16e39 | 2012-10-08 15:11:26 +0200 | [diff] [blame] | 54 | if (pdata->num_ports) |
| 55 | ohci->num_ports = pdata->num_ports; |
| 56 | |
Manjunath Goudar | 928fb68 | 2013-06-03 20:46:08 +0530 | [diff] [blame] | 57 | return ohci_setup(hcd); |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 58 | } |
| 59 | |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 60 | static int ohci_platform_power_on(struct platform_device *dev) |
| 61 | { |
| 62 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
| 63 | struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd); |
| 64 | int clk, ret; |
| 65 | |
| 66 | for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) { |
| 67 | ret = clk_prepare_enable(priv->clks[clk]); |
| 68 | if (ret) |
| 69 | goto err_disable_clks; |
| 70 | } |
| 71 | |
| 72 | if (priv->phy) { |
| 73 | ret = phy_init(priv->phy); |
| 74 | if (ret) |
| 75 | goto err_disable_clks; |
| 76 | |
| 77 | ret = phy_power_on(priv->phy); |
| 78 | if (ret) |
| 79 | goto err_exit_phy; |
| 80 | } |
| 81 | |
| 82 | return 0; |
| 83 | |
| 84 | err_exit_phy: |
| 85 | phy_exit(priv->phy); |
| 86 | err_disable_clks: |
| 87 | while (--clk >= 0) |
| 88 | clk_disable_unprepare(priv->clks[clk]); |
| 89 | |
| 90 | return ret; |
| 91 | } |
| 92 | |
| 93 | static void ohci_platform_power_off(struct platform_device *dev) |
| 94 | { |
| 95 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
| 96 | struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd); |
| 97 | int clk; |
| 98 | |
| 99 | if (priv->phy) { |
| 100 | phy_power_off(priv->phy); |
| 101 | phy_exit(priv->phy); |
| 102 | } |
| 103 | |
| 104 | for (clk = OHCI_MAX_CLKS - 1; clk >= 0; clk--) |
| 105 | if (priv->clks[clk]) |
| 106 | clk_disable_unprepare(priv->clks[clk]); |
| 107 | } |
| 108 | |
Manjunath Goudar | 928fb68 | 2013-06-03 20:46:08 +0530 | [diff] [blame] | 109 | static struct hc_driver __read_mostly ohci_platform_hc_driver; |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 110 | |
Manjunath Goudar | 928fb68 | 2013-06-03 20:46:08 +0530 | [diff] [blame] | 111 | static const struct ohci_driver_overrides platform_overrides __initconst = { |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 112 | .product_desc = "Generic Platform OHCI controller", |
| 113 | .reset = ohci_platform_reset, |
| 114 | .extra_priv_size = sizeof(struct ohci_platform_priv), |
| 115 | }; |
| 116 | |
| 117 | static struct usb_ohci_pdata ohci_platform_defaults = { |
| 118 | .power_on = ohci_platform_power_on, |
| 119 | .power_suspend = ohci_platform_power_off, |
| 120 | .power_off = ohci_platform_power_off, |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 121 | }; |
| 122 | |
Bill Pemberton | 41ac7b3 | 2012-11-19 13:21:48 -0500 | [diff] [blame] | 123 | static int ohci_platform_probe(struct platform_device *dev) |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 124 | { |
| 125 | struct usb_hcd *hcd; |
| 126 | struct resource *res_mem; |
Jingoo Han | d4f09e2 | 2013-07-30 19:59:40 +0900 | [diff] [blame] | 127 | struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 128 | struct ohci_platform_priv *priv; |
Hans de Goede | b103441 | 2014-02-07 16:36:42 +0100 | [diff] [blame] | 129 | struct ohci_hcd *ohci; |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 130 | int err, irq, clk = 0; |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 131 | |
| 132 | if (usb_disabled()) |
| 133 | return -ENODEV; |
| 134 | |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 135 | /* |
| 136 | * Use reasonable defaults so platforms don't have to provide these |
| 137 | * with DT probing on ARM. |
| 138 | */ |
| 139 | if (!pdata) |
| 140 | pdata = &ohci_platform_defaults; |
| 141 | |
| 142 | err = dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); |
| 143 | if (err) |
| 144 | return err; |
| 145 | |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 146 | irq = platform_get_irq(dev, 0); |
| 147 | if (irq < 0) { |
Florian Fainelli | 976baf6 | 2012-10-08 15:11:42 +0200 | [diff] [blame] | 148 | dev_err(&dev->dev, "no irq provided"); |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 149 | return irq; |
| 150 | } |
| 151 | |
| 152 | res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); |
| 153 | if (!res_mem) { |
Florian Fainelli | ac0e3c0 | 2012-10-08 15:11:44 +0200 | [diff] [blame] | 154 | dev_err(&dev->dev, "no memory resource provided"); |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 155 | return -ENXIO; |
| 156 | } |
| 157 | |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 158 | hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev, |
| 159 | dev_name(&dev->dev)); |
| 160 | if (!hcd) |
| 161 | return -ENOMEM; |
| 162 | |
| 163 | platform_set_drvdata(dev, hcd); |
| 164 | dev->dev.platform_data = pdata; |
| 165 | priv = hcd_to_ohci_priv(hcd); |
Hans de Goede | b103441 | 2014-02-07 16:36:42 +0100 | [diff] [blame] | 166 | ohci = hcd_to_ohci(hcd); |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 167 | |
| 168 | if (pdata == &ohci_platform_defaults && dev->dev.of_node) { |
Hans de Goede | b103441 | 2014-02-07 16:36:42 +0100 | [diff] [blame] | 169 | if (of_property_read_bool(dev->dev.of_node, "big-endian-regs")) |
| 170 | ohci->flags |= OHCI_QUIRK_BE_MMIO; |
| 171 | |
| 172 | if (of_property_read_bool(dev->dev.of_node, "big-endian-desc")) |
| 173 | ohci->flags |= OHCI_QUIRK_BE_DESC; |
| 174 | |
| 175 | if (of_property_read_bool(dev->dev.of_node, "big-endian")) |
| 176 | ohci->flags |= OHCI_QUIRK_BE_MMIO | OHCI_QUIRK_BE_DESC; |
| 177 | |
Kevin Cernekee | c4b8692 | 2014-10-11 11:10:48 -0700 | [diff] [blame^] | 178 | if (of_property_read_bool(dev->dev.of_node, "no-big-frame-no")) |
| 179 | ohci->flags |= OHCI_QUIRK_FRAME_NO; |
| 180 | |
| 181 | of_property_read_u32(dev->dev.of_node, "num-ports", |
| 182 | &ohci->num_ports); |
| 183 | |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 184 | priv->phy = devm_phy_get(&dev->dev, "usb"); |
| 185 | if (IS_ERR(priv->phy)) { |
| 186 | err = PTR_ERR(priv->phy); |
| 187 | if (err == -EPROBE_DEFER) |
| 188 | goto err_put_hcd; |
| 189 | priv->phy = NULL; |
| 190 | } |
| 191 | |
| 192 | for (clk = 0; clk < OHCI_MAX_CLKS; clk++) { |
| 193 | priv->clks[clk] = of_clk_get(dev->dev.of_node, clk); |
| 194 | if (IS_ERR(priv->clks[clk])) { |
| 195 | err = PTR_ERR(priv->clks[clk]); |
| 196 | if (err == -EPROBE_DEFER) |
| 197 | goto err_put_clks; |
| 198 | priv->clks[clk] = NULL; |
| 199 | break; |
| 200 | } |
| 201 | } |
Maxime Ripard | 4615f3b | 2014-05-13 17:44:20 +0200 | [diff] [blame] | 202 | |
| 203 | } |
| 204 | |
| 205 | priv->rst = devm_reset_control_get_optional(&dev->dev, NULL); |
| 206 | if (IS_ERR(priv->rst)) { |
| 207 | err = PTR_ERR(priv->rst); |
| 208 | if (err == -EPROBE_DEFER) |
| 209 | goto err_put_clks; |
| 210 | priv->rst = NULL; |
| 211 | } else { |
| 212 | err = reset_control_deassert(priv->rst); |
| 213 | if (err) |
| 214 | goto err_put_clks; |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 215 | } |
| 216 | |
Alan Stern | adff529 | 2014-02-11 11:26:00 -0500 | [diff] [blame] | 217 | if (pdata->big_endian_desc) |
| 218 | ohci->flags |= OHCI_QUIRK_BE_DESC; |
| 219 | if (pdata->big_endian_mmio) |
| 220 | ohci->flags |= OHCI_QUIRK_BE_MMIO; |
| 221 | |
| 222 | #ifndef CONFIG_USB_OHCI_BIG_ENDIAN_MMIO |
| 223 | if (ohci->flags & OHCI_QUIRK_BE_MMIO) { |
| 224 | dev_err(&dev->dev, |
| 225 | "Error: CONFIG_USB_OHCI_BIG_ENDIAN_MMIO not set\n"); |
| 226 | err = -EINVAL; |
Maxime Ripard | 4615f3b | 2014-05-13 17:44:20 +0200 | [diff] [blame] | 227 | goto err_reset; |
Alan Stern | adff529 | 2014-02-11 11:26:00 -0500 | [diff] [blame] | 228 | } |
| 229 | #endif |
| 230 | #ifndef CONFIG_USB_OHCI_BIG_ENDIAN_DESC |
| 231 | if (ohci->flags & OHCI_QUIRK_BE_DESC) { |
| 232 | dev_err(&dev->dev, |
| 233 | "Error: CONFIG_USB_OHCI_BIG_ENDIAN_DESC not set\n"); |
| 234 | err = -EINVAL; |
Maxime Ripard | 4615f3b | 2014-05-13 17:44:20 +0200 | [diff] [blame] | 235 | goto err_reset; |
Alan Stern | adff529 | 2014-02-11 11:26:00 -0500 | [diff] [blame] | 236 | } |
| 237 | #endif |
| 238 | |
Kuninori Morimoto | e4d37ae | 2012-08-06 18:09:10 -0700 | [diff] [blame] | 239 | if (pdata->power_on) { |
| 240 | err = pdata->power_on(dev); |
| 241 | if (err < 0) |
Maxime Ripard | 4615f3b | 2014-05-13 17:44:20 +0200 | [diff] [blame] | 242 | goto err_reset; |
Kuninori Morimoto | e4d37ae | 2012-08-06 18:09:10 -0700 | [diff] [blame] | 243 | } |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 244 | |
| 245 | hcd->rsrc_start = res_mem->start; |
| 246 | hcd->rsrc_len = resource_size(res_mem); |
| 247 | |
Thierry Reding | 148e113 | 2013-01-21 11:09:22 +0100 | [diff] [blame] | 248 | hcd->regs = devm_ioremap_resource(&dev->dev, res_mem); |
| 249 | if (IS_ERR(hcd->regs)) { |
| 250 | err = PTR_ERR(hcd->regs); |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 251 | goto err_power; |
Julia Lawall | aece389 | 2012-08-14 08:47:37 +0200 | [diff] [blame] | 252 | } |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 253 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); |
| 254 | if (err) |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 255 | goto err_power; |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 256 | |
Peter Chen | 3c9740a | 2013-11-05 10:46:02 +0800 | [diff] [blame] | 257 | device_wakeup_enable(hcd->self.controller); |
| 258 | |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 259 | platform_set_drvdata(dev, hcd); |
| 260 | |
| 261 | return err; |
| 262 | |
Kuninori Morimoto | e4d37ae | 2012-08-06 18:09:10 -0700 | [diff] [blame] | 263 | err_power: |
| 264 | if (pdata->power_off) |
| 265 | pdata->power_off(dev); |
Maxime Ripard | 4615f3b | 2014-05-13 17:44:20 +0200 | [diff] [blame] | 266 | err_reset: |
| 267 | if (priv->rst) |
| 268 | reset_control_assert(priv->rst); |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 269 | err_put_clks: |
| 270 | while (--clk >= 0) |
| 271 | clk_put(priv->clks[clk]); |
| 272 | err_put_hcd: |
| 273 | if (pdata == &ohci_platform_defaults) |
| 274 | dev->dev.platform_data = NULL; |
| 275 | |
| 276 | usb_put_hcd(hcd); |
Kuninori Morimoto | e4d37ae | 2012-08-06 18:09:10 -0700 | [diff] [blame] | 277 | |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 278 | return err; |
| 279 | } |
| 280 | |
Bill Pemberton | fb4e98a | 2012-11-19 13:26:20 -0500 | [diff] [blame] | 281 | static int ohci_platform_remove(struct platform_device *dev) |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 282 | { |
| 283 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
Jingoo Han | d4f09e2 | 2013-07-30 19:59:40 +0900 | [diff] [blame] | 284 | struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 285 | struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd); |
| 286 | int clk; |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 287 | |
| 288 | usb_remove_hcd(hcd); |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 289 | |
Kuninori Morimoto | e4d37ae | 2012-08-06 18:09:10 -0700 | [diff] [blame] | 290 | if (pdata->power_off) |
| 291 | pdata->power_off(dev); |
| 292 | |
Maxime Ripard | 4615f3b | 2014-05-13 17:44:20 +0200 | [diff] [blame] | 293 | if (priv->rst) |
| 294 | reset_control_assert(priv->rst); |
| 295 | |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 296 | for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) |
| 297 | clk_put(priv->clks[clk]); |
| 298 | |
| 299 | usb_put_hcd(hcd); |
| 300 | |
| 301 | if (pdata == &ohci_platform_defaults) |
| 302 | dev->dev.platform_data = NULL; |
| 303 | |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 304 | return 0; |
| 305 | } |
| 306 | |
| 307 | #ifdef CONFIG_PM |
| 308 | |
| 309 | static int ohci_platform_suspend(struct device *dev) |
| 310 | { |
Manjunath Goudar | 39dbd7d | 2013-10-04 09:58:14 +0530 | [diff] [blame] | 311 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 312 | struct usb_ohci_pdata *pdata = dev->platform_data; |
Kuninori Morimoto | e4d37ae | 2012-08-06 18:09:10 -0700 | [diff] [blame] | 313 | struct platform_device *pdev = |
| 314 | container_of(dev, struct platform_device, dev); |
Manjunath Goudar | 39dbd7d | 2013-10-04 09:58:14 +0530 | [diff] [blame] | 315 | bool do_wakeup = device_may_wakeup(dev); |
| 316 | int ret; |
| 317 | |
| 318 | ret = ohci_suspend(hcd, do_wakeup); |
| 319 | if (ret) |
| 320 | return ret; |
Kuninori Morimoto | e4d37ae | 2012-08-06 18:09:10 -0700 | [diff] [blame] | 321 | |
| 322 | if (pdata->power_suspend) |
| 323 | pdata->power_suspend(pdev); |
| 324 | |
Manjunath Goudar | 39dbd7d | 2013-10-04 09:58:14 +0530 | [diff] [blame] | 325 | return ret; |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | static int ohci_platform_resume(struct device *dev) |
| 329 | { |
| 330 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
Jingoo Han | d4f09e2 | 2013-07-30 19:59:40 +0900 | [diff] [blame] | 331 | struct usb_ohci_pdata *pdata = dev_get_platdata(dev); |
Kuninori Morimoto | e4d37ae | 2012-08-06 18:09:10 -0700 | [diff] [blame] | 332 | struct platform_device *pdev = |
| 333 | container_of(dev, struct platform_device, dev); |
| 334 | |
| 335 | if (pdata->power_on) { |
| 336 | int err = pdata->power_on(pdev); |
| 337 | if (err < 0) |
| 338 | return err; |
| 339 | } |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 340 | |
Florian Fainelli | cfa49b4 | 2012-10-08 15:11:29 +0200 | [diff] [blame] | 341 | ohci_resume(hcd, false); |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 342 | return 0; |
| 343 | } |
| 344 | |
| 345 | #else /* !CONFIG_PM */ |
| 346 | #define ohci_platform_suspend NULL |
| 347 | #define ohci_platform_resume NULL |
| 348 | #endif /* CONFIG_PM */ |
| 349 | |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 350 | static const struct of_device_id ohci_platform_ids[] = { |
Hans de Goede | ce149c3 | 2014-02-11 17:35:28 +0100 | [diff] [blame] | 351 | { .compatible = "generic-ohci", }, |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 352 | { } |
| 353 | }; |
| 354 | MODULE_DEVICE_TABLE(of, ohci_platform_ids); |
| 355 | |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 356 | static const struct platform_device_id ohci_platform_table[] = { |
| 357 | { "ohci-platform", 0 }, |
| 358 | { } |
| 359 | }; |
| 360 | MODULE_DEVICE_TABLE(platform, ohci_platform_table); |
| 361 | |
| 362 | static const struct dev_pm_ops ohci_platform_pm_ops = { |
| 363 | .suspend = ohci_platform_suspend, |
| 364 | .resume = ohci_platform_resume, |
| 365 | }; |
| 366 | |
| 367 | static struct platform_driver ohci_platform_driver = { |
| 368 | .id_table = ohci_platform_table, |
| 369 | .probe = ohci_platform_probe, |
Bill Pemberton | 7690417 | 2012-11-19 13:21:08 -0500 | [diff] [blame] | 370 | .remove = ohci_platform_remove, |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 371 | .shutdown = usb_hcd_platform_shutdown, |
| 372 | .driver = { |
| 373 | .owner = THIS_MODULE, |
| 374 | .name = "ohci-platform", |
| 375 | .pm = &ohci_platform_pm_ops, |
Hans de Goede | ca52a17 | 2014-02-07 16:36:40 +0100 | [diff] [blame] | 376 | .of_match_table = ohci_platform_ids, |
Hauke Mehrtens | fa3364b | 2012-03-13 01:04:47 +0100 | [diff] [blame] | 377 | } |
| 378 | }; |
Manjunath Goudar | 928fb68 | 2013-06-03 20:46:08 +0530 | [diff] [blame] | 379 | |
| 380 | static int __init ohci_platform_init(void) |
| 381 | { |
| 382 | if (usb_disabled()) |
| 383 | return -ENODEV; |
| 384 | |
| 385 | pr_info("%s: " DRIVER_DESC "\n", hcd_name); |
| 386 | |
| 387 | ohci_init_driver(&ohci_platform_hc_driver, &platform_overrides); |
| 388 | return platform_driver_register(&ohci_platform_driver); |
| 389 | } |
| 390 | module_init(ohci_platform_init); |
| 391 | |
| 392 | static void __exit ohci_platform_cleanup(void) |
| 393 | { |
| 394 | platform_driver_unregister(&ohci_platform_driver); |
| 395 | } |
| 396 | module_exit(ohci_platform_cleanup); |
| 397 | |
| 398 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 399 | MODULE_AUTHOR("Hauke Mehrtens"); |
| 400 | MODULE_AUTHOR("Alan Stern"); |
| 401 | MODULE_LICENSE("GPL"); |