blob: 7868e75ad0772a95eaec0885696c52a12d3bac5a [file] [log] [blame]
Kevin Hilmane933ec72010-06-17 15:48:43 -07001/*
2 * Runtime PM support code for OMAP1
3 *
4 * Author: Kevin Hilman, Deep Root Systems, LLC
5 *
6 * Copyright (C) 2010 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/kernel.h>
14#include <linux/io.h>
15#include <linux/pm_runtime.h>
Rafael J. Wysockib5e8d262011-08-25 15:34:19 +020016#include <linux/pm_clock.h>
Kevin Hilmane933ec72010-06-17 15:48:43 -070017#include <linux/platform_device.h>
18#include <linux/mutex.h>
19#include <linux/clk.h>
20#include <linux/err.h>
21
22#include <plat/omap_device.h>
23#include <plat/omap-pm.h>
24
25#ifdef CONFIG_PM_RUNTIME
26static int omap1_pm_runtime_suspend(struct device *dev)
27{
Rafael J. Wysocki600b7762011-05-16 20:15:36 +020028 int ret;
Kevin Hilmane933ec72010-06-17 15:48:43 -070029
30 dev_dbg(dev, "%s\n", __func__);
31
32 ret = pm_generic_runtime_suspend(dev);
Rafael J. Wysocki600b7762011-05-16 20:15:36 +020033 if (ret)
34 return ret;
Kevin Hilmane933ec72010-06-17 15:48:43 -070035
Rafael J. Wysocki3d5c3032011-07-01 22:13:44 +020036 ret = pm_clk_suspend(dev);
Rafael J. Wysocki600b7762011-05-16 20:15:36 +020037 if (ret) {
38 pm_generic_runtime_resume(dev);
39 return ret;
Kevin Hilmane933ec72010-06-17 15:48:43 -070040 }
41
42 return 0;
Rafael J. Wysocki600b7762011-05-16 20:15:36 +020043}
Kevin Hilmane933ec72010-06-17 15:48:43 -070044
45static int omap1_pm_runtime_resume(struct device *dev)
46{
Kevin Hilmane933ec72010-06-17 15:48:43 -070047 dev_dbg(dev, "%s\n", __func__);
48
Rafael J. Wysocki3d5c3032011-07-01 22:13:44 +020049 pm_clk_resume(dev);
Kevin Hilmane933ec72010-06-17 15:48:43 -070050 return pm_generic_runtime_resume(dev);
Rafael J. Wysocki600b7762011-05-16 20:15:36 +020051}
52
Rafael J. Wysocki564b9052011-06-23 01:52:55 +020053static struct dev_pm_domain default_pm_domain = {
Rafael J. Wysocki600b7762011-05-16 20:15:36 +020054 .ops = {
55 .runtime_suspend = omap1_pm_runtime_suspend,
56 .runtime_resume = omap1_pm_runtime_resume,
57 USE_PLATFORM_PM_SLEEP_OPS
58 },
59};
Rafael J. Wysocki564b9052011-06-23 01:52:55 +020060#define OMAP1_PM_DOMAIN (&default_pm_domain)
Kevin Hilmane9e35c52011-06-14 05:53:18 -070061#else
Rafael J. Wysocki564b9052011-06-23 01:52:55 +020062#define OMAP1_PM_DOMAIN NULL
Kevin Hilmane9e35c52011-06-14 05:53:18 -070063#endif /* CONFIG_PM_RUNTIME */
Rafael J. Wysocki600b7762011-05-16 20:15:36 +020064
65static struct pm_clk_notifier_block platform_bus_notifier = {
Rafael J. Wysocki564b9052011-06-23 01:52:55 +020066 .pm_domain = OMAP1_PM_DOMAIN,
Rafael J. Wysocki600b7762011-05-16 20:15:36 +020067 .con_ids = { "ick", "fck", NULL, },
Kevin Hilmane933ec72010-06-17 15:48:43 -070068};
69
70static int __init omap1_pm_runtime_init(void)
71{
Tony Lindgren7f9187c2010-12-10 09:46:24 -080072 if (!cpu_class_is_omap1())
73 return -ENODEV;
74
Rafael J. Wysocki3d5c3032011-07-01 22:13:44 +020075 pm_clk_add_notifier(&platform_bus_type, &platform_bus_notifier);
Kevin Hilmane933ec72010-06-17 15:48:43 -070076
77 return 0;
78}
79core_initcall(omap1_pm_runtime_init);
Kevin Hilmane9e35c52011-06-14 05:53:18 -070080