* [PATCH 0/4] Use clock functions also for clk_h and clk_p on S3C2443/2416
@ 2012-03-03 21:14 Heiko Stübner
2012-03-03 21:15 ` [PATCH 1/4] ARM: S3C24XX: remove XXX_setup_clocks method from S3C2443 Heiko Stübner
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Heiko Stübner @ 2012-03-03 21:14 UTC (permalink / raw)
To: linux-arm-kernel
This series modifies the clock init in common-s3c2443 to use the
struct clk operations also for clk_p and clk_h whose values were until
now set statically in s3c24xx_setup_clocks - a function more suited to
the earlier S3C-SoCs.
In the end it makes the code (hopefully) easier to read, as strange
divisions through register values get replaced by simply clk_get_rate
calls.
To apply on top of the current s3c24xx consolidation.
Heiko Stuebner (4):
ARM: S3C24XX: remove XXX_setup_clocks method from S3C2443
ARM: S3C24XX: add get_rate for clk_h on S3C2416/2443
ARM: S3C24XX: add get_rate for clk_p on S3C2416/2443
ARM: S3C24XX: remove call to s3c24xx_setup_clocks
arch/arm/mach-s3c24xx/clock-s3c2443.c | 7 ---
arch/arm/mach-s3c24xx/common-s3c2443.c | 70 +++++++++++++++++++---------
arch/arm/plat-samsung/include/plat/clock.h | 1 -
3 files changed, 48 insertions(+), 30 deletions(-)
--
1.7.2.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] ARM: S3C24XX: remove XXX_setup_clocks method from S3C2443
2012-03-03 21:14 [PATCH 0/4] Use clock functions also for clk_h and clk_p on S3C2443/2416 Heiko Stübner
@ 2012-03-03 21:15 ` Heiko Stübner
2012-03-03 21:16 ` [PATCH 2/4] ARM: S3C24XX: add get_rate for clk_h on S3C2416/2443 Heiko Stübner
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Heiko Stübner @ 2012-03-03 21:15 UTC (permalink / raw)
To: linux-arm-kernel
s3c2443_common_setup_clocks is always called through
s3c2443_common_init_clocks, so there is no need to call it separately.
It was also called twice through this separate call.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
arch/arm/mach-s3c24xx/clock-s3c2443.c | 7 -------
arch/arm/plat-samsung/include/plat/clock.h | 1 -
2 files changed, 0 insertions(+), 8 deletions(-)
diff --git a/arch/arm/mach-s3c24xx/clock-s3c2443.c b/arch/arm/mach-s3c24xx/clock-s3c2443.c
index 6dde269..efb3ac3 100644
--- a/arch/arm/mach-s3c24xx/clock-s3c2443.c
+++ b/arch/arm/mach-s3c24xx/clock-s3c2443.c
@@ -179,11 +179,6 @@ static struct clk *clks[] __initdata = {
&clk_hsmmc,
};
-void __init_or_cpufreq s3c2443_setup_clocks(void)
-{
- s3c2443_common_setup_clocks(s3c2443_get_mpll);
-}
-
void __init s3c2443_init_clocks(int xtal)
{
unsigned long epllcon = __raw_readl(S3C2443_EPLLCON);
@@ -196,8 +191,6 @@ void __init s3c2443_init_clocks(int xtal)
armdiv, ARRAY_SIZE(armdiv),
S3C2443_CLKDIV0_ARMDIV_MASK);
- s3c2443_setup_clocks();
-
s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
diff --git a/arch/arm/plat-samsung/include/plat/clock.h b/arch/arm/plat-samsung/include/plat/clock.h
index 3b5a9dc..a62753d 100644
--- a/arch/arm/plat-samsung/include/plat/clock.h
+++ b/arch/arm/plat-samsung/include/plat/clock.h
@@ -118,7 +118,6 @@ extern void s3c24xx_setup_clocks(unsigned long fclk,
extern void s3c2410_setup_clocks(void);
extern void s3c2412_setup_clocks(void);
extern void s3c244x_setup_clocks(void);
-extern void s3c2443_setup_clocks(void);
/* S3C2410 specific clock functions */
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] ARM: S3C24XX: add get_rate for clk_h on S3C2416/2443
2012-03-03 21:14 [PATCH 0/4] Use clock functions also for clk_h and clk_p on S3C2443/2416 Heiko Stübner
2012-03-03 21:15 ` [PATCH 1/4] ARM: S3C24XX: remove XXX_setup_clocks method from S3C2443 Heiko Stübner
@ 2012-03-03 21:16 ` Heiko Stübner
2012-03-03 21:16 ` [PATCH 3/4] ARM: S3C24XX: add get_rate for clk_p " Heiko Stübner
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Heiko Stübner @ 2012-03-03 21:16 UTC (permalink / raw)
To: linux-arm-kernel
Currently the rate of clk_h is calculated once and set through the
s3c24xx_setup_clocks call. As the clk_h is a child of the prediv
we can evaluate its divider and calculate the rate in get_rate.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
arch/arm/mach-s3c24xx/common-s3c2443.c | 31 ++++++++++++++++++++++---------
1 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-s3c24xx/common-s3c2443.c b/arch/arm/mach-s3c24xx/common-s3c2443.c
index 30a3019..39f9613 100644
--- a/arch/arm/mach-s3c24xx/common-s3c2443.c
+++ b/arch/arm/mach-s3c24xx/common-s3c2443.c
@@ -168,6 +168,25 @@ static struct clk clk_prediv = {
},
};
+/* hclk divider
+ *
+ * divides the prediv and provides the hclk.
+ */
+
+static unsigned long s3c2443_hclkdiv_getrate(struct clk *clk)
+{
+ unsigned long rate = clk_get_rate(clk->parent);
+ unsigned long clkdiv0 = __raw_readl(S3C2443_CLKDIV0);
+
+ clkdiv0 &= S3C2443_CLKDIV0_HCLKDIV_MASK;
+
+ return rate / (clkdiv0 + 1);
+}
+
+static struct clk_ops clk_h_ops = {
+ .get_rate = s3c2443_hclkdiv_getrate,
+};
+
/* armdiv
*
* this clock is sourced from msysclk and can have a number of
@@ -524,13 +543,6 @@ static struct clk hsmmc1_clk = {
.ctrlbit = S3C2443_HCLKCON_HSMMC,
};
-static inline unsigned long s3c2443_get_hdiv(unsigned long clkcon0)
-{
- clkcon0 &= S3C2443_CLKDIV0_HCLKDIV_MASK;
-
- return clkcon0 + 1;
-}
-
/* EPLLCON compatible enough to get on/off information */
void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll)
@@ -554,8 +566,7 @@ void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll)
clk_msysclk.clk.rate = pll;
fclk = clk_get_rate(&clk_armdiv);
- hclk = s3c2443_prediv_getrate(&clk_prediv);
- hclk /= s3c2443_get_hdiv(clkdiv0);
+ hclk = clk_get_rate(&clk_h);
pclk = hclk / ((clkdiv0 & S3C2443_CLKDIV0_HALF_PCLK) ? 2 : 1);
s3c24xx_setup_clocks(fclk, hclk, pclk);
@@ -621,6 +632,8 @@ void __init s3c2443_common_init_clocks(int xtal, pll_fn get_mpll,
/* s3c2443 parents h and p clocks from prediv */
clk_h.parent = &clk_prediv;
+ clk_h.ops = &clk_h_ops;
+
clk_p.parent = &clk_prediv;
clk_usb_bus.parent = &clk_usb_bus_host.clk;
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] ARM: S3C24XX: add get_rate for clk_p on S3C2416/2443
2012-03-03 21:14 [PATCH 0/4] Use clock functions also for clk_h and clk_p on S3C2443/2416 Heiko Stübner
2012-03-03 21:15 ` [PATCH 1/4] ARM: S3C24XX: remove XXX_setup_clocks method from S3C2443 Heiko Stübner
2012-03-03 21:16 ` [PATCH 2/4] ARM: S3C24XX: add get_rate for clk_h on S3C2416/2443 Heiko Stübner
@ 2012-03-03 21:16 ` Heiko Stübner
2012-03-03 21:18 ` [PATCH 4/4] ARM: S3C24XX: remove call to s3c24xx_setup_clocks Heiko Stübner
2012-03-07 11:17 ` [PATCH 0/4] Use clock functions also for clk_h and clk_p on S3C2443/2416 Kukjin Kim
4 siblings, 0 replies; 6+ messages in thread
From: Heiko Stübner @ 2012-03-03 21:16 UTC (permalink / raw)
To: linux-arm-kernel
Currently the rate of clk_p is calculated once and set through the
s3c24xx_setup_clocks call. As the clk_p is a child of clk_h we can
evaluate its divider and calculate the rate in get_rate.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
arch/arm/mach-s3c24xx/common-s3c2443.c | 28 ++++++++++++++++++++++++----
1 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-s3c24xx/common-s3c2443.c b/arch/arm/mach-s3c24xx/common-s3c2443.c
index 39f9613..6f3bcad 100644
--- a/arch/arm/mach-s3c24xx/common-s3c2443.c
+++ b/arch/arm/mach-s3c24xx/common-s3c2443.c
@@ -187,6 +187,25 @@ static struct clk_ops clk_h_ops = {
.get_rate = s3c2443_hclkdiv_getrate,
};
+/* pclk divider
+ *
+ * divides the hclk and provides the pclk.
+ */
+
+static unsigned long s3c2443_pclkdiv_getrate(struct clk *clk)
+{
+ unsigned long rate = clk_get_rate(clk->parent);
+ unsigned long clkdiv0 = __raw_readl(S3C2443_CLKDIV0);
+
+ clkdiv0 = ((clkdiv0 & S3C2443_CLKDIV0_HALF_PCLK) ? 1 : 0);
+
+ return rate / (clkdiv0 + 1);
+}
+
+static struct clk_ops clk_p_ops = {
+ .get_rate = s3c2443_pclkdiv_getrate,
+};
+
/* armdiv
*
* this clock is sourced from msysclk and can have a number of
@@ -549,7 +568,6 @@ void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll)
{
unsigned long epllcon = __raw_readl(S3C2443_EPLLCON);
unsigned long mpllcon = __raw_readl(S3C2443_MPLLCON);
- unsigned long clkdiv0 = __raw_readl(S3C2443_CLKDIV0);
struct clk *xtal_clk;
unsigned long xtal;
unsigned long pll;
@@ -567,7 +585,7 @@ void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll)
fclk = clk_get_rate(&clk_armdiv);
hclk = clk_get_rate(&clk_h);
- pclk = hclk / ((clkdiv0 & S3C2443_CLKDIV0_HALF_PCLK) ? 2 : 1);
+ pclk = clk_get_rate(&clk_p);
s3c24xx_setup_clocks(fclk, hclk, pclk);
@@ -630,11 +648,13 @@ void __init s3c2443_common_init_clocks(int xtal, pll_fn get_mpll,
nr_armdiv = nr_divs;
armdivmask = divmask;
- /* s3c2443 parents h and p clocks from prediv */
+ /* s3c2443 parents h clock from prediv */
clk_h.parent = &clk_prediv;
clk_h.ops = &clk_h_ops;
- clk_p.parent = &clk_prediv;
+ /* and p clock from h clock */
+ clk_p.parent = &clk_h;
+ clk_p.ops = &clk_p_ops;
clk_usb_bus.parent = &clk_usb_bus_host.clk;
clk_epll.parent = &clk_epllref.clk;
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] ARM: S3C24XX: remove call to s3c24xx_setup_clocks
2012-03-03 21:14 [PATCH 0/4] Use clock functions also for clk_h and clk_p on S3C2443/2416 Heiko Stübner
` (2 preceding siblings ...)
2012-03-03 21:16 ` [PATCH 3/4] ARM: S3C24XX: add get_rate for clk_p " Heiko Stübner
@ 2012-03-03 21:18 ` Heiko Stübner
2012-03-07 11:17 ` [PATCH 0/4] Use clock functions also for clk_h and clk_p on S3C2443/2416 Kukjin Kim
4 siblings, 0 replies; 6+ messages in thread
From: Heiko Stübner @ 2012-03-03 21:18 UTC (permalink / raw)
To: linux-arm-kernel
As the clocks can calculate their rate themself now, there is no
need to set it statically.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
arch/arm/mach-s3c24xx/common-s3c2443.c | 15 ++++-----------
1 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/arch/arm/mach-s3c24xx/common-s3c2443.c b/arch/arm/mach-s3c24xx/common-s3c2443.c
index 6f3bcad..4604315 100644
--- a/arch/arm/mach-s3c24xx/common-s3c2443.c
+++ b/arch/arm/mach-s3c24xx/common-s3c2443.c
@@ -571,9 +571,6 @@ void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll)
struct clk *xtal_clk;
unsigned long xtal;
unsigned long pll;
- unsigned long fclk;
- unsigned long hclk;
- unsigned long pclk;
int ptr;
xtal_clk = clk_get(NULL, "xtal");
@@ -582,17 +579,13 @@ void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll)
pll = get_mpll(mpllcon, xtal);
clk_msysclk.clk.rate = pll;
-
- fclk = clk_get_rate(&clk_armdiv);
- hclk = clk_get_rate(&clk_h);
- pclk = clk_get_rate(&clk_p);
-
- s3c24xx_setup_clocks(fclk, hclk, pclk);
+ clk_mpll.rate = pll;
printk("CPU: MPLL %s %ld.%03ld MHz, cpu %ld.%03ld MHz, mem %ld.%03ld MHz, pclk %ld.%03ld MHz\n",
(mpllcon & S3C2443_PLLCON_OFF) ? "off" : "on",
- print_mhz(pll), print_mhz(fclk),
- print_mhz(hclk), print_mhz(pclk));
+ print_mhz(pll), print_mhz(clk_get_rate(&clk_armdiv)),
+ print_mhz(clk_get_rate(&clk_h)),
+ print_mhz(clk_get_rate(&clk_p)));
for (ptr = 0; ptr < ARRAY_SIZE(clksrc_clks); ptr++)
s3c_set_clksrc(&clksrc_clks[ptr], true);
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 0/4] Use clock functions also for clk_h and clk_p on S3C2443/2416
2012-03-03 21:14 [PATCH 0/4] Use clock functions also for clk_h and clk_p on S3C2443/2416 Heiko Stübner
` (3 preceding siblings ...)
2012-03-03 21:18 ` [PATCH 4/4] ARM: S3C24XX: remove call to s3c24xx_setup_clocks Heiko Stübner
@ 2012-03-07 11:17 ` Kukjin Kim
4 siblings, 0 replies; 6+ messages in thread
From: Kukjin Kim @ 2012-03-07 11:17 UTC (permalink / raw)
To: linux-arm-kernel
On 03/03/12 13:14, Heiko St?bner wrote:
> This series modifies the clock init in common-s3c2443 to use the
> struct clk operations also for clk_p and clk_h whose values were until
> now set statically in s3c24xx_setup_clocks - a function more suited to
> the earlier S3C-SoCs.
>
> In the end it makes the code (hopefully) easier to read, as strange
> divisions through register values get replaced by simply clk_get_rate
> calls.
>
> To apply on top of the current s3c24xx consolidation.
>
OK, applied.
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <kgene.kim@samsung.com>, Senior Engineer,
SW Solution Development Team, Samsung Electronics Co., Ltd.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-03-07 11:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-03 21:14 [PATCH 0/4] Use clock functions also for clk_h and clk_p on S3C2443/2416 Heiko Stübner
2012-03-03 21:15 ` [PATCH 1/4] ARM: S3C24XX: remove XXX_setup_clocks method from S3C2443 Heiko Stübner
2012-03-03 21:16 ` [PATCH 2/4] ARM: S3C24XX: add get_rate for clk_h on S3C2416/2443 Heiko Stübner
2012-03-03 21:16 ` [PATCH 3/4] ARM: S3C24XX: add get_rate for clk_p " Heiko Stübner
2012-03-03 21:18 ` [PATCH 4/4] ARM: S3C24XX: remove call to s3c24xx_setup_clocks Heiko Stübner
2012-03-07 11:17 ` [PATCH 0/4] Use clock functions also for clk_h and clk_p on S3C2443/2416 Kukjin Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).