davinci: pass clock flags to davinci_psc_config()

Enabling or disabling a PSC can take certain
modifiers like "disable with reset", "force
enable/disable" and "enable/disable with local
reset" apart from the regular clock gating
functionality.

Pass a flags argument to davinci_psc_config()
so these variations can be supported there.

At this time only "disable with reset" is
supported, but other functionality will be
added in subsequent patches.

Signed-off-by: Sekhar Nori <nsekhar@ti.com>
This commit is contained in:
Sekhar Nori 2011-07-06 06:01:21 +00:00
parent 8d54297b90
commit a51ca38b63
3 changed files with 15 additions and 7 deletions

View file

@ -44,7 +44,7 @@ static void __clk_enable(struct clk *clk)
__clk_enable(clk->parent); __clk_enable(clk->parent);
if (clk->usecount++ == 0 && (clk->flags & CLK_PSC)) if (clk->usecount++ == 0 && (clk->flags & CLK_PSC))
davinci_psc_config(psc_domain(clk), clk->gpsc, clk->lpsc, davinci_psc_config(psc_domain(clk), clk->gpsc, clk->lpsc,
PSC_STATE_ENABLE); true, clk->flags);
} }
static void __clk_disable(struct clk *clk) static void __clk_disable(struct clk *clk)
@ -54,8 +54,7 @@ static void __clk_disable(struct clk *clk)
if (--clk->usecount == 0 && !(clk->flags & CLK_PLL) && if (--clk->usecount == 0 && !(clk->flags & CLK_PLL) &&
(clk->flags & CLK_PSC)) (clk->flags & CLK_PSC))
davinci_psc_config(psc_domain(clk), clk->gpsc, clk->lpsc, davinci_psc_config(psc_domain(clk), clk->gpsc, clk->lpsc,
(clk->flags & PSC_SWRSTDISABLE) ? false, clk->flags);
PSC_STATE_SWRSTDISABLE : PSC_STATE_DISABLE);
if (clk->parent) if (clk->parent)
__clk_disable(clk->parent); __clk_disable(clk->parent);
} }
@ -239,8 +238,7 @@ static int __init clk_disable_unused(void)
pr_debug("Clocks: disable unused %s\n", ck->name); pr_debug("Clocks: disable unused %s\n", ck->name);
davinci_psc_config(psc_domain(ck), ck->gpsc, ck->lpsc, davinci_psc_config(psc_domain(ck), ck->gpsc, ck->lpsc,
(ck->flags & PSC_SWRSTDISABLE) ? false, ck->flags);
PSC_STATE_SWRSTDISABLE : PSC_STATE_DISABLE);
} }
spin_unlock_irq(&clockfw_lock); spin_unlock_irq(&clockfw_lock);

View file

@ -249,7 +249,7 @@
extern int davinci_psc_is_clk_active(unsigned int ctlr, unsigned int id); extern int davinci_psc_is_clk_active(unsigned int ctlr, unsigned int id);
extern void davinci_psc_config(unsigned int domain, unsigned int ctlr, extern void davinci_psc_config(unsigned int domain, unsigned int ctlr,
unsigned int id, u32 next_state); unsigned int id, bool enable, u32 flags);
#endif #endif

View file

@ -25,6 +25,8 @@
#include <mach/cputype.h> #include <mach/cputype.h>
#include <mach/psc.h> #include <mach/psc.h>
#include "clock.h"
/* Return nonzero iff the domain's clock is active */ /* Return nonzero iff the domain's clock is active */
int __init davinci_psc_is_clk_active(unsigned int ctlr, unsigned int id) int __init davinci_psc_is_clk_active(unsigned int ctlr, unsigned int id)
{ {
@ -48,11 +50,12 @@ int __init davinci_psc_is_clk_active(unsigned int ctlr, unsigned int id)
/* Enable or disable a PSC domain */ /* Enable or disable a PSC domain */
void davinci_psc_config(unsigned int domain, unsigned int ctlr, void davinci_psc_config(unsigned int domain, unsigned int ctlr,
unsigned int id, u32 next_state) unsigned int id, bool enable, u32 flags)
{ {
u32 epcpr, ptcmd, ptstat, pdstat, pdctl1, mdstat, mdctl; u32 epcpr, ptcmd, ptstat, pdstat, pdctl1, mdstat, mdctl;
void __iomem *psc_base; void __iomem *psc_base;
struct davinci_soc_info *soc_info = &davinci_soc_info; struct davinci_soc_info *soc_info = &davinci_soc_info;
u32 next_state = PSC_STATE_ENABLE;
if (!soc_info->psc_bases || (ctlr >= soc_info->psc_bases_num)) { if (!soc_info->psc_bases || (ctlr >= soc_info->psc_bases_num)) {
pr_warning("PSC: Bad psc data: 0x%x[%d]\n", pr_warning("PSC: Bad psc data: 0x%x[%d]\n",
@ -62,6 +65,13 @@ void davinci_psc_config(unsigned int domain, unsigned int ctlr,
psc_base = ioremap(soc_info->psc_bases[ctlr], SZ_4K); psc_base = ioremap(soc_info->psc_bases[ctlr], SZ_4K);
if (!enable) {
if (flags & PSC_SWRSTDISABLE)
next_state = PSC_STATE_SWRSTDISABLE;
else
next_state = PSC_STATE_DISABLE;
}
mdctl = __raw_readl(psc_base + MDCTL + 4 * id); mdctl = __raw_readl(psc_base + MDCTL + 4 * id);
mdctl &= ~MDSTAT_STATE_MASK; mdctl &= ~MDSTAT_STATE_MASK;
mdctl |= next_state; mdctl |= next_state;