clock/dpll autoidle support
Subsystems (5)
v2 cover clock/dpll autoidle support
OMAP has various clock nodes and dpll's
which support hardware level autoidle.
Enabling hardware level autoidle provides
better power savings without much software
intervention.
This series does the following to help enable
hardware level autoidling using clock framework
for some of these nodes on OMAP3 and OMAP4
-1- Adds support for providing function pointers for enabling/disabling autoidle in clkops
-2- Populates these in clkops for all OMAP3/4 dplls -3- Enables all dpll autoidle late in boot on OMAP3 and OMAP4 -4- Adds support for mx postdivider autoidle (present only on OMAP4) and enables it late in OMAP4 boot
Some of the patches in this series were earlier posted and discussed as part of another series here
http://marc.info/?l=linux-omap&m=129681356402594&w=2
They are now posted as a seperate series as discussed here
http://marc.info/?l=linux-omap&m=129713867702170&w=2
The patches are boot tested on OMAP3430sdp and
OMAP4430sdp.
The following changes since commit 100b33c8bd8a3235fd0b7948338d6cbb3db3c63d:
Linus Torvalds (1):
Linux 2.6.38-rc4
are available in the git repository at:
git://gitorious.org/omap-pm/linux.git dpll-autoidle-v2
Changes in v2:
-1- Added support for clkout_x2 autogating
-2- Populated dpll_usb_clkdcoldo_ck's missing
clksel register
Rajendra Nayak (7):
omap: clock: Check for enable/disable ops support
omap3: dpll: Populate clkops for dpll1_ck
omap: clock: Add allow_idle/deny_idle support in clkops
omap: dpll: Add allow_idle/deny_idle support for all DPLL's
omap: dpll: Enable all OMAP3/4 dpll autoidle late at boot
omap4: dpll: Add dpll api to control GATE_CTRL
omap4: dpll: Enable auto gate control for all MX postdividers
arch/arm/mach-omap2/clock.c | 25 +++++++++++--- arch/arm/mach-omap2/clock.h | 5 +++ arch/arm/mach-omap2/clock3xxx_data.c | 4 +- arch/arm/mach-omap2/clock44xx_data.c | 54 +++++++++++++++++------------ arch/arm/mach-omap2/dpll3xxx.c | 57 +++++++++++++++++++++++++++++++ arch/arm/mach-omap2/pm34xx.c | 18 ++------- arch/arm/mach-omap2/pm44xx.c | 4 ++ arch/arm/plat-omap/clock.c | 26 ++++++++++++++ arch/arm/plat-omap/include/plat/clock.h | 7 ++++ 9 files changed, 156 insertions(+), 44 deletions(-)
PATCH v2 1/7 omap: clock: Check for enable/disable ops support
Check if enable/disable operations are supported for a given clock node before attempting to call them.
--- arch/arm/mach-omap2/clock.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-)
arch/arm/mach-omap2/clock.c +9 -5
@@ -261,7 +261,8 @@ void omap2_clk_disable(struct clk *clk)pr_debug ("clock: %s: disabling in hardware\n" , clk->name); - clk->ops->disable (clk); +if (clk->ops && clk->ops->disable) + clk->ops->disable (clk);if (clk->clkdm)omap2_clkdm_clk_disable (clk->clkdm, clk);
@@ -312,10 +313,13 @@ int omap2_clk_enable(struct clk *clk) } } - ret = clk->ops->enable (clk); -if (ret) { -WARN (1 ,"clock: %s: could not enable: %d\n" , clk->name, ret); - goto oce_err3; +if (clk->ops && clk->ops->enable) { + ret = clk->ops->enable (clk); +if (ret) { +WARN (1 ,"clock: %s: could not enable: %d\n" , + clk->name, ret); + goto oce_err3; + } }return 0 ;
Signature · 1 line
1.7.0.4
PATCH v2 2/7 omap3: dpll: Populate clkops for dpll1_ck
DPLL1 on omap3 is very similar to the rest of
the non-core dpll's.
Hence populate clkops_omap3_noncore_dpll_ops
as the clkops for it, instead of the
currently populated clkops_null.
--- arch/arm/mach-omap2/clock3xxx_data.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/clock3xxx_data.c +1 -1
@@ -296,7 +296,7 @@ static struct dpll_data dpll1_dd = {static struct clk dpll1_ck = { .name ="dpll1_ck" , - .ops = &clkops_null, + .ops = &clkops_omap3_noncore_dpll_ops, .parent = &sys_ck, .dpll_data = &dpll1_dd, .round_rate = &omap2_dpll_round_rate,
Signature · 1 line
1.7.0.4
PATCH v2 3/7 omap: clock: Add allow_idle/deny_idle support in clkops
On OMAP various clock nodes (dpll's, mx post dividers, interface clocks) support hardware level autogating which can be controlled from software.
Support such functionality by adding two new function pointer allow_idle and deny_idle in the clkops structure.
These function pointers can be populated for any clock node which supports hardware level autogating.
Also add 2 new functions (omap_clk_enable_auotidle and omap_clk_disable_autoidle) which can be called from architecture specific PM core code, if hardware level autogating (for all supported clock nodes) is to be enabled or disabled.
--- arch/arm/plat-omap/clock.c | 26 ++++++++++++++++++++++++++ arch/arm/plat-omap/include/plat/clock.h | 6 ++++++ 2 files changed, 32 insertions(+), 0 deletions(-)
arch/arm/plat-omap/clock.c +26 -0
@@ -335,6 +335,32 @@ struct clk *omap_clk_get_by_name(const char *name)return ret; } +void omap_clk_enable_autoidle (void ) +{ +struct clk *c; + +mutex_lock (&clocks_mutex); + +list_for_each_entry (c, &clocks, node) +if (c->ops->allow_idle) + c->ops->allow_idle (c); + +mutex_unlock (&clocks_mutex); +} + +void omap_clk_disable_autoidle (void ) +{ +struct clk *c; + +mutex_lock (&clocks_mutex); + +list_for_each_entry (c, &clocks, node) +if (c->ops->deny_idle) + c->ops->deny_idle (c); + +mutex_unlock (&clocks_mutex); +} +/* * Low level helpers */
arch/arm/plat-omap/include/plat/clock.h +6 -0
@@ -25,6 +25,8 @@ struct clockdomain;* @disable: fn ptr that enables the current clock in hardware * @find_idlest: function returning the IDLEST register for the clock's IP blk * @find_companion: function returning the "companion" clk reg for the clock +* @allow_idle: fn ptr that enables autoidle for the current clock in hardware +* @deny_idle: fn ptr that disables autoidle for the current clock in hardware * * A "companion" clk is an accompanying clock to the one being queried * that must be enabled for the IP module connected to the clock to
@@ -42,6 +44,8 @@ struct clkops { u8 *, u8 *);void (*find_companion)(struct clk *,void __iomem **,u8 *); +void (*allow_idle)(struct clk *); +void (*deny_idle)(struct clk *); };#ifdef CONFIG_ARCH_OMAP2PLUS
@@ -292,6 +296,8 @@ extern void clk_init_cpufreq_table(struct cpufreq_frequency_table **table);extern void clk_exit_cpufreq_table (struct cpufreq_frequency_table **table);#endif extern struct clk *omap_clk_get_by_name (const char *name); +extern void omap_clk_enable_autoidle (void ); +extern void omap_clk_disable_autoidle (void );extern const struct clkops clkops_null;
Signature · 1 line
1.7.0.4
PATCH v2 4/7 omap: dpll: Add allow_idle/deny_idle support for all DPLL's
All OMAP3/4 dpll's support hardware level autogating. Populate allow_idle/deny_idle function pointers for all DPLL's in clkops.
--- arch/arm/mach-omap2/clock.c | 8 +++++++- arch/arm/mach-omap2/clock.h | 1 + arch/arm/mach-omap2/clock3xxx_data.c | 2 +- arch/arm/mach-omap2/clock44xx_data.c | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-)
arch/arm/mach-omap2/clock.c +7 -1
@@ -377,10 +377,16 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent)const struct clkops clkops_omap3_noncore_dpll_ops = { .enable = omap3_noncore_dpll_enable, .disable = omap3_noncore_dpll_disable, + .allow_idle = omap3_dpll_allow_idle, + .deny_idle = omap3_dpll_deny_idle, }; -#endif +const struct clkops clkops_omap3_core_dpll_ops = { + .allow_idle = omap3_dpll_allow_idle, + .deny_idle = omap3_dpll_deny_idle, +}; +#endif /* * OMAP2+ clock reset and init functions
arch/arm/mach-omap2/clock.h +1 -0
@@ -146,5 +146,6 @@ extern void omap2_clk_exit_cpufreq_table(struct cpufreq_frequency_table **table)#endif extern const struct clkops clkops_omap3_noncore_dpll_ops; +extern const struct clkops clkops_omap3_core_dpll_ops;#endif
arch/arm/mach-omap2/clock3xxx_data.c +1 -1
@@ -429,7 +429,7 @@ static struct dpll_data dpll3_dd = {static struct clk dpll3_ck = { .name ="dpll3_ck" , - .ops = &clkops_null, + .ops = &clkops_omap3_core_dpll_ops, .parent = &sys_ck, .dpll_data = &dpll3_dd, .round_rate = &omap2_dpll_round_rate,
arch/arm/mach-omap2/clock44xx_data.c +1 -1
@@ -443,7 +443,7 @@ static struct clk dpll_core_ck = { .parent = &sys_clkin_ck, .dpll_data = &dpll_core_dd, .init = &omap2_init_dpll_parent, - .ops = &clkops_null, + .ops = &clkops_omap3_core_dpll_ops, .recalc = &omap3_dpll_recalc, };
Signature · 1 line
1.7.0.4
PATCH v2 5/7 omap: dpll: Enable all OMAP3/4 dpll autoidle late at boot
Enable all dpll autoidle for OMAP4 and OMAP3 (OMAP3 already had dpll autoidle turned on, but was done using low level cm accessor apis).
On OMAP3, replace the cm accessor apis doing this with the now available support for doing this in clock framework, using omap_clk_enable_autoidle().
--- arch/arm/mach-omap2/pm34xx.c | 18 ++++-------------- arch/arm/mach-omap2/pm44xx.c | 4 ++++ 2 files changed, 8 insertions(+), 14 deletions(-)
arch/arm/mach-omap2/pm34xx.c +4 -14
@@ -38,6 +38,7 @@#include <plat/prcm.h> #include <plat/gpmc.h> #include <plat/dma.h> +#include <plat/clock.h> #include <asm/tlbflush.h>
@@ -814,21 +815,10 @@ static void __init prcm_setup_regs(void)omap_ctrl_writel (OMAP3430_AUTOIDLE_MASK ,OMAP2_CONTROL_SYSCONFIG );/* -* Set all plls to autoidle. This is needed until autoidle is -* enabled by clockfw +* Set all plls to autoidle. +* TODO: Add all the iclk autoidles in here as well. */ -omap2_cm_write_mod_reg (1 <<OMAP3430_AUTO_IVA2_DPLL_SHIFT , -OMAP3430_IVA2_MOD ,CM_AUTOIDLE2 ); -omap2_cm_write_mod_reg (1 <<OMAP3430_AUTO_MPU_DPLL_SHIFT , -MPU_MOD , -CM_AUTOIDLE2 ); -omap2_cm_write_mod_reg ((1 <<OMAP3430_AUTO_PERIPH_DPLL_SHIFT ) | - (1 <<OMAP3430_AUTO_CORE_DPLL_SHIFT ), -PLL_MOD , -CM_AUTOIDLE ); -omap2_cm_write_mod_reg (1 <<OMAP3430ES2_AUTO_PERIPH2_DPLL_SHIFT , -PLL_MOD , -CM_AUTOIDLE2 ); +omap_clk_enable_autoidle ();/* * Enable control of expternal oscillator through
arch/arm/mach-omap2/pm44xx.c +4 -0
@@ -15,6 +15,7 @@#include <linux/list.h> #include <linux/err.h> #include <linux/slab.h> +#include <plat/clock.h> #include "powerdomain.h" #include <mach/omap4-common.h>
@@ -111,6 +112,9 @@ static int __init omap4_pm_init(void)pr_err ("Failed to setup powerdomains\n" ); goto err2; } + +/* Enable autoidle for all clks which support it*/ +omap_clk_enable_autoidle ();#endif #ifdef CONFIG_SUSPEND
Signature · 1 line
1.7.0.4
PATCH v2 6/7 omap4: dpll: Add dpll api to control GATE_CTRL
On OMAP4, the dpll post divider outputs (MX outputs) along with clockout_x2 output provide a way to allow/deny hardware level autogating.
Allowing autoidle would mean that the hw would autogate this clock when there is no dependency for it. Denying idle would mean that this clock output will be forced to stay enabled.
Add dpll api's to read/allow/deny idle control for these dpll mx postdividers.
NOTE: The gatectrl bit set to 0 allows gatectrl, and the bit set to 1 denies gatectrl.
--- arch/arm/mach-omap2/clock.h | 3 ++ arch/arm/mach-omap2/dpll3xxx.c | 57 +++++++++++++++++++++++++++++++ arch/arm/plat-omap/include/plat/clock.h | 1 + 3 files changed, 61 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/clock.h +3 -0
@@ -65,6 +65,9 @@ u32 omap3_dpll_autoidle_read(struct clk *clk);int omap3_noncore_dpll_set_rate (struct clk *clk,unsigned long rate);int omap3_noncore_dpll_enable (struct clk *clk);void omap3_noncore_dpll_disable (struct clk *clk); +int omap4_dpllmx_gatectrl_read (struct clk *clk); +void omap4_dpllmx_allow_gatectrl (struct clk *clk); +void omap4_dpllmx_deny_gatectrl (struct clk *clk);#ifdef CONFIG_OMAP_RESET_CLOCKS void omap2_clk_disable_unused (struct clk *clk);
arch/arm/mach-omap2/dpll3xxx.c +57 -0
66 lines not on this page · raw message
arch/arm/plat-omap/include/plat/clock.h +1 -0
@@ -181,6 +181,7 @@ struct dpll_data {#define CLOCK_NO_IDLE_PARENT (1 << 2)#define ENABLE_ON_INIT (1 << 3)/* Enable upon framework init */ #define INVERT_ENABLE (1 << 4)/* 0 enables, 1 disables */ +#define CLOCK_CLKOUTX2 (1 << 5)/** * struct clk - OMAP struct clk
Signature · 1 line
1.7.0.4
PATCH v2 7/7 omap4: dpll: Enable auto gate control for all MX postdividers
Enable hardware gate control for all dpll MX and X2 postdividers. This requires the allow_idle/deny_idle functions to be populated for all clock nodes (mx/x2 post dividers) in clkops.
--- arch/arm/mach-omap2/clock.c | 5 +++ arch/arm/mach-omap2/clock.h | 1 + arch/arm/mach-omap2/clock44xx_data.c | 52 +++++++++++++++++++-------------- 3 files changed, 36 insertions(+), 22 deletions(-)
arch/arm/mach-omap2/clock.c +5 -0
@@ -388,6 +388,11 @@ const struct clkops clkops_omap3_core_dpll_ops = {#endif +const struct clkops clkops_omap4_dpllmx_ops = { + .allow_idle = omap4_dpllmx_allow_gatectrl, + .deny_idle = omap4_dpllmx_deny_gatectrl, +}; +/* * OMAP2+ clock reset and init functions */
arch/arm/mach-omap2/clock.h +1 -0
@@ -150,5 +150,6 @@ extern void omap2_clk_exit_cpufreq_table(struct cpufreq_frequency_table **table)extern const struct clkops clkops_omap3_noncore_dpll_ops;extern const struct clkops clkops_omap3_core_dpll_ops; +extern const struct clkops clkops_omap4_dpllmx_ops;#endif
arch/arm/mach-omap2/clock44xx_data.c +30 -22
204 lines not on this page · raw message
Signature · 1 line
1.7.0.4
Paul Walmsley
maintainerPATCH v2 7/7 omap4: dpll: Enable auto gate control for all MX postdividers
Quoted 6 lines · Rajendra Nayak
Enable hardware gate control for all dpll MX and X2 postdividers. This requires the allow_idle/deny_idle functions to be populated for all clock nodes (mx/x2 post dividers) in clkops.
Signed-off-by Rajendra Nayak <[email protected]>
Thanks, queued for 2.6.39 in the 'clk_autoidle_a_2.6.39' branch. Has the OMAP4 clock data autogenerator script been updated?
- Paul
PATCH v2 7/7 omap4: dpll: Enable auto gate control for all MX postdividers
Hi Paul,
Quoted 5 lines
-----Original Message-----
From: Paul Walmsley [mailto:paul at pwsan.com]
Sent: Sunday, February 13, 2011 6:41 AM
To: Rajendra Nayak
Cc: linux-omap at vger.kernel.org; b-cousson at ti.com; khilman at ti.com;
santosh.shilimkar at ti.com; linux-arm-
Quoted 2 lines
kernel at lists.infradead.org
Subject: Re: [PATCH v2 7/7] omap4: dpll: Enable auto gate control for
all MX postdividers
Quoted 11 lines · Rajendra Nayak
Quoted 7 lines
Enable hardware gate control for all dpll MX and X2 postdividers. This requires the allow_idle/deny_idle functions to be populated for all clock nodes (mx/x2 post dividers) in clkops.
Signed-off-by Rajendra Nayak <[email protected]>Thanks, queued for 2.6.39 in the 'clk_autoidle_a_2.6.39' branch. Has
the
Quoted 1 line
OMAP4 clock data autogenerator script been updated?
Yes, the autogen scripts are updated. Will merge the changes in master.
Regards,
Rajendra
Quoted 3 lines
- Paul
Paul Walmsley
maintainerPATCH v2 6/7 omap4: dpll: Add dpll api to control GATE_CTRL
In reply to Rajendra NayakQuoted 8 lines · Rajendra Nayak
On OMAP4, the dpll post divider outputs (MX outputs) along with
clockout_x2output provide a way to allow/deny hardware level autogating.
Allowing autoidle would mean that the hw would autogate this clock when there is no dependency for it. Denying idle would mean that this clock output will be forced to stay enabled.
Quoted 7 lines
Add dpll api's to read/allow/deny idle control for these dpll mx postdividers.
NOTE: The gatectrl bit set to 0 allows gatectrl, and the bit set to 1 denies gatectrl.
Signed-off-by Rajendra Nayak <[email protected]>
Thanks, I moved the OMAP4-specific code to a file that is only compiled in on OMAP4, and added some documentation, and queued it for 2.6.39 in the 'clk_autoidle_a_2.6.39' branch here. Updated version follows.
- Paul
From: Rajendra Nayak <[email protected]>
Date: Thu, 10 Feb 2011 14:46:39 +0530
Subject: [PATCH] OMAP4: DPLL: Add dpll api to control GATE_CTRL
On OMAP4, the dpll post divider outputs (MX outputs) along with clockout_x2 output provide a way to allow/deny hardware level autogating.
Allowing autoidle would mean that the hw would autogate this clock when there is no dependency for it. Denying idle would mean that this clock output will be forced to stay enabled.
Add dpll api's to read/allow/deny idle control
for these dpll mx postdividers.
NOTE: The gatectrl bit set to 0 allows gatectrl,
and the bit set to 1 denies gatectrl.
[paul at pwsan.com: moved OMAP4-specific DPLL control code to
mach-omap2/dpll44xx.c; added some documentation for CLOCK_CLKOUTX2]
--- arch/arm/mach-omap2/Makefile | 2 +- arch/arm/mach-omap2/clock.h | 3 + arch/arm/mach-omap2/dpll44xx.c | 78 +++++++++++++++++++++++++++++++ arch/arm/plat-omap/include/plat/clock.h | 14 +++++- 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 arch/arm/mach-omap2/dpll44xx.c
arch/arm/mach-omap2/Makefile +1 -1
@@ -120,7 +120,7 @@ obj-$(CONFIG_ARCH_OMAP3) += $(clock-common) clock3xxx.o \ clock3517.o clock36xx.o \ dpll3xxx.o clock3xxx_data.o obj-$(CONFIG_ARCH_OMAP4) += $(clock-common) clock44xx_data.o \ - dpll3xxx.o + dpll3xxx.o dpll44xx.o # OMAP2 clock rate set data (old "OPP" data) obj-$(CONFIG_SOC_OMAP2420) += opp2420_data.o
arch/arm/mach-omap2/clock.h +3 -0
@@ -65,6 +65,9 @@ u32 omap3_dpll_autoidle_read(struct clk *clk);int omap3_noncore_dpll_set_rate (struct clk *clk,unsigned long rate);int omap3_noncore_dpll_enable (struct clk *clk);void omap3_noncore_dpll_disable (struct clk *clk); +int omap4_dpllmx_gatectrl_read (struct clk *clk); +void omap4_dpllmx_allow_gatectrl (struct clk *clk); +void omap4_dpllmx_deny_gatectrl (struct clk *clk);#ifdef CONFIG_OMAP_RESET_CLOCKS void omap2_clk_disable_unused (struct clk *clk);
arch/arm/mach-omap2/dpll44xx.c new file +78 -0
78 lines not on this page · raw message
arch/arm/plat-omap/include/plat/clock.h +13 -1
@@ -175,12 +175,24 @@ struct dpll_data {#endif -/* struct clk.flags possibilities */ +/* +* struct clk.flags possibilities +* +* XXX document the rest of the clock flags here +* +* CLOCK_CLKOUTX2: (OMAP4 only) DPLL CLKOUT and CLKOUTX2 GATE_CTRL +* bits share the same register. This flag allows the +* omap4_dpllmx*() code to determine which GATE_CTRL bit field +* should be used. This is a temporary solution - a better approach +* would be to associate clock type-specific data with the clock, +* similar to the struct dpll_data approach. +*/ #define ENABLE_REG_32BIT (1 << 0)/* Use 32-bit access */ #define CLOCK_IDLE_CONTROL (1 << 1)#define CLOCK_NO_IDLE_PARENT (1 << 2)#define ENABLE_ON_INIT (1 << 3)/* Enable upon framework init */ #define INVERT_ENABLE (1 << 4)/* 0 enables, 1 disables */ +#define CLOCK_CLKOUTX2 (1 << 5)/** * struct clk - OMAP struct clk
Signature · 1 line
1.7.2.3
Paul Walmsley
maintainerPATCH v2 5/7 omap: dpll: Enable all OMAP3/4 dpll autoidle late at boot
In reply to Rajendra NayakQuoted 6 lines · Rajendra Nayak
Enable all dpll autoidle for OMAP4 and OMAP3 (OMAP3 already had dpll autoidle turned on, but was done using low level cm accessor apis).
On OMAP3, replace the cm accessor apis doing this with the now available support for doing this in clock framework, usingomap_clk_enable_autoidle().
I propose this patch instead. What do you think? Care to reply with a
Reviewed-by: and/or Tested-by: ?
- Paul
From: Paul Walmsley <[email protected]>
Date: Sat, 12 Feb 2011 17:36:38 -0600
Subject: [PATCH] OMAP2+: clock: autoidle as many clocks as possible in OMAP2+-common PM code
Attempt to enable autoidle for as many clocks as possible in the OMAP2+-common PM code. Currently, this only enables DPLL autoidle for OMAP3/4 DPLLs; but it should also eventually enable autoidle for other clocks and the OMAP2 DPLL/APLLs.
Based on a patch by Rajendra Nayak <[email protected]> that did this in the pm34xx.c/pm44xx.c code, rather than the common PM code.
--- arch/arm/mach-omap2/pm.c | 8 ++++++++ arch/arm/mach-omap2/pm34xx.c | 17 ----------------- 2 files changed, 8 insertions(+), 17 deletions(-)
arch/arm/mach-omap2/pm.c +8 -0
@@ -262,6 +262,14 @@ static int __init omap2_common_pm_late_init(void)/* Smartreflex device init */ omap_devinit_smartreflex (); +/* +* Set all OMAP3/4 DPLLs to autoidle. +* XXX TODO: Add all the iclk autoidles in here as well, +* the OMAP2 DPLL, the OMAP2 APLLs, and the AUTOEXTCLKMODE +* control here too. +*/ +omap_clk_enable_autoidle_all (); +return 0 ; }late_initcall (omap2_common_pm_late_init);
arch/arm/mach-omap2/pm34xx.c +0 -17
@@ -814,23 +814,6 @@ static void __init prcm_setup_regs(void)omap_ctrl_writel (OMAP3430_AUTOIDLE_MASK ,OMAP2_CONTROL_SYSCONFIG );/* -* Set all plls to autoidle. This is needed until autoidle is -* enabled by clockfw -*/ -omap2_cm_write_mod_reg (1 <<OMAP3430_AUTO_IVA2_DPLL_SHIFT , -OMAP3430_IVA2_MOD ,CM_AUTOIDLE2 ); -omap2_cm_write_mod_reg (1 <<OMAP3430_AUTO_MPU_DPLL_SHIFT , -MPU_MOD , -CM_AUTOIDLE2 ); -omap2_cm_write_mod_reg ((1 <<OMAP3430_AUTO_PERIPH_DPLL_SHIFT ) | - (1 <<OMAP3430_AUTO_CORE_DPLL_SHIFT ), -PLL_MOD , -CM_AUTOIDLE ); -omap2_cm_write_mod_reg (1 <<OMAP3430ES2_AUTO_PERIPH2_DPLL_SHIFT , -PLL_MOD , -CM_AUTOIDLE2 ); - -/* * Enable control of expternal oscillator through * sys_clkreq. In the long run clock framework should * take care of this.
Signature · 1 line
1.7.2.3
PATCH v2 5/7 omap: dpll: Enable all OMAP3/4 dpll autoidle late at boot
Hi Paul,
Quoted 5 lines
-----Original Message-----
From: Paul Walmsley [mailto:paul at pwsan.com]
Sent: Sunday, February 13, 2011 6:13 AM
To: Rajendra Nayak
Cc: linux-omap at vger.kernel.org; b-cousson at ti.com; khilman at ti.com;
santosh.shilimkar at ti.com; linux-arm-
Quoted 2 lines
kernel at lists.infradead.org
Subject: Re: [PATCH v2 5/7] omap: dpll: Enable all OMAP3/4 dpll autoidle
late at boot
Quoted 10 lines · Rajendra Nayak
Quoted 7 lines
Enable all dpll autoidle for OMAP4 and OMAP3 (OMAP3 already had dpll autoidle turned on, but was done using low level cm accessor apis).
On OMAP3, replace the cm accessor apis doing this with the now available support for doing this in clock framework, usingomap_clk_enable_autoidle().
Quoted 2 lines
I propose this patch instead. What do you think? Care to reply with a
Reviewed-by: and/or Tested-by: ?
I agree, this is a better approach than what I proposed in my patch.
Since I already tested the clk_autoidle_a_2.6.39 branch which also has this patch included, you can add a
Regards,
Rajendra
Quoted 7 lines
- Paul
From: Paul Walmsley <[email protected]>
Date: Sat, 12 Feb 2011 17:36:38 -0600
Subject: [PATCH] OMAP2+: clock: autoidle as many clocks as possible in
OMAP2+-common PM code
Quoted 64 lines
Attempt to enable autoidle for as many clocks as possible in the OMAP2+-common PM code. Currently, this only enables DPLL autoidle for OMAP3/4 DPLLs; but it should also eventually enable autoidle for other clocks and the OMAP2 DPLL/APLLs.
Based on a patch by Rajendra Nayak <[email protected]> that did this in the
pm34xx.c/pm44xx.ccode, rather than the common PM code.Signed-off-by Paul Walmsley <[email protected]>--- arch/arm/mach-omap2/pm.c | 8 ++++++++ arch/arm/mach-omap2/pm34xx.c | 17 ----------------- 2 files changed, 8 insertions(+), 17 deletions(-)arch/arm/mach-omap2/pm.c +8
-0@@ -262,6 +262,14 @@ static int __init omap2_common_pm_late_init(void)/* Smartreflex device init */ omap_devinit_smartreflex (); +/* +* Set all OMAP3/4 DPLLs to autoidle. +* XXX TODO: Add all the iclk autoidles in here as well, +* the OMAP2 DPLL, the OMAP2 APLLs, and the AUTOEXTCLKMODE +* control here too. +*/ +omap_clk_enable_autoidle_all (); +return 0 ; }late_initcall (omap2_common_pm_late_init);arch/arm/mach-omap2/pm34xx.c +0
-18@@ -814,23 +814,6 @@ static void __init prcm_setup_regs(void)omap_ctrl_writel (OMAP3430_AUTOIDLE_MASK ,OMAP2_CONTROL_SYSCONFIG );/* -* Set all plls to autoidle. This is needed until autoidle is -* enabled by clockfw -*/ -omap2_cm_write_mod_reg (1 <<OMAP3430_AUTO_IVA2_DPLL_SHIFT , -OMAP3430_IVA2_MOD ,CM_AUTOIDLE2 ); -omap2_cm_write_mod_reg (1 <<OMAP3430_AUTO_MPU_DPLL_SHIFT , -MPU_MOD , -CM_AUTOIDLE2 ); -omap2_cm_write_mod_reg ((1 <<OMAP3430_AUTO_PERIPH_DPLL_SHIFT ) | - (1 <<OMAP3430_AUTO_CORE_DPLL_SHIFT ), -PLL_MOD , -CM_AUTOIDLE ); -omap2_cm_write_mod_reg (1 <<OMAP3430ES2_AUTO_PERIPH2_DPLL_SHIFT , -PLL_MOD , -CM_AUTOIDLE2 ); - -/* * Enable control of expternal oscillator through * sys_clkreq. In the long run clock framework should * take care of this. -- 1.7.2.3
Paul Walmsley
maintainerPATCH v2 5/7 omap: dpll: Enable all OMAP3/4 dpll autoidle late at boot
Quoted 3 lines · Rajendra Nayak
Since I already tested the clk_autoidle_a_2.6.39 branch which also has this patch included, you can add a
Tested-by Rajendra Nayak <[email protected]>
Thanks, added.
- Paul
Paul Walmsley
maintainerPATCH v2 5/7 omap: dpll: Enable all OMAP3/4 dpll autoidle late at boot
In reply to Rajendra NayakHi
After Rajendra's E-mail here:
http://marc.info/?l=linux-arm-kernel&m=129785498406128&w=2
upon looking further, mach-omap2/pm.c is compiled in for !CONFIG_PM. This will be dealt with in a separate patch, but in the meantime, I propose we enable clock autoidle if CONFIG_OMAP_RESET_CLOCKS is set. (Really this config option should be called CONFIG_OMAP_DONT_BREAK_CLOCKFW or CONFIG_OMAP_MAKE_POWER_MANAGEMENT_WORK, but all that, too, is a matter for another patch.)
Here's what I'm proposing to use as a replacement; comments welcome. The clk_autoidle_a_2.6.39 branch has been updated accordingly.
- Paul
From: Paul Walmsley <[email protected]>
Date: Mon, 14 Feb 2011 09:39:11 -0700
Subject: [PATCH] OMAP2+: clock: autoidle as many clocks as possible if CONFIG_OMAP_RESET_CLOCKS
Attempt to enable autoidle for as many clocks as possible in the OMAP2+-common CONFIG_OMAP_RESET_CLOCKS code. Currently, this only enables DPLL autoidle for OMAP3/4 DPLLs; but future patches will enable autoidle for other clocks and the OMAP2 DPLL/APLLs.
In the long run, we should probably get rid of CONFIG_OMAP_RESET_CLOCKS, and unconditionally run the code that it selects. Otherwise, the state of the clock tree won't match the hardware state - this could result in clocks being enabled or disabled unpredictably.
Based on a patch by Rajendra Nayak <[email protected]> that did this in the pm34xx.c/pm44xx.c code.
--- arch/arm/mach-omap2/pm34xx.c | 17 ----------------- arch/arm/plat-omap/clock.c | 1 + 2 files changed, 1 insertions(+), 17 deletions(-)
arch/arm/mach-omap2/pm34xx.c +0 -17
@@ -814,23 +814,6 @@ static void __init prcm_setup_regs(void)omap_ctrl_writel (OMAP3430_AUTOIDLE_MASK ,OMAP2_CONTROL_SYSCONFIG );/* -* Set all plls to autoidle. This is needed until autoidle is -* enabled by clockfw -*/ -omap2_cm_write_mod_reg (1 <<OMAP3430_AUTO_IVA2_DPLL_SHIFT , -OMAP3430_IVA2_MOD ,CM_AUTOIDLE2 ); -omap2_cm_write_mod_reg (1 <<OMAP3430_AUTO_MPU_DPLL_SHIFT , -MPU_MOD , -CM_AUTOIDLE2 ); -omap2_cm_write_mod_reg ((1 <<OMAP3430_AUTO_PERIPH_DPLL_SHIFT ) | - (1 <<OMAP3430_AUTO_CORE_DPLL_SHIFT ), -PLL_MOD , -CM_AUTOIDLE ); -omap2_cm_write_mod_reg (1 <<OMAP3430ES2_AUTO_PERIPH2_DPLL_SHIFT , -PLL_MOD , -CM_AUTOIDLE2 ); - -/* * Enable control of expternal oscillator through * sys_clkreq. In the long run clock framework should * take care of this.
arch/arm/plat-omap/clock.c +1 -0
@@ -446,6 +446,7 @@ static int __init clk_disable_unused(void) return 0; }late_initcall (clk_disable_unused); +late_initcall (omap_clk_enable_autoidle_all);#endif int __init clk_init (struct clk_functions * custom_clocks)
Signature · 1 line
1.7.2.3
Paul Walmsley
maintainerPATCH v2 4/7 omap: dpll: Add allow_idle/deny_idle support for all DPLL's
In reply to Rajendra NayakQuoted 5 lines · Rajendra Nayak
All OMAP3/4 dpll's support hardware level autogating. Populate allow_idle/deny_idle function pointers for all DPLL's in clkops.
Signed-off-by Rajendra Nayak <[email protected]>
Thanks, queued for 2.6.39. Two questions though. Was the OMAP4 autogeneration script updated? Also, any technical reason why you didn't add the OMAP2 DPLL?
- Paul
PATCH v2 4/7 omap: dpll: Add allow_idle/deny_idle support for all DPLL's
Hi Paul,
Quoted 5 lines
-----Original Message-----
From: Paul Walmsley [mailto:paul at pwsan.com]
Sent: Sunday, February 13, 2011 5:58 AM
To: Rajendra Nayak
Cc: linux-omap at vger.kernel.org; b-cousson at ti.com; khilman at ti.com;
santosh.shilimkar at ti.com; linux-arm-
Quoted 2 lines
kernel at lists.infradead.org
Subject: Re: [PATCH v2 4/7] omap: dpll: Add allow_idle/deny_idle support
for all DPLL's
Quoted 11 lines · Rajendra Nayak
Quoted 6 lines
All OMAP3/4 dpll's support hardware level autogating. Populate allow_idle/deny_idle function pointers for all DPLL's in clkops.
Signed-off-by Rajendra Nayak <[email protected]>Thanks, queued for 2.6.39. Two questions though. Was the OMAP4 autogeneration script updated? Also, any technical reason why you
didn't
Quoted 1 line
add the OMAP2 DPLL?
Yes, the autogen scripts are updated, however they are currently in a separate branch (dpll-gatectrl). Will merge them into master soon.
No real reason for not adding OMAP2 dpll autoidle support. Its just that I started off trying to do this for OMAP4, and then found me touching some omap3 stuff and hence also did it for OMAP3.(For some reason I thought there were no DPLL's in OMAP2).
Regards,
Rajendra
Quoted 3 lines
- Paul
Paul Walmsley
maintainerPATCH v2 4/7 omap: dpll: Add allow_idle/deny_idle support for all DPLL's
Quoted 3 lines · Rajendra Nayak
Yes, the autogen scripts are updated, however they are currently in a separate branch (dpll-gatectrl). Will merge them into master soon.
OK, great.
Quoted 5 lines
No real reason for not adding OMAP2 dpll autoidle support. Its just that I started off trying to do this for OMAP4, and then found me touching some omap3 stuff and hence also did it for OMAP3.(For some reason I thought there were no DPLL's in OMAP2).
That's fine, I have some patches in progress that enable this for the OMAP2 DPLL and APLLs.
- Paul
Paul Walmsley
maintainerPATCH v2 3/7 omap: clock: Add allow_idle/deny_idle support in clkops
In reply to Rajendra NayakHi Rajendra
arch/arm/plat-omap/clock.c struct clk *omap_clk_get_by_name(const char *name) · line 342
Quoted 13 lines · Rajendra Nayak
arch/arm/plat-omap/clock.c +5
-0@@ -335,6 +335,32 @@ struct clk *omap_clk_get_by_name(const char *name)return ret; } +void omap_clk_enable_autoidle (void ) +{ +struct clk *c; + +mutex_lock (&clocks_mutex);
With the current OMAP clock code, it isn't sufficient to use a mutex here. Your underlying functions have to read, modify, and write a register that is also touched by clock functions like clk_set_rate(), which take the clockfw spinlock and not the mutex. This is potentially racy and could result in inconsistencies between the internal clock tree data and the hardware settings.
While it is true that these functions are currently only called during PM init, I'd rather not commit code that is subject to known races into the tree.
So, before applying this patch, the mutexes have been converted into spinlocks. I would appreciate it if you could help test this. Updated patch follows, which has been queued for 2.6.39 as part of the 'clk_autoidle_a_2.6.39' branch of git://git.pwsan.com/linux-2.6.
- Paul
From: Rajendra Nayak <[email protected]>
Date: Thu, 10 Feb 2011 14:46:36 +0530
Subject: [PATCH] omap: clock: Add allow_idle/deny_idle support in clkops
On OMAP various clock nodes (dpll's, mx post dividers, interface clocks) support hardware level autogating which can be controlled from software.
Support such functionality by adding two new function pointer allow_idle and deny_idle in the clkops structure.
These function pointers can be populated for any clock node which supports hardware level autogating.
Also add 2 new functions (omap_clk_enable_auotidle and omap_clk_disable_autoidle) which can be called from architecture specific PM core code, if hardware level autogating (for all supported clock nodes) is to be enabled or disabled.
--- arch/arm/plat-omap/clock.c | 28 ++++++++++++++++++++++++++++ arch/arm/plat-omap/include/plat/clock.h | 6 ++++++ 2 files changed, 34 insertions(+), 0 deletions(-)
arch/arm/plat-omap/clock.c +28 -0
@@ -335,6 +335,34 @@ struct clk *omap_clk_get_by_name(const char *name)return ret; } +void omap_clk_enable_autoidle (void ) +{ +struct clk *c; +unsigned long flags; + +spin_lock_irqsave (&clockfw_lock, flags); + +list_for_each_entry (c, &clocks, node) +if (c->ops->allow_idle) + c->ops->allow_idle (c); + +spin_lock_irqrestore (&clockfw_lock, flags); +} + +void omap_clk_disable_autoidle (void ) +{ +struct clk *c; +unsigned long flags; + +spin_lock_irqsave (&clockfw_lock, flags); + +list_for_each_entry (c, &clocks, node) +if (c->ops->deny_idle) + c->ops->deny_idle (c); + +spin_lock_irqrestore (&clockfw_lock, flags); +} +/* * Low level helpers */
arch/arm/plat-omap/include/plat/clock.h +6 -0
@@ -25,6 +25,8 @@ struct clockdomain;* @disable: fn ptr that enables the current clock in hardware * @find_idlest: function returning the IDLEST register for the clock's IP blk * @find_companion: function returning the "companion" clk reg for the clock +* @allow_idle: fn ptr that enables autoidle for the current clock in hardware +* @deny_idle: fn ptr that disables autoidle for the current clock in hardware * * A "companion" clk is an accompanying clock to the one being queried * that must be enabled for the IP module connected to the clock to
@@ -42,6 +44,8 @@ struct clkops { u8 *, u8 *);void (*find_companion)(struct clk *,void __iomem **,u8 *); +void (*allow_idle)(struct clk *); +void (*deny_idle)(struct clk *); };#ifdef CONFIG_ARCH_OMAP2PLUS
@@ -292,6 +296,8 @@ extern void clk_init_cpufreq_table(struct cpufreq_frequency_table **table);extern void clk_exit_cpufreq_table (struct cpufreq_frequency_table **table);#endif extern struct clk *omap_clk_get_by_name (const char *name); +extern void omap_clk_enable_autoidle (void ); +extern void omap_clk_disable_autoidle (void );extern const struct clkops clkops_null;
Signature · 1 line
1.7.2.3
Paul Walmsley
maintainerPATCH v2 3/7 omap: clock: Add allow_idle/deny_idle support in clkops
Quoted 11 lines · Paul Walmsley
arch/arm/plat-omap/clock.c struct clk *omap_clk_get_by_name(const char *name) · line 338
Quoted 9 lines · Rajendra Nayak
arch/arm/plat-omap/clock.c +1
-0@@ -335,6 +335,32 @@ struct clk *omap_clk_get_by_name(const char *name)return ret; } +void omap_clk_enable_autoidle (void )
I also renamed these functions to
omap_clk_enable_autoidle_all()omap_clk_disable_autoidle_all()
since they operate on all clocks. Updated patch follows.
- Paul
From: Rajendra Nayak <[email protected]>
Date: Thu, 10 Feb 2011 14:46:36 +0530
Subject: [PATCH] OMAP: clock: Add allow_idle/deny_idle support in clkops
On OMAP various clock nodes (dpll's, mx post dividers, interface clocks) support hardware level autogating which can be controlled from software.
Support such functionality by adding two new function pointer allow_idle and deny_idle in the clkops structure.
These function pointers can be populated for any clock node which supports hardware level autogating.
Also add 2 new functions (omap_clk_enable_autoidle_all and omap_clk_disable_autoidle_all) which can be called from architecture specific PM core code, if hardware level autogating (for all supported clock nodes) is to be enabled or disabled.
--- arch/arm/plat-omap/clock.c | 28 ++++++++++++++++++++++++++++ arch/arm/plat-omap/include/plat/clock.h | 6 ++++++ 2 files changed, 34 insertions(+), 0 deletions(-)
arch/arm/plat-omap/clock.c +28 -0
@@ -335,6 +335,34 @@ struct clk *omap_clk_get_by_name(const char *name)return ret; } +void omap_clk_enable_autoidle_all (void ) +{ +struct clk *c; +unsigned long flags; + +spin_lock_irqsave (&clockfw_lock, flags); + +list_for_each_entry (c, &clocks, node) +if (c->ops->allow_idle) + c->ops->allow_idle (c); + +spin_lock_irqrestore (&clockfw_lock, flags); +} + +void omap_clk_disable_autoidle_all (void ) +{ +struct clk *c; +unsigned long flags; + +spin_lock_irqsave (&clockfw_lock, flags); + +list_for_each_entry (c, &clocks, node) +if (c->ops->deny_idle) + c->ops->deny_idle (c); + +spin_lock_irqrestore (&clockfw_lock, flags); +} +/* * Low level helpers */
arch/arm/plat-omap/include/plat/clock.h +6 -0
@@ -25,6 +25,8 @@ struct clockdomain;* @disable: fn ptr that enables the current clock in hardware * @find_idlest: function returning the IDLEST register for the clock's IP blk * @find_companion: function returning the "companion" clk reg for the clock +* @allow_idle: fn ptr that enables autoidle for the current clock in hardware +* @deny_idle: fn ptr that disables autoidle for the current clock in hardware * * A "companion" clk is an accompanying clock to the one being queried * that must be enabled for the IP module connected to the clock to
@@ -42,6 +44,8 @@ struct clkops { u8 *, u8 *);void (*find_companion)(struct clk *,void __iomem **,u8 *); +void (*allow_idle)(struct clk *); +void (*deny_idle)(struct clk *); };#ifdef CONFIG_ARCH_OMAP2PLUS
@@ -292,6 +296,8 @@ extern void clk_init_cpufreq_table(struct cpufreq_frequency_table **table);extern void clk_exit_cpufreq_table (struct cpufreq_frequency_table **table);#endif extern struct clk *omap_clk_get_by_name (const char *name); +extern void omap_clk_enable_autoidle_all (void ); +extern void omap_clk_disable_autoidle_all (void );extern const struct clkops clkops_null;
Signature · 1 line
1.7.2.3
PATCH v2 3/7 omap: clock: Add allow_idle/deny_idle support in clkops
In reply to Paul WalmsleyHi Paul,
Quoted 5 lines
-----Original Message-----
From: Paul Walmsley [mailto:paul at pwsan.com]
Sent: Sunday, February 13, 2011 5:35 AM
To: Rajendra Nayak
Cc: linux-omap at vger.kernel.org; b-cousson at ti.com; khilman at ti.com;
santosh.shilimkar at ti.com; linux-arm-
Quoted 2 lines
kernel at lists.infradead.org
Subject: Re: [PATCH v2 3/7] omap: clock: Add allow_idle/deny_idle
support in clkops
Quoted 10 lines
Hi Rajendra
arch/arm/plat-omap/clock.c struct clk *omap_clk_get_by_name(const char
Quoted 5 lines · Rajendra Nayak
arch/arm/plat-omap/clock.c +0
-0@@ -335,6 +335,32 @@ struct clk *omap_clk_get_by_name(const char
*name)
Quoted 10 lines
arch/arm/plat-omap/clock.c struct clk *omap_clk_get_by_name(const char *name)
Quoted 8 lines
arch/arm/plat-omap/clock.c +5
-0return ret; } +void omap_clk_enable_autoidle (void ) +{ +struct clk *c; + +mutex_lock (&clocks_mutex);With the current OMAP clock code, it isn't sufficient to use a mutex
here.
Quoted 1 line
Your underlying functions have to read, modify, and write a register
that
Quoted 6 lines
is also touched by clock functions like
clk_set_rate(), which take the clockfw spinlock and not the mutex. This is potentially racy and could result in inconsistencies between the internal clock tree data and the hardware settings.While it is true that these functions are currently only called during
PM
Quoted 7 lines
init, I'd rather not commit code that is subject to known races into the tree.
So, before applying this patch, the mutexes have been converted into spinlocks. I would appreciate it if you could help test this. Updated patch follows, which has been queued for 2.6.39 as part of the 'clk_autoidle_a_2.6.39' branch of
git://git.pwsan.com/linux-2.6.
I used the clk_autoidle_a_2.6.39 branch and tested OFF mode in suspend on 3430sdp.
I also tested CORE ret in suspend (using some out of tree patches) on 4430sdp.
A couple of issues on the clk_autoidle_a_2.6.39 branch:
-1- There seems to be a missing fix which causes an abort at boot on omap4
http://marc.info/?l=linux-omap&m=129768574027232&w=2
-2- There is a trivial fix (Patch below) needed which otherwise breaks build
----
Paul Walmsley
maintainerPATCH v2 3/7 omap: clock: Add allow_idle/deny_idle support in clkops
Quoted 4 lines · Rajendra Nayak
A couple of issues on the clk_autoidle_a_2.6.39 branch:
-1- There seems to be a missing fix which causes an abort at boot on omap4
http://marc.info/?l=linux-omap&m=129768574027232&w=2
This should be fixed now that this branch is rebased on your first two clock patches.
Quoted 2 lines
-2- There is a trivial fix (Patch below) needed which otherwise breaks build
Thanks for this, I've folded this fix into the original patch.
- Paul
Paul Walmsley
maintainerv2 cover clock/dpll autoidle support
In reply to Rajendra NayakHi Rajendra
Quoted 10 lines · Rajendra Nayak
OMAP has various clock nodes and dpll's which support hardware level autoidle. Enabling hardware level autoidle provides better power savings without much software intervention.
This series does the following to help enable hardware level autoidling using clock framework for some of these nodes on OMAP3 and OMAP4
Quoted 6 lines
-1- Adds support for providing function pointers for enabling/disabling autoidle in clkops
-2- Populates these in clkops for all OMAP3/4 dplls -3- Enables all dpll autoidle late in boot on OMAP3 and OMAP4 -4- Adds support for mx postdivider autoidle (present only on OMAP4) and enables it late in OMAP4 boot
I've reviewed and commented on all of these, asked a few questions, made a few changes, and queued the results for 2.6.39 in two branches ofgit://git.pwsan.com/linux-2.6:
clk_a_2.6.39 (for the autoidle-independent fixes) clk_autoidle_a_2.6.39 (for the autoidle-specific code and data changes)
Both branches have been added to the 'integration-2.6.39' branch ofgit://git.pwsan.com/linux-integration, and are available as part of the tag "integration-2.6.39-20110212-004".
thanks,
- Paul