Samsung clock PM consolidation part 1
Subsystems (6)
cover Samsung clock PM consolidation part 1
This series reworks suspend/resume handling of Samsung clock drivers to cover more SoC specific aspects that are beyond simple register save and restore. The goal is to have all the suspend/resume code that touches the clock controller in single place, which is the clock driver.
On Exynos4210-based Trats, Exynos4412-based Trats2 and Exynos5250-based Arndale boards (except suspend/resume, which is broken because of unrelated reasons):
Tomasz Figa (9):
clk: exynos4: Remove remnants of non-DT support
clk: samsung: Provide common helpers for register save/restore
clk: samsung: exynos4: Move suspend/resume handling to SoC driver
clk: samsung: exynos5250: Move suspend/resume handling to SoC driver
clk: samsung: exynos5420: Move suspend/resume handling to SoC driver
clk: samsung: s3c64xx: Move suspend/resume handling to SoC driver
clk: samsung: Drop old suspend/resume code
clk: samsung: exynos4: Add remaining suspend/resume handling
ARM: EXYNOS: pm: Drop legacy Exynos4 clock suspend/resume code
arch/arm/mach-exynos/pm.c | 125 +------------------------- drivers/clk/samsung/clk-exynos4.c | 170 ++++++++++++++++++++++++++++++----- drivers/clk/samsung/clk-exynos5250.c | 49 ++++++++-- drivers/clk/samsung/clk-exynos5420.c | 49 ++++++++-- drivers/clk/samsung/clk-exynos5440.c | 2 +- drivers/clk/samsung/clk-s3c64xx.c | 79 +++++++++++++--- drivers/clk/samsung/clk.c | 71 ++++++--------- drivers/clk/samsung/clk.h | 14 ++- 8 files changed, 346 insertions(+), 213 deletions(-)
Signature · 1 line
1.8.3.2
PATCH 1/9 clk: exynos4: Remove remnants of non-DT support
This patch simplifies a bit clock initialization code by removing remnants of non-DT clock initialization, such as reg_base and xom values passed in function parameters.
--- drivers/clk/samsung/clk-exynos4.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/clk/samsung/clk-exynos4.c +8 -6
@@ -960,12 +960,13 @@ static unsigned long exynos4_get_xom(void)return xom; } -static void __init exynos4_clk_register_finpll (unsigned long xom) +static void __init exynos4_clk_register_finpll (void ) {struct samsung_fixed_rate_clock fclk;struct clk *clk;unsigned long finpll_f =24000000 ;char *parent_name; +unsigned int xom =exynos4_get_xom (); parent_name = xom &1 ?"xusbxti" :"xxti" ; clk =clk_get (NULL , parent_name);
@@ -1090,9 +1091,10 @@ static struct samsung_pll_clock exynos4x12_plls[nr_plls] __initdata = {/* register exynos4 clocks */ static void __init exynos4_clk_init (struct device_node *np, -enum exynos4_soc exynos4_soc, -void __iomem *reg_base,unsigned long xom) +enum exynos4_soc exynos4_soc) { +void __iomem *reg_base; + reg_base =of_iomap (np,0 );if (!reg_base)panic ("%s: failed to map registers\n" , __func__);
@@ -1110,7 +1112,7 @@ static void __init exynos4_clk_init(struct device_node *np,ARRAY_SIZE (exynos4_fixed_rate_ext_clks), ext_clk_match); -exynos4_clk_register_finpll (xom); +exynos4_clk_register_finpll ();if (exynos4_soc ==EXYNOS4210 ) { samsung_clk_register_mux(exynos4210_mux_early,
@@ -1188,12 +1190,12 @@ static void __init exynos4_clk_init(struct device_node *np,static void __init exynos4210_clk_init (struct device_node *np) { -exynos4_clk_init (np,EXYNOS4210 ,NULL ,exynos4_get_xom ()); +exynos4_clk_init (np,EXYNOS4210 ); }CLK_OF_DECLARE (exynos4210_clk,"samsung,exynos4210-clock" , exynos4210_clk_init);static void __init exynos4412_clk_init (struct device_node *np) { -exynos4_clk_init (np,EXYNOS4X12 ,NULL ,exynos4_get_xom ()); +exynos4_clk_init (np,EXYNOS4X12 ); }CLK_OF_DECLARE (exynos4412_clk,"samsung,exynos4412-clock" , exynos4412_clk_init);
Signature · 1 line
1.8.3.2
PATCH 2/9 clk: samsung: Provide common helpers for register save/restore
In reply to Tomasz FigaAs suspend/resume handlers are being moved to SoC specific code, due to differencies in suspend/resume handling of particular SoCs, to minimize code duplication this patch provides common register save/restore helpers that save/restore given list of registers of clock controller.
--- drivers/clk/samsung/clk.c | 32 ++++++++++++++++++++++++++++++++ drivers/clk/samsung/clk.h | 10 ++++++++++ 2 files changed, 42 insertions(+)
drivers/clk/samsung/clk.c +32 -0
@@ -22,6 +22,38 @@ static struct clk_onecell_data clk_data;#endif #ifdef CONFIG_PM_SLEEP +void samsung_clk_save (void __iomem *base, +struct samsung_clk_reg_dump *rd, +unsigned int num_regs) +{ +for (; num_regs >0 ; --num_regs, ++rd) + rd->value =readl (base + rd->offset); +} + +void samsung_clk_restore (void __iomem *base, +const struct samsung_clk_reg_dump *rd, +unsigned int num_regs) +{ +for (; num_regs >0 ; --num_regs, ++rd) +writel (rd->value, base + rd->offset); +} + +struct samsung_clk_reg_dump *samsung_clk_alloc_reg_dump (unsigned long *rdump, +unsigned long nr_rdump) +{ +struct samsung_clk_reg_dump *rd; +unsigned int i; + + rd =kcalloc (nr_rdump,sizeof (*rd),GFP_KERNEL ); +if (!rd) +return NULL ; + +for (i =0 ; i < nr_rdump; ++i) + rd[i].offset = rdump[i]; + +return rd; +} +static struct samsung_clk_reg_dump *reg_dump;static unsigned long nr_reg_dump;
drivers/clk/samsung/clk.h +10 -0
@@ -340,4 +340,14 @@ extern void __init samsung_clk_register_pll(struct samsung_pll_clock *pll_list,extern unsigned long _get_rate (const char *clk_name); +extern void samsung_clk_save (void __iomem *base, +struct samsung_clk_reg_dump *rd, +unsigned int num_regs); +extern void samsung_clk_restore (void __iomem *base, +const struct samsung_clk_reg_dump *rd, +unsigned int num_regs); +extern struct samsung_clk_reg_dump *samsung_clk_alloc_reg_dump ( +unsigned long *rdump, +unsigned long nr_rdump); +#endif /* __SAMSUNG_CLK_H */
Signature · 1 line
1.8.3.2
PATCH 3/9 clk: samsung: exynos4: Move suspend/resume handling to SoC driver
In reply to Tomasz FigaSince there are multiple differences in how suspend/resume of particular Exynos SoCs must be handled, SoC driver is better place for suspend/resume handlers and so this patch moves them.
--- drivers/clk/samsung/clk-exynos4.c | 90 ++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 10 deletions(-)
drivers/clk/samsung/clk-exynos4.c +80 -10
@@ -15,6 +15,7 @@#include <linux/clk-provider.h> #include <linux/of.h> #include <linux/of_address.h> +#include <linux/syscore_ops.h> #include "clk.h"
@@ -191,6 +192,16 @@ enum exynos4_clks { nr_clks, }; +static void __iomem *reg_base; +static enum exynos4_soc exynos4_soc; + +/* +* Support for CMU save/restore across system suspends +*/ +#ifdef CONFIG_PM_SLEEP +static struct samsung_clk_reg_dump *exynos4_save_common; +static struct samsung_clk_reg_dump *exynos4_save_soc; +/* * list of controller registers to be saved and restored during a * suspend/resume cycle.
@@ -288,6 +299,70 @@ static unsigned long exynos4_clk_regs[] __initdata = { GATE_IP_CPU, }; +static int exynos4_clk_suspend (void ) +{ +samsung_clk_save (reg_base, exynos4_save_common, +ARRAY_SIZE (exynos4_clk_regs)); + +if (exynos4_soc ==EXYNOS4210 ) +samsung_clk_save (reg_base, exynos4_save_soc, +ARRAY_SIZE (exynos4210_clk_save)); +else +samsung_clk_save (reg_base, exynos4_save_soc, +ARRAY_SIZE (exynos4x12_clk_save)); + +return 0 ; +} + +static void exynos4_clk_resume (void ) +{ +samsung_clk_restore (reg_base, exynos4_save_common, +ARRAY_SIZE (exynos4_clk_regs)); + +if (exynos4_soc ==EXYNOS4210 ) +samsung_clk_restore (reg_base, exynos4_save_soc, +ARRAY_SIZE (exynos4210_clk_save)); +else +samsung_clk_restore (reg_base, exynos4_save_soc, +ARRAY_SIZE (exynos4x12_clk_save)); +} + +static struct syscore_ops exynos4_clk_syscore_ops = { + .suspend = exynos4_clk_suspend, + .resume = exynos4_clk_resume, +}; + +static void exynos4_clk_sleep_init (void ) +{ + exynos4_save_common =samsung_clk_alloc_reg_dump (exynos4_clk_regs, +ARRAY_SIZE (exynos4_clk_regs)); +if (!exynos4_save_common) + goto err_warn; + +if (exynos4_soc ==EXYNOS4210 ) + exynos4_save_soc =samsung_clk_alloc_reg_dump ( + exynos4210_clk_save, +ARRAY_SIZE (exynos4210_clk_save)); +else + exynos4_save_soc =samsung_clk_alloc_reg_dump ( + exynos4x12_clk_save, +ARRAY_SIZE (exynos4x12_clk_save)); +if (!exynos4_save_soc) + goto err_common; + +register_syscore_ops (&exynos4_clk_syscore_ops); +return ; + +err_common: +kfree (exynos4_save_common); +err_warn: +pr_warn ("%s: failed to allocate sleep save data, no sleep support!\n" , + __func__); +} +#else +static void exynos4_clk_sleep_init (void ) {} +#endif +/* list of all parent clock list */ PNAME (mout_apll_p) = {"fin_pll" ,"fout_apll" , };PNAME (mout_mpll_p) = {"fin_pll" ,"fout_mpll" , };
@@ -1091,22 +1166,15 @@ static struct samsung_pll_clock exynos4x12_plls[nr_plls] __initdata = {/* register exynos4 clocks */ static void __init exynos4_clk_init (struct device_node *np, -enum exynos4_soc exynos4_soc) +enum exynos4_soc soc) { -void __iomem *reg_base; + exynos4_soc = soc; reg_base =of_iomap (np,0 );if (!reg_base)panic ("%s: failed to map registers\n" , __func__); -if (exynos4_soc ==EXYNOS4210 ) -samsung_clk_init (np, reg_base, nr_clks, - exynos4_clk_regs,ARRAY_SIZE (exynos4_clk_regs), - exynos4210_clk_save,ARRAY_SIZE (exynos4210_clk_save)); -else -samsung_clk_init (np, reg_base, nr_clks, - exynos4_clk_regs,ARRAY_SIZE (exynos4_clk_regs), - exynos4x12_clk_save,ARRAY_SIZE (exynos4x12_clk_save)); +samsung_clk_init (np, reg_base, nr_clks,NULL ,0 ,NULL ,0 ); samsung_clk_of_register_fixed_ext(exynos4_fixed_rate_ext_clks, ARRAY_SIZE(exynos4_fixed_rate_ext_clks),
@@ -1179,6 +1247,8 @@ static void __init exynos4_clk_init(struct device_node *np,samsung_clk_register_alias (exynos4_aliases,ARRAY_SIZE (exynos4_aliases)); +exynos4_clk_sleep_init (); + pr_info("%s clocks: sclk_apll = %ld, sclk_mpll = %ld\n" "\tsclk_epll = %ld, sclk_vpll = %ld, arm_clk = %ld\n", exynos4_soc == EXYNOS4210 ? "Exynos4210" : "Exynos4x12",
Signature · 1 line
1.8.3.2
PATCH 3/9 clk: samsung: exynos4: Move suspend/resume handling to SoC driver
Hi Tomasz,
[ ... ]
drivers/clk/samsung/clk-exynos4.c static unsigned long exynos4_clk_regs[] __initdata = { · line 305
Quoted 11 lines
/*
* list of controller registers to be saved and restored during a
* suspend/resume cycle.drivers/clk/samsung/clk-exynos4.c +4
-0@@ -288,6 +299,70 @@ static unsigned long exynos4_clk_regs[] __initdata = { GATE_IP_CPU, }; +static int exynos4_clk_suspend (void ) +{ +samsung_clk_save (reg_base, exynos4_save_common, +ARRAY_SIZE (exynos4_clk_regs));
a doubt here, Is sizeof(exynos4_clk_regs) works with exynos4_clk_regs[] as __initdata ?
Quoted 4 lines
drivers/clk/samsung/clk-exynos4.c +4
-0+ +if (exynos4_soc ==EXYNOS4210 ) +samsung_clk_save (reg_base, exynos4_save_soc, +ARRAY_SIZE (exynos4210_clk_save));
[ ... ]
Quoted 1 line
+static void
exynos4_clk_sleep_init(void)
I think, this fuction can be placed in __init section.
Same in other patches as well.
Regards,
Yadwinder
PATCH 3/9 clk: samsung: exynos4: Move suspend/resume handling to SoC driver
Quoted 10 lines · On Thursday 17 of October 2013 19:12:08 Yadwinder Singh Brar wrote:
Hi Tomasz,
[ ... ]
Quoted 7 lines
/*
* list of controller registers to be saved and restored during a
* suspend/resume cycle.drivers/clk/samsung/clk-exynos4.c +0
-0@@ -288,6 +299,70 @@ static unsigned long exynos4_clk_regs[] __initdata = { GATE_IP_CPU, };
Quoted 7 lines
drivers/clk/samsung/clk-exynos4.c static unsigned long exynos4_clk_regs[] __initdata = { · line 305
Quoted 4 lines
drivers/clk/samsung/clk-exynos4.c +4
-0+static int exynos4_clk_suspend (void ) +{ +samsung_clk_save (reg_base, exynos4_save_common, +ARRAY_SIZE (exynos4_clk_regs));a doubt here, Is
sizeof(exynos4_clk_regs)works with exynos4_clk_regs[] as__initdata?
Hmm, this is a compile time constant, so I don't see why it couldn't work.
Quoted 9 lines
Quoted 4 lines
drivers/clk/samsung/clk-exynos4.c +4
-0+ +if (exynos4_soc ==EXYNOS4210 ) +samsung_clk_save (reg_base, exynos4_save_soc, +ARRAY_SIZE (exynos4210_clk_save));[ ... ]
Quoted 1 line
+static void
exynos4_clk_sleep_init(void)I think, this fuction can be placed in
__initsection.
That's right. Thanks for pointing this out.
Best regards,
Tomasz
PATCH 3/9 clk: samsung: exynos4: Move suspend/resume handling to SoC driver
Quoted 19 lines · Tomasz Figa
Quoted 10 lines · On Thursday 17 of October 2013 19:12:08 Yadwinder Singh Brar wrote:
Hi Tomasz,
[ ... ]
Quoted 7 lines
/*
* list of controller registers to be saved and restored during a
* suspend/resume cycle.drivers/clk/samsung/clk-exynos4.c +0
-0@@ -288,6 +299,70 @@ static unsigned long exynos4_clk_regs[] __initdata = { GATE_IP_CPU, };Quoted 7 lines
drivers/clk/samsung/clk-exynos4.c static unsigned long exynos4_clk_regs[] __initdata = { · line 305
Quoted 4 lines
drivers/clk/samsung/clk-exynos4.c +4
-0+static int exynos4_clk_suspend (void ) +{ +samsung_clk_save (reg_base, exynos4_save_common, +ARRAY_SIZE (exynos4_clk_regs));a doubt here, Is
sizeof(exynos4_clk_regs)works with exynos4_clk_regs[] as__initdata?
Quoted 2 lines
Hmm, this is a compile time constant, so I don't see why it couldn't work.
why this doubt came in mind is sizeof() is a operator.. like we can use sizeof(x++).
PATCH 4/9 clk: samsung: exynos5250: Move suspend/resume handling to SoC driver
In reply to Tomasz FigaSince there are multiple differences in how suspend/resume of particular Exynos SoCs must be handled, SoC driver is better place for suspend/resume handlers and so this patch moves them.
--- drivers/clk/samsung/clk-exynos5250.c | 49 ++++++++++++++++++++++++++++++++---- drivers/clk/samsung/clk.c | 5 ++-- drivers/clk/samsung/clk.h | 4 +-- 3 files changed, 49 insertions(+), 9 deletions(-)
drivers/clk/samsung/clk-exynos5250.c +44 -5
@@ -15,6 +15,7 @@#include <linux/clk-provider.h> #include <linux/of.h> #include <linux/of_address.h> +#include <linux/syscore_ops.h> #include "clk.h"
@@ -129,6 +130,11 @@ enum exynos5250_clks { nr_clks, }; +static void __iomem *reg_base; + +#ifdef CONFIG_PM_SLEEP +static struct samsung_clk_reg_dump *exynos5250_save; +/* * list of controller registers to be saved and restored during a * suspend/resume cycle.
@@ -181,6 +187,41 @@ static unsigned long exynos5250_clk_regs[] __initdata = { GATE_IP_ACP, }; +static int exynos5250_clk_suspend (void ) +{ +samsung_clk_save (reg_base, exynos5250_save, +ARRAY_SIZE (exynos5250_clk_regs)); + +return 0 ; +} + +static void exynos5250_clk_resume (void ) +{ +samsung_clk_restore (reg_base, exynos5250_save, +ARRAY_SIZE (exynos5250_clk_regs)); +} + +static struct syscore_ops exynos5250_clk_syscore_ops = { + .suspend = exynos5250_clk_suspend, + .resume = exynos5250_clk_resume, +}; + +static void exynos5250_clk_sleep_init (void ) +{ + exynos5250_save =samsung_clk_alloc_reg_dump (exynos5250_clk_regs, +ARRAY_SIZE (exynos5250_clk_regs)); +if (!exynos5250_save) { +pr_warn ("%s: failed to allocate sleep save data, no sleep support!\n" , + __func__); +return ; + } + +register_syscore_ops (&exynos5250_clk_syscore_ops); +} +#else +static void exynos5250_clk_sleep_init (void ) {} +#endif +/* list of all parent clock list */ PNAME (mout_apll_p) = {"fin_pll" ,"fout_apll" , };PNAME (mout_cpu_p) = {"mout_apll" ,"mout_mpll" , };
@@ -650,8 +691,6 @@ static struct of_device_id ext_clk_match[] __initdata = {/* register exynox5250 clocks */ static void __init exynos5250_clk_init (struct device_node *np) { -void __iomem *reg_base; -if (np) { reg_base =of_iomap (np,0 );if (!reg_base)
@@ -660,9 +699,7 @@ static void __init exynos5250_clk_init(struct device_node *np)panic ("%s: unable to determine soc\n" , __func__); } -samsung_clk_init (np, reg_base, nr_clks, - exynos5250_clk_regs,ARRAY_SIZE (exynos5250_clk_regs), -NULL ,0 ); +samsung_clk_init (np, reg_base, nr_clks,NULL ,0 ,NULL ,0 );samsung_clk_of_register_fixed_ext (exynos5250_fixed_rate_ext_clks,ARRAY_SIZE (exynos5250_fixed_rate_ext_clks), ext_clk_match);
@@ -688,6 +725,8 @@ static void __init exynos5250_clk_init(struct device_node *np)samsung_clk_register_gate (exynos5250_gate_clks,ARRAY_SIZE (exynos5250_gate_clks)); +exynos5250_clk_sleep_init (); +pr_info ("Exynos5250: clock setup completed, armclk=%ld\n" ,_get_rate ("div_arm2" )); }
drivers/clk/samsung/clk.c +3 -2
@@ -38,8 +38,9 @@ void samsung_clk_restore(void __iomem *base,writel (rd->value, base + rd->offset); } -struct samsung_clk_reg_dump *samsung_clk_alloc_reg_dump (unsigned long *rdump, -unsigned long nr_rdump) +struct samsung_clk_reg_dump *samsung_clk_alloc_reg_dump ( +const unsigned long *rdump, +unsigned long nr_rdump) {struct samsung_clk_reg_dump *rd;unsigned int i;
drivers/clk/samsung/clk.h +2 -2
@@ -347,7 +347,7 @@ extern void samsung_clk_restore(void __iomem *base,const struct samsung_clk_reg_dump *rd, unsigned int num_regs);extern struct samsung_clk_reg_dump *samsung_clk_alloc_reg_dump ( -unsigned long *rdump, -unsigned long nr_rdump); +const unsigned long *rdump, +unsigned long nr_rdump);#endif /* __SAMSUNG_CLK_H */
Signature · 1 line
1.8.3.2
PATCH 5/9 clk: samsung: exynos5420: Move suspend/resume handling to SoC driver
In reply to Tomasz FigaSince there are multiple differences in how suspend/resume of particular Exynos SoCs must be handled, SoC driver is better place for suspend/resume handlers and so this patch moves them.
--- drivers/clk/samsung/clk-exynos5420.c | 49 ++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 5 deletions(-)
drivers/clk/samsung/clk-exynos5420.c +44 -5
@@ -15,6 +15,7 @@#include <linux/clk-provider.h> #include <linux/of.h> #include <linux/of_address.h> +#include <linux/syscore_ops.h> #include "clk.h"
@@ -149,6 +150,11 @@ enum exynos5420_clks { nr_clks, }; +static void __iomem *reg_base; + +#ifdef CONFIG_PM_SLEEP +static struct samsung_clk_reg_dump *exynos5420_save; +/* * list of controller registers to be saved and restored during a * suspend/resume cycle.
@@ -215,6 +221,41 @@ static unsigned long exynos5420_clk_regs[] __initdata = { DIV_KFC0, }; +static int exynos5420_clk_suspend (void ) +{ +samsung_clk_save (reg_base, exynos5420_save, +ARRAY_SIZE (exynos5420_clk_regs)); + +return 0 ; +} + +static void exynos5420_clk_resume (void ) +{ +samsung_clk_restore (reg_base, exynos5420_save, +ARRAY_SIZE (exynos5420_clk_regs)); +} + +static struct syscore_ops exynos5420_clk_syscore_ops = { + .suspend = exynos5420_clk_suspend, + .resume = exynos5420_clk_resume, +}; + +static void exynos5420_clk_sleep_init (void ) +{ + exynos5420_save =samsung_clk_alloc_reg_dump (exynos5420_clk_regs, +ARRAY_SIZE (exynos5420_clk_regs)); +if (!exynos5420_save) { +pr_warn ("%s: failed to allocate sleep save data, no sleep support!\n" , + __func__); +return ; + } + +register_syscore_ops (&exynos5420_clk_syscore_ops); +} +#else +static void exynos5420_clk_sleep_init (void ) {} +#endif +/* list of all parent clocks */ PNAME (mspll_cpu_p) = {"sclk_cpll" ,"sclk_dpll" ,"sclk_mpll" ,"sclk_spll" };
@@ -767,8 +808,6 @@ static struct of_device_id ext_clk_match[] __initdata = {/* register exynos5420 clocks */ static void __init exynos5420_clk_init (struct device_node *np) { -void __iomem *reg_base; -if (np) { reg_base =of_iomap (np,0 );if (!reg_base)
@@ -777,9 +816,7 @@ static void __init exynos5420_clk_init(struct device_node *np)panic ("%s: unable to determine soc\n" , __func__); } -samsung_clk_init (np, reg_base, nr_clks, - exynos5420_clk_regs,ARRAY_SIZE (exynos5420_clk_regs), -NULL ,0 ); +samsung_clk_init (np, reg_base, nr_clks,NULL ,0 ,NULL ,0 );samsung_clk_of_register_fixed_ext (exynos5420_fixed_rate_ext_clks,ARRAY_SIZE (exynos5420_fixed_rate_ext_clks), ext_clk_match);
@@ -795,5 +832,7 @@ static void __init exynos5420_clk_init(struct device_node *np) ARRAY_SIZE(exynos5420_div_clks));samsung_clk_register_gate (exynos5420_gate_clks,ARRAY_SIZE (exynos5420_gate_clks)); + +exynos5420_clk_sleep_init (); }CLK_OF_DECLARE (exynos5420_clk,"samsung,exynos5420-clock" , exynos5420_clk_init);
Signature · 1 line
1.8.3.2
PATCH 6/9 clk: samsung: s3c64xx: Move suspend/resume handling to SoC driver
In reply to Tomasz FigaSince there are multiple differences in how suspend/resume of particular Exynos SoCs must be handled, SoC driver is better place for suspend/resume handlers and so this patch moves them.
--- drivers/clk/samsung/clk-s3c64xx.c | 79 +++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 11 deletions(-)
drivers/clk/samsung/clk-s3c64xx.c +68 -11
@@ -13,6 +13,7 @@#include <linux/clk-provider.h> #include <linux/of.h> #include <linux/of_address.h> +#include <linux/syscore_ops.h> #include <dt-bindings/clock/samsung,s3c64xx-clock.h>
@@ -61,6 +62,13 @@ enum s3c64xx_plls { apll, mpll, epll, }; +static void __iomem *reg_base; +static bool is_s3c6400; + +#ifdef CONFIG_PM_SLEEP +static struct samsung_clk_reg_dump *s3c64xx_save_common; +static struct samsung_clk_reg_dump *s3c64xx_save_soc; +/* * List of controller registers to be saved and restored during * a suspend/resume cycle.
@@ -87,6 +95,60 @@ static unsigned long s3c6410_clk_regs[] __initdata = { MEM0_GATE, }; +static int s3c64xx_clk_suspend (void ) +{ +samsung_clk_save (reg_base, s3c64xx_save_common, +ARRAY_SIZE (s3c64xx_clk_regs)); + +if (!is_s3c6400) +samsung_clk_save (reg_base, s3c64xx_save_soc, +ARRAY_SIZE (s3c6410_clk_regs)); + +return 0 ; +} + +static void s3c64xx_clk_resume (void ) +{ +samsung_clk_restore (reg_base, s3c64xx_save_common, +ARRAY_SIZE (s3c64xx_clk_regs)); + +if (!is_s3c6400) +samsung_clk_restore (reg_base, s3c64xx_save_soc, +ARRAY_SIZE (s3c6410_clk_regs)); +} + +static struct syscore_ops s3c64xx_clk_syscore_ops = { + .suspend = s3c64xx_clk_suspend, + .resume = s3c64xx_clk_resume, +}; + +static void s3c64xx_clk_sleep_init (void ) +{ + s3c64xx_save_common =samsung_clk_alloc_reg_dump (s3c64xx_clk_regs, +ARRAY_SIZE (s3c64xx_clk_regs)); +if (!s3c64xx_save_common) + goto err_warn; + +if (!is_s3c6400) { + s3c64xx_save_soc =samsung_clk_alloc_reg_dump (s3c6410_clk_regs, +ARRAY_SIZE (s3c6410_clk_regs)); +if (!s3c64xx_save_soc) + goto err_soc; + } + +register_syscore_ops (&s3c64xx_clk_syscore_ops); +return ; + +err_soc: +kfree (s3c64xx_save_common); +err_warn: +pr_warn ("%s: failed to allocate sleep save data, no sleep support!\n" , + __func__); +} +#else +static void s3c64xx_clk_sleep_init (void ) {} +#endif +/* List of parent clocks common for all S3C64xx SoCs. */ PNAME (spi_mmc_p) = {"mout_epll" ,"dout_mpll" ,"fin_pll" ,"clk27m" };PNAME (uart_p) = {"mout_epll" ,"dout_mpll" };
@@ -391,11 +453,11 @@ static void __init s3c64xx_clk_register_fixed_ext(unsigned long fin_pll_f,/* Register s3c64xx clocks. */ void __init s3c64xx_clk_init (struct device_node *np,unsigned long xtal_f, -unsigned long xusbxti_f,bool is_s3c6400, -void __iomem *reg_base) +unsigned long xusbxti_f,bool s3c6400, +void __iomem *base) { -unsigned long *soc_regs =NULL ; -unsigned long nr_soc_regs =0 ; + reg_base = base; + is_s3c6400 = s3c6400;if (np) { reg_base =of_iomap (np,0 );
@@ -403,13 +465,7 @@ void __init s3c64xx_clk_init(struct device_node *np, unsigned long xtal_f,panic ("%s: failed to map registers\n" , __func__); } -if (!is_s3c6400) { - soc_regs = s3c6410_clk_regs; - nr_soc_regs =ARRAY_SIZE (s3c6410_clk_regs); - } - -samsung_clk_init (np, reg_base,NR_CLKS , s3c64xx_clk_regs, -ARRAY_SIZE (s3c64xx_clk_regs), soc_regs, nr_soc_regs); +samsung_clk_init (np, reg_base,NR_CLKS ,NULL ,0 ,NULL ,0 );/* Register external clocks. */ if (!np)
@@ -452,6 +508,7 @@ void __init s3c64xx_clk_init(struct device_node *np, unsigned long xtal_f,samsung_clk_register_alias (s3c64xx_clock_aliases,ARRAY_SIZE (s3c64xx_clock_aliases)); +s3c64xx_clk_sleep_init (); pr_info("%s clocks: apll = %lu, mpll = %lu\n" "\tepll = %lu, arm_clk = %lu\n",
Signature · 1 line
1.8.3.2
PATCH 7/9 clk: samsung: Drop old suspend/resume code
In reply to Tomasz FigaSince all SoC drivers have been moved to local suspend/resume handling, the old code can be safely dropped.
--- drivers/clk/samsung/clk-exynos4.c | 2 +- drivers/clk/samsung/clk-exynos5250.c | 2 +- drivers/clk/samsung/clk-exynos5420.c | 2 +- drivers/clk/samsung/clk-exynos5440.c | 2 +- drivers/clk/samsung/clk-s3c64xx.c | 2 +- drivers/clk/samsung/clk.c | 54 +----------------------------------- drivers/clk/samsung/clk.h | 4 +-- 7 files changed, 7 insertions(+), 61 deletions(-)
drivers/clk/samsung/clk-exynos4.c +1 -1
@@ -1174,7 +1174,7 @@ static void __init exynos4_clk_init(struct device_node *np,if (!reg_base)panic ("%s: failed to map registers\n" , __func__); -samsung_clk_init (np, reg_base, nr_clks,NULL ,0 ,NULL ,0 ); +samsung_clk_init (np, reg_base, nr_clks); samsung_clk_of_register_fixed_ext(exynos4_fixed_rate_ext_clks, ARRAY_SIZE(exynos4_fixed_rate_ext_clks),
drivers/clk/samsung/clk-exynos5250.c +1 -1
@@ -699,7 +699,7 @@ static void __init exynos5250_clk_init(struct device_node *np)panic ("%s: unable to determine soc\n" , __func__); } -samsung_clk_init (np, reg_base, nr_clks,NULL ,0 ,NULL ,0 ); +samsung_clk_init (np, reg_base, nr_clks);samsung_clk_of_register_fixed_ext (exynos5250_fixed_rate_ext_clks,ARRAY_SIZE (exynos5250_fixed_rate_ext_clks), ext_clk_match);
drivers/clk/samsung/clk-exynos5420.c +1 -1
@@ -816,7 +816,7 @@ static void __init exynos5420_clk_init(struct device_node *np)panic ("%s: unable to determine soc\n" , __func__); } -samsung_clk_init (np, reg_base, nr_clks,NULL ,0 ,NULL ,0 ); +samsung_clk_init (np, reg_base, nr_clks);samsung_clk_of_register_fixed_ext (exynos5420_fixed_rate_ext_clks,ARRAY_SIZE (exynos5420_fixed_rate_ext_clks), ext_clk_match);
drivers/clk/samsung/clk-exynos5440.c +1 -1
@@ -114,7 +114,7 @@ static void __init exynos5440_clk_init(struct device_node *np)return ; } -samsung_clk_init (np, reg_base, nr_clks,NULL ,0 ,NULL ,0 ); +samsung_clk_init (np, reg_base, nr_clks);samsung_clk_of_register_fixed_ext (exynos5440_fixed_rate_ext_clks,ARRAY_SIZE (exynos5440_fixed_rate_ext_clks), ext_clk_match);
drivers/clk/samsung/clk-s3c64xx.c +1 -1
@@ -465,7 +465,7 @@ void __init s3c64xx_clk_init(struct device_node *np, unsigned long xtal_f,panic ("%s: failed to map registers\n" , __func__); } -samsung_clk_init (np, reg_base,NR_CLKS ,NULL ,0 ,NULL ,0 ); +samsung_clk_init (np, reg_base,NR_CLKS );/* Register external clocks. */ if (!np)
drivers/clk/samsung/clk.c +1 -53
71 lines not on this page · raw message
drivers/clk/samsung/clk.h +1 -3
@@ -313,9 +313,7 @@ struct samsung_pll_clock { _lock, _con, _rtable, _alias)extern void __init samsung_clk_init (struct device_node *np,void __iomem *base, -unsigned long nr_clks,unsigned long *rdump, -unsigned long nr_rdump,unsigned long *soc_rdump, -unsigned long nr_soc_rdump); +unsigned long nr_clks); extern void __init samsung_clk_of_register_fixed_ext( struct samsung_fixed_rate_clock *fixed_rate_clk, unsigned int nr_fixed_rate_clk,
Signature · 1 line
1.8.3.2
PATCH 8/9 clk: samsung: exynos4: Add remaining suspend/resume handling
In reply to Tomasz FigaAs of now, part of Exynos4 clock suspend/resume handling is located in mach-exynos/pm.c, which is not where code accessing CMU registers should reside.
This patch implements all the necessary suspend/resume handling code in Exynos4 clock driver to allow dropping that old code.
--- drivers/clk/samsung/clk-exynos4.c | 74 ++++++++++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 8 deletions(-)
drivers/clk/samsung/clk-exynos4.c +66 -8
@@ -201,6 +201,7 @@ static enum exynos4_soc exynos4_soc;#ifdef CONFIG_PM_SLEEP static struct samsung_clk_reg_dump *exynos4_save_common;static struct samsung_clk_reg_dump *exynos4_save_soc; +static struct samsung_clk_reg_dump *exynos4_save_pll;/* * list of controller registers to be saved and restored during a
@@ -226,6 +227,17 @@ static unsigned long exynos4x12_clk_save[] __initdata = { E4X12_MPLL_CON0, }; +static unsigned long exynos4_clk_pll_regs[]__initdata = { +EPLL_LOCK , +VPLL_LOCK , +EPLL_CON0 , +EPLL_CON1 , +EPLL_CON2 , +VPLL_CON0 , +VPLL_CON1 , +VPLL_CON2 , +}; +static unsigned long exynos4_clk_regs[]__initdata = {SRC_LEFTBUS ,DIV_LEFTBUS ,
@@ -233,12 +245,6 @@ static unsigned long exynos4_clk_regs[] __initdata = {SRC_RIGHTBUS ,DIV_RIGHTBUS ,GATE_IP_RIGHTBUS , -EPLL_CON0 , -EPLL_CON1 , -EPLL_CON2 , -VPLL_CON0 , -VPLL_CON1 , -VPLL_CON2 ,SRC_TOP0 ,SRC_TOP1 , SRC_CAM,
@@ -299,23 +305,68 @@ static unsigned long exynos4_clk_regs[] __initdata = { GATE_IP_CPU, }; +static const struct samsung_clk_reg_dump src_mask_suspend[] = { + { .offset =SRC_MASK_TOP , .value =0x00000001 , }, + { .offset =SRC_MASK_CAM , .value =0x11111111 , }, + { .offset =SRC_MASK_TV , .value =0x00000111 , }, + { .offset =SRC_MASK_LCD0 , .value =0x00001111 , }, + { .offset =SRC_MASK_MAUDIO , .value =0x00000001 , }, + { .offset =SRC_MASK_FSYS , .value =0x01011111 , }, + { .offset =SRC_MASK_PERIL0 , .value =0x01111111 , }, + { .offset =SRC_MASK_PERIL1 , .value =0x01110111 , }, + { .offset =SRC_MASK_DMC , .value =0x00010000 , }, +}; + +static const struct samsung_clk_reg_dump src_mask_suspend_e4210[] = { + { .offset =E4210_SRC_MASK_LCD1 , .value =0x00001111 , }, +}; + +#define PLL_ENABLED (1 << 31) +#define PLL_LOCKED (1 << 29) + +static void exynos4_clk_wait_for_pll (u32 reg) +{ +u32 pll_con; + + pll_con =readl (reg_base + reg); +if (!(pll_con &PLL_ENABLED )) +return ; + +while (!(pll_con &PLL_LOCKED )) { +cpu_relax (); + pll_con =readl (reg_base + reg); + } +} +static int exynos4_clk_suspend (void ) {samsung_clk_save (reg_base, exynos4_save_common,ARRAY_SIZE (exynos4_clk_regs)); -if (exynos4_soc ==EXYNOS4210 ) +if (exynos4_soc ==EXYNOS4210 ) {samsung_clk_save (reg_base, exynos4_save_soc,ARRAY_SIZE (exynos4210_clk_save)); -else +samsung_clk_restore (reg_base, src_mask_suspend_e4210, +ARRAY_SIZE (src_mask_suspend_e4210)); + }else {samsung_clk_save (reg_base, exynos4_save_soc,ARRAY_SIZE (exynos4x12_clk_save)); + } + +samsung_clk_restore (reg_base, src_mask_suspend, +ARRAY_SIZE (src_mask_suspend));return 0 ; }static void exynos4_clk_resume (void ) { +samsung_clk_restore (reg_base, exynos4_save_pll, +ARRAY_SIZE (exynos4_clk_pll_regs)); + +exynos4_clk_wait_for_pll (EPLL_CON0 ); +exynos4_clk_wait_for_pll (VPLL_CON0 ); +samsung_clk_restore (reg_base, exynos4_save_common,ARRAY_SIZE (exynos4_clk_regs));
@@ -350,9 +401,16 @@ static void exynos4_clk_sleep_init(void)if (!exynos4_save_soc) goto err_common; + exynos4_save_pll =samsung_clk_alloc_reg_dump (exynos4_clk_pll_regs, +ARRAY_SIZE (exynos4_clk_pll_regs)); +if (!exynos4_save_pll) + goto err_soc; +register_syscore_ops (&exynos4_clk_syscore_ops);return ; +err_soc: +kfree (exynos4_save_soc); err_common:kfree (exynos4_save_common); err_warn:
Signature · 1 line
1.8.3.2
PATCH 9/9 ARM: EXYNOS: pm: Drop legacy Exynos4 clock suspend/resume code
In reply to Tomasz FigaAll the suspend/resume handling is already implemented in Exynos4 clock driver, so this legacy code can be safely dropped.
--- arch/arm/mach-exynos/pm.c | 125 +--------------------------------------------- 1 file changed, 2 insertions(+), 123 deletions(-)
arch/arm/mach-exynos/pm.c +2 -123
@@ -30,38 +30,11 @@#include <plat/regs-srom.h> #include <mach/regs-irq.h> -#include <mach/regs-clock.h> #include <mach/regs-pmu.h> #include <mach/pm-core.h> #include "common.h" -static struct sleep_save exynos4_set_clksrc[] = { - { .reg =EXYNOS4_CLKSRC_MASK_TOP , .val =0x00000001 , }, - { .reg =EXYNOS4_CLKSRC_MASK_CAM , .val =0x11111111 , }, - { .reg =EXYNOS4_CLKSRC_MASK_TV , .val =0x00000111 , }, - { .reg =EXYNOS4_CLKSRC_MASK_LCD0 , .val =0x00001111 , }, - { .reg =EXYNOS4_CLKSRC_MASK_MAUDIO , .val =0x00000001 , }, - { .reg =EXYNOS4_CLKSRC_MASK_FSYS , .val =0x01011111 , }, - { .reg =EXYNOS4_CLKSRC_MASK_PERIL0 , .val =0x01111111 , }, - { .reg =EXYNOS4_CLKSRC_MASK_PERIL1 , .val =0x01110111 , }, - { .reg =EXYNOS4_CLKSRC_MASK_DMC , .val =0x00010000 , }, -}; - -static struct sleep_save exynos4210_set_clksrc[] = { - { .reg =EXYNOS4210_CLKSRC_MASK_LCD1 , .val =0x00001111 , }, -}; - -static struct sleep_save exynos4_epll_save[] = { -SAVE_ITEM (EXYNOS4_EPLL_CON0 ), -SAVE_ITEM (EXYNOS4_EPLL_CON1 ), -}; - -static struct sleep_save exynos4_vpll_save[] = { -SAVE_ITEM (EXYNOS4_VPLL_CON0 ), -SAVE_ITEM (EXYNOS4_VPLL_CON1 ), -}; -static struct sleep_save exynos5_sys_save[] = {SAVE_ITEM (EXYNOS5_SYS_I2C_CFG ), };
@@ -101,10 +74,7 @@ static void exynos_pm_prepare(void)s3c_pm_do_save (exynos_core_save,ARRAY_SIZE (exynos_core_save)); -if (!soc_is_exynos5250 ()) { -s3c_pm_do_save (exynos4_epll_save,ARRAY_SIZE (exynos4_epll_save)); -s3c_pm_do_save (exynos4_vpll_save,ARRAY_SIZE (exynos4_vpll_save)); - }else { +if (soc_is_exynos5250 ()) {s3c_pm_do_save (exynos5_sys_save,ARRAY_SIZE (exynos5_sys_save));/* Disable USE_RETENTION of JPEG_MEM_OPTION */ tmp =__raw_readl (EXYNOS5_JPEG_MEM_OPTION );
@@ -120,15 +90,6 @@ static void exynos_pm_prepare(void)/* ensure at least INFORM0 has the resume address */ __raw_writel (virt_to_phys (s3c_cpu_resume),S5P_INFORM0 ); - -/* Before enter central sequence mode, clock src register have to set */ - -if (!soc_is_exynos5250 ()) -s3c_pm_do_restore_core (exynos4_set_clksrc,ARRAY_SIZE (exynos4_set_clksrc)); - -if (soc_is_exynos4210 ()) -s3c_pm_do_restore_core (exynos4210_set_clksrc,ARRAY_SIZE (exynos4210_set_clksrc)); - }static int exynos_pm_add (struct device *dev,struct subsys_interface *sif)
@@ -139,73 +100,6 @@ static int exynos_pm_add(struct device *dev, struct subsys_interface *sif)return 0 ; } -static unsigned long pll_base_rate; - -static void exynos4_restore_pll (void ) -{ -unsigned long pll_con, locktime, lockcnt; -unsigned long pll_in_rate; -unsigned int p_div, epll_wait =0 , vpll_wait =0 ; - -if (pll_base_rate ==0 ) -return ; - - pll_in_rate = pll_base_rate; - -/* EPLL */ - pll_con = exynos4_epll_save[0 ].val; - -if (pll_con & (1 <<31 )) { - pll_con &= (PLL46XX_PDIV_MASK <<PLL46XX_PDIV_SHIFT ); - p_div = (pll_con >>PLL46XX_PDIV_SHIFT ); - - pll_in_rate /=1000000 ; - - locktime = (3000 / pll_in_rate) * p_div; - lockcnt = locktime *10000 / (10000 / pll_in_rate); - -__raw_writel (lockcnt,EXYNOS4_EPLL_LOCK ); - -s3c_pm_do_restore_core (exynos4_epll_save, -ARRAY_SIZE (exynos4_epll_save)); - epll_wait =1 ; - } - - pll_in_rate = pll_base_rate; - -/* VPLL */ - pll_con = exynos4_vpll_save[0 ].val; - -if (pll_con & (1 <<31 )) { - pll_in_rate /=1000000 ; -/* 750us */ - locktime =750 ; - lockcnt = locktime *10000 / (10000 / pll_in_rate); - -__raw_writel (lockcnt,EXYNOS4_VPLL_LOCK ); - -s3c_pm_do_restore_core (exynos4_vpll_save, -ARRAY_SIZE (exynos4_vpll_save)); - vpll_wait =1 ; - } - -/* Wait PLL locking */ - -do { -if (epll_wait) { - pll_con =__raw_readl (EXYNOS4_EPLL_CON0 ); -if (pll_con & (1 <<EXYNOS4_EPLLCON0_LOCKED_SHIFT )) - epll_wait =0 ; - } - -if (vpll_wait) { - pll_con =__raw_readl (EXYNOS4_VPLL_CON0 ); -if (pll_con & (1 <<EXYNOS4_VPLLCON0_LOCKED_SHIFT )) - vpll_wait =0 ; - } - }while (epll_wait || vpll_wait); -} -static struct subsys_interface exynos_pm_interface = { .name ="exynos_pm" , .subsys = &exynos_subsys,
@@ -257,7 +151,6 @@ int s3c_irq_wake(struct irq_data *data, unsigned int state)static __init int exynos_pm_drvinit (void ) {const struct exynos_wkup_irq *wkup_irq; -struct clk *pll_base;unsigned int tmp;if (soc_is_exynos5440 ())
@@ -283,15 +176,6 @@ static __init int exynos_pm_drvinit(void) tmp |= ((0xFF <<8 ) | (0x1F <<1 ));__raw_writel (tmp,S5P_WAKEUP_MASK ); -if (!soc_is_exynos5250 ()) { - pll_base =clk_get (NULL ,"xtal" ); - -if (!IS_ERR (pll_base)) { - pll_base_rate =clk_get_rate (pll_base); -clk_put (pll_base); - } - } -return subsys_interface_register (&exynos_pm_interface); }arch_initcall (exynos_pm_drvinit);
@@ -375,13 +259,8 @@ static void exynos_pm_resume(void)s3c_pm_do_restore_core (exynos_core_save,ARRAY_SIZE (exynos_core_save)); -if (!soc_is_exynos5250 ()) { -exynos4_restore_pll (); - -#ifdef CONFIG_SMP +if (IS_ENABLED (CONFIG_SMP ) && !soc_is_exynos5250 ())scu_enable (S5P_VA_SCU ); -#endif - } early_wakeup:
Signature · 1 line
1.8.3.2
cover Samsung clock PM consolidation part 1
In reply to Tomasz FigaHi Tomasz,
Are you planning to respin this series? It is not applying on mike's for-next.
Regards,
Rahul Sharma.
Quoted 41 lines · Tomasz Figa
This series reworks suspend/resume handling of Samsung clock drivers to cover more SoC specific aspects that are beyond simple register save and restore. The goal is to have all the suspend/resume code that touches the clock controller in single place, which is the clock driver.
On Exynos4210-based Trats, Exynos4412-based Trats2 and Exynos5250-based Arndale boards (except suspend/resume, which is broken because of unrelated reasons):
Tested-by Tomasz Figa <[email protected]>Tomasz Figa (9):
clk: exynos4: Remove remnants of non-DT support
clk: samsung: Provide common helpers for register save/restore
clk: samsung: exynos4: Move suspend/resume handling to SoC driver
clk: samsung: exynos5250: Move suspend/resume handling to SoC driver
clk: samsung: exynos5420: Move suspend/resume handling to SoC driver
clk: samsung: s3c64xx: Move suspend/resume handling to SoC driver
clk: samsung: Drop old suspend/resume code
clk: samsung: exynos4: Add remaining suspend/resume handling
ARM: EXYNOS: pm: Drop legacy Exynos4 clock suspend/resume codearch/arm/mach-exynos/pm.c | 125 +------------------------- drivers/clk/samsung/clk-exynos4.c | 170 ++++++++++++++++++++++++++++++----- drivers/clk/samsung/clk-exynos5250.c | 49 ++++++++-- drivers/clk/samsung/clk-exynos5420.c | 49 ++++++++-- drivers/clk/samsung/clk-exynos5440.c | 2 +- drivers/clk/samsung/clk-s3c64xx.c | 79 +++++++++++++--- drivers/clk/samsung/clk.c | 71 ++++++--------- drivers/clk/samsung/clk.h | 14 ++- 8 files changed, 346 insertions(+), 213 deletions(-)--
1.8.3.2_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
cover Samsung clock PM consolidation part 1
Hi Rahul,
Quoted 3 lines · Rahul Sharma
Hi Tomasz,
Are you planning to respin this series? It is not applying on mike's for-next.
Yes, I have already rebased it and was planning to resend it later today or tomorrow after checking one more thing.
Best regards,
Tomasz