Skip to contentSkip to conversation

clk: pass the 'flags' parameter to clk_fixed()

RFC In review Antony Pavlov 2 participants 4 messages Dec 6, 2012

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

cover clk: pass the 'flags' parameter to clk_fixed()

The 'flags' parameter make possible creation of a 'CLK_ALWAYS_ENABLED' clock without code overhead.

So it is possible to create clock this way
clk_fixed("main_clock", 24000000, 0);
or that way
clk_fixed("main_clock", 24000000, CLK_ALWAYS_ENABLED);

I can't check my clk_fixed-related changes for ARM-based boards, so please consider, do we need CLK_ALWAYS_ENABLED in the patch '[RFC 2/2]' or we need '0'.

[RFC 1/2] clk: pass the 'flags' parameter to clk_fixed() [RFC 2/2] ARM: pass the 'flags'=0 parameter to clk_fixed()

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

RFC 1/2 clk: pass the 'flags' parameter to clk_fixed()

The 'flags' parameter make possible creation of a 'CLK_ALWAYS_ENABLED' clock without code overhead.

---
 drivers/clk/clk-fixed.c |    3 ++-
 include/linux/clk.h     |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/clk/clk-fixed.c +2 -1
index fa89cb2..5ac5663 100644
@@ -36,7 +36,7 @@ struct clk_ops clk_fixed_ops = {
 	.recalc_rate = clk_fixed_recalc_rate,
 };
 
