BACKPORT: usb: host: ohci-platform: Add basic runtime PM support

This is needed in preparation of adding support for omap3 and
later OHCI. The runtime PM will only do something on platforms
that implement it.

Change-Id: I497d03902648e7c4010a2de24d4cb8490887ee85
Cc: devicetree@vger.kernel.org
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Roger Quadros <rogerq@ti.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit 0aa0b93e7a)
This commit is contained in:
Tony Lindgren
2017-05-25 09:13:31 -07:00
committed by Tao Huang
parent 54e977ad63
commit cf15e865dd

View File

@@ -24,6 +24,7 @@
#include <linux/err.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/reset.h>
#include <linux/usb/ohci_pdriver.h>
#include <linux/usb.h>
@@ -236,6 +237,9 @@ static int ohci_platform_probe(struct platform_device *dev)
}
#endif
pm_runtime_set_active(&dev->dev);
pm_runtime_enable(&dev->dev);
pm_runtime_get_sync(&dev->dev);
if (pdata->power_on) {
err = pdata->power_on(dev);
if (err < 0)
@@ -267,6 +271,8 @@ err_power:
if (pdata->power_off)
pdata->power_off(dev);
err_reset:
pm_runtime_put_sync(&dev->dev);
pm_runtime_disable(&dev->dev);
if (priv->rst)
reset_control_assert(priv->rst);
err_put_clks:
@@ -301,6 +307,9 @@ static int ohci_platform_remove(struct platform_device *dev)
usb_put_hcd(hcd);
pm_runtime_put_sync(&dev->dev);
pm_runtime_disable(&dev->dev);
if (pdata == &ohci_platform_defaults)
dev->dev.platform_data = NULL;