1 /* linux/arch/arm/plat-samsung/pd.c
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
6 * Samsung Power domain support
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/init.h>
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
16 #include <linux/err.h>
17 #include <linux/pm_runtime.h>
21 static int samsung_pd_probe(struct platform_device *pdev)
23 struct samsung_pd_info *pdata = pdev->dev.platform_data;
24 struct device *dev = &pdev->dev;
28 dev_err(dev, "no device data specified\n");
33 ret = pdata->init(dev);
35 dev_err(dev, "init fails");
41 * boot_on means that this powerdomain should NOT be turned off
42 * until the user explicitly says so by executing get and then put
43 * By setting set_suspended, this power-domain is NOT
44 * turned off until a driver actually gets it.
47 pm_runtime_set_suspended(dev);
49 pm_runtime_set_active(dev);
50 pm_runtime_enable(dev);
52 dev_info(dev, "power domain registered\n");
56 static int __devexit samsung_pd_remove(struct platform_device *pdev)
58 struct device *dev = &pdev->dev;
60 pm_runtime_disable(dev);
64 static int samsung_pd_runtime_suspend(struct device *dev)
66 struct samsung_pd_info *pdata = dev->platform_data;
70 ret = pdata->disable(dev);
72 dev_dbg(dev, "suspended\n");
76 static int samsung_pd_runtime_resume(struct device *dev)
78 struct samsung_pd_info *pdata = dev->platform_data;
82 ret = pdata->enable(dev);
84 dev_dbg(dev, "resumed\n");
89 static int samsung_pd_suspend(struct device *dev)
93 * Do not turn it off if there is possibility that
94 * some driver is still using the power-domain at
100 static int samsung_pd_resume(struct device *dev)
104 ret = samsung_pd_runtime_resume(dev);
106 * Bring the device to full powered state upon resume
107 * and update the runtime PM status as recommended
108 * in Documentation/power/runtime_pm.txt.
111 pm_runtime_disable(dev);
112 pm_runtime_set_active(dev);
113 pm_runtime_enable(dev);
118 #define samsung_pd_resume NULL
119 #define samsung_pd_suspend NULL
122 static const struct dev_pm_ops samsung_pd_pm_ops = {
123 .runtime_suspend = samsung_pd_runtime_suspend,
124 .runtime_resume = samsung_pd_runtime_resume,
125 .suspend = samsung_pd_suspend,
126 .resume = samsung_pd_resume,
129 static struct platform_driver samsung_pd_driver = {
131 .name = "samsung-pd",
132 .owner = THIS_MODULE,
133 .pm = &samsung_pd_pm_ops,
135 .probe = samsung_pd_probe,
136 .remove = __devexit_p(samsung_pd_remove),
139 static int __init samsung_pd_init(void)
143 ret = platform_driver_register(&samsung_pd_driver);
145 printk(KERN_ERR "%s: failed to add PD driver\n", __func__);
149 arch_initcall(samsung_pd_init);