clk: samsung: small fixes and enhancements
Subsystems (3)
cover clk: samsung: small fixes and enhancements
Small fixes and enhancements that came up when implementing the common clock support for s3c2443, s3c2416 and s3c2450.
The 3rd and 4th patch enable the adding of separate aliases to previously defined clocks, as discussed with Sylwester Nawrocki.
This is often needed as some clocks need more than one alias. The hsmmc hclks on s3c2416 for example are both "hsmmc" and "mmc_busclk.0" .
These changes are required for the common clock conversion of s3c24xx SoCs.
Heiko Stuebner (4):
clk: samsung: register clk_div_tables for divider clocks
clk: samsung: remove np check in clock init
clk: samsung: always allocate the clk_table
clk: samsung: add infrastructure to add separate aliases
drivers/clk/samsung/clk.c | 51 +++++++++++++++++++++++++++++++++++++++----- drivers/clk/samsung/clk.h | 34 ++++++++++++++++++++++++++--- 2 files changed, 75 insertions(+), 10 deletions(-)
Signature · 1 line
1.7.2.3
PATCH 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 2/4 clk: samsung: remove np check in clock init
In reply to Heiko StübnerThis let to the suspend init never being reached on non-DT platforms.
--- drivers/clk/samsung/clk.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/clk/samsung/clk.c +0 -2
@@ -57,8 +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 );
Signature · 1 line
1.7.2.3
PATCH 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.
--- drivers/clk/samsung/clk.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/clk/samsung/clk.c +1 -1
@@ -58,11 +58,11 @@ void __init samsung_clk_init(struct device_node *np, void __iomem *base, { reg_base = base; -#ifdef CONFIG_OF clk_table =kzalloc (sizeof (struct clk *) * nr_clks,GFP_KERNEL );if (!clk_table)panic ("could not allocate clock lookup table\n" ); +#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 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.
---
change since the discussion: removed the list->alias check
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
@@ -94,6 +94,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
PATCH 1/4 clk: samsung: register clk_div_tables for divider clocks
In reply to Heiko StübnerQuoted 81 lines · Heiko St?bner
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_clockand if filled with a table, useclk_register_divider_tableinstead ofclk_register_dividerto register a divider clockSigned-off-by Heiko Stuebner <[email protected]>--- 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
-5@@ -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 --
Quoted 2 lines
1.7.2.3
PATCH 2/4 clk: samsung: remove np check in clock init
In reply to Heiko StübnerQuoted 12 lines · Heiko St?bner
This let to the suspend init never being reached on non-DT platforms.
Signed-off-by Heiko Stueber <[email protected]>--- drivers/clk/samsung/clk.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)drivers/clk/samsung/clk.c +0
-0
drivers/clk/samsung/clk.c void __init samsung_clk_init(struct device_node *np, void __iomem *base, · line 61
Quoted 5 lines
drivers/clk/samsung/clk.c +0
-2@@ -57,8 +57,6 @@ void __init samsung_clk_init(struct device_node *np, void __iomem *base, unsigned long nr_rdump) { reg_base = base; -if (!np) -return ;
Hi Heiko,
Sorry, I did not understand the need for this. Could you please add few more details on this change.
Thanks,
Thomas.
Quoted 6 lines
drivers/clk/samsung/clk.c +0
-1#ifdef CONFIG_OF clk_table =kzalloc (sizeof (struct clk *) * nr_clks,GFP_KERNEL ); --1.7.2.3
PATCH 2/4 clk: samsung: remove np check in clock init
Am Dienstag, 12. M?rz 2013, 09:53:00 schrieb Thomas Abraham:
Quoted 22 lines · Heiko St?bner
Quoted 21 lines
This let to the suspend init never being reached on non-DT platforms.
Signed-off-by Heiko Stueber <[email protected]>---
drivers/clk/samsung/clk.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)drivers/clk/samsung/clk.c +0
-0@@ -57,8 +57,6 @@ void __init samsung_clk_init(struct device_node *np,void __iomem *base, unsigned long nr_rdump) { reg_base = base;
Quoted 7 lines
drivers/clk/samsung/clk.c void __init samsung_clk_init(struct device_node *np, void __iomem *base, · line 61
Quoted 2 lines
drivers/clk/samsung/clk.c +0
-2-if (!np) -return ;Hi Heiko,
Sorry, I did not understand the need for this. Could you please add few more details on this change.
Hi Thomas,
On non-dt platforms the init would stop here, therefore never reaching the code that inits the syscore ops below to save the register values on suspend and restores them on resume.
I might be overlooking something, but I think we want to save/restore the register values on both dt and non-dt platforms.
Heiko
Quoted 6 lines
Quoted 6 lines
#ifdef
CONFIG_OFclk_table = kzalloc(sizeof(struct clk *) * nr_clks, GFP_KERNEL);--
1.7.2.3
PATCH 2/4 clk: samsung: remove np check in clock init
Am Dienstag, 12. M?rz 2013, 10:02:55 schrieb Heiko St?bner:
Quoted 31 lines
Am Dienstag, 12. M?rz 2013, 09:53:00 schrieb Thomas Abraham:
Quoted 22 lines · Heiko St?bner
Quoted 21 lines
This let to the suspend init never being reached on non-DT platforms.
Signed-off-by Heiko Stueber <[email protected]>---
drivers/clk/samsung/clk.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)drivers/clk/samsung/clk.c +0
-0@@ -57,8 +57,6 @@ void __init samsung_clk_init(struct device_node *np,void __iomem *base, unsigned long nr_rdump) { reg_base = base;Quoted 7 lines
drivers/clk/samsung/clk.c void __init samsung_clk_init(struct device_node *np, void __iomem *base, · line 61
Quoted 2 lines
drivers/clk/samsung/clk.c +0
-2-if (!np) -return ;Hi Heiko,
Sorry, I did not understand the need for this. Could you please add few more details on this change.
Quoted 8 lines
Hi Thomas,
On non-dt platforms the init would stop here, therefore never reaching the code that inits the syscore ops below to save the register values on suspend and restores them on resume.
I might be overlooking something, but I think we want to save/restore the register values on both dt and non-dt platforms.
ok, I did overlook something :-)
The register saving seems to be done separately on non-dt platforms (mach- exynos/pm.c for example). So I probably need to redo patch 2 and 3.
Heiko
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
#ifdef
CONFIG_OF
clk_table=kzalloc(sizeof(struct clk *) * nr_clks, GFP_KERNEL);--
1.7.2.3
PATCH 2/4 clk: samsung: remove np check in clock init
Quoted 38 lines · Heiko St?bner
Am Dienstag, 12. M?rz 2013, 10:02:55 schrieb Heiko St?bner:
Quoted 37 lines
Am Dienstag, 12. M?rz 2013, 09:53:00 schrieb Thomas Abraham:
Quoted 22 lines · Heiko St?bner
Quoted 21 lines
This let to the suspend init never being reached on non-DT platforms.
Signed-off-by Heiko Stueber <[email protected]>---
drivers/clk/samsung/clk.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)drivers/clk/samsung/clk.c +0
-0@@ -57,8 +57,6 @@ void __init samsung_clk_init(struct device_node *np,void __iomem *base, unsigned long nr_rdump) { reg_base = base;Quoted 7 lines
drivers/clk/samsung/clk.c void __init samsung_clk_init(struct device_node *np, void __iomem *base, · line 61
Quoted 2 lines
drivers/clk/samsung/clk.c +0
-2-if (!np) -return ;Hi Heiko,
Sorry, I did not understand the need for this. Could you please add few more details on this change.
Hi Thomas,
On non-dt platforms the init would stop here, therefore never reaching the code that inits the syscore ops below to save the register values on suspend and restores them on resume.
Quoted 7 lines
Quoted 2 lines
I might be overlooking something, but I think we want to save/restore the register values on both dt and non-dt platforms.
ok, I did overlook something :-)
The register saving seems to be done separately on non-dt platforms (mach-
exynos/pm.cfor example). So I probably need to redo patch 2 and 3.
The register saving is supposed to be done in the clock driver itself for both dt and non-dt platforms. So you are right in pointing out this issue.
But in this patch, removing the check on 'np' is not right. Because, on builds were CONFIG_OF is enabled but kernel image executing on non-dt platforms, the allocation of clk_table should be avoided.
So instead of removing the check on 'np', the code inside #ifdef CONFIG_PM_SLEEP should be placed after the assignment to reg_base. The check on 'np' should then follow.
Thanks,
Thomas.
Quoted 13 lines
Heiko
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
#ifdef
CONFIG_OF
clk_table=kzalloc(sizeof(struct clk *) * nr_clks, GFP_KERNEL);--
1.7.2.3
PATCH 2/4 clk: samsung: remove np check in clock init
Am Dienstag, 12. M?rz 2013, 10:36:54 schrieb Thomas Abraham:
Quoted 53 lines · Heiko St?bner
Quoted 39 lines
Am Dienstag, 12. M?rz 2013, 10:02:55 schrieb Heiko St?bner:
Quoted 38 lines
Am Dienstag, 12. M?rz 2013, 09:53:00 schrieb Thomas Abraham:
Quoted 23 lines · Heiko St?bner
Quoted 22 lines
This let to the suspend init never being reached on non-DT platforms.
Signed-off-by Heiko Stueber <[email protected]>---
drivers/clk/samsung/clk.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)drivers/clk/samsung/clk.c +0
-0@@ -57,8 +57,6 @@ void __init samsung_clk_init(struct device_node *np, void__iomem *base, unsigned long nr_rdump) { reg_base = base;Quoted 7 lines
drivers/clk/samsung/clk.c void __init samsung_clk_init(struct device_node *np, void __iomem *base, · line 61
Quoted 2 lines
drivers/clk/samsung/clk.c +0
-2-if (!np) -return ;Hi Heiko,
Sorry, I did not understand the need for this. Could you please add few more details on this change.
Hi Thomas,
On non-dt platforms the init would stop here, therefore never reaching the code that inits the syscore ops below to save the register values on suspend and restores them on resume.
Quoted 8 lines
Quoted 2 lines
I might be overlooking something, but I think we want to save/restore the register values on both dt and non-dt platforms.
ok, I did overlook something :-)
The register saving seems to be done separately on non-dt platforms (mach-
exynos/pm.cfor example). So I probably need to redo patch 2 and 3.The register saving is supposed to be done in the clock driver itself for both dt and non-dt platforms. So you are right in pointing out this issue.
Quoted 7 lines
But in this patch, removing the check on 'np' is not right. Because, on builds were
CONFIG_OFis enabled but kernel image executing on non-dt platforms, the allocation ofclk_tableshould be avoided.So instead of removing the check on 'np', the code inside #ifdef
CONFIG_PM_SLEEPshould be placed after the assignment toreg_base. The check on 'np' should then follow.
The following two patches do exactly that ... allocating the clk_table all the time, to allow us to add separate aliases to clocks later.
So I'll wait until we talked about them :-) .
Thanks for looking thru the patches
Heiko
PATCH 3/4 clk: samsung: always allocate the clk_table
In reply to Heiko StübnerQuoted 13 lines · Heiko St?bner
This is needed to allow looking up previous created clocks when adding separate aliases to them.
Signed-off-by Heiko Stuebner <[email protected]>--- drivers/clk/samsung/clk.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/clk/samsung/clk.c +0
-0
drivers/clk/samsung/clk.c void __init samsung_clk_init(struct device_node *np, void __iomem *base, · line 63
Quoted 7 lines
drivers/clk/samsung/clk.c +0
-1@@ -58,11 +58,11 @@ void __init samsung_clk_init(struct device_node *np, void __iomem *base, { reg_base = base; -#ifdef CONFIG_OF clk_table =kzalloc (sizeof (struct clk *) * nr_clks,GFP_KERNEL );if (!clk_table)panic ("could not allocate clock lookup table\n" );
This change is fine but one point that should be considered is that on non-dt platforms, the memory allocation of clk_table cannot really be justified just because few clocks require two or more aliases.
Instead, the optional alias passed for divider/mux register functions can actually be a list of alias names, the list being terminated by a zero-length string. The clock register helper functions can then loop through that list and register all the aliases.
Thanks,
Thomas.
Quoted 8 lines
drivers/clk/samsung/clk.c +1
-1+#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); --1.7.2.3
PATCH 4/4 clk: samsung: add infrastructure to add separate aliases
In reply to Heiko StübnerQuoted 101 lines · Heiko St?bner
The 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.
Signed-off-by Heiko Stuebner <[email protected]>---
change since the discussion: removed thelist->aliascheckdrivers/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@@ -94,6 +94,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
-1@@ -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( --
Quoted 2 lines
1.7.2.3
This change looks fine but as discussed on 3/4 patch of this series, allocating clk_table for non-dt platforms would not be very helpful.
Thanks,
Thomas.
PATCH 4/4 clk: samsung: add infrastructure to add separate aliases
Am Dienstag, 12. M?rz 2013, 10:57:30 schrieb Thomas Abraham:
Quoted 116 lines · Heiko St?bner
Quoted 115 lines
The 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.
Signed-off-by Heiko Stuebner <[email protected]>---
change since the discussion: removed thelist->aliascheckdrivers/clk/samsung/clk.c | 33 +++++++++++++++++++++++++++++++++ drivers/clk/samsung/clk.h | 21 +++++++++++++++++++++ 2 files changed, 54 insertions(+), 0 deletions(-)drivers/clk/samsung/clk.c +15
-0@@ -94,6 +94,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);drivers/clk/samsung/clk.c +11
-0+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)drivers/clk/samsung/clk.c +5
-0+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 +19
-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.drivers/clk/samsung/clk.h +2
-0@@ -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 intnr_clk);
Quoted 7 lines
Quoted 4 lines
extern void
__initsamsung_clk_register_fixed_factor(--
1.7.2.3This change looks fine but as discussed on 3/4 patch of this series, allocating
clk_tablefor non-dt platforms would not be very helpful.
But how would we look up the previously registered clk otherwise? Using clk_table for this lookup seemed like the best way to easily access these clocks.
Thanks
Heiko
PATCH 4/4 clk: samsung: add infrastructure to add separate aliases
Quoted 125 lines · Heiko St?bner
Am Dienstag, 12. M?rz 2013, 10:57:30 schrieb Thomas Abraham:
Quoted 116 lines · Heiko St?bner
Quoted 115 lines
The 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.
Signed-off-by Heiko Stuebner <[email protected]>---
change since the discussion: removed thelist->aliascheckdrivers/clk/samsung/clk.c | 33 +++++++++++++++++++++++++++++++++ drivers/clk/samsung/clk.h | 21 +++++++++++++++++++++ 2 files changed, 54 insertions(+), 0 deletions(-)drivers/clk/samsung/clk.c +15
-0@@ -94,6 +94,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);drivers/clk/samsung/clk.c +11
-0+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)drivers/clk/samsung/clk.c +5
-0+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 +19
-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.drivers/clk/samsung/clk.h +2
-0@@ -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 intnr_clk);Quoted 7 lines
Quoted 4 lines
extern void
__initsamsung_clk_register_fixed_factor(--
1.7.2.3This change looks fine but as discussed on 3/4 patch of this series, allocating
clk_tablefor non-dt platforms would not be very helpful.
Quoted 3 lines
But how would we look up the previously registered clk otherwise? Using
clk_tablefor this lookup seemed like the best way to easily access these clocks.
I did assume that the aliases for a clock are set when that clock is registered. Are there any instances where the aliases have to be set after a clock has been registered (using the samsung clock driver helper functions)?
Thanks,
Thomas.
Quoted 4 lines
Thanks
Heiko
PATCH 3/4 clk: samsung: always allocate the clk_table
In reply to Thomas AbrahamAm Dienstag, 12. M?rz 2013, 10:54:47 schrieb Thomas Abraham:
Quoted 23 lines · Heiko St?bner
Quoted 22 lines
This is needed to allow looking up previous created clocks when adding separate aliases to them.
Signed-off-by Heiko Stuebner <[email protected]>---
drivers/clk/samsung/clk.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/clk/samsung/clk.c +0
-1@@ -58,11 +58,11 @@ void __init samsung_clk_init(struct device_node *np,void __iomem *base, { reg_base = base; -#ifdef CONFIG_OF
Quoted 8 lines
drivers/clk/samsung/clk.c void __init samsung_clk_init(struct device_node *np, void __iomem *base,
Quoted 4 lines
drivers/clk/samsung/clk.c +0
-0clk_table =kzalloc (sizeof (struct clk *) * nr_clks,GFP_KERNEL );if (!clk_table)panic ("could not allocate clock lookup table\n" );This change is fine but one point that should be considered is that on non-dt platforms, the memory allocation of
clk_tablecannot really be justified just because few clocks require two or more aliases.
hmm, at least on s3c24xx there are quite a lot of the clocks requiring more than one alias. Also the clk_table is allocated on all dt platforms so these platforms have to handle the (small) memory consumption in any case and non-dt platforms are supposed to die out in the not to distant future.
I.e. I'm working on s3c24xx dt support, Tomasz is working on s3c64xx dt support, exynos5 already only has dt support and exynos4 will probably lose non-dt support at some point. And if someone converts the other s5p SoCs to the common clock framework they should already have the means to go to dt directly by then.
So the non-dt common-clock path is merely a "short" intermediate step to support smooth transitions to dt making the memory argument in my opinion a moot point :-)
Handling the aliases directly also requires adding quit a lot more {MUX/DIV/...}_*A aliases for all the necessary combinations.
And in general I also find the readability of separate aliases a lot better - as shown in the s3c2443 clk driver in the second series. And the removal once we only support dt will be a lot cleaner too.
Heiko
Quoted 14 lines
Instead, the optional alias passed for divider/mux register functions can actually be a list of alias names, the list being terminated by a zero-length string. The clock register helper functions can then loop through that list and register all the aliases.
Quoted 8 lines
+#ifdef
CONFIG_OFclk_data.clks = clk_table; clk_data.clk_num = nr_clks; of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);--
1.7.2.3
Sylwester Nawrocki
maintainerPATCH 3/4 clk: samsung: always allocate the clk_table
In reply to Thomas AbrahamHi,
Quoted 8 lines · Thomas Abraham
This change is fine but one point that should be considered is that on non-dt platforms, the memory allocation of
clk_tablecannot really be justified just because few clocks require two or more aliases.Instead, the optional alias passed for divider/mux register functions can actually be a list of alias names, the list being terminated by a zero-length string. The clock register helper functions can then loop through that list and register all the aliases.
Heiko's approach look much more clean to me and even for Exynos platform which has currently about 350 clocks and is going to be dt-only starting from 3.10 we are talking about 1.5kB of memory. Other (s3c64/24xx) platforms have much less clocks (70...150).
IMHO all clocks aliases should be registered as it is done in Heiko's patch series. And the clocks table could just be freed on non-dt platforms if it is a real issue and anyone is concerned about it.
Regards,
Sylwester
PATCH 3/4 clk: samsung: always allocate the clk_table
In reply to Heiko StübnerQuoted 49 lines · Heiko St?bner
Am Dienstag, 12. M?rz 2013, 10:54:47 schrieb Thomas Abraham:
Quoted 23 lines · Heiko St?bner
Quoted 22 lines
This is needed to allow looking up previous created clocks when adding separate aliases to them.
Signed-off-by Heiko Stuebner <[email protected]>---
drivers/clk/samsung/clk.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/clk/samsung/clk.c +0
-1@@ -58,11 +58,11 @@ void __init samsung_clk_init(struct device_node *np,void __iomem *base, { reg_base = base; -#ifdef CONFIG_OF Quoted 8 lines
drivers/clk/samsung/clk.c void __init samsung_clk_init(struct device_node *np, void __iomem *base,
Quoted 4 lines
drivers/clk/samsung/clk.c +0
-0clk_table =kzalloc (sizeof (struct clk *) * nr_clks,GFP_KERNEL );if (!clk_table)panic ("could not allocate clock lookup table\n" );This change is fine but one point that should be considered is that on non-dt platforms, the memory allocation of
clk_tablecannot really be justified just because few clocks require two or more aliases.hmm, at least on s3c24xx there are quite a lot of the clocks requiring more than one alias. Also the
clk_tableis allocated on all dt platforms so these platforms have to handle the (small) memory consumption in any case and non-dt platforms are supposed to die out in the not to distant future.I.e. I'm working on s3c24xx dt support, Tomasz is working on s3c64xx dt support, exynos5 already only has dt support and exynos4 will probably lose non-dt support at some point. And if someone converts the other s5p SoCs to the common clock framework they should already have the means to go to dt directly by then.
So the non-dt common-clock path is merely a "short" intermediate step to support smooth transitions to dt making the memory argument in my opinion a moot point :-)
Quoted 6 lines
Handling the aliases directly also requires adding quit a lot more {MUX/DIV/...}_*A aliases for all the necessary combinations.
And in general I also find the readability of separate aliases a lot better - as shown in the s3c2443 clk driver in the second series. And the removal once we only support dt will be a lot cleaner too.
True, I agree on your comments.
For this patch,
Quoted 19 lines
Heiko
Quoted 14 lines
Instead, the optional alias passed for divider/mux register functions can actually be a list of alias names, the list being terminated by a zero-length string. The clock register helper functions can then loop through that list and register all the aliases.
Quoted 8 lines
+#ifdef
CONFIG_OFclk_data.clks = clk_table; clk_data.clk_num = nr_clks; of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);--
1.7.2.3
PATCH 3/4 clk: samsung: always allocate the clk_table
In reply to Sylwester NawrockiQuoted 12 lines · Sylwester Nawrocki
Hi,
Quoted 8 lines · Thomas Abraham
This change is fine but one point that should be considered is that on non-dt platforms, the memory allocation of
clk_tablecannot really be justified just because few clocks require two or more aliases.Instead, the optional alias passed for divider/mux register functions can actually be a list of alias names, the list being terminated by a zero-length string. The clock register helper functions can then loop through that list and register all the aliases.
Quoted 8 lines
Heiko's approach look much more clean to me and even for Exynos platform which has currently about 350 clocks and is going to be dt-only starting from 3.10 we are talking about 1.5kB of memory. Other (s3c64/24xx) platforms have much less clocks (70...150).
IMHO all clocks aliases should be registered as it is done in Heiko's patch series. And the clocks table could just be freed on non-dt platforms if it is a real issue and anyone is concerned about it.
Ok, thanks.
And, you mentioned Exynos4 will be dt-only from 3.10. Does that mean we just drop support for universal and nuri non-dt board support? Or, will there be a equivalent dt support added for these boards?
Thanks,
Thomas.
Quoted 3 lines
Regards,
Sylwester
Sylwester Nawrocki
maintainerPATCH 3/4 clk: samsung: always allocate the clk_table
Quoted 3 lines · Thomas Abraham
And, you mentioned Exynos4 will be dt-only from 3.10. Does that mean we just drop support for universal and nuri non-dt board support? Or, will there be a equivalent dt support added for these boards?
I think Tomasz has some initial dts files for Universal_c210 ready, and Nuri could probably just be dropped. But we need Kyungmin's opinion on that.
I'm not sure about other boards, they look pretty basic though. So it shouldn't be difficult to replace them with corresponding dts files. Currently there are:
arch/arm/mach-exynos/mach-smdk4x12.carch/arm/mach-exynos/mach-origen.carch/arm/mach-exynos/mach-nuri.carch/arm/mach-exynos/mach-universal_c210.carch/arm/mach-exynos/mach-armlex4210.carch/arm/mach-exynos/mach-smdkv310.c
And there are dts files for:
arch/arm/boot/dts/exynos4210-smdkv310.dtsarch/arm/boot/dts/exynos4210-origen.dtsarch/arm/boot/dts/exynos5250-smdk5250.dtsarch/arm/boot/dts/exynos5250-snow.dtsarch/arm/boot/dts/exynos4210-trats.dtsarch/arm/boot/dts/exynos5440-ssdk5440.dtsarch/arm/boot/dts/exynos4412-smdk4412.dts
So except Universal_c210 and Nuri the only ones not supporting booting from DT are these two simple boards, which seem to be maintained by Samsung:
arch/arm/mach-exynos/mach-smdk4x12.carch/arm/mach-exynos/mach-armlex4210.c
It would be nice to make Exynos DT only in this kernel release. I guess there was enough time to get all boards converted to DT already.
--
Regards,
Sylwester
PATCH 3/4 clk: samsung: always allocate the clk_table
Quoted 30 lines · Sylwester Nawrocki
Quoted 3 lines · Thomas Abraham
And, you mentioned Exynos4 will be dt-only from 3.10. Does that mean we just drop support for universal and nuri non-dt board support? Or, will there be a equivalent dt support added for these boards?
I think Tomasz has some initial dts files for
Universal_c210ready, and Nuri could probably just be dropped. But we need Kyungmin's opinion on that.I'm not sure about other boards, they look pretty basic though. So it shouldn't be difficult to replace them with corresponding dts files. Currently there are:
arch/arm/mach-exynos/mach-smdk4x12.carch/arm/mach-exynos/mach-origen.carch/arm/mach-exynos/mach-nuri.carch/arm/mach-exynos/mach-universal_c210.carch/arm/mach-exynos/mach-armlex4210.carch/arm/mach-exynos/mach-smdkv310.cAnd there are dts files for:
arch/arm/boot/dts/exynos4210-smdkv310.dtsarch/arm/boot/dts/exynos4210-origen.dtsarch/arm/boot/dts/exynos5250-smdk5250.dtsarch/arm/boot/dts/exynos5250-snow.dtsarch/arm/boot/dts/exynos4210-trats.dtsarch/arm/boot/dts/exynos5440-ssdk5440.dtsarch/arm/boot/dts/exynos4412-smdk4412.dts
Quoted 6 lines
So except
Universal_c210and Nuri the only ones not supporting booting from DT are these two simple boards, which seem to be maintained by Samsung:
arch/arm/mach-exynos/mach-smdk4x12.carch/arm/mach-exynos/mach-armlex4210.c
There has not been much board support development for these boards for couple of kernel releases now.
Quoted 4 lines
It would be nice to make Exynos DT only in this kernel release. I guess there was enough time to get all boards converted to DT already.
Thanks for sharing your thoughts on this.
Regards,
Thomas.
Quoted 5 lines
--
Regards,
Sylwester
PATCH 3/4 clk: samsung: always allocate the clk_table
Hi All
Quoted 35 lines · Thomas Abraham
Quoted 34 lines · Sylwester Nawrocki
Quoted 3 lines · Thomas Abraham
And, you mentioned Exynos4 will be dt-only from 3.10. Does that mean we just drop support for universal and nuri non-dt board support? Or, will there be a equivalent dt support added for these boards?
I think Tomasz has some initial dts files for
Universal_c210ready, and Nuri could probably just be dropped. But we need Kyungmin's opinion on that.I'm not sure about other boards, they look pretty basic though. So it shouldn't be difficult to replace them with corresponding dts files. Currently there are:
arch/arm/mach-exynos/mach-smdk4x12.carch/arm/mach-exynos/mach-origen.carch/arm/mach-exynos/mach-nuri.carch/arm/mach-exynos/mach-universal_c210.carch/arm/mach-exynos/mach-armlex4210.carch/arm/mach-exynos/mach-smdkv310.cAnd there are dts files for:
arch/arm/boot/dts/exynos4210-smdkv310.dtsarch/arm/boot/dts/exynos4210-origen.dtsarch/arm/boot/dts/exynos5250-smdk5250.dtsarch/arm/boot/dts/exynos5250-snow.dtsarch/arm/boot/dts/exynos4210-trats.dtsarch/arm/boot/dts/exynos5440-ssdk5440.dtsarch/arm/boot/dts/exynos4412-smdk4412.dtsSo except
Universal_c210and Nuri the only ones not supporting booting from DT are these two simple boards, which seem to be maintained by Samsung:
Quoted 6 lines
Quoted 2 lines
arch/arm/mach-exynos/mach-smdk4x12.carch/arm/mach-exynos/mach-armlex4210.cThere has not been much board support development for these boards for couple of kernel releases now.
Right, Armlex4210 can be removed as there is no much development happening. And I do not think any one else using it now.
I do not know about smdk4x12.c though,
Quoted 19 lines
Quoted 4 lines
It would be nice to make Exynos DT only in this kernel release. I guess there was enough time to get all boards converted to DT already.
Thanks for sharing your thoughts on this.
Regards,
Thomas.Quoted 5 lines
--
Regards,
Sylwester--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Regards, Alim
PATCH 3/4 clk: samsung: always allocate the clk_table
In reply to Sylwester NawrockiQuoted 6 lines
So except
Universal_c210and Nuri the only ones not supporting booting from DT are these two simple boards, which seem to be maintained by Samsung:
arch/arm/mach-exynos/mach-smdk4x12.c
SMDK4412 is already supported through DT (exynos4412-smdk4412.dts) as you already pointed out. I am not sure if anyone is using SMDK4212. Even if it is required, one can easily add a dts file for that board as DT support for 4x12 already exists.
arch/arm/boot/dts/exynos4x12.dtsiarch/arm/boot/dts/exynos4x12-pinctrl.dtsi
Signature · 2 lines
With warm regards, Sachin
PATCH 3/4 clk: samsung: always allocate the clk_table
In reply to Sylwester NawrockiQuoted 8 lines · Sylwester Nawrocki
Quoted 3 lines · Thomas Abraham
And, you mentioned Exynos4 will be dt-only from 3.10. Does that mean we just drop support for universal and nuri non-dt board support? Or, will there be a equivalent dt support added for these boards?
I think Tomasz has some initial dts files for
Universal_c210ready, and Nuri could probably just be dropped. But we need Kyungmin's opinion on that.
Agree.
Tomasz will send unviersal DT files soon.
Thank you,
Kyungmin Park
Quoted 42 lines
I'm not sure about other boards, they look pretty basic though. So it shouldn't be difficult to replace them with corresponding dts files. Currently there are:
arch/arm/mach-exynos/mach-smdk4x12.carch/arm/mach-exynos/mach-origen.carch/arm/mach-exynos/mach-nuri.carch/arm/mach-exynos/mach-universal_c210.carch/arm/mach-exynos/mach-armlex4210.carch/arm/mach-exynos/mach-smdkv310.cAnd there are dts files for:
arch/arm/boot/dts/exynos4210-smdkv310.dtsarch/arm/boot/dts/exynos4210-origen.dtsarch/arm/boot/dts/exynos5250-smdk5250.dtsarch/arm/boot/dts/exynos5250-snow.dtsarch/arm/boot/dts/exynos4210-trats.dtsarch/arm/boot/dts/exynos5440-ssdk5440.dtsarch/arm/boot/dts/exynos4412-smdk4412.dtsSo except
Universal_c210and Nuri the only ones not supporting booting from DT are these two simple boards, which seem to be maintained by Samsung:
arch/arm/mach-exynos/mach-smdk4x12.carch/arm/mach-exynos/mach-armlex4210.cIt would be nice to make Exynos DT only in this kernel release. I guess there was enough time to get all boards converted to DT already.
--
Regards,
Sylwester_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel