Skip to content

Commit

Permalink
[ARM] OMAP2/3 clockdomains: combine pwrdm, pwrdm_name into union in s…
Browse files Browse the repository at this point in the history
…truct 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>
  • Loading branch information
Paul Walmsley authored and Russell King committed Feb 8, 2009
1 parent aeec299 commit 5b74c67
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 65 deletions.
59 changes: 30 additions & 29 deletions arch/arm/mach-omap2/clockdomain.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/delay.h>
#include <linux/clk.h>
#include <linux/limits.h>
#include <linux/err.h>

#include <linux/io.h>

Expand Down Expand Up @@ -71,14 +72,14 @@ static void _autodep_lookup(struct clkdm_pwrdm_autodep *autodep)
if (!omap_chip_is(autodep->omap_chip))
return;

pwrdm = pwrdm_lookup(autodep->pwrdm_name);
pwrdm = pwrdm_lookup(autodep->pwrdm.name);
if (!pwrdm) {
pr_debug("clockdomain: _autodep_lookup: powerdomain %s "
"does not exist\n", autodep->pwrdm_name);
"does not exist\n", autodep->pwrdm.name);
WARN_ON(1);
return;
pwrdm = ERR_PTR(-ENOENT);
}
autodep->pwrdm = pwrdm;
autodep->pwrdm.ptr = pwrdm;

return;
}
Expand All @@ -95,16 +96,16 @@ static void _clkdm_add_autodeps(struct clockdomain *clkdm)
{
struct clkdm_pwrdm_autodep *autodep;

for (autodep = autodeps; autodep->pwrdm_name; autodep++) {
if (!autodep->pwrdm)
for (autodep = autodeps; autodep->pwrdm.ptr; autodep++) {
if (IS_ERR(autodep->pwrdm.ptr))
continue;

pr_debug("clockdomain: adding %s sleepdep/wkdep for "
"pwrdm %s\n", autodep->pwrdm_name,
clkdm->pwrdm->name);
"pwrdm %s\n", autodep->pwrdm.ptr->name,
clkdm->pwrdm.ptr->name);

pwrdm_add_sleepdep(clkdm->pwrdm, autodep->pwrdm);
pwrdm_add_wkdep(clkdm->pwrdm, autodep->pwrdm);
pwrdm_add_sleepdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
pwrdm_add_wkdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
}
}

Expand All @@ -120,16 +121,16 @@ static void _clkdm_del_autodeps(struct clockdomain *clkdm)
{
struct clkdm_pwrdm_autodep *autodep;

for (autodep = autodeps; autodep->pwrdm_name; autodep++) {
if (!autodep->pwrdm)
for (autodep = autodeps; autodep->pwrdm.ptr; autodep++) {
if (IS_ERR(autodep->pwrdm.ptr))
continue;

pr_debug("clockdomain: removing %s sleepdep/wkdep for "
"pwrdm %s\n", autodep->pwrdm_name,
clkdm->pwrdm->name);
"pwrdm %s\n", autodep->pwrdm.ptr->name,
clkdm->pwrdm.ptr->name);

pwrdm_del_sleepdep(clkdm->pwrdm, autodep->pwrdm);
pwrdm_del_wkdep(clkdm->pwrdm, autodep->pwrdm);
pwrdm_del_sleepdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
pwrdm_del_wkdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
}
}

Expand Down Expand Up @@ -179,7 +180,7 @@ void clkdm_init(struct clockdomain **clkdms,

autodeps = init_autodeps;
if (autodeps)
for (autodep = autodeps; autodep->pwrdm_name; autodep++)
for (autodep = autodeps; autodep->pwrdm.ptr; autodep++)
_autodep_lookup(autodep);
}

Expand All @@ -202,13 +203,13 @@ int clkdm_register(struct clockdomain *clkdm)
if (!omap_chip_is(clkdm->omap_chip))
return -EINVAL;

pwrdm = pwrdm_lookup(clkdm->pwrdm_name);
pwrdm = pwrdm_lookup(clkdm->pwrdm.name);
if (!pwrdm) {
pr_debug("clockdomain: clkdm_register %s: powerdomain %s "
"does not exist\n", clkdm->name, clkdm->pwrdm_name);
"does not exist\n", clkdm->name, clkdm->pwrdm.name);
return -EINVAL;
}
clkdm->pwrdm = pwrdm;
clkdm->pwrdm.ptr = pwrdm;

mutex_lock(&clkdm_mutex);
/* Verify that the clockdomain is not already registered */
Expand Down Expand Up @@ -242,7 +243,7 @@ int clkdm_unregister(struct clockdomain *clkdm)
if (!clkdm)
return -EINVAL;

pwrdm_del_clkdm(clkdm->pwrdm, clkdm);
pwrdm_del_clkdm(clkdm->pwrdm.ptr, clkdm);

mutex_lock(&clkdm_mutex);
list_del(&clkdm->node);
Expand Down Expand Up @@ -327,7 +328,7 @@ struct powerdomain *clkdm_get_pwrdm(struct clockdomain *clkdm)
if (!clkdm)
return NULL;

return clkdm->pwrdm;
return clkdm->pwrdm.ptr;
}


Expand All @@ -348,7 +349,7 @@ static int omap2_clkdm_clktrctrl_read(struct clockdomain *clkdm)
if (!clkdm)
return -EINVAL;

v = cm_read_mod_reg(clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL);
v = cm_read_mod_reg(clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
v &= clkdm->clktrctrl_mask;
v >>= __ffs(clkdm->clktrctrl_mask);

Expand Down Expand Up @@ -380,15 +381,15 @@ int omap2_clkdm_sleep(struct clockdomain *clkdm)
if (cpu_is_omap24xx()) {

cm_set_mod_reg_bits(OMAP24XX_FORCESTATE,
clkdm->pwrdm->prcm_offs, PM_PWSTCTRL);
clkdm->pwrdm.ptr->prcm_offs, PM_PWSTCTRL);

} else if (cpu_is_omap34xx()) {

u32 v = (OMAP34XX_CLKSTCTRL_FORCE_SLEEP <<
__ffs(clkdm->clktrctrl_mask));

cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask, v,
clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL);
clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);

} else {
BUG();
Expand Down Expand Up @@ -422,15 +423,15 @@ int omap2_clkdm_wakeup(struct clockdomain *clkdm)
if (cpu_is_omap24xx()) {

cm_clear_mod_reg_bits(OMAP24XX_FORCESTATE,
clkdm->pwrdm->prcm_offs, PM_PWSTCTRL);
clkdm->pwrdm.ptr->prcm_offs, PM_PWSTCTRL);

} else if (cpu_is_omap34xx()) {

u32 v = (OMAP34XX_CLKSTCTRL_FORCE_WAKEUP <<
__ffs(clkdm->clktrctrl_mask));

cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask, v,
clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL);
clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);

} else {
BUG();
Expand Down Expand Up @@ -478,7 +479,7 @@ void omap2_clkdm_allow_idle(struct clockdomain *clkdm)

cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask,
v << __ffs(clkdm->clktrctrl_mask),
clkdm->pwrdm->prcm_offs,
clkdm->pwrdm.ptr->prcm_offs,
CM_CLKSTCTRL);
}

Expand Down Expand Up @@ -516,7 +517,7 @@ void omap2_clkdm_deny_idle(struct clockdomain *clkdm)

cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask,
v << __ffs(clkdm->clktrctrl_mask),
clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL);
clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);

if (atomic_read(&clkdm->usecount) > 0)
_clkdm_del_autodeps(clkdm);
Expand Down
Loading

0 comments on commit 5b74c67

Please sign in to comment.