diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2011-04-28 11:41:02 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-04-30 04:24:34 +0400 |
commit | 6e267da8f10b1a6551b6c4dee3779f6f56e2644d (patch) | |
tree | feade70626460e60bad6db5dd11bc82a06d83964 /drivers/usb/renesas_usbhs/common.c | |
parent | 206dcc2cfe15b6174f15293ae15a097ee03eb386 (diff) | |
download | linux-6e267da8f10b1a6551b6c4dee3779f6f56e2644d.tar.xz |
usb: renesas_usbhs: add power control function
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/renesas_usbhs/common.c')
-rw-r--r-- | drivers/usb/renesas_usbhs/common.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 53be4443b5ed..db13cef9effe 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -148,7 +148,31 @@ static u32 usbhsc_default_pipe_type[] = { }; /* - * driver callback functions + * power control + */ +static void usbhsc_power_ctrl(struct usbhs_priv *priv, int enable) +{ + struct device *dev = usbhs_priv_to_dev(priv); + + if (enable) { + /* enable PM */ + pm_runtime_get_sync(dev); + + /* USB on */ + usbhs_sys_clock_ctrl(priv, enable); + usbhsc_bus_ctrl(priv, enable); + } else { + /* USB off */ + usbhsc_bus_ctrl(priv, enable); + usbhs_sys_clock_ctrl(priv, enable); + + /* disable PM */ + pm_runtime_put_sync(dev); + } +} + +/* + * notify hotplug */ static void usbhsc_notify_hotplug(struct work_struct *work) { @@ -178,12 +202,8 @@ static void usbhsc_notify_hotplug(struct work_struct *work) dev_dbg(&pdev->dev, "%s enable\n", __func__); - /* enable PM */ - pm_runtime_get_sync(&pdev->dev); - - /* USB on */ - usbhs_sys_clock_ctrl(priv, enable); - usbhsc_bus_ctrl(priv, enable); + /* power on */ + usbhsc_power_ctrl(priv, enable); /* module start */ usbhs_mod_call(priv, start, priv); @@ -194,12 +214,8 @@ static void usbhsc_notify_hotplug(struct work_struct *work) /* module stop */ usbhs_mod_call(priv, stop, priv); - /* USB off */ - usbhsc_bus_ctrl(priv, enable); - usbhs_sys_clock_ctrl(priv, enable); - - /* disable PM */ - pm_runtime_put_sync(&pdev->dev); + /* power off */ + usbhsc_power_ctrl(priv, enable); usbhs_mod_change(priv, -1); |