2 * pm.c - Common OMAP2+ power management-related code
4 * Copyright (C) 2010 Texas Instruments, Inc.
5 * Copyright (C) 2010 Nokia Corporation
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/kernel.h>
13 #include <linux/init.h>
15 #include <linux/err.h>
16 #include <linux/pm_opp.h>
17 #include <linux/export.h>
18 #include <linux/suspend.h>
19 #include <linux/clk.h>
20 #include <linux/cpu.h>
22 #include <asm/system_misc.h>
24 #include "omap_device.h"
28 #include "prcm-common.h"
30 #include "powerdomain.h"
31 #include "clockdomain.h"
36 * omap_pm_suspend: points to a function that does the SoC-specific
39 static int (*omap_pm_suspend)(void);
44 * struct omap2_oscillator - Describe the board main oscillator latencies
45 * @startup_time: oscillator startup latency
46 * @shutdown_time: oscillator shutdown latency
48 struct omap2_oscillator {
53 static struct omap2_oscillator oscillator = {
54 .startup_time = ULONG_MAX,
55 .shutdown_time = ULONG_MAX,
58 void omap_pm_setup_oscillator(u32 tstart, u32 tshut)
60 oscillator.startup_time = tstart;
61 oscillator.shutdown_time = tshut;
64 void omap_pm_get_oscillator(u32 *tstart, u32 *tshut)
66 if (!tstart || !tshut)
69 *tstart = oscillator.startup_time;
70 *tshut = oscillator.shutdown_time;
74 int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused)
76 clkdm_allow_idle(clkdm);
81 static int omap_pm_enter(suspend_state_t suspend_state)
86 return -ENOENT; /* XXX doublecheck */
88 switch (suspend_state) {
90 ret = omap_pm_suspend();
99 static int omap_pm_begin(suspend_state_t state)
101 cpu_idle_poll_ctrl(true);
102 if (soc_is_omap34xx())
103 omap_prcm_irq_prepare();
107 static void omap_pm_end(void)
109 cpu_idle_poll_ctrl(false);
112 static void omap_pm_wake(void)
114 if (soc_is_omap34xx())
115 omap_prcm_irq_complete();
118 static const struct platform_suspend_ops omap_pm_ops = {
119 .begin = omap_pm_begin,
121 .enter = omap_pm_enter,
122 .wake = omap_pm_wake,
123 .valid = suspend_valid_only_mem,
127 * omap_common_suspend_init - Set common suspend routines for OMAP SoCs
128 * @pm_suspend: function pointer to SoC specific suspend function
130 void omap_common_suspend_init(void *pm_suspend)
132 omap_pm_suspend = pm_suspend;
133 suspend_set_ops(&omap_pm_ops);
135 #endif /* CONFIG_SUSPEND */
137 int __maybe_unused omap_pm_nop_init(void)
142 int (*omap_pm_soc_init)(void);
144 int __init omap2_common_pm_late_init(void)
148 if (!omap_pm_soc_init)
151 /* Init the voltage layer */
154 omap_voltage_late_init();
156 /* Smartreflex device init */
157 omap_devinit_smartreflex();
159 error = omap_pm_soc_init();
161 pr_warn("%s: pm soc init failed: %i\n", __func__, error);
163 omap2_clk_enable_autoidle_all();
167 omap_late_initcall(omap2_common_pm_late_init);