1 /*
2  * Runtime PM support code for DaVinci
3  *
4  * Author: Kevin Hilman
5  *
6  * Copyright (C) 2012 Texas Instruments, Inc.
7  *
8  * This file is licensed under the terms of the GNU General Public
9  * License version 2. This program is licensed "as is" without any
10  * warranty of any kind, whether express or implied.
11  */
12 #include <linux/init.h>
13 #include <linux/pm_runtime.h>
14 #include <linux/pm_clock.h>
15 #include <linux/platform_device.h>
16 
17 #ifdef CONFIG_PM_RUNTIME
18 static int davinci_pm_runtime_suspend(struct device *dev)
19 {
20 	int ret;
21 
22 	dev_dbg(dev, "%s\n", __func__);
23 
24 	ret = pm_generic_runtime_suspend(dev);
25 	if (ret)
26 		return ret;
27 
28 	ret = pm_clk_suspend(dev);
29 	if (ret) {
30 		pm_generic_runtime_resume(dev);
31 		return ret;
32 	}
33 
34 	return 0;
35 }
36 
37 static int davinci_pm_runtime_resume(struct device *dev)
38 {
39 	dev_dbg(dev, "%s\n", __func__);
40 
41 	pm_clk_resume(dev);
42 	return pm_generic_runtime_resume(dev);
43 }
44 #endif
45 
46 static struct dev_pm_domain davinci_pm_domain = {
47 	.ops = {
48 		SET_RUNTIME_PM_OPS(davinci_pm_runtime_suspend,
49 				   davinci_pm_runtime_resume, NULL)
50 		USE_PLATFORM_PM_SLEEP_OPS
51 	},
52 };
53 
54 static struct pm_clk_notifier_block platform_bus_notifier = {
55 	.pm_domain = &davinci_pm_domain,
56 };
57 
58 static int __init davinci_pm_runtime_init(void)
59 {
60 	pm_clk_add_notifier(&platform_bus_type, &platform_bus_notifier);
61 
62 	return 0;
63 }
64 core_initcall(davinci_pm_runtime_init);
65