blob: 080014197f25fe2a3331842ac065196204d095dd [file] [log] [blame]
Greg Kroah-Hartman5fd54ac2017-11-03 11:28:30 +01001// SPDX-License-Identifier: GPL-2.0
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +01002/*
3 * Generic platform ehci driver
4 *
5 * Copyright 2007 Steven Brown <sbrown@cortland.com>
6 * Copyright 2010-2012 Hauke Mehrtens <hauke@hauke-m.de>
Hans de Goedea4aeb212014-02-07 16:36:41 +01007 * Copyright 2014 Hans de Goede <hdegoede@redhat.com>
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +01008 *
9 * Derived from the ohci-ssb driver
10 * Copyright 2007 Michael Buesch <m@bues.ch>
11 *
12 * Derived from the EHCI-PCI driver
13 * Copyright (c) 2000-2004 by David Brownell
14 *
15 * Derived from the ohci-pci driver
16 * Copyright 1999 Roman Weissgaerber
17 * Copyright 2000-2002 David Brownell
18 * Copyright 1999 Linus Torvalds
19 * Copyright 1999 Gregory P. Smith
20 *
21 * Licensed under the GNU/GPL. See COPYING for details.
22 */
Jeremy Linton776c15d2015-08-19 16:36:32 -050023#include <linux/acpi.h>
Hans de Goedea4aeb212014-02-07 16:36:41 +010024#include <linux/clk.h>
Arnd Bergmannf3bc64d2013-03-27 21:44:22 +000025#include <linux/dma-mapping.h>
Thierry Reding148e1132013-01-21 11:09:22 +010026#include <linux/err.h>
Alan Stern99f91932012-11-01 11:13:08 -040027#include <linux/kernel.h>
Alan Sternd1bb67a2012-11-02 10:13:24 -040028#include <linux/hrtimer.h>
29#include <linux/io.h>
Alan Stern99f91932012-11-01 11:13:08 -040030#include <linux/module.h>
Arnd Bergmannf3bc64d2013-03-27 21:44:22 +000031#include <linux/of.h>
Hans de Goedea4aeb212014-02-07 16:36:41 +010032#include <linux/phy/phy.h>
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +010033#include <linux/platform_device.h>
Boris BREZILLON2d87bbd2014-05-13 17:44:19 +020034#include <linux/reset.h>
Alan Stern99f91932012-11-01 11:13:08 -040035#include <linux/usb.h>
36#include <linux/usb/hcd.h>
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +010037#include <linux/usb/ehci_pdriver.h>
Yoshihiro Shimodad4d75122017-02-21 19:59:48 +090038#include <linux/usb/of.h>
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +010039
Alan Stern99f91932012-11-01 11:13:08 -040040#include "ehci.h"
41
42#define DRIVER_DESC "EHCI generic platform driver"
Icenowy Zheng73577d62016-08-12 11:06:22 +080043#define EHCI_MAX_CLKS 4
Hans de Goedea4aeb212014-02-07 16:36:41 +010044#define hcd_to_ehci_priv(h) ((struct ehci_platform_priv *)hcd_to_ehci(h)->priv)
45
46struct ehci_platform_priv {
47 struct clk *clks[EHCI_MAX_CLKS];
Masahiro Yamada8e84f8a2017-11-02 01:01:58 +090048 struct reset_control *rsts;
Arun Ramamurthy7e7a0e62015-01-19 16:05:29 -080049 struct phy **phys;
50 int num_phys;
Alban Bedelb4629a72015-08-04 10:59:17 +020051 bool reset_on_resume;
Hans de Goedea4aeb212014-02-07 16:36:41 +010052};
Alan Stern99f91932012-11-01 11:13:08 -040053
54static const char hcd_name[] = "ehci-platform";
55
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +010056static int ehci_platform_reset(struct usb_hcd *hcd)
57{
58 struct platform_device *pdev = to_platform_device(hcd->self.controller);
Jingoo Hand4f09e22013-07-30 19:59:40 +090059 struct usb_ehci_pdata *pdata = dev_get_platdata(&pdev->dev);
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +010060 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
61 int retval;
62
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +010063 ehci->has_synopsys_hc_bug = pdata->has_synopsys_hc_bug;
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +010064
Sergei Shtylyov743fcce2013-06-02 01:33:56 +040065 if (pdata->pre_setup) {
66 retval = pdata->pre_setup(hcd);
67 if (retval < 0)
68 return retval;
69 }
70
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +010071 ehci->caps = hcd->regs + pdata->caps_offset;
72 retval = ehci_setup(hcd);
73 if (retval)
74 return retval;
75
Florian Fainelli45348742012-10-08 15:11:21 +020076 if (pdata->no_io_watchdog)
77 ehci->need_io_watchdog = 0;
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +010078 return 0;
79}
80
Hans de Goedea4aeb212014-02-07 16:36:41 +010081static int ehci_platform_power_on(struct platform_device *dev)
82{
83 struct usb_hcd *hcd = platform_get_drvdata(dev);
84 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
Arun Ramamurthy7e7a0e62015-01-19 16:05:29 -080085 int clk, ret, phy_num;
Hans de Goedea4aeb212014-02-07 16:36:41 +010086
87 for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++) {
88 ret = clk_prepare_enable(priv->clks[clk]);
89 if (ret)
90 goto err_disable_clks;
91 }
92
Arun Ramamurthy7e7a0e62015-01-19 16:05:29 -080093 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
Arun Ramamurthy216e2992015-04-22 16:04:12 -070094 ret = phy_init(priv->phys[phy_num]);
95 if (ret)
96 goto err_exit_phy;
97 ret = phy_power_on(priv->phys[phy_num]);
98 if (ret) {
99 phy_exit(priv->phys[phy_num]);
100 goto err_exit_phy;
Arun Ramamurthy7e7a0e62015-01-19 16:05:29 -0800101 }
Hans de Goedea4aeb212014-02-07 16:36:41 +0100102 }
103
104 return 0;
105
106err_exit_phy:
Arun Ramamurthy7e7a0e62015-01-19 16:05:29 -0800107 while (--phy_num >= 0) {
Arun Ramamurthy216e2992015-04-22 16:04:12 -0700108 phy_power_off(priv->phys[phy_num]);
109 phy_exit(priv->phys[phy_num]);
Arun Ramamurthy7e7a0e62015-01-19 16:05:29 -0800110 }
Hans de Goedea4aeb212014-02-07 16:36:41 +0100111err_disable_clks:
112 while (--clk >= 0)
113 clk_disable_unprepare(priv->clks[clk]);
114
115 return ret;
116}
117
118static void ehci_platform_power_off(struct platform_device *dev)
119{
120 struct usb_hcd *hcd = platform_get_drvdata(dev);
121 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
Arun Ramamurthy7e7a0e62015-01-19 16:05:29 -0800122 int clk, phy_num;
Hans de Goedea4aeb212014-02-07 16:36:41 +0100123
Arun Ramamurthy7e7a0e62015-01-19 16:05:29 -0800124 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
Arun Ramamurthy216e2992015-04-22 16:04:12 -0700125 phy_power_off(priv->phys[phy_num]);
126 phy_exit(priv->phys[phy_num]);
Hans de Goedea4aeb212014-02-07 16:36:41 +0100127 }
128
129 for (clk = EHCI_MAX_CLKS - 1; clk >= 0; clk--)
130 if (priv->clks[clk])
131 clk_disable_unprepare(priv->clks[clk]);
132}
133
Alan Stern99f91932012-11-01 11:13:08 -0400134static struct hc_driver __read_mostly ehci_platform_hc_driver;
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100135
Andi Kleen62d08a12013-04-22 09:44:56 -0700136static const struct ehci_driver_overrides platform_overrides __initconst = {
Hans de Goedea4aeb212014-02-07 16:36:41 +0100137 .reset = ehci_platform_reset,
138 .extra_priv_size = sizeof(struct ehci_platform_priv),
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100139};
140
Hans de Goedea4aeb212014-02-07 16:36:41 +0100141static struct usb_ehci_pdata ehci_platform_defaults = {
142 .power_on = ehci_platform_power_on,
143 .power_suspend = ehci_platform_power_off,
144 .power_off = ehci_platform_power_off,
145};
Arnd Bergmannf3bc64d2013-03-27 21:44:22 +0000146
Bill Pemberton41ac7b32012-11-19 13:21:48 -0500147static int ehci_platform_probe(struct platform_device *dev)
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100148{
149 struct usb_hcd *hcd;
150 struct resource *res_mem;
Hans de Goedea4aeb212014-02-07 16:36:41 +0100151 struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev);
152 struct ehci_platform_priv *priv;
Hans de Goedead3db5d2014-02-07 16:36:43 +0100153 struct ehci_hcd *ehci;
Masahiro Yamada8e84f8a2017-11-02 01:01:58 +0900154 int err, irq, phy_num, clk = 0;
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100155
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100156 if (usb_disabled())
157 return -ENODEV;
158
Arnd Bergmannf3bc64d2013-03-27 21:44:22 +0000159 /*
Hans de Goedea4aeb212014-02-07 16:36:41 +0100160 * Use reasonable defaults so platforms don't have to provide these
161 * with DT probing on ARM.
Arnd Bergmannf3bc64d2013-03-27 21:44:22 +0000162 */
Hans de Goedea4aeb212014-02-07 16:36:41 +0100163 if (!pdata)
164 pdata = &ehci_platform_defaults;
Russell Kinge1fd7342013-06-27 12:36:37 +0100165
Andreas Herrmannc99e76c2015-01-12 16:05:52 +0100166 err = dma_coerce_mask_and_coherent(&dev->dev,
167 pdata->dma_mask_64 ? DMA_BIT_MASK(64) : DMA_BIT_MASK(32));
Jeremy Linton17f69b52015-08-19 16:36:31 -0500168 if (err) {
169 dev_err(&dev->dev, "Error: DMA mask configuration failed\n");
Russell King22d9d8e2013-06-10 16:28:49 +0100170 return err;
Jeremy Linton17f69b52015-08-19 16:36:31 -0500171 }
Arnd Bergmannf3bc64d2013-03-27 21:44:22 +0000172
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100173 irq = platform_get_irq(dev, 0);
174 if (irq < 0) {
Florian Fainelli2350cb02012-10-08 15:11:41 +0200175 dev_err(&dev->dev, "no irq provided");
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100176 return irq;
177 }
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100178
Hans de Goedea4aeb212014-02-07 16:36:41 +0100179 hcd = usb_create_hcd(&ehci_platform_hc_driver, &dev->dev,
180 dev_name(&dev->dev));
181 if (!hcd)
182 return -ENOMEM;
183
184 platform_set_drvdata(dev, hcd);
185 dev->dev.platform_data = pdata;
186 priv = hcd_to_ehci_priv(hcd);
Hans de Goedead3db5d2014-02-07 16:36:43 +0100187 ehci = hcd_to_ehci(hcd);
Hans de Goedea4aeb212014-02-07 16:36:41 +0100188
189 if (pdata == &ehci_platform_defaults && dev->dev.of_node) {
Hans de Goedead3db5d2014-02-07 16:36:43 +0100190 if (of_property_read_bool(dev->dev.of_node, "big-endian-regs"))
191 ehci->big_endian_mmio = 1;
192
193 if (of_property_read_bool(dev->dev.of_node, "big-endian-desc"))
194 ehci->big_endian_desc = 1;
195
196 if (of_property_read_bool(dev->dev.of_node, "big-endian"))
197 ehci->big_endian_mmio = ehci->big_endian_desc = 1;
198
Wu Liang feng314b41b2014-12-24 18:22:19 +0800199 if (of_property_read_bool(dev->dev.of_node,
200 "needs-reset-on-resume"))
Alban Bedelb4629a72015-08-04 10:59:17 +0200201 priv->reset_on_resume = true;
Wu Liang feng314b41b2014-12-24 18:22:19 +0800202
Joachim Eastwood40f2f2a2015-05-16 17:17:40 +0200203 if (of_property_read_bool(dev->dev.of_node,
204 "has-transaction-translator"))
Alban Bedelb4629a72015-08-04 10:59:17 +0200205 hcd->has_tt = 1;
Joachim Eastwood40f2f2a2015-05-16 17:17:40 +0200206
Arun Ramamurthy7e7a0e62015-01-19 16:05:29 -0800207 priv->num_phys = of_count_phandle_with_args(dev->dev.of_node,
208 "phys", "#phy-cells");
Arun Ramamurthy7e7a0e62015-01-19 16:05:29 -0800209
Arun Ramamurthy216e2992015-04-22 16:04:12 -0700210 if (priv->num_phys > 0) {
211 priv->phys = devm_kcalloc(&dev->dev, priv->num_phys,
212 sizeof(struct phy *), GFP_KERNEL);
213 if (!priv->phys)
214 return -ENOMEM;
215 } else
216 priv->num_phys = 0;
Arun Ramamurthy7e7a0e62015-01-19 16:05:29 -0800217
218 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
Arun Ramamurthy216e2992015-04-22 16:04:12 -0700219 priv->phys[phy_num] = devm_of_phy_get_by_index(
220 &dev->dev, dev->dev.of_node, phy_num);
221 if (IS_ERR(priv->phys[phy_num])) {
222 err = PTR_ERR(priv->phys[phy_num]);
223 goto err_put_hcd;
Yoshihiro Shimoda42a58c92017-03-13 15:25:23 +0900224 } else if (!hcd->phy) {
225 /* Avoiding phy_get() in usb_add_hcd() */
226 hcd->phy = priv->phys[phy_num];
Arun Ramamurthy216e2992015-04-22 16:04:12 -0700227 }
Hans de Goedea4aeb212014-02-07 16:36:41 +0100228 }
229
230 for (clk = 0; clk < EHCI_MAX_CLKS; clk++) {
231 priv->clks[clk] = of_clk_get(dev->dev.of_node, clk);
232 if (IS_ERR(priv->clks[clk])) {
233 err = PTR_ERR(priv->clks[clk]);
234 if (err == -EPROBE_DEFER)
235 goto err_put_clks;
236 priv->clks[clk] = NULL;
237 break;
238 }
239 }
240 }
241
Masahiro Yamada8e84f8a2017-11-02 01:01:58 +0900242 priv->rsts = devm_reset_control_array_get_optional_shared(&dev->dev);
243 if (IS_ERR(priv->rsts)) {
244 err = PTR_ERR(priv->rsts);
245 goto err_put_clks;
Boris BREZILLON2d87bbd2014-05-13 17:44:19 +0200246 }
247
Masahiro Yamada8e84f8a2017-11-02 01:01:58 +0900248 err = reset_control_deassert(priv->rsts);
249 if (err)
250 goto err_put_clks;
251
Alan Stern843d5e02014-02-11 11:26:10 -0500252 if (pdata->big_endian_desc)
253 ehci->big_endian_desc = 1;
254 if (pdata->big_endian_mmio)
255 ehci->big_endian_mmio = 1;
Alban Bedelb4629a72015-08-04 10:59:17 +0200256 if (pdata->has_tt)
257 hcd->has_tt = 1;
258 if (pdata->reset_on_resume)
259 priv->reset_on_resume = true;
Alan Stern843d5e02014-02-11 11:26:10 -0500260
261#ifndef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
262 if (ehci->big_endian_mmio) {
263 dev_err(&dev->dev,
264 "Error: CONFIG_USB_EHCI_BIG_ENDIAN_MMIO not set\n");
265 err = -EINVAL;
Boris BREZILLON2d87bbd2014-05-13 17:44:19 +0200266 goto err_reset;
Alan Stern843d5e02014-02-11 11:26:10 -0500267 }
268#endif
269#ifndef CONFIG_USB_EHCI_BIG_ENDIAN_DESC
270 if (ehci->big_endian_desc) {
271 dev_err(&dev->dev,
272 "Error: CONFIG_USB_EHCI_BIG_ENDIAN_DESC not set\n");
273 err = -EINVAL;
Boris BREZILLON2d87bbd2014-05-13 17:44:19 +0200274 goto err_reset;
Alan Stern843d5e02014-02-11 11:26:10 -0500275 }
276#endif
277
Kuninori Morimoto04216be2012-08-06 18:08:39 -0700278 if (pdata->power_on) {
279 err = pdata->power_on(dev);
280 if (err < 0)
Boris BREZILLON2d87bbd2014-05-13 17:44:19 +0200281 goto err_reset;
Kuninori Morimoto04216be2012-08-06 18:08:39 -0700282 }
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100283
Varka Bhadram2062ff42014-11-04 07:51:25 +0530284 res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
Thierry Reding148e1132013-01-21 11:09:22 +0100285 hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
286 if (IS_ERR(hcd->regs)) {
287 err = PTR_ERR(hcd->regs);
Hans de Goedea4aeb212014-02-07 16:36:41 +0100288 goto err_power;
Julia Lawallec03ad82012-08-14 08:47:38 +0200289 }
Varka Bhadram2062ff42014-11-04 07:51:25 +0530290 hcd->rsrc_start = res_mem->start;
291 hcd->rsrc_len = resource_size(res_mem);
292
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100293 err = usb_add_hcd(hcd, irq, IRQF_SHARED);
294 if (err)
Hans de Goedea4aeb212014-02-07 16:36:41 +0100295 goto err_power;
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100296
Peter Chen3c9740a2013-11-05 10:46:02 +0800297 device_wakeup_enable(hcd->self.controller);
Yoshihiro Shimodad4d75122017-02-21 19:59:48 +0900298 device_enable_async_suspend(hcd->self.controller);
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100299 platform_set_drvdata(dev, hcd);
300
301 return err;
302
Kuninori Morimoto04216be2012-08-06 18:08:39 -0700303err_power:
304 if (pdata->power_off)
305 pdata->power_off(dev);
Boris BREZILLON2d87bbd2014-05-13 17:44:19 +0200306err_reset:
Masahiro Yamada8e84f8a2017-11-02 01:01:58 +0900307 reset_control_assert(priv->rsts);
Hans de Goedea4aeb212014-02-07 16:36:41 +0100308err_put_clks:
309 while (--clk >= 0)
310 clk_put(priv->clks[clk]);
311err_put_hcd:
312 if (pdata == &ehci_platform_defaults)
313 dev->dev.platform_data = NULL;
314
315 usb_put_hcd(hcd);
Kuninori Morimoto04216be2012-08-06 18:08:39 -0700316
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100317 return err;
318}
319
Bill Pembertonfb4e98a2012-11-19 13:26:20 -0500320static int ehci_platform_remove(struct platform_device *dev)
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100321{
322 struct usb_hcd *hcd = platform_get_drvdata(dev);
Jingoo Hand4f09e22013-07-30 19:59:40 +0900323 struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev);
Hans de Goedea4aeb212014-02-07 16:36:41 +0100324 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
Masahiro Yamada8e84f8a2017-11-02 01:01:58 +0900325 int clk;
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100326
327 usb_remove_hcd(hcd);
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100328
Kuninori Morimoto04216be2012-08-06 18:08:39 -0700329 if (pdata->power_off)
330 pdata->power_off(dev);
331
Masahiro Yamada8e84f8a2017-11-02 01:01:58 +0900332 reset_control_assert(priv->rsts);
Boris BREZILLON2d87bbd2014-05-13 17:44:19 +0200333
Hans de Goedea4aeb212014-02-07 16:36:41 +0100334 for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++)
335 clk_put(priv->clks[clk]);
336
337 usb_put_hcd(hcd);
338
Arnd Bergmannf3bc64d2013-03-27 21:44:22 +0000339 if (pdata == &ehci_platform_defaults)
340 dev->dev.platform_data = NULL;
341
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100342 return 0;
343}
344
Wonhong Kwon5e4ccd92014-10-24 13:45:47 +0900345#ifdef CONFIG_PM_SLEEP
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100346static int ehci_platform_suspend(struct device *dev)
347{
348 struct usb_hcd *hcd = dev_get_drvdata(dev);
Jingoo Hand4f09e22013-07-30 19:59:40 +0900349 struct usb_ehci_pdata *pdata = dev_get_platdata(dev);
Geliang Tang20db5512015-12-23 21:26:52 +0800350 struct platform_device *pdev = to_platform_device(dev);
Alan Sternc5cf9212012-06-28 11:19:02 -0400351 bool do_wakeup = device_may_wakeup(dev);
Kuninori Morimoto04216be2012-08-06 18:08:39 -0700352 int ret;
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100353
Kuninori Morimoto04216be2012-08-06 18:08:39 -0700354 ret = ehci_suspend(hcd, do_wakeup);
Vivek Gautame155b5b2014-04-10 15:58:02 +0530355 if (ret)
356 return ret;
Kuninori Morimoto04216be2012-08-06 18:08:39 -0700357
358 if (pdata->power_suspend)
359 pdata->power_suspend(pdev);
360
361 return ret;
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100362}
363
364static int ehci_platform_resume(struct device *dev)
365{
366 struct usb_hcd *hcd = dev_get_drvdata(dev);
Jingoo Hand4f09e22013-07-30 19:59:40 +0900367 struct usb_ehci_pdata *pdata = dev_get_platdata(dev);
Geliang Tang20db5512015-12-23 21:26:52 +0800368 struct platform_device *pdev = to_platform_device(dev);
Alban Bedelb4629a72015-08-04 10:59:17 +0200369 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
Yoshihiro Shimodad4d75122017-02-21 19:59:48 +0900370 struct device *companion_dev;
Kuninori Morimoto04216be2012-08-06 18:08:39 -0700371
372 if (pdata->power_on) {
373 int err = pdata->power_on(pdev);
374 if (err < 0)
375 return err;
376 }
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100377
Yoshihiro Shimodad4d75122017-02-21 19:59:48 +0900378 companion_dev = usb_of_get_companion_dev(hcd->self.controller);
Johan Hovolda7415472017-05-16 16:26:13 +0200379 if (companion_dev) {
Yoshihiro Shimodad4d75122017-02-21 19:59:48 +0900380 device_pm_wait_for_dev(hcd->self.controller, companion_dev);
Johan Hovolda7415472017-05-16 16:26:13 +0200381 put_device(companion_dev);
382 }
Yoshihiro Shimodad4d75122017-02-21 19:59:48 +0900383
Alban Bedelb4629a72015-08-04 10:59:17 +0200384 ehci_resume(hcd, priv->reset_on_resume);
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100385 return 0;
386}
Wonhong Kwon5e4ccd92014-10-24 13:45:47 +0900387#endif /* CONFIG_PM_SLEEP */
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100388
Arnd Bergmannf3bc64d2013-03-27 21:44:22 +0000389static const struct of_device_id vt8500_ehci_ids[] = {
390 { .compatible = "via,vt8500-ehci", },
391 { .compatible = "wm,prizm-ehci", },
Hans de Goede915974c2014-02-11 17:35:29 +0100392 { .compatible = "generic-ehci", },
Andreas Herrmanna95cfa62015-01-06 13:48:56 +0100393 { .compatible = "cavium,octeon-6335-ehci", },
Arnd Bergmannf3bc64d2013-03-27 21:44:22 +0000394 {}
395};
Hans de Goedea4aeb212014-02-07 16:36:41 +0100396MODULE_DEVICE_TABLE(of, vt8500_ehci_ids);
Arnd Bergmannf3bc64d2013-03-27 21:44:22 +0000397
Jeremy Linton776c15d2015-08-19 16:36:32 -0500398static const struct acpi_device_id ehci_acpi_match[] = {
399 { "PNP0D20", 0 }, /* EHCI controller without debug */
400 { }
401};
402MODULE_DEVICE_TABLE(acpi, ehci_acpi_match);
403
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100404static const struct platform_device_id ehci_platform_table[] = {
405 { "ehci-platform", 0 },
406 { }
407};
408MODULE_DEVICE_TABLE(platform, ehci_platform_table);
409
Wonhong Kwon5e4ccd92014-10-24 13:45:47 +0900410static SIMPLE_DEV_PM_OPS(ehci_platform_pm_ops, ehci_platform_suspend,
411 ehci_platform_resume);
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100412
413static struct platform_driver ehci_platform_driver = {
414 .id_table = ehci_platform_table,
415 .probe = ehci_platform_probe,
Bill Pemberton76904172012-11-19 13:21:08 -0500416 .remove = ehci_platform_remove,
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100417 .shutdown = usb_hcd_platform_shutdown,
418 .driver = {
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100419 .name = "ehci-platform",
420 .pm = &ehci_platform_pm_ops,
Sachin Kamatae5e5f72013-05-21 17:17:16 +0530421 .of_match_table = vt8500_ehci_ids,
Jeremy Linton776c15d2015-08-19 16:36:32 -0500422 .acpi_match_table = ACPI_PTR(ehci_acpi_match),
Hauke Mehrtens7a7a4a592012-03-13 01:04:48 +0100423 }
424};
Alan Stern99f91932012-11-01 11:13:08 -0400425
426static int __init ehci_platform_init(void)
427{
428 if (usb_disabled())
429 return -ENODEV;
430
431 pr_info("%s: " DRIVER_DESC "\n", hcd_name);
432
433 ehci_init_driver(&ehci_platform_hc_driver, &platform_overrides);
434 return platform_driver_register(&ehci_platform_driver);
435}
436module_init(ehci_platform_init);
437
438static void __exit ehci_platform_cleanup(void)
439{
440 platform_driver_unregister(&ehci_platform_driver);
441}
442module_exit(ehci_platform_cleanup);
443
444MODULE_DESCRIPTION(DRIVER_DESC);
445MODULE_AUTHOR("Hauke Mehrtens");
446MODULE_AUTHOR("Alan Stern");
447MODULE_LICENSE("GPL");