clk: samsung: pm fixes and multiple aliases
Subsystems (3)
v2 cover clk: samsung: pm fixes and multiple aliases
Second version of the fixes to address comments gathered from the first version, like not entering the dt code on non-dt platforms even if dt-support is present in the kernel.
Patch 1 and 3 got "Reviewed-by" tags but I only included the one for patch 1, because patch 3 changed due to the changes in patch 2.
Heiko Stuebner (4):
clk: samsung: register clk_div_tables for divider clocks
clk: samsung: fix pm init on non-dt platforms
clk: samsung: always allocate the clk_table
clk: samsung: add infrastructure to add separate aliases
drivers/clk/samsung/clk.c | 72 +++++++++++++++++++++++++++++++++++--------- drivers/clk/samsung/clk.h | 34 ++++++++++++++++++-- 2 files changed, 87 insertions(+), 19 deletions(-)
Signature · 1 line
1.7.2.3
PATCH v2 1/4 clk: samsung: register clk_div_tables for divider clocks
On some Samsung platforms divider clocks only use specific divider combinations like the armdiv on s3c2443 and s3c2416. For these usecases the generic divider clock already provides the option of providing a lookup table mapping register values to divider values.
Therefore add a new field to samsung_div_clock and if filled with a table, use clk_register_divider_table instead of clk_register_divider to register a divider clock
--- drivers/clk/samsung/clk.c | 14 +++++++++++--- drivers/clk/samsung/clk.h | 13 +++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-)
drivers/clk/samsung/clk.c +11 -3
@@ -183,9 +183,17 @@ void __init samsung_clk_register_div(struct samsung_div_clock *list,unsigned int idx, ret;for (idx =0 ; idx < nr_clk; idx++, list++) { - clk =clk_register_divider (NULL , list->name, list->parent_name, - list->flags, reg_base + list->offset, list->shift, - list->width, list->div_flags, &lock); +if (list->table) + clk =clk_register_divider_table (NULL , list->name, + list->parent_name, list->flags, + reg_base + list->offset, list->shift, + list->width, list->div_flags, + list->table, &lock); +else + clk =clk_register_divider (NULL , list->name, + list->parent_name, list->flags, + reg_base + list->offset, list->shift, + list->width, list->div_flags, &lock);if (IS_ERR (clk)) {pr_err ("%s: failed to register clock %s\n" , __func__, list->name);
drivers/clk/samsung/clk.h +9 -4
@@ -150,9 +150,10 @@ struct samsung_div_clock {u8 width;u8 div_flags;const char *alias; +struct clk_div_table *table; }; -#define __DIV (_id, dname, cname, pname, o, s, w, f, df, a) \ +#define __DIV (_id, dname, cname, pname, o, s, w, f, df, a, t) \ { \ .id = _id, \ .dev_name = dname, \
@@ -164,16 +165,20 @@ struct samsung_div_clock { .width = w, \ .div_flags = df, \ .alias = a, \ + .table = t, \ }#define DIV (_id, cname, pname, o, s, w) \ - __DIV(_id, NULL, cname, pname, o, s, w, 0, 0, NULL) + __DIV(_id, NULL, cname, pname, o, s, w, 0, 0, NULL, NULL)#define DIV_A (_id, cname, pname, o, s, w, a) \ - __DIV(_id, NULL, cname, pname, o, s, w, 0, 0, a) + __DIV(_id, NULL, cname, pname, o, s, w, 0, 0, a, NULL)#define DIV_F (_id, cname, pname, o, s, w, f, df) \ - __DIV(_id, NULL, cname, pname, o, s, w, f, df, NULL) + __DIV(_id, NULL, cname, pname, o, s, w, f, df, NULL, NULL) + +#define DIV_T (_id, cname, pname, o, s, w, t) \ + __DIV(_id, NULL, cname, pname, o, s, w, 0, 0, NULL, t)/** * struct samsung_gate_clock: information about gate clock
Signature · 1 line
1.7.2.3
PATCH v2 2/4 clk: samsung: fix pm init on non-dt platforms
In reply to Heiko StübnerThe clock_init function checked for a dt node, returning immediately for non-dt machines. This let to the suspend init never being reached on those non-DT machines.
So fix this by moving the pm init code above the check.
---
changes since v1:
instead of removing the np check, move the pm init above it, as suggested by Thomas Abraham.
When removing the np check the dt code is wrongly entered on non-dt machines if dt support is enabled in the kernel
drivers/clk/samsung/clk.c | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-)
drivers/clk/samsung/clk.c +13 -12
@@ -57,18 +57,6 @@ void __init samsung_clk_init(struct device_node *np, void __iomem *base, unsigned long nr_rdump) { reg_base = base; -if (!np) -return ; - -#ifdef CONFIG_OF - clk_table =kzalloc (sizeof (struct clk *) * nr_clks,GFP_KERNEL ); -if (!clk_table) -panic ("could not allocate clock lookup table\n" ); - - clk_data.clks = clk_table; - clk_data.clk_num = nr_clks; -of_clk_add_provider (np, of_clk_src_onecell_get, &clk_data); -#endif #ifdef CONFIG_PM_SLEEP if (rdump && nr_rdump) {
@@ -87,6 +75,19 @@ void __init samsung_clk_init(struct device_node *np, void __iomem *base, register_syscore_ops(&samsung_clk_syscore_ops); }#endif + +if (!np) +return ; + +#ifdef CONFIG_OF + clk_table =kzalloc (sizeof (struct clk *) * nr_clks,GFP_KERNEL ); +if (!clk_table) +panic ("could not allocate clock lookup table\n" ); + + clk_data.clks = clk_table; + clk_data.clk_num = nr_clks; +of_clk_add_provider (np, of_clk_src_onecell_get, &clk_data); +#endif }/* add a clock instance to the clock lookup table used for dt based lookup */
Signature · 1 line
1.7.2.3
PATCH v2 3/4 clk: samsung: always allocate the clk_table
In reply to Heiko StübnerThis is needed to allow looking up previous created clocks when adding separate aliases to them.
---
changes since v1:
adapt to the changes in patch 2/4
drivers/clk/samsung/clk.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/clk/samsung/clk.c +4 -4
@@ -76,14 +76,14 @@ void __init samsung_clk_init(struct device_node *np, void __iomem *base, }#endif -if (!np) -return ; - -#ifdef CONFIG_OF clk_table =kzalloc (sizeof (struct clk *) * nr_clks,GFP_KERNEL );if (!clk_table)panic ("could not allocate clock lookup table\n" ); +if (!np) +return ; + +#ifdef CONFIG_OF clk_data.clks = clk_table; clk_data.clk_num = nr_clks;of_clk_add_provider (np, of_clk_src_onecell_get, &clk_data);
Signature · 1 line
1.7.2.3
PATCH v2 4/4 clk: samsung: add infrastructure to add separate aliases
In reply to Heiko StübnerThe current code adds aliases, if necessary, directly when adding the clock, limiting the number of possible aliases to one.
Some platforms need more than one alias, like the hsmmc pclocks on s3c2416 which need a "hsmmc" and "mmc_busclk.0" alias for the s3c-sdhci driver.
Therefore add the possibility to separately add clock aliases for previously created clocks.
--- drivers/clk/samsung/clk.c | 33 +++++++++++++++++++++++++++++++++ drivers/clk/samsung/clk.h | 21 +++++++++++++++++++++ 2 files changed, 54 insertions(+), 0 deletions(-)
drivers/clk/samsung/clk.c +33 -0
@@ -97,6 +97,39 @@ void samsung_clk_add_lookup(struct clk *clk, unsigned int id) clk_table[id] = clk; } +/* register a list of aliases */ +void __init samsung_clk_register_alias (struct samsung_clock_alias *list, +unsigned int nr_clk) +{ +struct clk *clk; +unsigned int idx, ret; + +if (!clk_table) { +pr_err ("%s: clock table missing\n" , __func__); +return ; + } + +for (idx =0 ; idx < nr_clk; idx++, list++) { +if (!list->id) { +pr_err ("%s: clock id missing for index %d\n" , __func__, + idx); +continue ; + } + + clk = clk_table[list->id]; +if (!clk) { +pr_err ("%s: failed to find clock %d\n" , __func__, + list->id); +continue ; + } + + ret =clk_register_clkdev (clk, list->alias, list->dev_name); +if (ret) +pr_err ("%s: failed to register lookup %s\n" , + __func__, list->alias); + } +} +/* register a list of fixed clocks */ void __init samsung_clk_register_fixed_rate (struct samsung_fixed_rate_clock *list,unsigned int nr_clk)
drivers/clk/samsung/clk.h +21 -0
@@ -23,6 +23,25 @@#include <mach/map.h> /** +* struct samsung_clock_alias: information about mux clock +* @id: platform specific id of the clock. +* @dev_name: name of the device to which this clock belongs. +* @alias: optional clock alias name to be assigned to this clock. +*/ +struct samsung_clock_alias { +unsigned int id; +const char *dev_name; +const char *alias; +}; + +#define ALIAS (_id, dname, a) \ + { \ + .id = _id, \ + .dev_name = dname, \ + .alias = a, \ + } + +/** * struct samsung_fixed_rate_clock: information about fixed-rate clock * @id: platform specific id of the clock. * @name: name of this fixed-rate clock.
@@ -251,6 +270,8 @@ extern void __init samsung_clk_of_register_fixed_ext(extern void samsung_clk_add_lookup (struct clk *clk,unsigned int id); +extern void samsung_clk_register_alias (struct samsung_clock_alias *list, +unsigned int nr_clk);extern void __init samsung_clk_register_fixed_rate (struct samsung_fixed_rate_clock *clk_list,unsigned int nr_clk); extern void __init samsung_clk_register_fixed_factor(
Signature · 1 line
1.7.2.3
v2 cover clk: samsung: pm fixes and multiple aliases
In reply to Heiko StübnerQuoted 14 lines · Heiko St?bner
Second version of the fixes to address comments gathered from the first version, like not entering the dt code on non-dt platforms even if dt-support is present in the kernel.
Patch 1 and 3 got "Reviewed-by" tags but I only included the one for patch 1, because patch 3 changed due to the changes in patch 2.
Heiko Stuebner (4):
clk: samsung: registerclk_div_tablesfor divider clocks
clk: samsung: fix pm init on non-dt platforms
clk: samsung: always allocate theclk_table
clk: samsung: add infrastructure to add separate aliases
Quoted 7 lines
drivers/clk/samsung/clk.c | 72 +++++++++++++++++++++++++++++++++++------ --- drivers/clk/samsung/clk.h | 34 ++++++++++++++++++-- 2 files changed, 87 insertions(+), 19 deletions(-)--
1.7.2.3
Looks good to me and applied into samsung tree based on samsung common clock by Thomas P Abraham for testing.
But would be helpful to me if I could get Mike's ack on this series.
Thanks.
- Kukjin
v2 cover clk: samsung: pm fixes and multiple aliases
Quoting Kukjin Kim (2013-03-25 02:26:34)
Quoted 20 lines
Quoted 19 lines · Heiko St?bner
Second version of the fixes to address comments gathered from the first version, like not entering the dt code on non-dt platforms even if dt-support is present in the kernel.
Patch 1 and 3 got "Reviewed-by" tags but I only included the one for patch 1, because patch 3 changed due to the changes in patch 2.
Heiko Stuebner (4):
clk: samsung: registerclk_div_tablesfor divider clocks
clk: samsung: fix pm init on non-dt platforms
clk: samsung: always allocate theclk_table
clk: samsung: add infrastructure to add separate aliasesdrivers/clk/samsung/clk.c | 72 +++++++++++++++++++++++++++++++++++------ --- drivers/clk/samsung/clk.h | 34 ++++++++++++++++++-- 2 files changed, 87 insertions(+), 19 deletions(-)
Quoted 7 lines
Quoted 2 lines
--
1.7.2.3Looks good to me and applied into samsung tree based on samsung common clock by Thomas P Abraham for testing.
But would be helpful to me if I could get Mike's ack on this series.
Quoted 3 lines
Thanks.
- Kukjin
Kukjin Kim
Appliedv2 cover clk: samsung: pm fixes and multiple aliases
Quoted 27 lines · Mike Turquette
Quoting Kukjin Kim (2013-03-25 02:26:34)
Quoted 3 lines
Quoted 2 lines · Heiko St?bner
Second version of the fixes to address comments gathered from the
first
Quoted 6 lines
Quoted 6 lines
version, like not entering the dt code on non-dt platforms even if dt-support is present in the kernel.
Patch 1 and 3 got "Reviewed-by" tags but I only included the one for patch 1, because patch 3 changed due to the changes in patch 2.
Quoted 7 lines
Quoted 7 lines
Heiko Stuebner (4):
clk: samsung: registerclk_div_tablesfor divider clocks
clk: samsung: fix pm init on non-dt platforms
clk: samsung: always allocate theclk_table
clk: samsung: add infrastructure to add separate aliasesdrivers/clk/samsung/clk.c | 72 +++++++++++++++++++++++++++++++++++------
Quoted 7 lines
Quoted 6 lines
--- drivers/clk/samsung/clk.h | 34 ++++++++++++++++++-- 2 files changed, 87 insertions(+), 19 deletions(-)--
1.7.2.3
Quoted 8 lines
Quoted 1 line
Looks good to me and applied into samsung tree based on samsung common
clock by Thomas P Abraham for testing.
Quoted 3 lines
But would be helpful to me if I could get Mike's ack on this series.
Acked-by Mike Turquette <[email protected]>
Applied, thanks.
- Kukjin