-struct clk *clk_fixed(const char *name, int rate)
+struct clk *clk_fixed(const char *name, int rate, unsigned long flags)
 {
 	struct clk_fixed *fix = xzalloc(sizeof *fix);
 	int ret;
@@ -44,6 +44,7 @@ struct clk *clk_fixed(const char *name, int rate)
 	fix->rate = rate;
 	fix->clk.ops = &clk_fixed_ops;
 	fix->clk.name = name;
+	fix->clk.flags = flags;
 
 	ret = clk_register(&fix->clk);
 	if (ret) {
include/linux/clk.h +1 -1
index 1030b50..9d89a21 100644
@@ -184,7 +184,7 @@ struct clk {
 
 #define CLK_ALWAYS_ENABLED	(1 << 0)
 
-struct clk *clk_fixed(const char *name, int rate);
+struct clk *clk_fixed(const char *name, int rate, unsigned long flags);
 struct clk *clk_divider(const char *name, const char *parent,
 		void __iomem *reg, u8 shift, u8 width);
 struct clk *clk_fixed_factor(const char *name,
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

RFC 2/2 ARM: pass the 'flags'=0 parameter to clk_fixed()

In reply to Antony Pavlov
---
 arch/arm/mach-bcm2835/core.c  |    6 +++---
 arch/arm/mach-imx/clk-imx1.c  |    6 +++---
 arch/arm/mach-imx/clk-imx21.c |    4 ++--
 arch/arm/mach-imx/clk-imx25.c |    4 ++--
 arch/arm/mach-imx/clk-imx27.c |    6 +++---
 arch/arm/mach-imx/clk-imx31.c |    4 ++--
 arch/arm/mach-imx/clk-imx35.c |    2 +-
 arch/arm/mach-imx/clk-imx5.c  |   10 +++++-----
 arch/arm/mach-imx/clk-imx6.c  |    8 ++++----
 9 files changed, 25 insertions(+), 25 deletions(-)
arch/arm/mach-bcm2835/core.c +3 -3
index b0fec8b..01672a6 100644
@@ -42,9 +42,9 @@ static int bcm2835_clk_init(void)
 {
 	int ret;
 
-	clks[dummy] = clk_fixed("dummy", 0);
-	clks[clk_ref_3] = clk_fixed("ref3", 3 * 1000 * 1000);
-	clks[clk_ref_1] = clk_fixed("ref1", 1 * 1000 * 1000);
+	clks[dummy] = clk_fixed("dummy", 0, 0);
+	clks[clk_ref_3] = clk_fixed("ref3", 3 * 1000 * 1000, 0);
+	clks[clk_ref_1] = clk_fixed("ref1", 1 * 1000 * 1000, 0);
 
 	ret = clk_register_clkdev(clks[dummy], "apb_pclk", NULL);
 	if (ret)
arch/arm/mach-imx/clk-imx1.c +3 -3
index 0d04a92..f221342 100644
@@ -55,9 +55,9 @@ static const char *clko_sel_clks[] = {
 
 int __init mx1_clocks_init(void __iomem *regs, unsigned long fref)
 {
-	clks[dummy] = clk_fixed("dummy", 0);
-	clks[clk32] = clk_fixed("clk32", fref);
-	clks[clk16m] = clk_fixed("clk16m", 16000000);
+	clks[dummy] = clk_fixed("dummy", 0, 0);
+	clks[clk32] = clk_fixed("clk32", fref, 0);
+	clks[clk16m] = clk_fixed("clk16m", 16000000, 0);
 	clks[clk32_premult] = imx_clk_fixed_factor("clk32_premult", "clk32", 512, 1);
 	clks[prem] = imx_clk_mux("prem", regs + CCM_CSCR, 16, 1, prem_sel_clks,
 			ARRAY_SIZE(prem_sel_clks));
arch/arm/mach-imx/clk-imx21.c +2 -2
index 9e7af81..1ce1efe 100644
@@ -80,8 +80,8 @@ static int imx21_ccm_probe(struct device_d *dev)
 			(1 << 28) | (1 << 29) | (1 << 30) | (1 << 31),
 			base + CCM_PCCR1);
 
-	clks[ckil] = clk_fixed("ckil", lref);
-	clks[ckih] = clk_fixed("ckih", href);
+	clks[ckil] = clk_fixed("ckil", lref, 0);
+	clks[ckih] = clk_fixed("ckih", href, 0);
 	clks[fpm] = imx_clk_fixed_factor("fpm", "ckil", 512, 1);
 	clks[mpll_sel] = imx_clk_mux("mpll_sel", base + CCM_CSCR, 16, 1, mpll_sel_clks,
 			ARRAY_SIZE(mpll_sel_clks));
arch/arm/mach-imx/clk-imx25.c +2 -2
index 38f15a6..e459218 100644
@@ -90,8 +90,8 @@ static int imx25_ccm_probe(struct device_d *dev)
 			(1 << 15) | (1 << 16) | (1 << 17) | (1 << 18),
 			base + CCM_CGCR2);
 
-	clks[dummy] = clk_fixed("dummy", 0);
-	clks[osc] = clk_fixed("osc", 24000000);
+	clks[dummy] = clk_fixed("dummy", 0, 0);
+	clks[osc] = clk_fixed("osc", 24000000, 0);
 	clks[mpll] = imx_clk_pllv1("mpll", "osc", base + CCM_MPCTL);
 	clks[upll] = imx_clk_pllv1("upll", "osc", base + CCM_UPCTL);
 	clks[mpll_cpu_3_4] = imx_clk_fixed_factor("mpll_cpu_3_4", "mpll", 3, 4);
arch/arm/mach-imx/clk-imx27.c +3 -3
index 222d2a6..854dab9 100644
@@ -149,9 +149,9 @@ static int imx27_ccm_probe(struct device_d *dev)
 			PCCR1_UART4_EN | PCCR1_UART3_EN | PCCR1_UART2_EN | PCCR1_UART1_EN,
 			base + CCM_PCCR1);
 
-	clks[dummy] = clk_fixed("dummy", 0);
-	clks[ckih] = clk_fixed("ckih", 26000000);
-	clks[ckil] = clk_fixed("ckil", 32768);
+	clks[dummy] = clk_fixed("dummy", 0, 0);
+	clks[ckih] = clk_fixed("ckih", 26000000, 0);
+	clks[ckil] = clk_fixed("ckil", 32768, 0);
 	clks[mpll] = imx_clk_pllv1("mpll", "ckih", base + CCM_MPCTL0);
 	clks[spll] = imx_clk_pllv1("spll", "ckih", base + CCM_SPCTL0);
 	clks[mpll_main2] = imx_clk_fixed_factor("mpll_main2", "mpll", 2, 3);
arch/arm/mach-imx/clk-imx31.c +2 -2
index aa1b652..37a092b 100644
@@ -88,8 +88,8 @@ static int imx31_ccm_probe(struct device_d *dev)
 	writel(0xffffffff, base + CCM_CGR1);
 	writel(0xffffffff, base + CCM_CGR2);
 
-	clks[ckih] = clk_fixed("ckih", 26000000);
-	clks[ckil] = clk_fixed("ckil", 32768);
+	clks[ckih] = clk_fixed("ckih", 26000000, 0);
+	clks[ckil] = clk_fixed("ckil", 32768, 0);
 	clks[mpll] = imx_clk_pllv1("mpll", "ckih", base + CCM_MPCTL);
 	clks[spll] = imx_clk_pllv1("spll", "ckih", base + CCM_SRPCTL);
 	clks[upll] = imx_clk_pllv1("upll", "ckih", base + CCM_UPCTL);
arch/arm/mach-imx/clk-imx35.c +1 -1
index 5b5a9e7..886e262 100644
@@ -114,7 +114,7 @@ static int imx35_ccm_probe(struct device_d *dev)
 		aad = &clk_consumer[0];
 	}
 
-	clks[ckih] = clk_fixed("ckih", 24000000);
+	clks[ckih] = clk_fixed("ckih", 24000000, 0);
 	clks[mpll] = imx_clk_pllv1("mpll", "ckih", base + CCM_MPCTL);
 	clks[ppll] = imx_clk_pllv1("ppll", "ckih", base + CCM_PPCTL);
 
arch/arm/mach-imx/clk-imx5.c +5 -5
index 050842d..f7ee56c 100644
@@ -137,11 +137,11 @@ static void __init mx5_clocks_common_init(void __iomem *base, unsigned long rate
 	writel(0xffffffff, base + CCM_CCGR6);
 	writel(0xffffffff, base + CCM_CCGR7);
 
-	clks[dummy] = clk_fixed("dummy", 0);
-	clks[ckil] = clk_fixed("ckil", rate_ckil);
-	clks[osc] = clk_fixed("osc", rate_osc);
-	clks[ckih1] = clk_fixed("ckih1", rate_ckih1);
-	clks[ckih2] = clk_fixed("ckih2", rate_ckih2);
+	clks[dummy] = clk_fixed("dummy", 0, 0);
+	clks[ckil] = clk_fixed("ckil", rate_ckil, 0);
+	clks[osc] = clk_fixed("osc", rate_osc, 0);
+	clks[ckih1] = clk_fixed("ckih1", rate_ckih1, 0);
+	clks[ckih2] = clk_fixed("ckih2", rate_ckih2, 0);
 
 	clks[lp_apm] = imx_clk_mux("lp_apm", base + CCM_CCSR, 9, 1,
 				lp_apm_sel, ARRAY_SIZE(lp_apm_sel));
arch/arm/mach-imx/clk-imx6.c +4 -4
index a1da47a..e027578 100644
@@ -181,10 +181,10 @@ static int imx6_ccm_probe(struct device_d *dev)
 
 	base = anatop_base;
 
-	clks[dummy] = clk_fixed("dummy", 0);
-	clks[ckil] = clk_fixed("ckil", ckil_rate);
-	clks[ckih] = clk_fixed("ckih", ckih_rate);
-	clks[osc] = clk_fixed("osc", osc_rate);
+	clks[dummy] = clk_fixed("dummy", 0, 0);
+	clks[ckil] = clk_fixed("ckil", ckil_rate, 0);
+	clks[ckih] = clk_fixed("ckih", ckih_rate, 0);
+	clks[osc] = clk_fixed("osc", osc_rate, 0);
 
 	/*                   type                               name            parent_name base       gate_mask div_mask */
 	clks[pll1_sys]      = imx_clk_pllv3(IMX_PLLV3_SYS,	"pll1_sys",	"osc", base,        0x2000,   0x7f);
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
maintainer
#3 lore raw
In reply to Antony Pavlov

Hi Antony,

Quoted 11 lines · Antony Pavlov

The 'flags' parameter make possible creation of a 'CLK_ALWAYS_ENABLED' clock without code overhead.

So it is possible to create clock this way
clk_fixed("main_clock", 24000000, 0);
or that way
clk_fixed("main_clock", 24000000, CLK_ALWAYS_ENABLED);

I can't check my clk_fixed-related changes for ARM-based boards, so please consider, do we need CLK_ALWAYS_ENABLED in the patch '[RFC 2/2]' or we need '0'.

Nice move to be able to pass the flags to clk_fixed. For this special clock and flag we won't need it though: The fixed clock by definition always is enabled. We should rather set this flag unconditionally for them.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox