diff options
author | Joonyoung Shim <jy0922.shim@samsung.com> | 2014-07-10 01:22:34 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-07-11 21:14:10 -0400 |
commit | ecdc071d02a052c30a3ba9cc574ae1544ea9be15 (patch) | |
tree | 1c3e468333c6070acaee8c1fc7dad5538952123f | |
parent | 0e278b3408999d5bdce50bd0d7f97608483eebea (diff) |
usb: usb3503: add PM functions
The usb3503 needs to switch to standby mode while suspending and should
switch to hub mode when resumed. Also we can control clock on PM
function.
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/misc/usb3503.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c index 652855b40289..47cb143716a1 100644 --- a/drivers/usb/misc/usb3503.c +++ b/drivers/usb/misc/usb3503.c | |||
@@ -149,8 +149,6 @@ static int usb3503_switch_mode(struct usb3503 *hub, enum usb3503_mode mode) | |||
149 | 149 | ||
150 | case USB3503_MODE_STANDBY: | 150 | case USB3503_MODE_STANDBY: |
151 | usb3503_reset(hub, 0); | 151 | usb3503_reset(hub, 0); |
152 | |||
153 | hub->mode = mode; | ||
154 | dev_info(dev, "switched to STANDBY mode\n"); | 152 | dev_info(dev, "switched to STANDBY mode\n"); |
155 | break; | 153 | break; |
156 | 154 | ||
@@ -347,6 +345,37 @@ static int usb3503_platform_probe(struct platform_device *pdev) | |||
347 | return usb3503_probe(hub); | 345 | return usb3503_probe(hub); |
348 | } | 346 | } |
349 | 347 | ||
348 | #ifdef CONFIG_PM_SLEEP | ||
349 | static int usb3503_i2c_suspend(struct device *dev) | ||
350 | { | ||
351 | struct i2c_client *client = to_i2c_client(dev); | ||
352 | struct usb3503 *hub = i2c_get_clientdata(client); | ||
353 | |||
354 | usb3503_switch_mode(hub, USB3503_MODE_STANDBY); | ||
355 | |||
356 | if (hub->clk) | ||
357 | clk_disable_unprepare(hub->clk); | ||
358 | |||
359 | return 0; | ||
360 | } | ||
361 | |||
362 | static int usb3503_i2c_resume(struct device *dev) | ||
363 | { | ||
364 | struct i2c_client *client = to_i2c_client(dev); | ||
365 | struct usb3503 *hub = i2c_get_clientdata(client); | ||
366 | |||
367 | if (hub->clk) | ||
368 | clk_prepare_enable(hub->clk); | ||
369 | |||
370 | usb3503_switch_mode(hub, hub->mode); | ||
371 | |||
372 | return 0; | ||
373 | } | ||
374 | #endif | ||
375 | |||
376 | static SIMPLE_DEV_PM_OPS(usb3503_i2c_pm_ops, usb3503_i2c_suspend, | ||
377 | usb3503_i2c_resume); | ||
378 | |||
350 | static const struct i2c_device_id usb3503_id[] = { | 379 | static const struct i2c_device_id usb3503_id[] = { |
351 | { USB3503_I2C_NAME, 0 }, | 380 | { USB3503_I2C_NAME, 0 }, |
352 | { } | 381 | { } |
@@ -365,6 +394,7 @@ MODULE_DEVICE_TABLE(of, usb3503_of_match); | |||
365 | static struct i2c_driver usb3503_i2c_driver = { | 394 | static struct i2c_driver usb3503_i2c_driver = { |
366 | .driver = { | 395 | .driver = { |
367 | .name = USB3503_I2C_NAME, | 396 | .name = USB3503_I2C_NAME, |
397 | .pm = &usb3503_i2c_pm_ops, | ||
368 | .of_match_table = of_match_ptr(usb3503_of_match), | 398 | .of_match_table = of_match_ptr(usb3503_of_match), |
369 | }, | 399 | }, |
370 | .probe = usb3503_i2c_probe, | 400 | .probe = usb3503_i2c_probe, |