aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2014-10-21 16:22:29 -0400
committerTony Lindgren <tony@atomide.com>2014-11-10 19:01:40 -0500
commitb9f5fe6425ef1622fb0f16f0fa33f19b993863a6 (patch)
treeb9667fc414d66e89c09c968264cd90d31586af87
parent9008d83fe9dc2e0f19b8ba17a423b3759d8e0fd7 (diff)
ARM: OMAP4+: PM: Centralize static dependency mapping table
As we add more static dependency mapping for various errata, the logic gets clunkier. Since it is a simple lookup and map logic, centralize the same and provide the mapping as a simple list. Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r--arch/arm/mach-omap2/pm44xx.c117
1 files changed, 57 insertions, 60 deletions
diff --git a/arch/arm/mach-omap2/pm44xx.c b/arch/arm/mach-omap2/pm44xx.c
index e7f823b960c2..d697cecf762b 100644
--- a/arch/arm/mach-omap2/pm44xx.c
+++ b/arch/arm/mach-omap2/pm44xx.c
@@ -37,6 +37,16 @@ struct power_state {
37 struct list_head node; 37 struct list_head node;
38}; 38};
39 39
40/**
41 * struct static_dep_map - Static dependency map
42 * @from: from clockdomain
43 * @to: to clockdomain
44 */
45struct static_dep_map {
46 const char *from;
47 const char *to;
48};
49
40static u32 cpu_suspend_state = PWRDM_POWER_OFF; 50static u32 cpu_suspend_state = PWRDM_POWER_OFF;
41 51
42static LIST_HEAD(pwrst_list); 52static LIST_HEAD(pwrst_list);
@@ -148,74 +158,61 @@ static void omap_default_idle(void)
148 omap_do_wfi(); 158 omap_do_wfi();
149} 159}
150 160
151/** 161/*
152 * omap4_init_static_deps - Add OMAP4 static dependencies 162 * The dynamic dependency between MPUSS -> MEMIF and
153 * 163 * MPUSS -> L4_PER/L3_* and DUCATI -> L3_* doesn't work as
154 * Add needed static clockdomain dependencies on OMAP4 devices. 164 * expected. The hardware recommendation is to enable static
155 * Return: 0 on success or 'err' on failures 165 * dependencies for these to avoid system lock ups or random crashes.
166 * The L4 wakeup depedency is added to workaround the OCP sync hardware
167 * BUG with 32K synctimer which lead to incorrect timer value read
168 * from the 32K counter. The BUG applies for GPTIMER1 and WDT2 which
169 * are part of L4 wakeup clockdomain.
156 */ 170 */
157static inline int omap4_init_static_deps(void) 171static const struct static_dep_map omap4_static_dep_map[] = {
158{ 172 {.from = "mpuss_clkdm", .to = "l3_emif_clkdm"},
159 struct clockdomain *emif_clkdm, *mpuss_clkdm, *l3_1_clkdm; 173 {.from = "mpuss_clkdm", .to = "l3_1_clkdm"},
160 struct clockdomain *ducati_clkdm, *l3_2_clkdm; 174 {.from = "mpuss_clkdm", .to = "l3_2_clkdm"},
161 int ret = 0; 175 {.from = "ducati_clkdm", .to = "l3_1_clkdm"},
162 176 {.from = "ducati_clkdm", .to = "l3_2_clkdm"},
163 /* 177 {.from = NULL} /* TERMINATION */
164 * The dynamic dependency between MPUSS -> MEMIF and 178};
165 * MPUSS -> L4_PER/L3_* and DUCATI -> L3_* doesn't work as
166 * expected. The hardware recommendation is to enable static
167 * dependencies for these to avoid system lock ups or random crashes.
168 * The L4 wakeup depedency is added to workaround the OCP sync hardware
169 * BUG with 32K synctimer which lead to incorrect timer value read
170 * from the 32K counter. The BUG applies for GPTIMER1 and WDT2 which
171 * are part of L4 wakeup clockdomain.
172 */
173 mpuss_clkdm = clkdm_lookup("mpuss_clkdm");
174 emif_clkdm = clkdm_lookup("l3_emif_clkdm");
175 l3_1_clkdm = clkdm_lookup("l3_1_clkdm");
176 l3_2_clkdm = clkdm_lookup("l3_2_clkdm");
177 ducati_clkdm = clkdm_lookup("ducati_clkdm");
178 if ((!mpuss_clkdm) || (!emif_clkdm) || (!l3_1_clkdm) ||
179 (!l3_2_clkdm) || (!ducati_clkdm))
180 return -EINVAL;
181
182 ret = clkdm_add_wkdep(mpuss_clkdm, emif_clkdm);
183 ret |= clkdm_add_wkdep(mpuss_clkdm, l3_1_clkdm);
184 ret |= clkdm_add_wkdep(mpuss_clkdm, l3_2_clkdm);
185 ret |= clkdm_add_wkdep(ducati_clkdm, l3_1_clkdm);
186 ret |= clkdm_add_wkdep(ducati_clkdm, l3_2_clkdm);
187 if (ret) {
188 pr_err("Failed to add MPUSS -> L3/EMIF/L4PER, DUCATI -> L3 wakeup dependency\n");
189 return -EINVAL;
190 }
191 179
192 return ret; 180static const struct static_dep_map omap5_dra7_static_dep_map[] = {
193} 181 {.from = "mpu_clkdm", .to = "emif_clkdm"},
182 {.from = NULL} /* TERMINATION */
183};
194 184
195/** 185/**
196 * omap5_dra7_init_static_deps - Init static clkdm dependencies on OMAP5 and 186 * omap4plus_init_static_deps() - Initialize a static dependency map
197 * DRA7 187 * @map: Mapping of clock domains
198 *
199 * The dynamic dependency between MPUSS -> EMIF is broken and has
200 * not worked as expected. The hardware recommendation is to
201 * enable static dependencies for these to avoid system
202 * lock ups or random crashes.
203 */ 188 */
204static inline int omap5_dra7_init_static_deps(void) 189static inline int omap4plus_init_static_deps(const struct static_dep_map *map)
205{ 190{
206 struct clockdomain *mpuss_clkdm, *emif_clkdm;
207 int ret; 191 int ret;
192 struct clockdomain *from, *to;
208 193
209 mpuss_clkdm = clkdm_lookup("mpu_clkdm"); 194 if (!map)
210 emif_clkdm = clkdm_lookup("emif_clkdm"); 195 return 0;
211 if (!mpuss_clkdm || !emif_clkdm) 196
212 return -EINVAL; 197 while (map->from) {
198 from = clkdm_lookup(map->from);
199 to = clkdm_lookup(map->to);
200 if (!from || !to) {
201 pr_err("Failed lookup %s or %s for wakeup dependency\n",
202 map->from, map->to);
203 return -EINVAL;
204 }
205 ret = clkdm_add_wkdep(from, to);
206 if (ret) {
207 pr_err("Failed to add %s -> %s wakeup dependency(%d)\n",
208 map->from, map->to, ret);
209 return ret;
210 }
213 211
214 ret = clkdm_add_wkdep(mpuss_clkdm, emif_clkdm); 212 map++;
215 if (ret) 213 };
216 pr_err("Failed to add MPUSS -> EMIF wakeup dependency\n");
217 214
218 return ret; 215 return 0;
219} 216}
220 217
221/** 218/**
@@ -268,9 +265,9 @@ int __init omap4_pm_init(void)
268 } 265 }
269 266
270 if (cpu_is_omap44xx()) 267 if (cpu_is_omap44xx())
271 ret = omap4_init_static_deps(); 268 ret = omap4plus_init_static_deps(omap4_static_dep_map);
272 else if (soc_is_omap54xx() || soc_is_dra7xx()) 269 else if (soc_is_omap54xx() || soc_is_dra7xx())
273 ret = omap5_dra7_init_static_deps(); 270 ret = omap4plus_init_static_deps(omap5_dra7_static_dep_map);
274 271
275 if (ret) { 272 if (ret) {
276 pr_err("Failed to initialise static dependencies.\n"); 273 pr_err("Failed to initialise static dependencies.\n");