aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/clockdomain.c
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2009-02-03 04:10:03 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-02-08 12:50:28 -0500
commit5b74c67660dbd536a4f4e8cea12d10683ad2e432 (patch)
treebca554fd538d1bf0d984164acab73d6cc832760b /arch/arm/mach-omap2/clockdomain.c
parentaeec299011da8c3f07a47fe5d988f0eafda53906 (diff)
[ARM] OMAP2/3 clockdomains: combine pwrdm, pwrdm_name into union in struct clockdomain
struct clockdomain contains a struct powerdomain *pwrdm and const char *pwrdm_name. The pwrdm_name is only used at initialization to look up the appropriate pwrdm pointer. Combining these into a union saves about 100 bytes on 3430SDP. This patch should not cause any change in kernel function. Updated to gracefully handle autodeps that contain invalid powerdomains, per Russell King's review comments. Boot-tested on BeagleBoard ES2.1. linux-omap source commit is 718fc6cd4db902aa2242a736cc3feb8744a4c71a. Signed-off-by: Paul Walmsley <paul@pwsan.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-omap2/clockdomain.c')
-rw-r--r--arch/arm/mach-omap2/clockdomain.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index 4c3ce9cfd948..e9b4f6c564e4 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -22,6 +22,7 @@
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <linux/limits.h> 24#include <linux/limits.h>
25#include <linux/err.h>
25 26
26#include <linux/io.h> 27#include <linux/io.h>
27 28
@@ -71,14 +72,14 @@ static void _autodep_lookup(struct clkdm_pwrdm_autodep *autodep)
71 if (!omap_chip_is(autodep->omap_chip)) 72 if (!omap_chip_is(autodep->omap_chip))
72 return; 73 return;
73 74
74 pwrdm = pwrdm_lookup(autodep->pwrdm_name); 75 pwrdm = pwrdm_lookup(autodep->pwrdm.name);
75 if (!pwrdm) { 76 if (!pwrdm) {
76 pr_debug("clockdomain: _autodep_lookup: powerdomain %s " 77 pr_debug("clockdomain: _autodep_lookup: powerdomain %s "
77 "does not exist\n", autodep->pwrdm_name); 78 "does not exist\n", autodep->pwrdm.name);
78 WARN_ON(1); 79 WARN_ON(1);
79 return; 80 pwrdm = ERR_PTR(-ENOENT);
80 } 81 }
81 autodep->pwrdm = pwrdm; 82 autodep->pwrdm.ptr = pwrdm;
82 83
83 return; 84 return;
84} 85}
@@ -95,16 +96,16 @@ static void _clkdm_add_autodeps(struct clockdomain *clkdm)
95{ 96{
96 struct clkdm_pwrdm_autodep *autodep; 97 struct clkdm_pwrdm_autodep *autodep;
97 98
98 for (autodep = autodeps; autodep->pwrdm_name; autodep++) { 99 for (autodep = autodeps; autodep->pwrdm.ptr; autodep++) {
99 if (!autodep->pwrdm) 100 if (IS_ERR(autodep->pwrdm.ptr))
100 continue; 101 continue;
101 102
102 pr_debug("clockdomain: adding %s sleepdep/wkdep for " 103 pr_debug("clockdomain: adding %s sleepdep/wkdep for "
103 "pwrdm %s\n", autodep->pwrdm_name, 104 "pwrdm %s\n", autodep->pwrdm.ptr->name,
104 clkdm->pwrdm->name); 105 clkdm->pwrdm.ptr->name);
105 106
106 pwrdm_add_sleepdep(clkdm->pwrdm, autodep->pwrdm); 107 pwrdm_add_sleepdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
107 pwrdm_add_wkdep(clkdm->pwrdm, autodep->pwrdm); 108 pwrdm_add_wkdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
108 } 109 }
109} 110}
110 111
@@ -120,16 +121,16 @@ static void _clkdm_del_autodeps(struct clockdomain *clkdm)
120{ 121{
121 struct clkdm_pwrdm_autodep *autodep; 122 struct clkdm_pwrdm_autodep *autodep;
122 123
123 for (autodep = autodeps; autodep->pwrdm_name; autodep++) { 124 for (autodep = autodeps; autodep->pwrdm.ptr; autodep++) {
124 if (!autodep->pwrdm) 125 if (IS_ERR(autodep->pwrdm.ptr))
125 continue; 126 continue;
126 127
127 pr_debug("clockdomain: removing %s sleepdep/wkdep for " 128 pr_debug("clockdomain: removing %s sleepdep/wkdep for "
128 "pwrdm %s\n", autodep->pwrdm_name, 129 "pwrdm %s\n", autodep->pwrdm.ptr->name,
129 clkdm->pwrdm->name); 130 clkdm->pwrdm.ptr->name);
130 131
131 pwrdm_del_sleepdep(clkdm->pwrdm, autodep->pwrdm); 132 pwrdm_del_sleepdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
132 pwrdm_del_wkdep(clkdm->pwrdm, autodep->pwrdm); 133 pwrdm_del_wkdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
133 } 134 }
134} 135}
135 136
@@ -179,7 +180,7 @@ void clkdm_init(struct clockdomain **clkdms,
179 180
180 autodeps = init_autodeps; 181 autodeps = init_autodeps;
181 if (autodeps) 182 if (autodeps)
182 for (autodep = autodeps; autodep->pwrdm_name; autodep++) 183 for (autodep = autodeps; autodep->pwrdm.ptr; autodep++)
183 _autodep_lookup(autodep); 184 _autodep_lookup(autodep);
184} 185}
185 186
@@ -202,13 +203,13 @@ int clkdm_register(struct clockdomain *clkdm)
202 if (!omap_chip_is(clkdm->omap_chip)) 203 if (!omap_chip_is(clkdm->omap_chip))
203 return -EINVAL; 204 return -EINVAL;
204 205
205 pwrdm = pwrdm_lookup(clkdm->pwrdm_name); 206 pwrdm = pwrdm_lookup(clkdm->pwrdm.name);
206 if (!pwrdm) { 207 if (!pwrdm) {
207 pr_debug("clockdomain: clkdm_register %s: powerdomain %s " 208 pr_debug("clockdomain: clkdm_register %s: powerdomain %s "
208 "does not exist\n", clkdm->name, clkdm->pwrdm_name); 209 "does not exist\n", clkdm->name, clkdm->pwrdm.name);
209 return -EINVAL; 210 return -EINVAL;
210 } 211 }
211 clkdm->pwrdm = pwrdm; 212 clkdm->pwrdm.ptr = pwrdm;
212 213
213 mutex_lock(&clkdm_mutex); 214 mutex_lock(&clkdm_mutex);
214 /* Verify that the clockdomain is not already registered */ 215 /* Verify that the clockdomain is not already registered */
@@ -242,7 +243,7 @@ int clkdm_unregister(struct clockdomain *clkdm)
242 if (!clkdm) 243 if (!clkdm)
243 return -EINVAL; 244 return -EINVAL;
244 245
245 pwrdm_del_clkdm(clkdm->pwrdm, clkdm); 246 pwrdm_del_clkdm(clkdm->pwrdm.ptr, clkdm);
246 247
247 mutex_lock(&clkdm_mutex); 248 mutex_lock(&clkdm_mutex);
248 list_del(&clkdm->node); 249 list_del(&clkdm->node);
@@ -327,7 +328,7 @@ struct powerdomain *clkdm_get_pwrdm(struct clockdomain *clkdm)
327 if (!clkdm) 328 if (!clkdm)
328 return NULL; 329 return NULL;
329 330
330 return clkdm->pwrdm; 331 return clkdm->pwrdm.ptr;
331} 332}
332 333
333 334
@@ -348,7 +349,7 @@ static int omap2_clkdm_clktrctrl_read(struct clockdomain *clkdm)
348 if (!clkdm) 349 if (!clkdm)
349 return -EINVAL; 350 return -EINVAL;
350 351
351 v = cm_read_mod_reg(clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL); 352 v = cm_read_mod_reg(clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
352 v &= clkdm->clktrctrl_mask; 353 v &= clkdm->clktrctrl_mask;
353 v >>= __ffs(clkdm->clktrctrl_mask); 354 v >>= __ffs(clkdm->clktrctrl_mask);
354 355
@@ -380,7 +381,7 @@ int omap2_clkdm_sleep(struct clockdomain *clkdm)
380 if (cpu_is_omap24xx()) { 381 if (cpu_is_omap24xx()) {
381 382
382 cm_set_mod_reg_bits(OMAP24XX_FORCESTATE, 383 cm_set_mod_reg_bits(OMAP24XX_FORCESTATE,
383 clkdm->pwrdm->prcm_offs, PM_PWSTCTRL); 384 clkdm->pwrdm.ptr->prcm_offs, PM_PWSTCTRL);
384 385
385 } else if (cpu_is_omap34xx()) { 386 } else if (cpu_is_omap34xx()) {
386 387
@@ -388,7 +389,7 @@ int omap2_clkdm_sleep(struct clockdomain *clkdm)
388 __ffs(clkdm->clktrctrl_mask)); 389 __ffs(clkdm->clktrctrl_mask));
389 390
390 cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask, v, 391 cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask, v,
391 clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL); 392 clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
392 393
393 } else { 394 } else {
394 BUG(); 395 BUG();
@@ -422,7 +423,7 @@ int omap2_clkdm_wakeup(struct clockdomain *clkdm)
422 if (cpu_is_omap24xx()) { 423 if (cpu_is_omap24xx()) {
423 424
424 cm_clear_mod_reg_bits(OMAP24XX_FORCESTATE, 425 cm_clear_mod_reg_bits(OMAP24XX_FORCESTATE,
425 clkdm->pwrdm->prcm_offs, PM_PWSTCTRL); 426 clkdm->pwrdm.ptr->prcm_offs, PM_PWSTCTRL);
426 427
427 } else if (cpu_is_omap34xx()) { 428 } else if (cpu_is_omap34xx()) {
428 429
@@ -430,7 +431,7 @@ int omap2_clkdm_wakeup(struct clockdomain *clkdm)
430 __ffs(clkdm->clktrctrl_mask)); 431 __ffs(clkdm->clktrctrl_mask));
431 432
432 cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask, v, 433 cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask, v,
433 clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL); 434 clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
434 435
435 } else { 436 } else {
436 BUG(); 437 BUG();
@@ -478,7 +479,7 @@ void omap2_clkdm_allow_idle(struct clockdomain *clkdm)
478 479
479 cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask, 480 cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask,
480 v << __ffs(clkdm->clktrctrl_mask), 481 v << __ffs(clkdm->clktrctrl_mask),
481 clkdm->pwrdm->prcm_offs, 482 clkdm->pwrdm.ptr->prcm_offs,
482 CM_CLKSTCTRL); 483 CM_CLKSTCTRL);
483} 484}
484 485
@@ -516,7 +517,7 @@ void omap2_clkdm_deny_idle(struct clockdomain *clkdm)
516 517
517 cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask, 518 cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask,
518 v << __ffs(clkdm->clktrctrl_mask), 519 v << __ffs(clkdm->clktrctrl_mask),
519 clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL); 520 clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
520 521
521 if (atomic_read(&clkdm->usecount) > 0) 522 if (atomic_read(&clkdm->usecount) > 0)
522 _clkdm_del_autodeps(clkdm); 523 _clkdm_del_autodeps(clkdm);