aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/wm8994-core.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-11-26 12:19:35 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2011-01-14 06:37:43 -0500
commitd450f19eea0c3f64d60dc37655bae03b2455e5bb (patch)
treefab4ec06b46b517fb8a8fb1b8d9b07b4f978447b /drivers/mfd/wm8994-core.c
parent4c90aa94f6b3e33f57faaf19ef9819195dff61d3 (diff)
mfd: Implement runtime PM for WM8994 core driver
Allow the WM8994 to completely power off, including disabling the LDOs if they are software controlled, when it goes idle. The CODEC subdevice controls activity for the MFD as a whole. If the GPIOs need to be used while the device is active runtime PM should be disabled for the device by machine specific code. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/wm8994-core.c')
-rw-r--r--drivers/mfd/wm8994-core.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index 8d221ba5e38d..41233c7fa581 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -18,6 +18,7 @@
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/mfd/core.h> 20#include <linux/mfd/core.h>
21#include <linux/pm_runtime.h>
21#include <linux/regulator/consumer.h> 22#include <linux/regulator/consumer.h>
22#include <linux/regulator/machine.h> 23#include <linux/regulator/machine.h>
23 24
@@ -169,8 +170,16 @@ out:
169EXPORT_SYMBOL_GPL(wm8994_set_bits); 170EXPORT_SYMBOL_GPL(wm8994_set_bits);
170 171
171static struct mfd_cell wm8994_regulator_devs[] = { 172static struct mfd_cell wm8994_regulator_devs[] = {
172 { .name = "wm8994-ldo", .id = 1 }, 173 {
173 { .name = "wm8994-ldo", .id = 2 }, 174 .name = "wm8994-ldo",
175 .id = 1,
176 .pm_runtime_no_callbacks = true,
177 },
178 {
179 .name = "wm8994-ldo",
180 .id = 2,
181 .pm_runtime_no_callbacks = true,
182 },
174}; 183};
175 184
176static struct resource wm8994_codec_resources[] = { 185static struct resource wm8994_codec_resources[] = {
@@ -200,6 +209,7 @@ static struct mfd_cell wm8994_devs[] = {
200 .name = "wm8994-gpio", 209 .name = "wm8994-gpio",
201 .num_resources = ARRAY_SIZE(wm8994_gpio_resources), 210 .num_resources = ARRAY_SIZE(wm8994_gpio_resources),
202 .resources = wm8994_gpio_resources, 211 .resources = wm8994_gpio_resources,
212 .pm_runtime_no_callbacks = true,
203 }, 213 },
204}; 214};
205 215
@@ -231,7 +241,7 @@ static const char *wm8958_main_supplies[] = {
231}; 241};
232 242
233#ifdef CONFIG_PM 243#ifdef CONFIG_PM
234static int wm8994_device_suspend(struct device *dev) 244static int wm8994_suspend(struct device *dev)
235{ 245{
236 struct wm8994 *wm8994 = dev_get_drvdata(dev); 246 struct wm8994 *wm8994 = dev_get_drvdata(dev);
237 int ret; 247 int ret;
@@ -261,7 +271,7 @@ static int wm8994_device_suspend(struct device *dev)
261 return 0; 271 return 0;
262} 272}
263 273
264static int wm8994_device_resume(struct device *dev) 274static int wm8994_resume(struct device *dev)
265{ 275{
266 struct wm8994 *wm8994 = dev_get_drvdata(dev); 276 struct wm8994 *wm8994 = dev_get_drvdata(dev);
267 int ret; 277 int ret;
@@ -471,6 +481,9 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
471 goto err_irq; 481 goto err_irq;
472 } 482 }
473 483
484 pm_runtime_enable(wm8994->dev);
485 pm_runtime_resume(wm8994->dev);
486
474 return 0; 487 return 0;
475 488
476err_irq: 489err_irq:
@@ -490,6 +503,7 @@ err:
490 503
491static void wm8994_device_exit(struct wm8994 *wm8994) 504static void wm8994_device_exit(struct wm8994 *wm8994)
492{ 505{
506 pm_runtime_disable(wm8994->dev);
493 mfd_remove_devices(wm8994->dev); 507 mfd_remove_devices(wm8994->dev);
494 wm8994_irq_exit(wm8994); 508 wm8994_irq_exit(wm8994);
495 regulator_bulk_disable(wm8994->num_supplies, 509 regulator_bulk_disable(wm8994->num_supplies,
@@ -573,21 +587,6 @@ static int wm8994_i2c_remove(struct i2c_client *i2c)
573 return 0; 587 return 0;
574} 588}
575 589
576#ifdef CONFIG_PM
577static int wm8994_i2c_suspend(struct i2c_client *i2c, pm_message_t state)
578{
579 return wm8994_device_suspend(&i2c->dev);
580}
581
582static int wm8994_i2c_resume(struct i2c_client *i2c)
583{
584 return wm8994_device_resume(&i2c->dev);
585}
586#else
587#define wm8994_i2c_suspend NULL
588#define wm8994_i2c_resume NULL
589#endif
590
591static const struct i2c_device_id wm8994_i2c_id[] = { 590static const struct i2c_device_id wm8994_i2c_id[] = {
592 { "wm8994", WM8994 }, 591 { "wm8994", WM8994 },
593 { "wm8958", WM8958 }, 592 { "wm8958", WM8958 },
@@ -595,15 +594,16 @@ static const struct i2c_device_id wm8994_i2c_id[] = {
595}; 594};
596MODULE_DEVICE_TABLE(i2c, wm8994_i2c_id); 595MODULE_DEVICE_TABLE(i2c, wm8994_i2c_id);
597 596
597UNIVERSAL_DEV_PM_OPS(wm8994_pm_ops, wm8994_suspend, wm8994_resume, NULL);
598
598static struct i2c_driver wm8994_i2c_driver = { 599static struct i2c_driver wm8994_i2c_driver = {
599 .driver = { 600 .driver = {
600 .name = "wm8994", 601 .name = "wm8994",
601 .owner = THIS_MODULE, 602 .owner = THIS_MODULE,
603 .pm = &wm8994_pm_ops,
602 }, 604 },
603 .probe = wm8994_i2c_probe, 605 .probe = wm8994_i2c_probe,
604 .remove = wm8994_i2c_remove, 606 .remove = wm8994_i2c_remove,
605 .suspend = wm8994_i2c_suspend,
606 .resume = wm8994_i2c_resume,
607 .id_table = wm8994_i2c_id, 607 .id_table = wm8994_i2c_id,
608}; 608};
609 609