SPEAr: Move to common clock framework
Subsystems (4)
cover SPEAr: Move to common clock framework
Arnd,
SPEAr now supports common clock framework. This patchset contains changes related to this. It also contain few dependency commits for clock framework that are earlier sent separately.
@Mike: It would be easiest to get these through ARM-SoC tree. So, would need your Acked-by on these patches. But firstly they must get reivewed :)
This patchset is rebased over:
- clk: add a fixed factor clock - by Sascha Hauer
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/090680.html
- common clk framework misc fixes - by Mike Turquette
https://lkml.org/lkml/2012/4/11/780
- V4: pinctrl: Add SPEAr pinctrl support
http://www.spinics.net/lists/arm-kernel/msg169387.html
- V3: SPEAr DT support updates
http://comments.gmane.org/gmane.linux.drivers.devicetree/14197
Russell King (1):
CLKDEV: Add helper routines to allocate and add clkdevs for given
struct clk *
Viresh Kumar (12):
clk: Fix typo in comment
clk: Fix typo in comment
clk: clk-private: Add DEFINE_CLK macro
clk: clk-gate: Create clk_gate_endisable()
clk: Don't set clk->new_rate twice
clk: clk_set_rate() must fail if CLK_SET_RATE_GATE is set and clk is
enabled
SPEAr: clk: Add VCO-PLL Synthesizer clock
SPEAr: clk: Add Auxiliary Synthesizer clock
SPEAr: clk: Add Fractional Synthesizer clock
SPEAr: clk: Add General Purpose Timer Synthesizer clock
SPEAr: Switch to common clock framework
SPEAr: Call clk_prepare() before calling clk_enable
MAINTAINERS | 4 +- arch/arm/Kconfig | 1 + arch/arm/mach-spear3xx/clock.c | 1354 +++++++++-------------- arch/arm/mach-spear3xx/include/mach/generic.h | 4 +- arch/arm/mach-spear3xx/include/mach/misc_regs.h | 2 + arch/arm/mach-spear3xx/include/mach/spear.h | 13 + arch/arm/mach-spear3xx/spear300.c | 1 - arch/arm/mach-spear3xx/spear310.c | 1 - arch/arm/mach-spear3xx/spear320.c | 12 +- arch/arm/mach-spear3xx/spear3xx.c | 2 + arch/arm/mach-spear6xx/clock.c | 1015 +++++------------ arch/arm/mach-spear6xx/include/mach/misc_regs.h | 2 + arch/arm/mach-spear6xx/spear6xx.c | 5 +- arch/arm/plat-spear/Makefile | 3 +- arch/arm/plat-spear/clk-aux-synth.c | 195 ++++ arch/arm/plat-spear/clk-frac-synth.c | 156 +++ arch/arm/plat-spear/clk-gpt-synth.c | 145 +++ arch/arm/plat-spear/clk-vco-pll.c | 346 ++++++ arch/arm/plat-spear/clock.c | 1005 ----------------- arch/arm/plat-spear/include/plat/clk.h | 143 +++ arch/arm/plat-spear/include/plat/clock.h | 249 ----- arch/arm/plat-spear/time.c | 8 +- drivers/clk/clk-gate.c | 54 +- drivers/clk/clk.c | 7 +- drivers/clk/clkdev.c | 64 +- include/linux/clk-private.h | 59 +- include/linux/clk-provider.h | 4 +- include/linux/clkdev.h | 3 + 28 files changed, 1963 insertions(+), 2894 deletions(-) create mode 100644 arch/arm/plat-spear/clk-aux-synth.c create mode 100644 arch/arm/plat-spear/clk-frac-synth.c create mode 100644 arch/arm/plat-spear/clk-gpt-synth.c create mode 100644 arch/arm/plat-spear/clk-vco-pll.c delete mode 100644 arch/arm/plat-spear/clock.c create mode 100644 arch/arm/plat-spear/include/plat/clk.h delete mode 100644 arch/arm/plat-spear/include/plat/clock.h
Signature · 1 line
1.7.9
PATCH 1/13 CLKDEV: Add helper routines to allocate and add clkdevs for given struct clk *
From: Russell King <[email protected]>
With common clock framework, clks are allocated at runtime. Some of them require clkdevs to be allocated and added in global clkdev list.
This patch introduces helper routines to:
- allocate and add single clkdev for a single clk structure.
- add multiple clkdevs for a single clk structure.
--- drivers/clk/clkdev.c | 64 +++++++++++++++++++++++++++++++++++++++++++---- include/linux/clkdev.h | 3 ++ 2 files changed, 61 insertions(+), 6 deletions(-)
drivers/clk/clkdev.c +58 -6
@@ -121,8 +121,9 @@ struct clk_lookup_alloc {char con_id[MAX_CON_ID ]; }; -struct clk_lookup * __init_refok -clkdev_alloc (struct clk *clk,const char *con_id,const char *dev_fmt, ...) +static struct clk_lookup * __init_refok +__clkdev_alloc_valist (struct clk *clk,const char *con_id,const char *dev_fmt, +va_list ap) {struct clk_lookup_alloc *cla;
@@ -137,16 +138,35 @@ clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...) }if (dev_fmt) { -va_list ap; - -va_start (ap, dev_fmt);vscnprintf (cla->dev_id,sizeof (cla->dev_id), dev_fmt, ap); cla->cl.dev_id = cla->dev_id; -va_end (ap); }return &cla->cl; } + +#define clkdev_alloc_valist (_cl, _clk, _con_id, _dev_fmt, _ap) \ + do { \ + if (_dev_fmt) \ + va_start(_ap, _dev_fmt); \ + \ + _cl = __clkdev_alloc_valist(_clk, _con_id, _dev_fmt, \ + _ap); \ + \ + if (_dev_fmt) \ + va_end(ap); \ + } while (0); + +struct clk_lookup * __init_refok +clkdev_alloc (struct clk *clk,const char *con_id,const char *dev_fmt, ...) +{ +struct clk_lookup *cl; +va_list ap; + +clkdev_alloc_valist (cl, clk, con_id, dev_fmt, ap); + +return cl; +}EXPORT_SYMBOL (clkdev_alloc); int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
@@ -178,3 +198,35 @@ void clkdev_drop(struct clk_lookup *cl)kfree (cl); }EXPORT_SYMBOL (clkdev_drop); + +int clk_register_clkdev (struct clk *clk,const char *con_id, +const char *dev_fmt, ...) +{ +struct clk_lookup *cl; +va_list ap; + +clkdev_alloc_valist (cl, clk, con_id, dev_fmt, ap); + +if (!cl) +return -ENOMEM ; + +clkdev_add (cl); +return 0 ; +} +EXPORT_SYMBOL (clk_register_clkdev); + +int clk_register_clkdevs (struct clk *clk,struct clk_lookup *cl,size_t num) +{ +unsigned i; + +if (!clk) +return -ENOMEM ; + +for (i =0 ; i < num; i++, cl++) { + cl->clk = clk; +clkdev_add (cl); + } + +return 0 ; +} +EXPORT_SYMBOL (clk_register_clkdevs);
include/linux/clkdev.h +3 -0
@@ -39,5 +39,8 @@ void clkdev_drop(struct clk_lookup *cl);void clkdev_add_table (struct clk_lookup *,size_t );int clk_add_alias (const char *,const char *,char *,struct device *); +int clk_register_clkdev (struct clk *clk,const char *con_id, +const char *dev_fmt, ...); +int clk_register_clkdevs (struct clk *clk,struct clk_lookup *cl,size_t num);#endif
Signature · 1 line
1.7.9
PATCH 2/13 clk: Fix typo in comment
In reply to Viresh KumarCLK_GATE_SET_TO_DISABLE is mistakenly written as CLK_GATE_SET_DISABLE in comment. Fix it.
--- include/linux/clk-provider.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/clk-provider.h +1 -1
@@ -166,7 +166,7 @@ struct clk *clk_register_fixed_rate(struct device *dev, const char *name,* Clock which can gate its output. Implements .enable & .disable * * Flags: -* CLK_GATE_SET_DISABLE - by default this clock sets the bit at bit_idx to +* CLK_GATE_SET_TO_DISABLE - by default this clock sets the bit at bit_idx to * enable the clock. Setting this flag does the opposite: setting the bit * disable the clock and clearing it enables the clock */
Signature · 1 line
1.7.9
PATCH 2/13 clk: Fix typo in comment
Quoted 4 lines · Viresh Kumar
CLK_GATE_SET_TO_DISABLEis mistakenly written asCLK_GATE_SET_DISABLEin comment. Fix it.Signed-off-by Viresh Kumar <[email protected]>
Thanks for the fix. I'll combine this patch with your CLK_MUX_INDEX_BIT typo fix and pull into my -next branch.
Regards,
Mike
Quoted 20 lines
---
?include/linux/clk-provider.h | ? ?2 +-
?1 files changed, 1 insertions(+), 1 deletions(-)include/linux/clk-provider.h +0
-0@@ -166,7 +166,7 @@ struct clk *clk_register_fixed_rate(struct device *dev, const char *name,?* Clock which can gate its output. ?Implements .enable & .disable ?*
?* Flags:
- *CLK_GATE_SET_DISABLE- by default this clock sets the bit atbit_idxto
+ *CLK_GATE_SET_TO_DISABLE- by default this clock sets the bit atbit_idxto ?* ? ? enable the clock. ?Setting this flag does the opposite: setting the bit ?* ? ? disable the clock and clearing it enables the clock
?*/
--
1.7.9
PATCH 3/13 clk: Fix typo in comment
In reply to Viresh KumarCLK_MUX_INDEX_BIT is mistakenly written as CLK_MUX_INDEX_BITWISE in comment. Fix it.
--- include/linux/clk-provider.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/clk-provider.h +1 -1
@@ -239,7 +239,7 @@ struct clk *clk_register_divider(struct device *dev, const char *name,* * Flags: * CLK_MUX_INDEX_ONE - register index starts at 1, not 0 -* CLK_MUX_INDEX_BITWISE - register index is a single bit (power of two) +* CLK_MUX_INDEX_BIT - register index is a single bit (power of two) */ struct clk_mux {struct clk_hw hw;
Signature · 1 line
1.7.9
PATCH 4/13 clk: clk-private: Add DEFINE_CLK macro
In reply to Viresh KumarAll macros used for creating different kind of clocks have similar code for initializing struct clk. This patch removes those redundant lines and create another macro DEFINE_CLK.
--- include/linux/clk-private.h | 59 ++++++++++++++---------------------------- 1 files changed, 20 insertions(+), 39 deletions(-)
include/linux/clk-private.h +20 -39
@@ -55,6 +55,18 @@ struct clk {* alternative macro for static initialization */ +#define DEFINE_CLK (_name, _ops, _flags, _parent_names, \ + _parents) \ + static struct clk _name = { \ + .name = #_name, \ + .ops = &_ops, \ + .hw = &_name##_hw.hw, \ + .parent_names = _parent_names, \ + .num_parents = ARRAY_SIZE(_parent_names), \ + .parents = _parents, \ + .flags = _flags, \ + } +#define DEFINE_CLK_FIXED_RATE (_name, _flags, _rate, \ _fixed_rate_flags) \ static struct clk _name; \
@@ -66,15 +78,8 @@ struct clk { .fixed_rate = _rate, \ .flags = _fixed_rate_flags, \ }; \ -static struct clk _name = { \ - .name = #_name, \ - .ops = &clk_fixed_rate_ops, \ - .hw = &_name##_hw.hw, \ - .parent_names = _name##_parent_names, \ - .num_parents = \ - ARRAY_SIZE(_name##_parent_names), \ - .flags = _flags, \ - }; +DEFINE_CLK (_name, clk_fixed_rate_ops, _flags, \ + _name##_parent_names, NULL); #define DEFINE_CLK_GATE(_name, _parent_name, _parent_ptr, \ _flags, _reg, _bit_idx, \
@@ -95,16 +100,8 @@ struct clk { .flags = _gate_flags, \ .lock = _lock, \ }; \ -static struct clk _name = { \ - .name = #_name, \ - .ops = &clk_gate_ops, \ - .hw = &_name##_hw.hw, \ - .parent_names = _name##_parent_names, \ - .num_parents = \ - ARRAY_SIZE(_name##_parent_names), \ - .parents = _name##_parents, \ - .flags = _flags, \ - }; +DEFINE_CLK (_name, clk_gate_ops, _flags, \ + _name##_parent_names, _name##_parents); #define DEFINE_CLK_DIVIDER(_name, _parent_name, _parent_ptr, \ _flags, _reg, _shift, _width, \
@@ -126,16 +123,8 @@ struct clk { .flags = _divider_flags, \ .lock = _lock, \ }; \ -static struct clk _name = { \ - .name = #_name, \ - .ops = &clk_divider_ops, \ - .hw = &_name##_hw.hw, \ - .parent_names = _name##_parent_names, \ - .num_parents = \ - ARRAY_SIZE(_name##_parent_names), \ - .parents = _name##_parents, \ - .flags = _flags, \ - }; +DEFINE_CLK (_name, clk_divider_ops, _flags, \ + _name##_parent_names, _name##_parents); #define DEFINE_CLK_MUX(_name, _parent_names, _parents, _flags, \ _reg, _shift, _width, \
@@ -151,16 +140,8 @@ struct clk { .flags = _mux_flags, \ .lock = _lock, \ }; \ -static struct clk _name = { \ - .name = #_name, \ - .ops = &clk_mux_ops, \ - .hw = &_name##_hw.hw, \ - .parent_names = _parent_names, \ - .num_parents = \ -ARRAY_SIZE (_parent_names), \ - .parents = _parents, \ - .flags = _flags, \ - }; +DEFINE_CLK (_name, clk_mux_ops, _flags, _parent_names, \ + _parents);/** * __clk_init - initialize the data structures in a struct clk
Signature · 1 line
1.7.9
PATCH 4/13 clk: clk-private: Add DEFINE_CLK macro
Quoted 5 lines · Viresh Kumar
All macros used for creating different kind of clocks have similar code for initializing struct clk. This patch removes those redundant lines and create another macro
DEFINE_CLK.Signed-off-by Viresh Kumar <[email protected]>
Viresh,
I want to kill off these macros entirely in the future. That said, your patch reduces LoC and the macros will certainly be there in 3.5, so I'll take this into my -next branch.
Thanks,
Mike
Quoted 105 lines
---
?include/linux/clk-private.h | ? 59 ++++++++++++++---------------------------- ?1 files changed, 20 insertions(+), 39 deletions(-)include/linux/clk-private.h +0
-0@@ -55,6 +55,18 @@ struct clk {?* alternative macro for static initialization
?*/include/linux/clk-private.h +12
-0+#define DEFINE_CLK(_name, _ops, _flags, _parent_names, ? ? ? ? \ + ? ? ? ? ? ? ? _parents) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ + ? ? ? static struct clk _name = { ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ + ? ? ? ? ? ? ? .name = #_name, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ + ? ? ? ? ? ? ? .ops = &_ops, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ + ? ? ? ? ? ? ? .hw = &_name##_hw.hw, ? ? ? ? ? ? ? ? ? ? ? ? ? \ + ? ? ? ? ? ? ? .parent_names = _parent_names, ? ? ? ? ? ? ? ? ?\ + ? ? ? ? ? ? ? .num_parents = ARRAY_SIZE(_parent_names), ? ? ? \ + ? ? ? ? ? ? ? .parents = _parents, ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ + ? ? ? ? ? ? ? .flags = _flags, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ + ? ? ? } +?#define DEFINE_CLK_FIXED_RATE(_name,
_flags,_rate, ? ? ? ? ? ?\
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?_fixed_rate_flags) ? ? ? ? ? ? ?\
? ? ? ?static struct clk_name; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\include/linux/clk-private.h +8
-39@@ -66,15 +78,8 @@ struct clk { ? ? ? ? ? ? ? ?.fixed_rate = _rate, ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ ? ? ? ? ? ? ? ?.flags = _fixed_rate_flags, ? ? ? ? ? ? ? ? ? ? \ ? ? ? ?}; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? static struct clk _name = { ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .name = #_name, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .ops = &clk_fixed_rate_ops, ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .hw = &_name##_hw.hw, ? ? ? ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .parent_names = _name##_parent_names, ? ? ? ? ? \ - ? ? ? ? ? ? ? .num_parents = ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? ? ? ? ? ? ? ? ? ARRAY_SIZE(_name##_parent_names), ? ? ? \ - ? ? ? ? ? ? ? .flags = _flags, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? }; + ? ? ? DEFINE_CLK(_name, clk_fixed_rate_ops, _flags, ? ? ? ? ? \ + ? ? ? ? ? ? ? ? ? ? ? _name##_parent_names, NULL); ?#define DEFINE_CLK_GATE(_name, _parent_name, _parent_ptr, ? ? ?\ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?_flags, _reg, _bit_idx, ? ? ? ? \@@ -95,16 +100,8 @@ struct clk { ? ? ? ? ? ? ? ?.flags = _gate_flags, ? ? ? ? ? ? ? ? ? ? ? ? ? \ ? ? ? ? ? ? ? ?.lock = _lock, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ ? ? ? ?}; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? static struct clk _name = { ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .name = #_name, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .ops = &clk_gate_ops, ? ? ? ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .hw = &_name##_hw.hw, ? ? ? ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .parent_names = _name##_parent_names, ? ? ? ? ? \ - ? ? ? ? ? ? ? .num_parents = ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? ? ? ? ? ? ? ? ? ARRAY_SIZE(_name##_parent_names), ? ? ? \ - ? ? ? ? ? ? ? .parents = _name##_parents, ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .flags = _flags, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? }; + ? ? ? DEFINE_CLK(_name, clk_gate_ops, _flags, ? ? ? ? ? ? ? ? \ + ? ? ? ? ? ? ? ? ? ? ? _name##_parent_names, _name##_parents); ?#define DEFINE_CLK_DIVIDER(_name, _parent_name, _parent_ptr, ? \ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?_flags, _reg, _shift, _width, ? \@@ -126,16 +123,8 @@ struct clk { ? ? ? ? ? ? ? ?.flags = _divider_flags, ? ? ? ? ? ? ? ? ? ? ? ?\ ? ? ? ? ? ? ? ?.lock = _lock, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ ? ? ? ?}; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? static struct clk _name = { ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .name = #_name, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .ops = &clk_divider_ops, ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? ? ? ? ? .hw = &_name##_hw.hw, ? ? ? ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .parent_names = _name##_parent_names, ? ? ? ? ? \ - ? ? ? ? ? ? ? .num_parents = ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? ? ? ? ? ? ? ? ? ARRAY_SIZE(_name##_parent_names), ? ? ? \ - ? ? ? ? ? ? ? .parents = _name##_parents, ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .flags = _flags, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? }; + ? ? ? DEFINE_CLK(_name, clk_divider_ops, _flags, ? ? ? ? ? ? ?\ + ? ? ? ? ? ? ? ? ? ? ? _name##_parent_names, _name##_parents); ?#define DEFINE_CLK_MUX(_name, _parent_names, _parents, _flags, \ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?_reg, _shift, _width, ? ? ? ? ? \@@ -151,16 +140,8 @@ struct clk { ? ? ? ? ? ? ? ?.flags = _mux_flags, ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ ? ? ? ? ? ? ? ?.lock = _lock, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ ? ? ? ?}; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? static struct clk _name = { ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .name = #_name, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .ops = &clk_mux_ops, ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? ? ? ? ? .hw = &_name##_hw.hw, ? ? ? ? ? ? ? ? ? ? ? ? ? \ - ? ? ? ? ? ? ? .parent_names = _parent_names, ? ? ? ? ? ? ? ? ?\ - ? ? ? ? ? ? ? .num_parents = ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? ? ? ? ? ? ? ? ? ARRAY_SIZE(_parent_names), ? ? ? ? ? ? ?\ - ? ? ? ? ? ? ? .parents = _parents, ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? ? ? ? ? .flags = _flags, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ - ? ? ? }; + ? ? ? DEFINE_CLK(_name, clk_mux_ops, _flags, _parent_names, ? \ + ? ? ? ? ? ? ? ? ? ? ? _parents);?/**
?*__clk_init- initialize the data structures in a struct clk --
1.7.9
PATCH 5/13 clk: clk-gate: Create clk_gate_endisable()
In reply to Viresh KumarThis patch tries to remove duplicate code for clk_gate clocks. This creates another routine clk_gate_endisable() which will take care of enable/disable clock with knowledge of CLK_GATE_SET_TO_DISABLE flag.
It works on following logic:
For enabling clock, enable = 1
set2dis = 1 -> clear bit -> set = 0 set2dis = 0 -> set bit -> set = 1
For disabling clock, enable = 0
set2dis = 1 -> set bit -> set = 1 set2dis = 0 -> clear bit -> set = 0
So, result is always: enable xor set2dis.
--- drivers/clk/clk-gate.c | 54 ++++++++++++++++++++++------------------------- 1 files changed, 25 insertions(+), 29 deletions(-)
drivers/clk/clk-gate.c +25 -29
@@ -28,32 +28,38 @@#define to_clk_gate (_hw) container_of(_hw, struct clk_gate, hw) -static void clk_gate_set_bit (struct clk_gate *gate) +/* +* It works on following logic: +* +* For enabling clock, enable = 1 +* set2dis = 1 -> clear bit -> set = 0 +* set2dis = 0 -> set bit -> set = 1 +* +* For disabling clock, enable = 0 +* set2dis = 1 -> set bit -> set = 1 +* set2dis = 0 -> clear bit -> set = 0 +* +* So, result is always: enable xor set2dis. +*/ +static void clk_gate_endisable (struct clk_hw *hw,int enable) { -u32 reg; +struct clk_gate *gate =to_clk_gate (hw); +int set = gate->flags &CLK_GATE_SET_TO_DISABLE ?1 :0 ;unsigned long flags =0 ; +u32 reg; + + set ^= enable;if (gate->lock)spin_lock_irqsave (gate->lock, flags); reg =readl (gate->reg); - reg |=BIT (gate->bit_idx); -writel (reg, gate->reg); - -if (gate->lock) -spin_unlock_irqrestore (gate->lock, flags); -} - -static void clk_gate_clear_bit (struct clk_gate *gate) -{ -u32 reg; -unsigned long flags =0 ; -if (gate->lock) -spin_lock_irqsave (gate->lock, flags); +if (set) + reg |=BIT (gate->bit_idx); +else + reg &= ~BIT (gate->bit_idx); - reg =readl (gate->reg); - reg &= ~BIT (gate->bit_idx);writel (reg, gate->reg);if (gate->lock)
@@ -62,24 +68,14 @@ static void clk_gate_clear_bit(struct clk_gate *gate)static int clk_gate_enable (struct clk_hw *hw) { -struct clk_gate *gate =to_clk_gate (hw); - -if (gate->flags &CLK_GATE_SET_TO_DISABLE ) -clk_gate_clear_bit (gate); -else -clk_gate_set_bit (gate); +clk_gate_endisable (hw,1 );return 0 ; }static void clk_gate_disable (struct clk_hw *hw) { -struct clk_gate *gate =to_clk_gate (hw); - -if (gate->flags &CLK_GATE_SET_TO_DISABLE ) -clk_gate_set_bit (gate); -else -clk_gate_clear_bit (gate); +clk_gate_endisable (hw,0 ); }static int clk_gate_is_enabled (struct clk_hw *hw)
Signature · 1 line
1.7.9
PATCH 5/13 clk: clk-gate: Create clk_gate_endisable()
Quoted 10 lines · Viresh Kumar
This patch tries to remove duplicate code for
clk_gateclocks. This creates another routineclk_gate_endisable()which will take care of enable/disable clock with knowledge ofCLK_GATE_SET_TO_DISABLEflag.It works on following logic:
For enabling clock, enable = 1
? ? ? ?set2dis = 1 ? ? -> clear bit ? ?-> set = 0
? ? ? ?set2dis = 0 ? ? -> set bit ? ? ?-> set = 1
Quoted 7 lines
For disabling clock, enable = 0
? ? ? ?set2dis = 1 ? ? -> set bit ? ? ?-> set = 1
? ? ? ?set2dis = 0 ? ? -> clear bit ? ?-> set = 0So, result is always: enable xor set2dis.
Signed-off-by Viresh Kumar <[email protected]>
Hi Viresh,
Looks good to me. I'll take into my -next branch.
Thanks,
Mike
Quoted 94 lines
---
?drivers/clk/clk-gate.c | ? 54 ++++++++++++++++++++++------------------------- ?1 files changed, 25 insertions(+), 29 deletions(-)drivers/clk/clk-gate.c +25
-30@@ -28,32 +28,38 @@ ?#define to_clk_gate(_hw) container_of(_hw, struct clk_gate, hw) -static void clk_gate_set_bit (struct clk_gate *gate) +/* +* It works on following logic: +* +* For enabling clock, enable = 1 +* ? ? set2dis = 1 ? ? -> clear bit ? ?-> set = 0 +* ? ? set2dis = 0 ? ? -> set bit ? ? ?-> set = 1 +* +* For disabling clock, enable = 0 +* ? ? set2dis = 1 ? ? -> set bit ? ? ?-> set = 1 +* ? ? set2dis = 0 ? ? -> clear bit ? ?-> set = 0 +* +* So, result is always: enable xor set2dis. +*/ +static void clk_gate_endisable (struct clk_hw *hw,int enable) ?{ - ? ? ? u32 reg; + ? ? ? struct clk_gate *gate = to_clk_gate(hw); + ? ? ? int set = gate->flags & CLK_GATE_SET_TO_DISABLE ? 1 : 0; ? ? ? ?unsigned long flags = 0; + ? ? ? u32 reg; + + ? ? ? set ^= enable; ? ? ? ?if (gate->lock) ? ? ? ? ? ? ? ?spin_lock_irqsave(gate->lock, flags); ? ? ? ?reg = readl(gate->reg); - ? ? ? reg |= BIT(gate->bit_idx); - ? ? ? writel(reg, gate->reg); - - ? ? ? if (gate->lock) - ? ? ? ? ? ? ? spin_unlock_irqrestore(gate->lock, flags); -} - -static void clk_gate_clear_bit (struct clk_gate *gate) -{ - ? ? ? u32 reg; - ? ? ? unsigned long flags = 0; - ? ? ? if (gate->lock) - ? ? ? ? ? ? ? spin_lock_irqsave(gate->lock, flags); + ? ? ? if (set) + ? ? ? ? ? ? ? reg |= BIT(gate->bit_idx); + ? ? ? else + ? ? ? ? ? ? ? reg &= ~BIT(gate->bit_idx); - ? ? ? reg = readl(gate->reg); - ? ? ? reg &= ~BIT(gate->bit_idx); ? ? ? ?writel(reg, gate->reg); ? ? ? ?if (gate->lock)@@ -62,24 +68,14 @@ static void clk_gate_clear_bit(struct clk_gate *gate) ?static int clk_gate_enable(struct clk_hw *hw) ?{ - ? ? ? struct clk_gate *gate = to_clk_gate(hw); - - ? ? ? if (gate->flags & CLK_GATE_SET_TO_DISABLE) - ? ? ? ? ? ? ? clk_gate_clear_bit(gate); - ? ? ? else - ? ? ? ? ? ? ? clk_gate_set_bit(gate); + ? ? ? clk_gate_endisable(hw, 1); ? ? ? ?return 0; ?} ?static void clk_gate_disable(struct clk_hw *hw) ?{ - ? ? ? struct clk_gate *gate = to_clk_gate(hw); - - ? ? ? if (gate->flags & CLK_GATE_SET_TO_DISABLE) - ? ? ? ? ? ? ? clk_gate_set_bit(gate); - ? ? ? else - ? ? ? ? ? ? ? clk_gate_clear_bit(gate); + ? ? ? clk_gate_endisable(hw, 0); ?} ?static int clk_gate_is_enabled(struct clk_hw *hw) --1.7.9
PATCH 6/13 clk: Don't set clk->new_rate twice
In reply to Viresh Kumarif (!clk->ops->round_rate && (clk->flags & CLK_SET_RATE_PARENT)) is true, then we don't need to set clk->new_rate here, as we will call clk_calc_subtree() afterwards and it also sets clk->new_rate.
--- drivers/clk/clk.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/clk/clk.c +1 -1
@@ -789,7 +789,7 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate)if (!clk->ops->round_rate) { top =clk_calc_new_rates (clk->parent, rate); - new_rate = clk->new_rate = clk->parent->new_rate; + new_rate = clk->parent->new_rate; goto out; }
Signature · 1 line
1.7.9
PATCH 6/13 clk: Don't set clk->new_rate twice
Quoted 5 lines · Viresh Kumar
if (!clk->ops->round_rate && (
clk->flags&CLK_SET_RATE_PARENT)) is true, then we don't need to setclk->new_ratehere, as we will callclk_calc_subtree()afterwards and it also setsclk->new_rate.Signed-off-by Viresh Kumar <[email protected]>
Looks good. Will take into -next.
Thanks,
Mike
Quoted 20 lines
---
?drivers/clk/clk.c | ? ?2 +-
?1 files changed, 1 insertions(+), 1 deletions(-)drivers/clk/clk.c +1
-2@@ -789,7 +789,7 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate) ? ? ? ?if (!clk->ops->round_rate) { ? ? ? ? ? ? ? ?top = clk_calc_new_rates(clk->parent, rate); - ? ? ? ? ? ? ? new_rate = clk->new_rate = clk->parent->new_rate; + ? ? ? ? ? ? ? new_rate = clk->parent->new_rate; ? ? ? ? ? ? ? ?goto out; ? ? ? ?} --1.7.9
PATCH 7/13 clk: clk_set_rate() must fail if CLK_SET_RATE_GATE is set and clk is enabled
In reply to Viresh KumarThis is well documented but isn't implemented. clk_set_rate() must check if flags have CLK_SET_RATE_GATE bit set and is enabled too.
Untested patch.
--- drivers/clk/clk.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/clk/clk.c +5 -0
@@ -898,6 +898,11 @@ int clk_set_rate(struct clk *clk, unsigned long rate)if (rate == clk->rate) goto out; +if ((clk->flags &CLK_SET_RATE_GATE ) &&__clk_is_enabled (clk)) { + ret = -EBUSY ; + goto out; + } +/* calculate new rates and get the topmost changed clock */ top =clk_calc_new_rates (clk, rate);if (!top) {
Signature · 1 line
1.7.9
PATCH 8/13 SPEAr: clk: Add VCO-PLL Synthesizer clock
In reply to Viresh KumarAll SPEAr SoC's contain PLLs. Their Fout is derived based on following equations
- In normal mode
vco = (2 * M[15:8] * Fin)/N
- In Dithered mode
vco = (2 * M[15:0] * Fin)/(256 * N)
pll_rate = vco/2^p
vco and pll are very closely bound to each other,
"vco needs to program: mode, m & n" and "pll needs to program p", both share common enable/disable logic and registers.
This patch adds in support for this type of clock.
--- arch/arm/plat-spear/Makefile | 1 + arch/arm/plat-spear/clk-vco-pll.c | 346 ++++++++++++++++++++++++++++++++ arch/arm/plat-spear/include/plat/clk.h | 78 +++++++ 3 files changed, 425 insertions(+), 0 deletions(-) create mode 100644 arch/arm/plat-spear/clk-vco-pll.c create mode 100644 arch/arm/plat-spear/include/plat/clk.h
arch/arm/plat-spear/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-y := clock.o restart.o time.o pl080.o obj-$(CONFIG_ARCH_SPEAR3XX) += shirq.o +obj-$(CONFIG_COMMON_CLK) += clk-vco-pll.o
arch/arm/plat-spear/clk-vco-pll.c new file +346 -0
346 lines not on this page · raw message
arch/arm/plat-spear/include/plat/clk.h new file +78 -0
78 lines not on this page · raw message
Signature · 1 line
1.7.9
PATCH 9/13 SPEAr: clk: Add Auxiliary Synthesizer clock
In reply to Viresh KumarAll SPEAr SoC's contain Auxiliary Synthesizers. Their Fout is derived based on values of eq, x and y.
Fout from synthesizer can be given from two equations:
Fout1 = (Fin * X/Y)/2 EQ1
Fout2 = Fin * X/Y EQ2
This patch adds in support for this type of clock.
--- arch/arm/plat-spear/Makefile | 2 +- arch/arm/plat-spear/clk-aux-synth.c | 195 ++++++++++++++++++++++++++++++++ arch/arm/plat-spear/include/plat/clk.h | 32 +++++ 3 files changed, 228 insertions(+), 1 deletions(-) create mode 100644 arch/arm/plat-spear/clk-aux-synth.c
arch/arm/plat-spear/Makefile +1 -1
@@ -6,4 +6,4 @@ obj-y := clock.o restart.o time.o pl080.o obj-$(CONFIG_ARCH_SPEAR3XX) += shirq.o -obj-$(CONFIG_COMMON_CLK) += clk-vco-pll.o +obj-$(CONFIG_COMMON_CLK) += clk-aux-synth.o clk-vco-pll.o
arch/arm/plat-spear/clk-aux-synth.c new file +195 -0
195 lines not on this page · raw message
arch/arm/plat-spear/include/plat/clk.h +32 -0
@@ -18,6 +18,34 @@#include <linux/spinlock_types.h> #include <linux/types.h> +/* Auxiliary Synth clk */ +struct aux_clk_masks { +u32 eq_sel_mask; +u32 eq_sel_shift; +u32 eq1_mask; +u32 eq2_mask; +u32 xscale_sel_mask; +u32 xscale_sel_shift; +u32 yscale_sel_mask; +u32 yscale_sel_shift; +u32 enable_bit; +}; + +struct aux_rate_tbl { +u16 xscale; +u16 yscale; +u8 eq; +}; + +struct clk_aux { +struct clk_hw hw; +void __iomem *reg; +struct aux_clk_masks *masks; +struct aux_rate_tbl *rtbl; +u8 rtbl_cnt; +spinlock_t *lock; +}; +/* VCO-PLL clk */ struct pll_rate_tbl {u8 mode;
@@ -46,6 +74,10 @@ typedef unsigned long (*clk_calc_rate)(struct clk_hw *hw, unsigned long prate, int index);/* clk register routines */ +struct clk *clk_register_aux (const char *aux_name,const char *gate_name, +const char *parent_name,unsigned long flags,void __iomem *reg, +struct aux_clk_masks *masks,struct aux_rate_tbl *rtbl, +u8 rtbl_cnt,spinlock_t *lock,struct clk **gate_clk);struct clk *clk_register_vco_pll (const char *vco_name,const char *pll_name,const char *vco_gate_name,const char *parent_name, unsigned long flags, void __iomem *mode_reg, void __iomem
Signature · 1 line
1.7.9
PATCH 9/13 SPEAr: clk: Add Auxiliary Synthesizer clock
Quoted 8 lines · Viresh Kumar
All SPEAr SoC's contain Auxiliary Synthesizers. Their Fout is derived based on values of eq, x and y.
arch/arm/plat-spear/clk-aux-synth.c new file +5
-0+static unsigned long clk_aux_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct clk_aux *aux =to_clk_aux (hw); +unsigned int num =1 , den =1 , val, eqn;
arch/arm/plat-spear/clk-aux-synth.c line 90
Quoted 10 lines
arch/arm/plat-spear/clk-aux-synth.c new file +10
-0+unsigned long flags =0 ; + +if (aux->lock) +spin_lock_irqsave (aux->lock, flags); + + val =readl_relaxed (aux->reg); + +if (aux->lock) +spin_unlock_irqrestore (aux->lock, flags); +
A single read is atomic and needs no lock.
Quoted 9 lines
arch/arm/plat-spear/clk-aux-synth.c new file +9
-0+struct clk *clk_register_aux (const char *aux_name,const char *gate_name, +const char *parent_name,unsigned long flags,void __iomem *reg, +struct aux_clk_masks *masks,struct aux_rate_tbl *rtbl, +u8 rtbl_cnt,spinlock_t *lock,struct clk **gate_clk) +{ +struct clk_aux *aux; +struct clk *clk, *tgate_clk; + + if (!aux_name || !gate_name || !parent_name || !reg || !rtbl ||
arch/arm/plat-spear/clk-aux-synth.c line 164
Quoted 10 lines
arch/arm/plat-spear/clk-aux-synth.c new file +10
-0+ !rtbl_cnt) { +pr_err ("Invalid arguments passed" ); +return ERR_PTR (-EINVAL ); + } + + aux =kzalloc (sizeof (*aux),GFP_KERNEL ); +if (!aux) { +pr_err ("could not allocate aux clk\n" ); +return NULL ; + }
This PTR_ERR stuff really is a pain in the ass, it's way too easy to get it wrong. IS_ERR_OR_NULL might be a good idea, but IS_ERR is just insane.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH 9/13 SPEAr: clk: Add Auxiliary Synthesizer clock
Quoted 7 lines · Sascha Hauer
Quoted 7 lines
arch/arm/plat-spear/clk-aux-synth.c new file +7
-0+{ +struct clk_aux *aux =to_clk_aux (hw); +unsigned int num =1 , den =1 , val, eqn; +unsigned long flags =0 ; + +if (aux->lock) +spin_lock_irqsave (aux->lock, flags);
Quoted 8 lines
arch/arm/plat-spear/clk-aux-synth.c line 90
Quoted 6 lines
arch/arm/plat-spear/clk-aux-synth.c new file +6
-0+ + val =readl_relaxed (aux->reg); + +if (aux->lock) +spin_unlock_irqrestore (aux->lock, flags); +A single read is atomic and needs no lock.
That depends on whether the read has any side-effects. There is another function that does a read-modify-write on the same register, and you might need to prevent this one from reading the register between the other read and the following write.
The spinlock also has the benefit of enforcing the ordering of the read with regard to your instruction stream, otherwise it can be delayed on out-of-order CPUs until the value is actually used.
Arnd
PATCH 9/13 SPEAr: clk: Add Auxiliary Synthesizer clock
Quoted 23 lines · Arnd Bergmann
Quoted 7 lines · Sascha Hauer
Quoted 7 lines
arch/arm/plat-spear/clk-aux-synth.c new file +7
-0+{ +struct clk_aux *aux =to_clk_aux (hw); +unsigned int num =1 , den =1 , val, eqn; +unsigned long flags =0 ; + +if (aux->lock) +spin_lock_irqsave (aux->lock, flags);Quoted 8 lines
arch/arm/plat-spear/clk-aux-synth.c line 90
Quoted 6 lines
arch/arm/plat-spear/clk-aux-synth.c new file +6
-0+ + val =readl_relaxed (aux->reg); + +if (aux->lock) +spin_unlock_irqrestore (aux->lock, flags); +A single read is atomic and needs no lock.
That depends on whether the read has any side-effects. There is another function that does a read-modify-write on the same register, and you might need to prevent this one from reading the register between the other read and the following write.
Quoted 4 lines
The spinlock also has the benefit of enforcing the ordering of the read with regard to your instruction stream, otherwise it can be delayed on out-of-order CPUs until the value is actually used.
Ah, I learned something. Sorry for the noise.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH 10/13 SPEAr: clk: Add Fractional Synthesizer clock
In reply to Viresh KumarAll SPEAr SoC's contain Fractional Synthesizers. Their Fout is derived from following equations:
Fout = Fin / (2 * div) (division factor)
div is 17 bits:-
0-13 (fractional part)
14-16 (integer part)
div is (16-14 bits).(13-0 bits) (in binary)
Fout = Fin/(2 * div)
Fout = ((Fin / 10000)/(2 * div)) * 10000
Fout = (2^14 * (Fin / 10000)/(2^14 * (2 * div))) * 10000
Fout = (((Fin / 10000) << 14)/(2 * (div << 14))) * 10000div << 14 is simply 17 bit value written at register.
This patch adds in support for this type of clock.
--- arch/arm/plat-spear/Makefile | 2 +- arch/arm/plat-spear/clk-frac-synth.c | 156 ++++++++++++++++++++++++++++++++ arch/arm/plat-spear/include/plat/clk.h | 16 ++++ 3 files changed, 173 insertions(+), 1 deletions(-) create mode 100644 arch/arm/plat-spear/clk-frac-synth.c
arch/arm/plat-spear/Makefile +1 -1
@@ -6,4 +6,4 @@ obj-y := clock.o restart.o time.o pl080.o obj-$(CONFIG_ARCH_SPEAR3XX) += shirq.o -obj-$(CONFIG_COMMON_CLK) += clk-aux-synth.o clk-vco-pll.o +obj-$(CONFIG_COMMON_CLK) += clk-aux-synth.o clk-frac-synth.o clk-vco-pll.o
arch/arm/plat-spear/clk-frac-synth.c new file +156 -0
156 lines not on this page · raw message
arch/arm/plat-spear/include/plat/clk.h +16 -0
@@ -46,6 +46,19 @@ struct clk_aux {spinlock_t *lock; }; +/* Fractional Synth clk */ +struct frac_rate_tbl { +u32 div; +}; + +struct clk_frac { +struct clk_hw hw; +void __iomem *reg; +struct frac_rate_tbl *rtbl; +u8 rtbl_cnt; +spinlock_t *lock; +}; +/* VCO-PLL clk */ struct pll_rate_tbl {u8 mode;
@@ -78,6 +91,9 @@ struct clk *clk_register_aux(const char *aux_name, const char *gate_name, const char *parent_name, unsigned long flags, void __iomem *reg, struct aux_clk_masks *masks, struct aux_rate_tbl *rtbl, u8 rtbl_cnt, spinlock_t *lock, struct clk **gate_clk); +struct clk *clk_register_frac (const char *name,const char *parent_name, +unsigned long flags,void __iomem *reg, +struct frac_rate_tbl *rtbl,u8 rtbl_cnt,spinlock_t *lock);struct clk *clk_register_vco_pll (const char *vco_name,const char *pll_name,const char *vco_gate_name,const char *parent_name, unsigned long flags, void __iomem *mode_reg, void __iomem
Signature · 1 line
1.7.9
PATCH 11/13 SPEAr: clk: Add General Purpose Timer Synthesizer clock
In reply to Viresh KumarAll SPEAr SoC's contain GPT Synthesizers. Their Fout is derived from following equations:
Fout= Fin/((2 ^ (N+1)) * (M+1))
This patch adds in support for this type of clock.
--- arch/arm/plat-spear/Makefile | 2 +- arch/arm/plat-spear/clk-gpt-synth.c | 145 ++++++++++++++++++++++++++++++++ arch/arm/plat-spear/include/plat/clk.h | 17 ++++ 3 files changed, 163 insertions(+), 1 deletions(-) create mode 100644 arch/arm/plat-spear/clk-gpt-synth.c
arch/arm/plat-spear/Makefile +1 -1
@@ -6,4 +6,4 @@ obj-y := clock.o restart.o time.o pl080.o obj-$(CONFIG_ARCH_SPEAR3XX) += shirq.o -obj-$(CONFIG_COMMON_CLK) += clk-aux-synth.o clk-frac-synth.o clk-vco-pll.o +obj-$(CONFIG_COMMON_CLK) += clk-aux-synth.o clk-frac-synth.o clk-gpt-synth.o clk-vco-pll.o
arch/arm/plat-spear/clk-gpt-synth.c new file +145 -0
145 lines not on this page · raw message
arch/arm/plat-spear/include/plat/clk.h +17 -0
@@ -59,6 +59,20 @@ struct clk_frac {spinlock_t *lock; }; +/* GPT clk */ +struct gpt_rate_tbl { +u16 mscale; +u16 nscale; +}; + +struct clk_gpt { +struct clk_hw hw; +void __iomem *reg; +struct gpt_rate_tbl *rtbl; +u8 rtbl_cnt; +spinlock_t *lock; +}; +/* VCO-PLL clk */ struct pll_rate_tbl {u8 mode;
@@ -94,6 +108,9 @@ struct clk *clk_register_aux(const char *aux_name, const char *gate_name,struct clk *clk_register_frac (const char *name,const char *parent_name,unsigned long flags,void __iomem *reg,struct frac_rate_tbl *rtbl,u8 rtbl_cnt,spinlock_t *lock); +struct clk *clk_register_gpt (const char *name,const char *parent_name,unsigned +long flags,void __iomem *reg,struct gpt_rate_tbl *rtbl,u8 + rtbl_cnt,spinlock_t *lock);struct clk *clk_register_vco_pll (const char *vco_name,const char *pll_name,const char *vco_gate_name,const char *parent_name, unsigned long flags, void __iomem *mode_reg, void __iomem
Signature · 1 line
1.7.9
PATCH 13/13 SPEAr: Call clk_prepare() before calling clk_enable
In reply to Viresh KumarWith common clock framework, it is must to call clk_{un}prepare() before/after clk_{dis}enable. This patch fixes this for SPEAr timer.
--- arch/arm/plat-spear/time.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/plat-spear/time.c +4 -4
@@ -218,10 +218,10 @@ void __init spear_setup_timer(resource_size_t base, int irq) goto err_iomap; } - ret =clk_enable (gpt_clk); + ret =clk_prepare_enable (gpt_clk);if (ret <0 ) { -pr_err ("%s:couldn't enable gpt clock\n" , __func__); - goto err_clk; +pr_err ("%s:couldn't prepare-enable gpt clock\n" , __func__); + goto err_prepare_enable_clk; }spear_clockevent_init (irq);
@@ -229,7 +229,7 @@ void __init spear_setup_timer(resource_size_t base, int irq)return ; -err_clk: +err_prepare_enable_clk:clk_put (gpt_clk); err_iomap:iounmap (gpt_base);
Signature · 1 line
1.7.9
PATCH 13/13 SPEAr: Call clk_prepare() before calling clk_enable
Hello.
Quoted 1 line · Viresh Kumar
With common clock framework, it is must to call clk_{un}prepare() before/after
Can't parse "it is must to call". Maybe simply "[we] must call"?
Quoted 3 lines
clk_{dis}enable. This patch fixes this for SPEAr timer.
Signed-off-by Viresh Kumar<[email protected]>
WBR, Sergei
PATCH 13/13 SPEAr: Call clk_prepare() before calling clk_enable
In reply to Viresh KumarQuoted 13 lines · Viresh Kumar
With common clock framework, it is must to call clk_{un}prepare() before/after clk_{dis}enable. This patch fixes this for SPEAr timer.
Signed-off-by Viresh Kumar <[email protected]>---
?arch/arm/plat-spear/time.c | ? ?8 ++++----
?1 files changed, 4 insertions(+), 4 deletions(-)arch/arm/plat-spear/time.c +0
-0
arch/arm/plat-spear/time.c void __init spear_setup_timer(resource_size_t base, int irq) · line 221
Quoted 5 lines
arch/arm/plat-spear/time.c +1
-1@@ -218,10 +218,10 @@ void __init spear_setup_timer(resource_size_t base, int irq) ? ? ? ? ? ? ? ?goto err_iomap; ? ? ? ?} - ? ? ? ret = clk_enable(gpt_clk); + ? ? ? ret = clk_prepare_enable(gpt_clk);
Where do you call clk_enable? Further down in the code somewhere?
Also does this change break git bisect for your platform? Maybe you should move this change before patch 12/13 to prevent run-time breakage?
Regards,
Mike
Quoted 20 lines
arch/arm/plat-spear/time.c +3
-3? ? ? ?if (ret < 0) { - ? ? ? ? ? ? ? pr_err("%s:couldn't enable gpt clock\n", __func__); - ? ? ? ? ? ? ? goto err_clk; + ? ? ? ? ? ? ? pr_err("%s:couldn't prepare-enable gpt clock\n", __func__); + ? ? ? ? ? ? ? goto err_prepare_enable_clk; ? ? ? ?} ? ? ? ?spear_clockevent_init(irq);@@ -229,7 +229,7 @@ void __init spear_setup_timer(resource_size_t base, int irq) ? ? ? ?return; -err_clk: +err_prepare_enable_clk: ? ? ? ?clk_put(gpt_clk);?err_iomap:
? ? ? ?iounmap(gpt_base);
--
1.7.9
A message that is not in the archive (sent off-list or not yet received): CAOh2x=maawrRjHhE3oGXfMOvsUbCkp9gWA_Kq-S0Dh7r6co6VA@mail.gmail.com
PATCH 13/13 SPEAr: Call clk_prepare() before calling clk_enable
Quoted 22 lines · viresh kumar
Quoted 20 lines · Mike
Quoted 18 lines · Viresh Kumar
With common clock framework, it is must to call clk_{un}prepare() before/after
clk_{dis}enable. This patch fixes this for SPEAr timer.Signed-off-by Viresh Kumar <[email protected]>---
?arch/arm/plat-spear/time.c | ? ?8 ++++----
?1 files changed, 4 insertions(+), 4 deletions(-)arch/arm/plat-spear/time.c +0
-0@@ -218,10 +218,10 @@ void __init spear_setup_timer(resource_size_t base, int irq) ? ? ? ? ? ? ? ?goto err_iomap; ? ? ? ?}
Quoted 7 lines
Quoted 4 lines
arch/arm/plat-spear/time.c void __init spear_setup_timer(resource_size_t · line 222
Quoted 2 lines
arch/arm/plat-spear/time.c +1
-1- ? ? ? ret = clk_enable(gpt_clk); + ? ? ? ret = clk_prepare_enable(gpt_clk);Where do you call
clk_enable? ?Further down in the code somewhere?I called
prepare_enable()here.
Did i get your question correctly?
My mistake. When I glanced over the code I saw "clk_prepare" and somehow skipped the "_enable" part.
Regards,
Mike
Quoted 8 lines
Quoted 3 lines
Also does this change break git bisect for your platform? ?Maybe you should move this change before patch 12/13 to prevent run-time breakage?
Correct.
--
Viresh
cover SPEAr: Move to common clock framework
In reply to Viresh KumarQuoted 6 lines · Viresh Kumar
SPEAr now supports common clock framework. This patchset contains changes related to this. It also contain few dependency commits for clock framework that are earlier sent separately.
@Mike: It would be easiest to get these through ARM-SoC tree. So, would need your Acked-by on these patches. But firstly they must get reivewed :)
We should agree on how we want to do the common clk patches for v3.5. The two options I see are either we take all the patches that Mike Acks into arm-soc, or Mike applies the patches in his own tree and submits them to arm-soc. I think either way is fine for me, but some people might feel strongly one way or another.
Quoted 11 lines
MAINTAINERS | 4 +- arch/arm/Kconfig | 1 + arch/arm/mach-spear3xx/clock.c | 1354 +++++++++-------------- arch/arm/mach-spear3xx/include/mach/generic.h | 4 +- arch/arm/mach-spear3xx/include/mach/misc_regs.h | 2 + arch/arm/mach-spear3xx/include/mach/spear.h | 13 + arch/arm/mach-spear3xx/spear300.c | 1 - arch/arm/mach-spear3xx/spear310.c | 1 - arch/arm/mach-spear3xx/spear320.c | 12 +- arch/arm/mach-spear3xx/spear3xx.c | 2 + arch/arm/mach-spear6xx/clock.c | 1015 +++++------------
Quoted 8 lines
arch/arm/mach-spear6xx/include/mach/misc_regs.h | 2 + arch/arm/mach-spear6xx/spear6xx.c | 5 +- arch/arm/plat-spear/Makefile | 3 +- arch/arm/plat-spear/clk-aux-synth.c | 195 ++++ arch/arm/plat-spear/clk-frac-synth.c | 156 +++ arch/arm/plat-spear/clk-gpt-synth.c | 145 +++ arch/arm/plat-spear/clk-vco-pll.c | 346 ++++++ arch/arm/plat-spear/clock.c | 1005 -----------------
I wonder: should the clock drivers remain part of the platform directory, or get moved into a subdirectory of drivers/clk? I was assuming that we'd do the latter, but I haven't been following the clk discussions that closely.
Arnd
cover SPEAr: Move to common clock framework
Quoted 5 lines · Arnd Bergmann
I wonder: should the clock drivers remain part of the platform directory, or get moved into a subdirectory of
drivers/clk? I was assuming that we'd do the latter, but I haven't been following the clk discussions that closely.
Mike had some comment [1] there, and I would second that.
Regards,
Shawn
[1] http://thread.gmane.org/gmane.linux.ports.arm.kernel/158320/focus=158543
cover SPEAr: Move to common clock framework
Quoted 7 lines · Shawn Guo
Quoted 5 lines · Arnd Bergmann
I wonder: should the clock drivers remain part of the platform directory, or get moved into a subdirectory of
drivers/clk? I was assuming that we'd do the latter, but I haven't been following the clk discussions that closely.Mike had some comment [1] there, and I would second that.
Thanks for bringing up that thread Shawn. Just to clarify, I don't oppose platform clock code living in drivers/clk/. If it can be done easily then I'm all for it.
I do oppose any _requirement_ for clock code to live there. That would be unreasonable for complex hardware.
For anyone planning on pushing their platform clock code into drivers/clk/ I would encourage them to think long and hard on the best ways to make that code useful to others.
Regards,
Mike
Quoted 4 lines
Regards,
Shawn[1] http://thread.gmane.org/gmane.linux.ports.arm.kernel/158320/focus=158543
cover SPEAr: Move to common clock framework
In reply to Arnd BergmannQuoted 5 lines · Arnd Bergmann
Quoted 4 lines · Viresh Kumar
SPEAr now supports common clock framework. This patchset contains changes related to this. It also contain few dependency commits for clock framework that are earlier sent separately.
Quoted 8 lines
Quoted 2 lines
@Mike: It would be easiest to get these through ARM-SoC tree. So, would need your Acked-by on these patches. But firstly they must get reivewed :)
We should agree on how we want to do the common clk patches for v3.5. The two options I see are either we take all the patches that Mike Acks into arm-soc, or Mike applies the patches in his own tree and submits them to arm-soc. I think either way is fine for me, but some people might feel strongly one way or another.
I would prefer the latter (I maintain a branch and submit it). Is arm-soc still the right place for common clk patches in 3.5 and beyond? I don't mind hosting a branch for inclusion into linux-next and sending a pull request to Linus. There is nothing ARM-specific about the common framework.
Regards,
Mike
cover SPEAr: Move to common clock framework
Quoted 15 lines · Mike
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · Viresh Kumar
SPEAr now supports common clock framework. This patchset contains changes related to this. It also contain few dependency commits for clock framework that are earlier sent separately.
Quoted 8 lines
Quoted 2 lines
@Mike: It would be easiest to get these through ARM-SoC tree. So, would need your Acked-by on these patches. But firstly they must get reivewed :)
We should agree on how we want to do the common clk patches for v3.5. The two options I see are either we take all the patches that Mike Acks into arm-soc, or Mike applies the patches in his own tree and submits them to arm-soc. I think either way is fine for me, but some people might feel strongly one way or another.
Quoted 5 lines
I would prefer the latter (I maintain a branch and submit it). Is arm-soc still the right place for common clk patches in 3.5 and beyond? I don't mind hosting a branch for inclusion into linux-next and sending a pull request to Linus. There is nothing ARM-specific about the common framework.
Either way is fine with me, but it's really important that all the floating clock framework patches begin to materialize in a visible branch.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
cover SPEAr: Move to common clock framework
Quoted 22 lines · Sascha Hauer
Quoted 15 lines · Mike
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · Viresh Kumar
SPEAr now supports common clock framework. This patchset contains changes related to this. It also contain few dependency commits for clock framework that are earlier sent separately.
Quoted 8 lines
Quoted 2 lines
@Mike: It would be easiest to get these through ARM-SoC tree. So, would need your Acked-by on these patches. But firstly they must get reivewed :)
We should agree on how we want to do the common clk patches for v3.5. The two options I see are either we take all the patches that Mike Acks into arm-soc, or Mike applies the patches in his own tree and submits them to arm-soc. I think either way is fine for me, but some people might feel strongly one way or another.
Quoted 5 lines
I would prefer the latter (I maintain a branch and submit it). ?Is arm-soc still the right place for common clk patches in 3.5 and beyond? ?I don't mind hosting a branch for inclusion into linux-next and sending a pull request to Linus. ?There is nothing ARM-specific about the common framework.
Quoted 3 lines
Either way is fine with me, but it's really important that all the floating clock framework patches begin to materialize in a visible branch.
Agreed. I've been busy the last several days with some tasks besides common clk maintenance, but I'm going through all the patches now and will have a -next branch up soon on git.linaro.org.
Regards,
Mike
cover SPEAr: Move to common clock framework
Quoted 23 lines · Mike
Quoted 22 lines · Sascha Hauer
Quoted 20 lines · Mike
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · Viresh Kumar
SPEAr now supports common clock framework. This patchset contains changes related to this. It also contain few dependency commits for clock framework that are earlier sent separately.
Quoted 8 lines
Quoted 2 lines
@Mike: It would be easiest to get these through ARM-SoC tree. So, would need your Acked-by on these patches. But firstly they must get reivewed :)
We should agree on how we want to do the common clk patches for v3.5. The two options I see are either we take all the patches that Mike Acks into arm-soc, or Mike applies the patches in his own tree and submits them to arm-soc. I think either way is fine for me, but some people might feel strongly one way or another.
I would prefer the latter (I maintain a branch and submit it). ?Is arm-soc still the right place for common clk patches in 3.5 and beyond? ?I don't mind hosting a branch for inclusion into linux-next and sending a pull request to Linus. ?There is nothing ARM-specific about the common framework.
Quoted 7 lines
Quoted 3 lines
Either way is fine with me, but it's really important that all the floating clock framework patches begin to materialize in a visible branch.
Agreed. ?I've been busy the last several days with some tasks besides common clk maintenance, but I'm going through all the patches now and will have a -next branch up soon on git.linaro.org.
Viresh,
I've taken patches 02 - 06 into my -next branch. Patch 01 isn't for me really, and I've not yet tested patch 07 (I'll take it everything looks good). The rest of your series (08 - 13) should probably go through Arnd.
Thanks,
Mike
A message that is not in the archive (sent off-list or not yet received): CAOh2x=nhZLQejWJb1Wdv=G9vU0hq+8CO0SSx95qQUJogL5ftNQ@mail.gmail.com
cover SPEAr: Move to common clock framework
Quoted 9 lines · viresh kumar
Quoted 5 lines · Mike
I've taken patches 02 - 06 into my -next branch. ?Patch 01 isn't for me really, and I've not yet tested patch 07 (I'll take it everything looks good). ?The rest of your series (08 - 13) should probably go through Arnd.
Quoted 4 lines
Yes you are correct. Even to get spear clk? patches through arnd, I would need fixed-factor clk's patch of Sascha to
go through your tree. What are your plans
for that patch.
It is on the review list :-)
Regards,
Mike
Quoted 1 line
Viresh
cover SPEAr: Move to common clock framework
In reply to Turquette, MikeQuoted 4 lines · Mike
I've taken patches 02 - 06 into my -next branch. Patch 01 isn't for me really, and I've not yet tested patch 07 (I'll take it everything looks good). The rest of your series (08 - 13) should probably go through Arnd.
My preference would be to have the whole series go through your tree and move the implementation of the spear clock code to drivers/clk in the process. This will reduce interdependencies between the spear clock branch and other branches that have spear patches.
I also think it's a good idea if you submit the clk patches to Linus directly for the next merge window, but it's ok to use arm-soc if that makes you feel more confident about it.
Arnd
cover SPEAr: Move to common clock framework
Quoted 4 lines · Arnd Bergmann
My preference would be to have the whole series go through your tree and move the implementation of the spear clock code to
drivers/clkin the process. This will reduce interdependencies between the spear clock branch and other branches that have spear patches.
Atleast for now, SPEAr clock patches have dependency on earlier SPEAr patches for which i have already sent you pull request.
So, this time atleast, these may go through your tree only.
You are talking about moving all clk files to drivers/clk or part of them (plat/clk-*.c or mach/clock.c)
Also, i don't know what's the best way, but arch/arm/*spear* looks to be the better place for SPEAr clock stuff. As it shares lot of registers/macros with non-clock stuff. If we keep them in drivers/clk we have to include <mach/...> files.
Signature · 1 line
viresh
cover SPEAr: Move to common clock framework
Quoted 8 lines · Viresh Kumar
Quoted 4 lines · Arnd Bergmann
My preference would be to have the whole series go through your tree and move the implementation of the spear clock code to
drivers/clkin the process. This will reduce interdependencies between the spear clock branch and other branches that have spear patches.Atleast for now, SPEAr clock patches have dependency on earlier SPEAr patches for which i have already sent you pull request.
Ok, I see. This could also be resolved by making the clock branch a superset of stuff that is in arm-soc, so that Mike would just have to wait for all the dependencies from arm-soc to go upstream before he asks Linus to pull the clock specific changes.
Quoted 4 lines
So, this time atleast, these may go through your tree only.
You are talking about moving all clk files to
drivers/clkor part of them (plat/clk-*.cormach/clock.c)
I mean all of them.
Quoted 4 lines
Also, i don't know what's the best way, but
arch/arm/*spear*looks to be the better place for SPEAr clock stuff. As it shares lot of registers/macros with non-clock stuff. If we keep them indrivers/clkwe have to include <mach/...> files.
There is a general tendencies to move stuff out of arch/arm into subsystem specific directories. We've already done this for drivers/gpio, drivers/pinctrl and some others, and I would like to see the same get done for irqchip and clock. The main reason is so that we have all drivers for the subsystem in one place, where a reader can compare them and they are put into the subsystem maintainers's responsibility rather than the platform maintainer. Obviously you still want both the subsystem and the platform maintainer to review any patches to those files, but in my experience this is done more consistently by sorting the files by subsystem.
Arnd
cover SPEAr: Move to common clock framework
In reply to Arnd BergmannQuoted 10 lines · Arnd Bergmann
Quoted 4 lines · Mike
I've taken patches 02 - 06 into my -next branch. ?Patch 01 isn't for me really, and I've not yet tested patch 07 (I'll take it everything looks good). ?The rest of your series (08 - 13) should probably go through Arnd.
My preference would be to have the whole series go through your tree and move the implementation of the spear clock code to
drivers/clkin the process. This will reduce interdependencies between the spear clock branch and other branches that have spear patches.
If Viresh moves his code to drivers/clk/ then I'll take it.
Quoted 3 lines
I also think it's a good idea if you submit the clk patches to Linus directly for the next merge window, but it's ok to use arm-soc if that makes you feel more confident about it.
As I said in my previous mail, I'd prefer to send to Linus directly. Sounds like we're in agreement.
Regards,
Mike