2 * OMAP4 Power Management Routines
4 * Copyright (C) 2010 Texas Instruments, Inc.
5 * Rajendra Nayak <rnayak@ti.com>
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.
13 #include <linux/suspend.h>
14 #include <linux/module.h>
15 #include <linux/list.h>
16 #include <linux/err.h>
17 #include <linux/slab.h>
20 #include "powerdomain.h"
23 struct powerdomain *pwrdm;
28 struct list_head node;
31 static LIST_HEAD(pwrst_list);
34 static int omap4_pm_suspend(void)
40 static int omap4_pm_enter(suspend_state_t suspend_state)
44 switch (suspend_state) {
45 case PM_SUSPEND_STANDBY:
47 ret = omap4_pm_suspend();
56 static int omap4_pm_begin(suspend_state_t state)
62 static void omap4_pm_end(void)
68 static const struct platform_suspend_ops omap_pm_ops = {
69 .begin = omap4_pm_begin,
71 .enter = omap4_pm_enter,
72 .valid = suspend_valid_only_mem,
74 #endif /* CONFIG_SUSPEND */
76 static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
78 struct power_state *pwrst;
83 pwrst = kmalloc(sizeof(struct power_state), GFP_ATOMIC);
87 pwrst->next_state = PWRDM_POWER_ON;
88 list_add(&pwrst->node, &pwrst_list);
90 return pwrdm_set_next_pwrst(pwrst->pwrdm, pwrst->next_state);
94 * omap4_pm_init - Init routine for OMAP4 PM
96 * Initializes all powerdomain and clockdomain target states
97 * and all PRCM settings.
99 static int __init omap4_pm_init(void)
102 struct clockdomain *emif_clkdm, *mpuss_clkdm, *l3_1_clkdm;
103 struct clockdomain *ducati_clkdm, *l3_2_clkdm, *l4_per_clkdm;
105 if (!cpu_is_omap44xx())
108 if (omap_rev() == OMAP4430_REV_ES1_0) {
109 WARN(1, "Power Management not supported on OMAP4430 ES1.0\n");
113 pr_err("Power Management for TI OMAP4.\n");
115 ret = pwrdm_for_each(pwrdms_setup, NULL);
117 pr_err("Failed to setup powerdomains\n");
122 * The dynamic dependency between MPUSS -> MEMIF and
123 * MPUSS -> L4_PER/L3_* and DUCATI -> L3_* doesn't work as
124 * expected. The hardware recommendation is to enable static
125 * dependencies for these to avoid system lock ups or random crashes.
127 mpuss_clkdm = clkdm_lookup("mpuss_clkdm");
128 emif_clkdm = clkdm_lookup("l3_emif_clkdm");
129 l3_1_clkdm = clkdm_lookup("l3_1_clkdm");
130 l3_2_clkdm = clkdm_lookup("l3_2_clkdm");
131 l4_per_clkdm = clkdm_lookup("l4_per_clkdm");
132 ducati_clkdm = clkdm_lookup("ducati_clkdm");
133 if ((!mpuss_clkdm) || (!emif_clkdm) || (!l3_1_clkdm) ||
134 (!l3_2_clkdm) || (!ducati_clkdm) || (!l4_per_clkdm))
137 ret = clkdm_add_wkdep(mpuss_clkdm, emif_clkdm);
138 ret |= clkdm_add_wkdep(mpuss_clkdm, l3_1_clkdm);
139 ret |= clkdm_add_wkdep(mpuss_clkdm, l3_2_clkdm);
140 ret |= clkdm_add_wkdep(mpuss_clkdm, l4_per_clkdm);
141 ret |= clkdm_add_wkdep(ducati_clkdm, l3_1_clkdm);
142 ret |= clkdm_add_wkdep(ducati_clkdm, l3_2_clkdm);
144 pr_err("Failed to add MPUSS -> L3/EMIF/L4PER, DUCATI -> L3 "
145 "wakeup dependency\n");
149 #ifdef CONFIG_SUSPEND
150 suspend_set_ops(&omap_pm_ops);
151 #endif /* CONFIG_SUSPEND */
156 late_initcall(omap4_pm_init);