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