| Kevin Hilman | e933ec7 | 2010-06-17 15:48:43 -0700 | [diff] [blame] | 1 | /* | 
|  | 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> | 
|  | 16 | #include <linux/platform_device.h> | 
|  | 17 | #include <linux/mutex.h> | 
|  | 18 | #include <linux/clk.h> | 
|  | 19 | #include <linux/err.h> | 
|  | 20 |  | 
|  | 21 | #include <plat/omap_device.h> | 
|  | 22 | #include <plat/omap-pm.h> | 
|  | 23 |  | 
|  | 24 | #ifdef CONFIG_PM_RUNTIME | 
|  | 25 | static int omap1_pm_runtime_suspend(struct device *dev) | 
|  | 26 | { | 
| Rafael J. Wysocki | 600b776 | 2011-05-16 20:15:36 +0200 | [diff] [blame] | 27 | int ret; | 
| Kevin Hilman | e933ec7 | 2010-06-17 15:48:43 -0700 | [diff] [blame] | 28 |  | 
|  | 29 | dev_dbg(dev, "%s\n", __func__); | 
|  | 30 |  | 
|  | 31 | ret = pm_generic_runtime_suspend(dev); | 
| Rafael J. Wysocki | 600b776 | 2011-05-16 20:15:36 +0200 | [diff] [blame] | 32 | if (ret) | 
|  | 33 | return ret; | 
| Kevin Hilman | e933ec7 | 2010-06-17 15:48:43 -0700 | [diff] [blame] | 34 |  | 
| Rafael J. Wysocki | 600b776 | 2011-05-16 20:15:36 +0200 | [diff] [blame] | 35 | ret = pm_runtime_clk_suspend(dev); | 
|  | 36 | if (ret) { | 
|  | 37 | pm_generic_runtime_resume(dev); | 
|  | 38 | return ret; | 
| Kevin Hilman | e933ec7 | 2010-06-17 15:48:43 -0700 | [diff] [blame] | 39 | } | 
|  | 40 |  | 
|  | 41 | return 0; | 
| Rafael J. Wysocki | 600b776 | 2011-05-16 20:15:36 +0200 | [diff] [blame] | 42 | } | 
| Kevin Hilman | e933ec7 | 2010-06-17 15:48:43 -0700 | [diff] [blame] | 43 |  | 
|  | 44 | static int omap1_pm_runtime_resume(struct device *dev) | 
|  | 45 | { | 
| Kevin Hilman | e933ec7 | 2010-06-17 15:48:43 -0700 | [diff] [blame] | 46 | dev_dbg(dev, "%s\n", __func__); | 
|  | 47 |  | 
| Rafael J. Wysocki | 600b776 | 2011-05-16 20:15:36 +0200 | [diff] [blame] | 48 | pm_runtime_clk_resume(dev); | 
| Kevin Hilman | e933ec7 | 2010-06-17 15:48:43 -0700 | [diff] [blame] | 49 | return pm_generic_runtime_resume(dev); | 
| Rafael J. Wysocki | 600b776 | 2011-05-16 20:15:36 +0200 | [diff] [blame] | 50 | } | 
|  | 51 |  | 
|  | 52 | static struct dev_power_domain default_power_domain = { | 
|  | 53 | .ops = { | 
|  | 54 | .runtime_suspend = omap1_pm_runtime_suspend, | 
|  | 55 | .runtime_resume = omap1_pm_runtime_resume, | 
|  | 56 | USE_PLATFORM_PM_SLEEP_OPS | 
|  | 57 | }, | 
|  | 58 | }; | 
|  | 59 |  | 
|  | 60 | static struct pm_clk_notifier_block platform_bus_notifier = { | 
|  | 61 | .pwr_domain = &default_power_domain, | 
|  | 62 | .con_ids = { "ick", "fck", NULL, }, | 
| Kevin Hilman | e933ec7 | 2010-06-17 15:48:43 -0700 | [diff] [blame] | 63 | }; | 
|  | 64 |  | 
|  | 65 | static int __init omap1_pm_runtime_init(void) | 
|  | 66 | { | 
| Tony Lindgren | 7f9187c | 2010-12-10 09:46:24 -0800 | [diff] [blame] | 67 | if (!cpu_class_is_omap1()) | 
|  | 68 | return -ENODEV; | 
|  | 69 |  | 
| Rafael J. Wysocki | 600b776 | 2011-05-16 20:15:36 +0200 | [diff] [blame] | 70 | pm_runtime_clk_add_notifier(&platform_bus_type, &platform_bus_notifier); | 
| Kevin Hilman | e933ec7 | 2010-06-17 15:48:43 -0700 | [diff] [blame] | 71 |  | 
|  | 72 | return 0; | 
|  | 73 | } | 
|  | 74 | core_initcall(omap1_pm_runtime_init); | 
|  | 75 | #endif /* CONFIG_PM_RUNTIME */ |