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