Skip to contentSkip to conversation

ARM: Add SPDIF support for EXYNOS4

PATCH New Naveen Krishna Chatradhi 4 participants 15 messages Jun 21, 2011 – Jul 20, 2011

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

v2 cover ARM: Add SPDIF support for EXYNOS4

o To Kukjin Kim, Sangbeom Kim, Jassi Brar and Seungwhan Youn

[PATCH v2 1/3] ARM: Samsung: Move duplicate code
o This is a prerequisite for 2/3 and 3/3 patches thus mentioned as "v2".
[PATCH v2 2/3] ARM: EXYNOS4: Add sclk_spdif clocks.
o v1 patch is https://patchwork.kernel.org/patch/867882/
[PATCH v2 3/3] ARM: EXYNOS4: Add EPLL clock operations
o v1 patch is https://patchwork.kernel.org/patch/867872/

Best Regards,
Naveen Krishna Chatradhi

#1 lore raw

PATCH v2 1/3 ARM: Samsung: Move duplicate code

Move the duplicated code for SPDIF ops from S5PV210 and S5PC100. So, the same can be used in EXYNOS4.

---
Note: Moved common code to plat-s5p, as suggested by Kukjin Kim.

 arch/arm/mach-s5pc100/clock.c              |   37 +---------------------------
 arch/arm/mach-s5pv210/clock.c              |   37 +---------------------------
 arch/arm/plat-s5p/clock.c                  |   35 ++++++++++++++++++++++++++
 arch/arm/plat-s5p/include/plat/s5p-clock.h |    5 ++++
 4 files changed, 42 insertions(+), 72 deletions(-)
arch/arm/mach-s5pc100/clock.c +1 -36
index cd248e6..ff5cbb3 100644
@@ -910,47 +910,12 @@ struct clksrc_sources clk_src_sclk_spdif = {
 	.nr_sources	= ARRAY_SIZE(clk_sclk_spdif_list),
 };
 
-static int s5pc100_spdif_set_rate(struct clk *clk, unsigned long rate)
-{
-	struct clk *pclk;
-	int ret;
-
-	pclk = clk_get_parent(clk);
-	if (IS_ERR(pclk))
-		return -EINVAL;
-
-	ret = pclk->ops->set_rate(pclk, rate);
-	clk_put(pclk);
-
-	return ret;
-}
-
-static unsigned long s5pc100_spdif_get_rate(struct clk *clk)
-{
-	struct clk *pclk;
-	int rate;
-
-	pclk = clk_get_parent(clk);
-	if (IS_ERR(pclk))
-		return -EINVAL;
-
-	rate = pclk->ops->get_rate(clk);
-	clk_put(pclk);
-
-	return rate;
-}
-
-static struct clk_ops s5pc100_sclk_spdif_ops = {
-	.set_rate	= s5pc100_spdif_set_rate,
-	.get_rate	= s5pc100_spdif_get_rate,
-};
-
 static struct clksrc_clk clk_sclk_spdif = {
 	.clk	= {
 		.name		= "sclk_spdif",
 		.ctrlbit	= (1 << 11),
 		.enable		= s5pc100_sclk1_ctrl,
-		.ops		= &s5pc100_sclk_spdif_ops,
+		.ops		= &s5p_sclk_spdif_ops,
 	},
 	.sources = &clk_src_sclk_spdif,
 	.reg_src = { .reg = S5P_CLK_SRC3, .shift = 24, .size = 2 },
arch/arm/mach-s5pv210/clock.c +1 -36
index b5c95e6..ae72f87 100644
@@ -686,47 +686,12 @@ static struct clksrc_sources clkset_sclk_spdif = {
 	.nr_sources	= ARRAY_SIZE(clkset_sclk_spdif_list),
 };
 
-static int s5pv210_spdif_set_rate(struct clk *clk, unsigned long rate)
-{
-	struct clk *pclk;
-	int ret;
-
-	pclk = clk_get_parent(clk);
-	if (IS_ERR(pclk))
-		return -EINVAL;
-
-	ret = pclk->ops->set_rate(pclk, rate);
-	clk_put(pclk);
-
-	return ret;
-}
-
-static unsigned long s5pv210_spdif_get_rate(struct clk *clk)
-{
-	struct clk *pclk;
-	int rate;
-
-	pclk = clk_get_parent(clk);
-	if (IS_ERR(pclk))
-		return -EINVAL;
-
-	rate = pclk->ops->get_rate(clk);
-	clk_put(pclk);
-
-	return rate;
-}
-
-static struct clk_ops s5pv210_sclk_spdif_ops = {
-	.set_rate	= s5pv210_spdif_set_rate,
-	.get_rate	= s5pv210_spdif_get_rate,
-};
-
 static struct clksrc_clk clk_sclk_spdif = {
 	.clk		= {
 		.name		= "sclk_spdif",
 		.enable		= s5pv210_clk_mask0_ctrl,
 		.ctrlbit	= (1 << 27),
-		.ops		= &s5pv210_sclk_spdif_ops,
+		.ops		= &s5p_sclk_spdif_ops,
 	},
 	.sources = &clkset_sclk_spdif,
 	.reg_src = { .reg = S5P_CLK_SRC6, .shift = 12, .size = 2 },
arch/arm/plat-s5p/clock.c +35 -0
index 8d081d9..02af235 100644
@@ -168,6 +168,41 @@ unsigned long s5p_epll_get_rate(struct clk *clk)
 	return clk->rate;
 }
 
+int s5p_spdif_set_rate(struct clk *clk, unsigned long rate)
+{
+	struct clk *pclk;
+	int ret;
+
+	pclk = clk_get_parent(clk);
+	if (IS_ERR(pclk))
+		return -EINVAL;
+
+	ret = pclk->ops->set_rate(pclk, rate);
+	clk_put(pclk);
+
+	return ret;
+}
+
+unsigned long s5p_spdif_get_rate(struct clk *clk)
+{
+	struct clk *pclk;
+	int rate;
+
+	pclk = clk_get_parent(clk);
+	if (IS_ERR(pclk))
+		return -EINVAL;
+
+	rate = pclk->ops->get_rate(clk);
+	clk_put(pclk);
+
+	return rate;
+}
+
+struct clk_ops s5p_sclk_spdif_ops = {
+	.set_rate	= s5p_spdif_set_rate,
+	.get_rate	= s5p_spdif_get_rate,
+};
+
 static struct clk *s5p_clks[] __initdata = {
 	&clk_ext_xtal_mux,
 	&clk_48m,
arch/arm/plat-s5p/include/plat/s5p-clock.h +5 -0
index 2b6dcff..769b5bd 100644
@@ -47,4 +47,9 @@ extern int s5p_gatectrl(void __iomem *reg, struct clk *clk, int enable);
 extern int s5p_epll_enable(struct clk *clk, int enable);
 extern unsigned long s5p_epll_get_rate(struct clk *clk);
 
+/* SPDIF clk operations common for S5PC100/V210/C110 and Exynos4 */
+extern int s5p_spdif_set_rate(struct clk *clk, unsigned long rate);
+extern unsigned long s5p_spdif_get_rate(struct clk *clk);
+
+extern struct clk_ops s5p_sclk_spdif_ops;
 #endif /* __ASM_PLAT_S5P_CLOCK_H */
Signature · 1 line
1.7.2.3
#2 lore raw

PATCH v2 1/3 ARM: Samsung: Move duplicate code

Quoted 7 lines · Naveen Krishna Chatradhi

Move the duplicated code for SPDIF ops from S5PV210 and S5PC100. So, the same can be used in EXYNOS4.

---
Note: Moved common code to plat-s5p, as suggested by Kukjin Kim.

Yes, I did :)
Looks ok to me, will apply.
Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

Quoted 2 lines
 arch/arm/mach-s5pc100/clock.c              |   37
+---------------------------
>  arch/arm/mach-s5pv210/clock.c              |   37
+---------------------------
>  arch/arm/plat-s5p/clock.c                  |   35

arch/arm/plat-s5p/include/plat/s5p-clock.h extern int s5p_gatectrl(void __iomem *reg, struct clk

Quoted 162 lines

++++++++++++++++++++++++++

 arch/arm/plat-s5p/include/plat/s5p-clock.h |    5 ++++
 4 files changed, 42 insertions(+), 72 deletions(-)
arch/arm/mach-s5pc100/clock.c +1 -36
index cd248e6..ff5cbb3 100644
@@ -910,47 +910,12 @@ struct clksrc_sources clk_src_sclk_spdif = {
 	.nr_sources	= ARRAY_SIZE(clk_sclk_spdif_list),
 };
 
-static int s5pc100_spdif_set_rate(struct clk *clk, unsigned long rate)
-{
-	struct clk *pclk;
-	int ret;
-
-	pclk = clk_get_parent(clk);
-	if (IS_ERR(pclk))
-		return -EINVAL;
-
-	ret = pclk->ops->set_rate(pclk, rate);
-	clk_put(pclk);
-
-	return ret;
-}
-
-static unsigned long s5pc100_spdif_get_rate(struct clk *clk)
-{
-	struct clk *pclk;
-	int rate;
-
-	pclk = clk_get_parent(clk);
-	if (IS_ERR(pclk))
-		return -EINVAL;
-
-	rate = pclk->ops->get_rate(clk);
-	clk_put(pclk);
-
-	return rate;
-}
-
-static struct clk_ops s5pc100_sclk_spdif_ops = {
-	.set_rate	= s5pc100_spdif_set_rate,
-	.get_rate	= s5pc100_spdif_get_rate,
-};
-
 static struct clksrc_clk clk_sclk_spdif = {
 	.clk	= {
 		.name		= "sclk_spdif",
 		.ctrlbit	= (1 << 11),
 		.enable		= s5pc100_sclk1_ctrl,
-		.ops		= &s5pc100_sclk_spdif_ops,
+		.ops		= &s5p_sclk_spdif_ops,
 	},
 	.sources = &clk_src_sclk_spdif,
 	.reg_src = { .reg = S5P_CLK_SRC3, .shift = 24, .size = 2 },
arch/arm/mach-s5pv210/clock.c +1 -36
index b5c95e6..ae72f87 100644
@@ -686,47 +686,12 @@ static struct clksrc_sources clkset_sclk_spdif = {
 	.nr_sources	= ARRAY_SIZE(clkset_sclk_spdif_list),
 };
 
-static int s5pv210_spdif_set_rate(struct clk *clk, unsigned long rate)
-{
-	struct clk *pclk;
-	int ret;
-
-	pclk = clk_get_parent(clk);
-	if (IS_ERR(pclk))
-		return -EINVAL;
-
-	ret = pclk->ops->set_rate(pclk, rate);
-	clk_put(pclk);
-
-	return ret;
-}
-
-static unsigned long s5pv210_spdif_get_rate(struct clk *clk)
-{
-	struct clk *pclk;
-	int rate;
-
-	pclk = clk_get_parent(clk);
-	if (IS_ERR(pclk))
-		return -EINVAL;
-
-	rate = pclk->ops->get_rate(clk);
-	clk_put(pclk);
-
-	return rate;
-}
-
-static struct clk_ops s5pv210_sclk_spdif_ops = {
-	.set_rate	= s5pv210_spdif_set_rate,
-	.get_rate	= s5pv210_spdif_get_rate,
-};
-
 static struct clksrc_clk clk_sclk_spdif = {
 	.clk		= {
 		.name		= "sclk_spdif",
 		.enable		= s5pv210_clk_mask0_ctrl,
 		.ctrlbit	= (1 << 27),
-		.ops		= &s5pv210_sclk_spdif_ops,
+		.ops		= &s5p_sclk_spdif_ops,
 	},
 	.sources = &clkset_sclk_spdif,
 	.reg_src = { .reg = S5P_CLK_SRC6, .shift = 12, .size = 2 },
arch/arm/plat-s5p/clock.c +35 -0
index 8d081d9..02af235 100644
@@ -168,6 +168,41 @@ unsigned long s5p_epll_get_rate(struct clk *clk)
 	return clk->rate;
 }
 
+int s5p_spdif_set_rate(struct clk *clk, unsigned long rate)
+{
+	struct clk *pclk;
+	int ret;
+
+	pclk = clk_get_parent(clk);
+	if (IS_ERR(pclk))
+		return -EINVAL;
+
+	ret = pclk->ops->set_rate(pclk, rate);
+	clk_put(pclk);
+
+	return ret;
+}
+
+unsigned long s5p_spdif_get_rate(struct clk *clk)
+{
+	struct clk *pclk;
+	int rate;
+
+	pclk = clk_get_parent(clk);
+	if (IS_ERR(pclk))
+		return -EINVAL;
+
+	rate = pclk->ops->get_rate(clk);
+	clk_put(pclk);
+
+	return rate;
+}
+
+struct clk_ops s5p_sclk_spdif_ops = {
+	.set_rate	= s5p_spdif_set_rate,
+	.get_rate	= s5p_spdif_get_rate,
+};
+
 static struct clk *s5p_clks[] __initdata = {
 	&clk_ext_xtal_mux,
 	&clk_48m,
arch/arm/plat- renamed from arch/arm/plat-s5p/include/plat/s5p-clock.h +0 -0

s5p/include/plat/s5p-clock.h
index 2b6dcff..769b5bd 100644

arch/arm/plat-s5p/include/plat/s5p-clock.h +0 -0
@@ -47,4 +47,9 @@ extern int s5p_gatectrl(void __iomem *reg, struct clk

*clk, int

Quoted 12 lines
arch/arm/plat-s5p/include/plat/s5p-clock.h +5 -0
 enable);
 extern int s5p_epll_enable(struct clk *clk, int enable);
 extern unsigned long s5p_epll_get_rate(struct clk *clk);
 
+/* SPDIF clk operations common for S5PC100/V210/C110 and Exynos4 */
+extern int s5p_spdif_set_rate(struct clk *clk, unsigned long rate);
+extern unsigned long s5p_spdif_get_rate(struct clk *clk);
+
+extern struct clk_ops s5p_sclk_spdif_ops;

#endif /* __ASM_PLAT_S5P_CLOCK_H */
--
1.7.2.3

#3 lore raw

PATCH v2 2/3 ARM: EXYNOS4: Add sclk_spdif clocks.

In reply to Naveen Krishna Chatradhi

Add the sclk_spdif clock is of type 'struct clksrc_clk' clock. Also, add clk_spdifextclk clocks of type 'struct clk' clock.

---
 arch/arm/mach-exynos4/clock.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
arch/arm/mach-exynos4/clock.c +35 -0
index 937335a..feeb27e 100644
@@ -64,6 +64,11 @@ static struct clk clk_audiocdclk2 = {
 	.name		= "audiocdclk",
 };
 
+static struct clk clk_spdifextclk = {
+	.name		= "spdif_extclk",
+	.id		= -1,
+};
+
 static int exynos4_clksrc_mask_top_ctrl(struct clk *clk, int enable)
 {
 	return s5p_gatectrl(S5P_CLKSRC_MASK_TOP, clk, enable);
@@ -550,6 +555,11 @@ static struct clk init_clocks_off[] = {
 		.enable		= exynos4_clk_ip_peril_ctrl,
 		.ctrlbit	= (1 << 21),
 	}, {
+		.name		= "spdif",
+		.id		= -1,
+		.enable		= exynos4_clk_ip_peril_ctrl,
+		.ctrlbit	= (1 << 26),
+	}, {
 		.name		= "ac97",
 		.id		= -1,
 		.enable		= exynos4_clk_ip_peril_ctrl,
@@ -801,6 +811,30 @@ static struct clk init_clocks[] = {
 	}
 };
 
+static struct clk *clkset_sclk_spdif_list[] = {
+	[0] = &clk_sclk_audio0.clk,
+	[1] = &clk_sclk_audio1.clk,
+	[2] = &clk_sclk_audio2.clk,
+	[3] = &clk_spdifextclk,
+};
+
+static struct clksrc_sources clkset_sclk_spdif = {
+	.sources	= clkset_sclk_spdif_list,
+	.nr_sources	= ARRAY_SIZE(clkset_sclk_spdif_list),
+};
+
+static struct clksrc_clk clk_sclk_spdif = {
+	.clk	= {
+		.name		= "sclk_spdif",
+		.id		= -1,
+		.enable		= exynos4_clksrc_mask_peril1_ctrl,
+		.ctrlbit	= (1 << 8),
+		.ops		= &s5p_sclk_spdif_ops,
+	},
+		.sources = &clkset_sclk_spdif,
+		.reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 8, .size = 2 },
+};
+
 static struct clk *clkset_group_list[] = {
 	[0] = &clk_ext_xtal_mux,
 	[1] = &clk_xusbxti,
@@ -1206,6 +1240,7 @@ static struct clksrc_clk *sysclks[] = {
 	&clk_sclk_audio0,
 	&clk_sclk_audio1,
 	&clk_sclk_audio2,
+	&clk_sclk_spdif,
 };
 
 static int xtal_rate;
Signature · 1 line
1.7.2.3
#4 lore raw

PATCH v2 2/3 ARM: EXYNOS4: Add sclk_spdif clocks.

Quoted 27 lines · Naveen Krishna Chatradhi

Add the sclk_spdif clock is of type 'struct clksrc_clk' clock. Also, add clk_spdifextclk clocks of type 'struct clk' clock.

---
 arch/arm/mach-exynos4/clock.c |   35
+++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
arch/arm/mach-exynos4/clock.c +5 -0
index 937335a..feeb27e 100644
@@ -64,6 +64,11 @@ static struct clk clk_audiocdclk2 = {
 	.name		= "audiocdclk",
 };
 
+static struct clk clk_spdifextclk = {
+	.name		= "spdif_extclk",
+	.id		= -1,
+};
+
 static int exynos4_clksrc_mask_top_ctrl(struct clk *clk, int enable)
 {
 	return s5p_gatectrl(S5P_CLKSRC_MASK_TOP, clk, enable);

arch/arm/mach-exynos4/clock.c static struct clk init_clocks_off[] = { · line 562

Quoted 8 lines
arch/arm/mach-exynos4/clock.c +5 -0
@@ -550,6 +555,11 @@ static struct clk init_clocks_off[] = {
 		.enable		= exynos4_clk_ip_peril_ctrl,
 		.ctrlbit	= (1 << 21),
 	}, {
+		.name		= "spdif",
+		.id		= -1,
+		.enable		= exynos4_clk_ip_peril_ctrl,
+		.ctrlbit	= (1 << 26),
+	}, {

Need to re-work based on clkdev :)

Quoted 19 lines
arch/arm/mach-exynos4/clock.c +12 -0
 		.name		= "ac97",
 		.id		= -1,
 		.enable		= exynos4_clk_ip_peril_ctrl,
@@ -801,6 +811,30 @@ static struct clk init_clocks[] = {
 	}
 };
 
+static struct clk *clkset_sclk_spdif_list[] = {
+	[0] = &clk_sclk_audio0.clk,
+	[1] = &clk_sclk_audio1.clk,
+	[2] = &clk_sclk_audio2.clk,
+	[3] = &clk_spdifextclk,
+};
+
+static struct clksrc_sources clkset_sclk_spdif = {
+	.sources	= clkset_sclk_spdif_list,
+	.nr_sources	= ARRAY_SIZE(clkset_sclk_spdif_list),
+};
+

arch/arm/mach-exynos4/clock.c static struct clk init_clocks[] = { · line 835

Quoted 10 lines
arch/arm/mach-exynos4/clock.c +10 -0
+static struct clksrc_clk clk_sclk_spdif = {
+	.clk	= {
+		.name		= "sclk_spdif",
+		.id		= -1,
+		.enable		= exynos4_clksrc_mask_peril1_ctrl,
+		.ctrlbit	= (1 << 8),
+		.ops		= &s5p_sclk_spdif_ops,
+	},
+		.sources = &clkset_sclk_spdif,
+		.reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 8, .size = 2

},

arch/arm/mach-exynos4/clock.c static struct clk init_clocks[] = { · line 836

Quoted 1 line
arch/arm/mach-exynos4/clock.c +1 -0
+};

Hmm...is it possible to move this into struct clksrc_clk clksrcs[] ?

Quoted 13 lines
arch/arm/mach-exynos4/clock.c +2 -1
+
 static struct clk *clkset_group_list[] = {
 	[0] = &clk_ext_xtal_mux,
 	[1] = &clk_xusbxti,
@@ -1206,6 +1240,7 @@ static struct clksrc_clk *sysclks[] = {
 	&clk_sclk_audio0,
 	&clk_sclk_audio1,
 	&clk_sclk_audio2,
+	&clk_sclk_spdif,
 };
 
 static int xtal_rate;
--
Quoted 1 line

1.7.2.3

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

#5 lore raw

PATCH v2 2/3 ARM: EXYNOS4: Add sclk_spdif clocks.

Hi Every one,

Quoted 30 lines · Kukjin Kim
Quoted 29 lines · Naveen Krishna Chatradhi

Add the sclk_spdif clock is of type 'struct clksrc_clk' clock. Also, add clk_spdifextclk clocks of type 'struct clk' clock.

---
?arch/arm/mach-exynos4/clock.c | ? 35
+++++++++++++++++++++++++++++++++++
?1 files changed, 35 insertions(+), 0 deletions(-)

arch/arm/mach-exynos4/clock.c +5 -0
index 937335a..feeb27e 100644
@@ -64,6 +64,11 @@ static struct clk clk_audiocdclk2 = {
 ? ? ? .name ? ? ? ? ? = "audiocdclk",
 ?};
 
+static struct clk clk_spdifextclk = {
+ ? ? .name ? ? ? ? ? = "spdif_extclk",
+ ? ? .id ? ? ? ? ? ? = -1,
+};
+
 ?static int exynos4_clksrc_mask_top_ctrl(struct clk *clk, int enable)
 ?{
 ? ? ? return s5p_gatectrl(S5P_CLKSRC_MASK_TOP, clk, enable);
@@ -550,6 +555,11 @@ static struct clk init_clocks_off[] = {
 ? ? ? ? ? ? ? .enable ? ? ? ? = exynos4_clk_ip_peril_ctrl,
 ? ? ? ? ? ? ? .ctrlbit ? ? ? ?= (1 << 21),
Quoted 8 lines

arch/arm/mach-exynos4/clock.c static struct clk init_clocks_off[] = { · line 562

Quoted 6 lines
arch/arm/mach-exynos4/clock.c +5 -0
 ? ? ? }, {
+ ? ? ? ? ? ? .name ? ? ? ? ? = "spdif",
+ ? ? ? ? ? ? .id ? ? ? ? ? ? = -1,
+ ? ? ? ? ? ? .enable ? ? ? ? = exynos4_clk_ip_peril_ctrl,
+ ? ? ? ? ? ? .ctrlbit ? ? ? ?= (1 << 26),
+ ? ? }, {

Need to re-work based on clkdev :)

Sure, will rebase on updated for-next branch.

Quoted 31 lines
Quoted 20 lines
arch/arm/mach-exynos4/clock.c +12 -0
 ? ? ? ? ? ? ? .name ? ? ? ? ? = "ac97",
 ? ? ? ? ? ? ? .id ? ? ? ? ? ? = -1,
 ? ? ? ? ? ? ? .enable ? ? ? ? = exynos4_clk_ip_peril_ctrl,
@@ -801,6 +811,30 @@ static struct clk init_clocks[] = {
 ? ? ? }
 ?};
 
+static struct clk *clkset_sclk_spdif_list[] = {
+ ? ? [0] = &clk_sclk_audio0.clk,
+ ? ? [1] = &clk_sclk_audio1.clk,
+ ? ? [2] = &clk_sclk_audio2.clk,
+ ? ? [3] = &clk_spdifextclk,
+};
+
+static struct clksrc_sources clkset_sclk_spdif = {
+ ? ? .sources ? ? ? ?= clkset_sclk_spdif_list,
+ ? ? .nr_sources ? ? = ARRAY_SIZE(clkset_sclk_spdif_list),
+};
+

arch/arm/mach-exynos4/clock.c static struct clk init_clocks[] = { · line 835

Quoted 10 lines
arch/arm/mach-exynos4/clock.c +10 -0
+static struct clksrc_clk clk_sclk_spdif = {
+ ? ? .clk ? ?= {
+ ? ? ? ? ? ? .name ? ? ? ? ? = "sclk_spdif",
+ ? ? ? ? ? ? .id ? ? ? ? ? ? = -1,
+ ? ? ? ? ? ? .enable ? ? ? ? = exynos4_clksrc_mask_peril1_ctrl,
+ ? ? ? ? ? ? .ctrlbit ? ? ? ?= (1 << 8),
+ ? ? ? ? ? ? .ops ? ? ? ? ? ?= &s5p_sclk_spdif_ops,
+ ? ? },
+ ? ? ? ? ? ? .sources = &clkset_sclk_spdif,
+ ? ? ? ? ? ? .reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 8, .size = 2

},

Quoted 3 lines

arch/arm/mach-exynos4/clock.c static struct clk init_clocks[] = { · line 836

Quoted 1 line
arch/arm/mach-exynos4/clock.c +1 -0
+};

Hmm...is it possible to move this into struct clksrc_clk clksrcs[] ?

When i try to move it under struct clksrc_clk clksrcs[], I encountered a problem with .ops field
The sample code as follows (I'm not sure if i can copy paste the code for RFC)

+static struct clk *clkset_sclk_spdif_list[] = {

+       [0] = &clk_sclk_audio0.clk,
+       [1] = &clk_sclk_audio1.clk,
+       [2] = &clk_sclk_audio2.clk,
+       [3] = &clk_spdifextclk,
+};
+
+static struct clksrc_sources clkset_sclk_spdif = {
+       .sources        = clkset_sclk_spdif_list,
+       .nr_sources     = ARRAY_SIZE(clkset_sclk_spdif_list),
+};
+
 static struct clk *clkset_group_list[] = {
        [0] = &clk_ext_xtal_mux,
        [1] = &clk_xusbxti,
@@ -1175,6 +1197,17 @@ static struct clksrc_clk clksrcs[] = {
                        .parent         = &clk_sclk_audio2.clk,
                },
                .reg_div = { .reg = S5P_CLKDIV_PERIL4, .shift = 20, .size = 8 },
+       }, {
+               .clk    = {
+                       .name           = "sclk_spdif",
+                       .id             = 0,
+                       .parent         = &clk_sclk_audio0.clk,
+       //              .ops            = &s5p_sclk_spdif_ops,

"When i keep this .ops, The system hangs during boot up. If i don't define the .ops, The WARN_ON would print a stack of call trace for undefined set_rate function"
I did not find any set_ops kind off utility functions.

Kindly, point me towards any better way of doing the same.

+                       .enable         = exynos4_clksrc_mask_peril1_ctrl,
+                       .ctrlbit        = (1 << 8),
+               },
+               .sources = &clkset_sclk_spdif,
+               .reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 8, .size = 2 },
        },

};

Quoted 30 lines
Quoted 14 lines
arch/arm/mach-exynos4/clock.c +2 -1
+
 ?static struct clk *clkset_group_list[] = {
 ? ? ? [0] = &clk_ext_xtal_mux,
 ? ? ? [1] = &clk_xusbxti,
@@ -1206,6 +1240,7 @@ static struct clksrc_clk *sysclks[] = {
 ? ? ? &clk_sclk_audio0,
 ? ? ? &clk_sclk_audio1,
 ? ? ? &clk_sclk_audio2,
+ ? ? &clk_sclk_spdif,
 ?};
 
 ?static int xtal_rate;
--
Quoted 1 line

1.7.2.3

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

--
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
Shine bright,
(: Nav :)
#6 lore raw

PATCH v2 2/3 ARM: EXYNOS4: Add sclk_spdif clocks.

Hi Everyone,

Any suggestions regarding this below problem.

Quoted 157 lines · Naveen Krishna Ch

Hi Every one,

Quoted 30 lines · Kukjin Kim
Quoted 29 lines · Naveen Krishna Chatradhi

Add the sclk_spdif clock is of type 'struct clksrc_clk' clock. Also, add clk_spdifextclk clocks of type 'struct clk' clock.

---
?arch/arm/mach-exynos4/clock.c | ? 35
+++++++++++++++++++++++++++++++++++
?1 files changed, 35 insertions(+), 0 deletions(-)

arch/arm/mach-exynos4/clock.c +5 -0
index 937335a..feeb27e 100644
@@ -64,6 +64,11 @@ static struct clk clk_audiocdclk2 = {
 ? ? ? .name ? ? ? ? ? = "audiocdclk",
 ?};
 
+static struct clk clk_spdifextclk = {
+ ? ? .name ? ? ? ? ? = "spdif_extclk",
+ ? ? .id ? ? ? ? ? ? = -1,
+};
+
 ?static int exynos4_clksrc_mask_top_ctrl(struct clk *clk, int enable)
 ?{
 ? ? ? return s5p_gatectrl(S5P_CLKSRC_MASK_TOP, clk, enable);
@@ -550,6 +555,11 @@ static struct clk init_clocks_off[] = {
 ? ? ? ? ? ? ? .enable ? ? ? ? = exynos4_clk_ip_peril_ctrl,
 ? ? ? ? ? ? ? .ctrlbit ? ? ? ?= (1 << 21),
Quoted 8 lines

arch/arm/mach-exynos4/clock.c static struct clk init_clocks_off[] = { · line 562

Quoted 6 lines
arch/arm/mach-exynos4/clock.c +5 -0
 ? ? ? }, {
+ ? ? ? ? ? ? .name ? ? ? ? ? = "spdif",
+ ? ? ? ? ? ? .id ? ? ? ? ? ? = -1,
+ ? ? ? ? ? ? .enable ? ? ? ? = exynos4_clk_ip_peril_ctrl,
+ ? ? ? ? ? ? .ctrlbit ? ? ? ?= (1 << 26),
+ ? ? }, {

Need to re-work based on clkdev :)

Sure, will rebase on updated for-next branch.

Quoted 31 lines
Quoted 20 lines
arch/arm/mach-exynos4/clock.c +12 -0
 ? ? ? ? ? ? ? .name ? ? ? ? ? = "ac97",
 ? ? ? ? ? ? ? .id ? ? ? ? ? ? = -1,
 ? ? ? ? ? ? ? .enable ? ? ? ? = exynos4_clk_ip_peril_ctrl,
@@ -801,6 +811,30 @@ static struct clk init_clocks[] = {
 ? ? ? }
 ?};
 
+static struct clk *clkset_sclk_spdif_list[] = {
+ ? ? [0] = &clk_sclk_audio0.clk,
+ ? ? [1] = &clk_sclk_audio1.clk,
+ ? ? [2] = &clk_sclk_audio2.clk,
+ ? ? [3] = &clk_spdifextclk,
+};
+
+static struct clksrc_sources clkset_sclk_spdif = {
+ ? ? .sources ? ? ? ?= clkset_sclk_spdif_list,
+ ? ? .nr_sources ? ? = ARRAY_SIZE(clkset_sclk_spdif_list),
+};
+

arch/arm/mach-exynos4/clock.c static struct clk init_clocks[] = { · line 835

Quoted 10 lines
arch/arm/mach-exynos4/clock.c +10 -0
+static struct clksrc_clk clk_sclk_spdif = {
+ ? ? .clk ? ?= {
+ ? ? ? ? ? ? .name ? ? ? ? ? = "sclk_spdif",
+ ? ? ? ? ? ? .id ? ? ? ? ? ? = -1,
+ ? ? ? ? ? ? .enable ? ? ? ? = exynos4_clksrc_mask_peril1_ctrl,
+ ? ? ? ? ? ? .ctrlbit ? ? ? ?= (1 << 8),
+ ? ? ? ? ? ? .ops ? ? ? ? ? ?= &s5p_sclk_spdif_ops,
+ ? ? },
+ ? ? ? ? ? ? .sources = &clkset_sclk_spdif,
+ ? ? ? ? ? ? .reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 8, .size = 2

},

Quoted 3 lines

arch/arm/mach-exynos4/clock.c static struct clk init_clocks[] = { · line 836

Quoted 1 line
arch/arm/mach-exynos4/clock.c +1 -0
+};

Hmm...is it possible to move this into struct clksrc_clk clksrcs[] ?

When i try to move it under struct clksrc_clk clksrcs[], I encountered a problem with .ops field
The sample code as follows (I'm not sure if i can copy paste the code for RFC)

arch/arm/mach-exynos4/clock.c +12 -0
+static struct clk *clkset_sclk_spdif_list[] = {
+ ? ? ? [0] = &clk_sclk_audio0.clk,
+ ? ? ? [1] = &clk_sclk_audio1.clk,
+ ? ? ? [2] = &clk_sclk_audio2.clk,
+ ? ? ? [3] = &clk_spdifextclk,
+};
+
+static struct clksrc_sources clkset_sclk_spdif = {
+ ? ? ? .sources ? ? ? ?= clkset_sclk_spdif_list,
+ ? ? ? .nr_sources ? ? = ARRAY_SIZE(clkset_sclk_spdif_list),
+};
+

?static struct clk *clkset_group_list[] = {
? ? ? ?[0] = &clk_ext_xtal_mux,
? ? ? ?[1] = &clk_xusbxti,

(quoted diff) +6 -0
@@ -1175,6 +1197,17 @@ static struct clksrc_clk clksrcs[] = {
 ? ? ? ? ? ? ? ? ? ? ? ?.parent ? ? ? ? = &clk_sclk_audio2.clk,
 ? ? ? ? ? ? ? ?},
 ? ? ? ? ? ? ? ?.reg_div = { .reg = S5P_CLKDIV_PERIL4, .shift = 20, .size = 8 },
+ ? ? ? }, {
+ ? ? ? ? ? ? ? .clk ? ?= {
+ ? ? ? ? ? ? ? ? ? ? ? .name ? ? ? ? ? = "sclk_spdif",
+ ? ? ? ? ? ? ? ? ? ? ? .id ? ? ? ? ? ? = 0,
+ ? ? ? ? ? ? ? ? ? ? ? .parent ? ? ? ? = &clk_sclk_audio0.clk,
+ ? ? ? // ? ? ? ? ? ? ?.ops ? ? ? ? ? ?= &s5p_sclk_spdif_ops,

"When i keep this .ops, The system hangs during boot up. If i don't define the .ops, The WARN_ON would print a stack of call trace for undefined set_rate function"
I did not find any set_ops kind off utility functions.

Kindly, point me towards any better way of doing the same.

+ ? ? ? ? ? ? ? ? ? ? ? .enable ? ? ? ? = exynos4_clksrc_mask_peril1_ctrl,
+ ? ? ? ? ? ? ? ? ? ? ? .ctrlbit ? ? ? ?= (1 << 8),
+ ? ? ? ? ? ? ? },
+ ? ? ? ? ? ? ? .sources = &clkset_sclk_spdif,
+ ? ? ? ? ? ? ? .reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 8, .size = 2 }, ? ? ? ?},
?};

Quoted 25 lines
Quoted 14 lines
arch/arm/mach-exynos4/clock.c +2 -1
+
 ?static struct clk *clkset_group_list[] = {
 ? ? ? [0] = &clk_ext_xtal_mux,
 ? ? ? [1] = &clk_xusbxti,
@@ -1206,6 +1240,7 @@ static struct clksrc_clk *sysclks[] = {
 ? ? ? &clk_sclk_audio0,
 ? ? ? &clk_sclk_audio1,
 ? ? ? &clk_sclk_audio2,
+ ? ? &clk_sclk_spdif,
 ?};
 
 ?static int xtal_rate;
--
Quoted 1 line

1.7.2.3

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

Quoted 5 lines

--
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

--
Shine bright,
(: Nav :)

Signature · 2 lines
Shine bright,
(: Nav :)
#7 lore raw

PATCH v2 3/3 ARM: EXYNOS4: Add EPLL clock operations

In reply to Naveen Krishna Chatradhi

S5PV210 and EXYNOS4 uses similar PLL(PLL46XX) for EPLL. So, The EPLL set rate function is duplicated.

Note: Moved common code to plat-s5p, as commented by Kukjin Kim.

---
 arch/arm/mach-exynos4/clock.c        |    1 +
 arch/arm/mach-s5pv210/clock.c        |   78 +---------------------------------
 arch/arm/plat-s5p/clock.c            |   77 +++++++++++++++++++++++++++++++++
 arch/arm/plat-s5p/include/plat/pll.h |    3 +
 4 files changed, 82 insertions(+), 77 deletions(-)
arch/arm/mach-exynos4/clock.c +1 -0
index feeb27e..7687087 100644
@@ -1294,6 +1294,7 @@ void __init_or_cpufreq exynos4_setup_clocks(void)
 				__raw_readl(S5P_VPLL_CON1), pll_4650);
 
 	clk_fout_apll.ops = &exynos4_fout_apll_ops;
+	clk_fout_epll.ops = &pll46xx_epll_ops;
 	clk_fout_mpll.rate = mpll;
 	clk_fout_epll.rate = epll;
 	clk_fout_vpll.rate = vpll;
arch/arm/mach-s5pv210/clock.c +1 -77

90 lines not on this page · raw message

arch/arm/plat-s5p/clock.c +77 -0

89 lines not on this page · raw message

arch/arm/plat-s5p/include/plat/pll.h +3 -0
index bf28fad..911a20e 100644
@@ -94,6 +94,9 @@ static inline unsigned long s5p_get_pll46xx(unsigned long baseclk,
 	return result;
 }
 
+extern int pll46xx_epll_set_rate(struct clk *clk, unsigned long rate);
+extern struct clk_ops pll46xx_epll_ops;
+
 #define PLL90XX_MDIV_MASK	(0xFF)
 #define PLL90XX_PDIV_MASK	(0x3F)
 #define PLL90XX_SDIV_MASK	(0x7)
Signature · 1 line
1.7.2.3
#8 lore raw

PATCH v2 3/3 ARM: EXYNOS4: Add EPLL clock operations

Hi Every one,

1. Both S5P6440 and S5P6450 uses PLL90XX for EPLL. However, the same epll_ops is duplicated in the following files arch/arm/mach-s5p64x0/clock-s5p6440.c arch/arm/mach-s5p64x0/clock-s5p6450.c

Please find attached patch which moves it to the common clock.c
Attachment: "0001-ARM-S5P64X0-Move-duplicated-epll-code.patch"

2. Also, S5PV210, C110, C100, 6450/6440 and EXYNOS4 define their own epll_ops.

The following attachment consolidates the same on the basis of PLL types "Eg: PLL90XX. PLL46XX, PLL45XX and PLL65XX"

Kindly, review the approach and comment.
Attachment: "0001-ARM-Samsung-organize-duplicated-EPLL-code.patch"

Thanks & Best regards,
Naveen Krishna Chatradhi

Quoted 238 lines · Naveen Krishna Chatradhi

S5PV210 and EXYNOS4 uses similar PLL(PLL46XX) for EPLL. So, The EPLL set rate function is duplicated.

Note: Moved common code to plat-s5p, as commented by Kukjin Kim.

---

?arch/arm/mach-exynos4/clock.c ? ? ? ?| ? ?1 +
?arch/arm/mach-s5pv210/clock.c ? ? ? ?| ? 78 +---------------------------------
?arch/arm/plat-s5p/clock.c ? ? ? ? ? ?| ? 77 +++++++++++++++++++++++++++++++++
?arch/arm/plat-s5p/include/plat/pll.h | ? ?3 +

?4 files changed, 82 insertions(+), 77 deletions(-)

arch/arm/mach-exynos4/clock.c +1 -0
index feeb27e..7687087 100644
@@ -1294,6 +1294,7 @@ void __init_or_cpufreq exynos4_setup_clocks(void)
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?__raw_readl(S5P_VPLL_CON1), pll_4650);
 
 ? ? ? ?clk_fout_apll.ops = &exynos4_fout_apll_ops;
+ ? ? ? clk_fout_epll.ops = &pll46xx_epll_ops;
 ? ? ? ?clk_fout_mpll.rate = mpll;
 ? ? ? ?clk_fout_epll.rate = epll;
 ? ? ? ?clk_fout_vpll.rate = vpll;
arch/arm/mach-s5pv210/clock.c +0 -76
index ae72f87..dd77c2c 100644
@@ -979,82 +979,6 @@ static struct clksrc_clk *sysclks[] = {
 ? ? ? ?&clk_sclk_spdif,
 ?};
 
-static u32 epll_div[][6] = {
- ? ? ? { ?48000000, 0, 48, 3, 3, 0 },
- ? ? ? { ?96000000, 0, 48, 3, 2, 0 },
- ? ? ? { 144000000, 1, 72, 3, 2, 0 },
- ? ? ? { 192000000, 0, 48, 3, 1, 0 },
- ? ? ? { 288000000, 1, 72, 3, 1, 0 },
- ? ? ? { ?32750000, 1, 65, 3, 4, 35127 },
- ? ? ? { ?32768000, 1, 65, 3, 4, 35127 },
- ? ? ? { ?45158400, 0, 45, 3, 3, 10355 },
- ? ? ? { ?45000000, 0, 45, 3, 3, 10355 },
- ? ? ? { ?45158000, 0, 45, 3, 3, 10355 },
- ? ? ? { ?49125000, 0, 49, 3, 3, 9961 },
- ? ? ? { ?49152000, 0, 49, 3, 3, 9961 },
- ? ? ? { ?67737600, 1, 67, 3, 3, 48366 },
- ? ? ? { ?67738000, 1, 67, 3, 3, 48366 },
- ? ? ? { ?73800000, 1, 73, 3, 3, 47710 },
- ? ? ? { ?73728000, 1, 73, 3, 3, 47710 },
- ? ? ? { ?36000000, 1, 32, 3, 4, 0 },
- ? ? ? { ?60000000, 1, 60, 3, 3, 0 },
- ? ? ? { ?72000000, 1, 72, 3, 3, 0 },
- ? ? ? { ?80000000, 1, 80, 3, 3, 0 },
- ? ? ? { ?84000000, 0, 42, 3, 2, 0 },
- ? ? ? { ?50000000, 0, 50, 3, 3, 0 },
-};
-
-static int s5pv210_epll_set_rate(struct clk *clk, unsigned long rate)
-{
- ? ? ? unsigned int epll_con, epll_con_k;
- ? ? ? unsigned int i;
-
- ? ? ? /* Return if nothing changed */
- ? ? ? if (clk->rate == rate)
- ? ? ? ? ? ? ? return 0;
-
- ? ? ? epll_con = __raw_readl(S5P_EPLL_CON);
- ? ? ? epll_con_k = __raw_readl(S5P_EPLL_CON1);
-
- ? ? ? epll_con_k &= ~PLL46XX_KDIV_MASK;
- ? ? ? epll_con &= ~(1 << 27 |
- ? ? ? ? ? ? ? ? ? ? ? PLL46XX_MDIV_MASK << PLL46XX_MDIV_SHIFT |
- ? ? ? ? ? ? ? ? ? ? ? PLL46XX_PDIV_MASK << PLL46XX_PDIV_SHIFT |
- ? ? ? ? ? ? ? ? ? ? ? PLL46XX_SDIV_MASK << PLL46XX_SDIV_SHIFT);
-
- ? ? ? for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
- ? ? ? ? ? ? ? if (epll_div[i][0] == rate) {
- ? ? ? ? ? ? ? ? ? ? ? epll_con_k |= epll_div[i][5] << 0;
- ? ? ? ? ? ? ? ? ? ? ? epll_con |= (epll_div[i][1] << 27 |
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? epll_div[i][2] << PLL46XX_MDIV_SHIFT |
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? epll_div[i][3] << PLL46XX_PDIV_SHIFT |
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? epll_div[i][4] << PLL46XX_SDIV_SHIFT);
- ? ? ? ? ? ? ? ? ? ? ? break;
- ? ? ? ? ? ? ? }
- ? ? ? }
-
- ? ? ? if (i == ARRAY_SIZE(epll_div)) {
- ? ? ? ? ? ? ? printk(KERN_ERR "%s: Invalid Clock EPLL Frequency\n",
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? __func__);
- ? ? ? ? ? ? ? return -EINVAL;
- ? ? ? }
-
- ? ? ? __raw_writel(epll_con, S5P_EPLL_CON);
- ? ? ? __raw_writel(epll_con_k, S5P_EPLL_CON1);
-
- ? ? ? printk(KERN_WARNING "EPLL Rate changes from %lu to %lu\n",
- ? ? ? ? ? ? ? ? ? ? ? clk->rate, rate);
-
- ? ? ? clk->rate = rate;
-
- ? ? ? return 0;
-}
-
-static struct clk_ops s5pv210_epll_ops = {
- ? ? ? .set_rate = s5pv210_epll_set_rate,
- ? ? ? .get_rate = s5p_epll_get_rate,
-};
-
 ?void __init_or_cpufreq s5pv210_setup_clocks(void)
 ?{
 ? ? ? ?struct clk *xtal_clk;
@@ -1075,7 +999,7 @@ void __init_or_cpufreq s5pv210_setup_clocks(void)
 

? ? ? ?/* Set functions for clk_fout_epll */
? ? ? ?clk_fout_epll.enable = s5p_epll_enable;
- ? ? ? clk_fout_epll.ops = &s5pv210_epll_ops;
+ ? ? ? clk_fout_epll.ops = &pll46xx_epll_ops;

? ? ? ?printk(KERN_DEBUG "%s: registering clocks\n", __func__);

arch/arm/plat-s5p/clock.c +0 -0
index 02af235..2a4678d 100644
@@ -24,6 +24,7 @@

?#include <mach/regs-clock.h>

?#include <plat/clock.h>
+#include <plat/pll.h>
?#include <plat/clock-clksrc.h>
?#include <plat/s5p-clock.h>

arch/arm/plat-s5p/clock.c +76 -0
@@ -203,6 +204,82 @@ struct clk_ops s5p_sclk_spdif_ops = {
 ? ? ? ?.get_rate ? ? ? = s5p_spdif_get_rate,
 ?};
 
+static u32 epll_div[][6] = {
+ ? ? ? { ?48000000, 0, 48, 3, 3, 0 },
+ ? ? ? { ?96000000, 0, 48, 3, 2, 0 },
+ ? ? ? { 144000000, 1, 72, 3, 2, 0 },
+ ? ? ? { 192000000, 0, 48, 3, 1, 0 },
+ ? ? ? { 288000000, 1, 72, 3, 1, 0 },
+ ? ? ? { ?32750000, 1, 65, 3, 4, 35127 },
+ ? ? ? { ?32768000, 1, 65, 3, 4, 35127 },
+ ? ? ? { ?45158400, 0, 45, 3, 3, 10355 },
+ ? ? ? { ?45000000, 0, 45, 3, 3, 10355 },
+ ? ? ? { ?45158000, 0, 45, 3, 3, 10355 },
+ ? ? ? { ?49125000, 0, 49, 3, 3, 9961 },
+ ? ? ? { ?49152000, 0, 49, 3, 3, 9961 },
+ ? ? ? { ?67737600, 1, 67, 3, 3, 48366 },
+ ? ? ? { ?67738000, 1, 67, 3, 3, 48366 },
+ ? ? ? { ?73800000, 1, 73, 3, 3, 47710 },
+ ? ? ? { ?73728000, 1, 73, 3, 3, 47710 },
+ ? ? ? { ?36000000, 1, 32, 3, 4, 0 },
+ ? ? ? { ?60000000, 1, 60, 3, 3, 0 },
+ ? ? ? { ?72000000, 1, 72, 3, 3, 0 },
+ ? ? ? { ?80000000, 1, 80, 3, 3, 0 },
+ ? ? ? { ?84000000, 0, 42, 3, 2, 0 },
+ ? ? ? { ?50000000, 0, 50, 3, 3, 0 },
+};
+
+int pll46xx_epll_set_rate(struct clk *clk, unsigned long rate)
+{
+ ? ? ? unsigned int epll_con, epll_con_k;
+ ? ? ? unsigned int i;
+
+ ? ? ? /* Return if nothing changed */
+ ? ? ? if (clk->rate == rate)
+ ? ? ? ? ? ? ? return 0;
+
+ ? ? ? epll_con = __raw_readl(S5P_EPLL_CON);
+ ? ? ? epll_con_k = __raw_readl(S5P_EPLL_CON1);
+
+ ? ? ? epll_con_k &= ~PLL46XX_KDIV_MASK;
+ ? ? ? epll_con &= ~(1 << 27 |
+ ? ? ? ? ? ? ? ? ? ? ? PLL46XX_MDIV_MASK << PLL46XX_MDIV_SHIFT |
+ ? ? ? ? ? ? ? ? ? ? ? PLL46XX_PDIV_MASK << PLL46XX_PDIV_SHIFT |
+ ? ? ? ? ? ? ? ? ? ? ? PLL46XX_SDIV_MASK << PLL46XX_SDIV_SHIFT);
+
+ ? ? ? for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
+ ? ? ? ? ? ? ? if (epll_div[i][0] == rate) {
+ ? ? ? ? ? ? ? ? ? ? ? epll_con_k |= epll_div[i][5] << 0;
+ ? ? ? ? ? ? ? ? ? ? ? epll_con |= (epll_div[i][1] << 27 |
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? epll_div[i][2] << PLL46XX_MDIV_SHIFT |
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? epll_div[i][3] << PLL46XX_PDIV_SHIFT |
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? epll_div[i][4] << PLL46XX_SDIV_SHIFT);
+ ? ? ? ? ? ? ? ? ? ? ? break;
+ ? ? ? ? ? ? ? }
+ ? ? ? }
+
+ ? ? ? if (i == ARRAY_SIZE(epll_div)) {
+ ? ? ? ? ? ? ? printk(KERN_ERR "%s: Invalid Clock EPLL Frequency\n",
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? __func__);
+ ? ? ? ? ? ? ? return -EINVAL;
+ ? ? ? }
+
+ ? ? ? __raw_writel(epll_con, S5P_EPLL_CON);
+ ? ? ? __raw_writel(epll_con_k, S5P_EPLL_CON1);
+
+ ? ? ? printk(KERN_WARNING "EPLL Rate changes from %lu to %lu\n",
+ ? ? ? ? ? ? ? ? ? ? ? clk->rate, rate);
+
+ ? ? ? clk->rate = rate;
+
+ ? ? ? return 0;
+}
+
+struct clk_ops pll46xx_epll_ops = {
+ ? ? ? .set_rate = pll46xx_epll_set_rate,
+ ? ? ? .get_rate = s5p_epll_get_rate,
+};
+
 ?static struct clk *s5p_clks[] __initdata = {
 ? ? ? ?&clk_ext_xtal_mux,
 ? ? ? ?&clk_48m,
arch/arm/plat-s5p/include/plat/pll.h +3 -1
index bf28fad..911a20e 100644
@@ -94,6 +94,9 @@ static inline unsigned long s5p_get_pll46xx(unsigned long baseclk,
 ? ? ? ?return result;
 ?}
 
+extern int pll46xx_epll_set_rate(struct clk *clk, unsigned long rate);
+extern struct clk_ops pll46xx_epll_ops;
+
 ?#define PLL90XX_MDIV_MASK ? ? ?(0xFF)
 ?#define PLL90XX_PDIV_MASK ? ? ?(0x3F)
 ?#define PLL90XX_SDIV_MASK ? ? ?(0x7)
--

1.7.2.3

--
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 · 16 lines
Shine bright,
(: Nav :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ARM-S5P64X0-Move-duplicated-epll-code.patch
Type: application/octet-stream
Size: 7901 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110622/a315f4a7/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ARM-Samsung-organize-duplicated-EPLL-code.patch
Type: application/octet-stream
Size: 30605 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110622/a315f4a7/attachment-0003.obj>
#9 lore raw

PATCH v2 3/3 ARM: EXYNOS4: Add EPLL clock operations

Hi Naveen,

Quoted 10 lines · Naveen Krishna Ch

Hi Every one,

1. Both S5P6440 and S5P6450 uses PLL90XX for EPLL. ?However, the same epll_ops is duplicated in the following files ?arch/arm/mach-s5p64x0/clock-s5p6440.c ?arch/arm/mach-s5p64x0/clock-s5p6450.c

?Please find attached patch which moves it to the common clock.c ?Attachment: "0001-ARM-S5P64X0-Move-duplicated-epll-code.patch"

Quoted 8 lines

2. Also, S5PV210, C110, C100, 6450/6440 and EXYNOS4 define their own ?epll_ops.

?The following attachment consolidates the same on the basis of PLL types ?"Eg: PLL90XX. PLL46XX, PLL45XX and PLL65XX"

?Kindly, review the approach and comment.
?Attachment: "0001-ARM-Samsung-organize-duplicated-EPLL-code.patch"

I think this is a good try to clean-up Samsung platform's PLL settings. :) But one thing that I concern is 'epll_div' values are not a common value, it depends on board because of these values come from outer xtl which was selected by OM on board side. So, I wonder if you want to make PLL as a common platform, you may solve these 'epll_div' values to be correct. For example, you may calculate 'epll_div' values with formula which is in user manual or set 'epll_div' values in board specific file not platform file.

claude

#10 lore raw

PATCH v2 3/3 ARM: EXYNOS4: Add EPLL clock operations

Hi Seungwhan,

Quoted 23 lines · Seungwhan Youn

Hi Naveen,

Quoted 10 lines · Naveen Krishna Ch

Hi Every one,

1. Both S5P6440 and S5P6450 uses PLL90XX for EPLL. ?However, the same epll_ops is duplicated in the following files ?arch/arm/mach-s5p64x0/clock-s5p6440.c ?arch/arm/mach-s5p64x0/clock-s5p6450.c

?Please find attached patch which moves it to the common clock.c ?Attachment: "0001-ARM-S5P64X0-Move-duplicated-epll-code.patch"

Quoted 8 lines

2. Also, S5PV210, C110, C100, 6450/6440 and EXYNOS4 define their own ?epll_ops.

?The following attachment consolidates the same on the basis of PLL types ?"Eg: PLL90XX. PLL46XX, PLL45XX and PLL65XX"

?Kindly, review the approach and comment.
?Attachment: "0001-ARM-Samsung-organize-duplicated-EPLL-code.patch"

Quoted 8 lines

I think this is a good try to clean-up Samsung platform's PLL settings. :) But one thing that I concern is 'epll_div' values are not a common value, it depends on board because of these values come from outer xtl which was selected by OM on board side. So, I wonder if you want to make PLL as a common platform, you may solve these 'epll_div' values to be correct. For example, you may calculate 'epll_div' values with formula which is in user manual or set 'epll_div' values in board specific file not platform file.

Thanks for your comments.

So far i was not lucky in finding out a generic way of deriving the epll_div values.
And it doesn't seem to
1. Save lines of code or
2. Consolidate the PLL code.

Any suggestions for a simpler implementation are welcome.

Quoted 3 lines

? ? ? ?claude

Signature · 2 lines
Shine bright,
(: Nav :)
#11 lore raw

PATCH v2 3/3 ARM: EXYNOS4: Add EPLL clock operations

Quoted 7 lines

So far i was not lucky in finding out a generic way of deriving the epll_div values.
And it doesn't seem to
1. Save lines of code or
2. Consolidate the PLL code.

Any suggestions for a simpler implementation are welcome.

No, I mean that 'epll_div' values are _not_always_correct_ on Samsung SoC platform. It depends on board setting. That 'epll_div' values only works fine when FINpll is 24MHz, as you know these're from reference values on User Manual, and board maker can change FINpll freq. with OM[0] pin setting, XXTI and XusbXTI.
So. if you want to make consolidate the PLL code, you should make a general formula to calculate that epll_div values on the fly OR move 'epll_div' values table into somewhere machine specific file, not into platform file 'arch/arm/plat-s5p/clock.c'.

claude

#12 lore raw

PATCH v2 3/3 ARM: EXYNOS4: Add EPLL clock operations

In reply to Naveen Krishna Chatradhi
Quoted 6 lines · Naveen Krishna Chatradhi

S5PV210 and EXYNOS4 uses similar PLL(PLL46XX) for EPLL. So, The EPLL set rate function is duplicated.

Note: Moved common code to plat-s5p, as commented by Kukjin Kim.

Since if you want to keep this in git log, this should be moved after below '---' :(

Quoted 4 lines
---
 arch/arm/mach-exynos4/clock.c        |    1 +
 arch/arm/mach-s5pv210/clock.c        |   78
+---------------------------------
>  arch/arm/plat-s5p/clock.c            |   77
Quoted 145 lines

+++++++++++++++++++++++++++++++++

 arch/arm/plat-s5p/include/plat/pll.h |    3 +
 4 files changed, 82 insertions(+), 77 deletions(-)
arch/arm/mach-exynos4/clock.c +1 -0
index feeb27e..7687087 100644
@@ -1294,6 +1294,7 @@ void __init_or_cpufreq exynos4_setup_clocks(void)
 				__raw_readl(S5P_VPLL_CON1), pll_4650);
 
 	clk_fout_apll.ops = &exynos4_fout_apll_ops;
+	clk_fout_epll.ops = &pll46xx_epll_ops;
 	clk_fout_mpll.rate = mpll;
 	clk_fout_epll.rate = epll;
 	clk_fout_vpll.rate = vpll;
arch/arm/mach-s5pv210/clock.c +0 -48
index ae72f87..dd77c2c 100644
@@ -979,82 +979,6 @@ static struct clksrc_clk *sysclks[] = {
 	&clk_sclk_spdif,
 };
 
-static u32 epll_div[][6] = {
-	{  48000000, 0, 48, 3, 3, 0 },
-	{  96000000, 0, 48, 3, 2, 0 },
-	{ 144000000, 1, 72, 3, 2, 0 },
-	{ 192000000, 0, 48, 3, 1, 0 },
-	{ 288000000, 1, 72, 3, 1, 0 },
-	{  32750000, 1, 65, 3, 4, 35127 },
-	{  32768000, 1, 65, 3, 4, 35127 },
-	{  45158400, 0, 45, 3, 3, 10355 },
-	{  45000000, 0, 45, 3, 3, 10355 },
-	{  45158000, 0, 45, 3, 3, 10355 },
-	{  49125000, 0, 49, 3, 3, 9961 },
-	{  49152000, 0, 49, 3, 3, 9961 },
-	{  67737600, 1, 67, 3, 3, 48366 },
-	{  67738000, 1, 67, 3, 3, 48366 },
-	{  73800000, 1, 73, 3, 3, 47710 },
-	{  73728000, 1, 73, 3, 3, 47710 },
-	{  36000000, 1, 32, 3, 4, 0 },
-	{  60000000, 1, 60, 3, 3, 0 },
-	{  72000000, 1, 72, 3, 3, 0 },
-	{  80000000, 1, 80, 3, 3, 0 },
-	{  84000000, 0, 42, 3, 2, 0 },
-	{  50000000, 0, 50, 3, 3, 0 },
-};
-
-static int s5pv210_epll_set_rate(struct clk *clk, unsigned long rate)
-{
-	unsigned int epll_con, epll_con_k;
-	unsigned int i;
-
-	/* Return if nothing changed */
-	if (clk->rate == rate)
-		return 0;
-
-	epll_con = __raw_readl(S5P_EPLL_CON);
-	epll_con_k = __raw_readl(S5P_EPLL_CON1);
-
-	epll_con_k &= ~PLL46XX_KDIV_MASK;
-	epll_con &= ~(1 << 27 |
-			PLL46XX_MDIV_MASK << PLL46XX_MDIV_SHIFT |
-			PLL46XX_PDIV_MASK << PLL46XX_PDIV_SHIFT |
-			PLL46XX_SDIV_MASK << PLL46XX_SDIV_SHIFT);
-
-	for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
-		if (epll_div[i][0] == rate) {
-			epll_con_k |= epll_div[i][5] << 0;
-			epll_con |= (epll_div[i][1] << 27 |
-					epll_div[i][2] <<

PLL46XX_MDIV_SHIFT |

arch/arm/mach-s5pv210/clock.c +0 -1
-					epll_div[i][3] <<

PLL46XX_PDIV_SHIFT |

arch/arm/mach-s5pv210/clock.c +0 -1
-					epll_div[i][4] <<

PLL46XX_SDIV_SHIFT);

arch/arm/mach-s5pv210/clock.c +1 -27
-			break;
-		}
-	}
-
-	if (i == ARRAY_SIZE(epll_div)) {
-		printk(KERN_ERR "%s: Invalid Clock EPLL Frequency\n",
-				__func__);
-		return -EINVAL;
-	}
-
-	__raw_writel(epll_con, S5P_EPLL_CON);
-	__raw_writel(epll_con_k, S5P_EPLL_CON1);
-
-	printk(KERN_WARNING "EPLL Rate changes from %lu to %lu\n",
-			clk->rate, rate);
-
-	clk->rate = rate;
-
-	return 0;
-}
-
-static struct clk_ops s5pv210_epll_ops = {
-	.set_rate = s5pv210_epll_set_rate,
-	.get_rate = s5p_epll_get_rate,
-};
-
 void __init_or_cpufreq s5pv210_setup_clocks(void)
 {
 	struct clk *xtal_clk;
@@ -1075,7 +999,7 @@ void __init_or_cpufreq s5pv210_setup_clocks(void)
 
 	/* Set functions for clk_fout_epll */
 	clk_fout_epll.enable = s5p_epll_enable;
-	clk_fout_epll.ops = &s5pv210_epll_ops;
+	clk_fout_epll.ops = &pll46xx_epll_ops;
 
 	printk(KERN_DEBUG "%s: registering clocks\n", __func__);
 
arch/arm/plat-s5p/clock.c +15 -0
index 02af235..2a4678d 100644
@@ -24,6 +24,7 @@
 #include <mach/regs-clock.h>
 
 #include <plat/clock.h>
+#include <plat/pll.h>
 #include <plat/clock-clksrc.h>
 #include <plat/s5p-clock.h>
 
@@ -203,6 +204,82 @@ struct clk_ops s5p_sclk_spdif_ops = {
 	.get_rate	= s5p_spdif_get_rate,
 };
 
+static u32 epll_div[][6] = {
+	{  48000000, 0, 48, 3, 3, 0 },
+	{  96000000, 0, 48, 3, 2, 0 },
+	{ 144000000, 1, 72, 3, 2, 0 },
+	{ 192000000, 0, 48, 3, 1, 0 },
+	{ 288000000, 1, 72, 3, 1, 0 },
+	{  32750000, 1, 65, 3, 4, 35127 },
+	{  32768000, 1, 65, 3, 4, 35127 },
+	{  45158400, 0, 45, 3, 3, 10355 },
+	{  45000000, 0, 45, 3, 3, 10355 },
+	{  45158000, 0, 45, 3, 3, 10355 },
+	{  49125000, 0, 49, 3, 3, 9961 },
+	{  49152000, 0, 49, 3, 3, 9961 },
+	{  67737600, 1, 67, 3, 3, 48366 },

arch/arm/plat-s5p/clock.c struct clk_ops s5p_sclk_spdif_ops = { · line 230

Quoted 10 lines
arch/arm/plat-s5p/clock.c +10 -0
+	{  67738000, 1, 67, 3, 3, 48366 },
+	{  73800000, 1, 73, 3, 3, 47710 },
+	{  73728000, 1, 73, 3, 3, 47710 },
+	{  36000000, 1, 32, 3, 4, 0 },
+	{  60000000, 1, 60, 3, 3, 0 },
+	{  72000000, 1, 72, 3, 3, 0 },
+	{  80000000, 1, 80, 3, 3, 0 },
+	{  84000000, 0, 42, 3, 2, 0 },
+	{  50000000, 0, 50, 3, 3, 0 },
+};

Hmm, ok for now. But as Seungwhan Youn said, you have to know it can be changed according to input clock for EPLL when you add this into common plat-s5p.

arch/arm/plat-s5p/clock.c struct clk_ops s5p_sclk_spdif_ops = { · line 232

Quoted 2 lines
arch/arm/plat-s5p/clock.c +2 -0
+
+int pll46xx_epll_set_rate(struct clk *clk, unsigned long rate)

How about to move this in plat-s5p/include/plat/pll.h like other pll helper functions?

Quoted 29 lines
arch/arm/plat-s5p/clock.c +22 -0
+{
+	unsigned int epll_con, epll_con_k;
+	unsigned int i;
+
+	/* Return if nothing changed */
+	if (clk->rate == rate)
+		return 0;
+
+	epll_con = __raw_readl(S5P_EPLL_CON);
+	epll_con_k = __raw_readl(S5P_EPLL_CON1);
+
+	epll_con_k &= ~PLL46XX_KDIV_MASK;
+	epll_con &= ~(1 << 27 |
+			PLL46XX_MDIV_MASK << PLL46XX_MDIV_SHIFT |
+			PLL46XX_PDIV_MASK << PLL46XX_PDIV_SHIFT |
+			PLL46XX_SDIV_MASK << PLL46XX_SDIV_SHIFT);
+
+	for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
+		if (epll_div[i][0] == rate) {
+			epll_con_k |= epll_div[i][5] << 0;
+			epll_con |= (epll_div[i][1] << 27 |
+					epll_div[i][2] <<

PLL46XX_MDIV_SHIFT |

arch/arm/plat-s5p/clock.c +1 -0
+					epll_div[i][3] <<

PLL46XX_PDIV_SHIFT |

arch/arm/plat-s5p/clock.c +1 -0
+					epll_div[i][4] <<

PLL46XX_SDIV_SHIFT);

arch/arm/plat-s5p/clock.c +2 -0
+			break;
+		}

arch/arm/plat-s5p/clock.c struct clk_ops s5p_sclk_spdif_ops = { · line 268

Quoted 10 lines
arch/arm/plat-s5p/clock.c +10 -0
+	}
+
+	if (i == ARRAY_SIZE(epll_div)) {
+		printk(KERN_ERR "%s: Invalid Clock EPLL Frequency\n",
+				__func__);
+		return -EINVAL;
+	}
+
+	__raw_writel(epll_con, S5P_EPLL_CON);
+	__raw_writel(epll_con_k, S5P_EPLL_CON1);

Basically, need to add check of pll locking after changing PLL value.

arch/arm/plat-s5p/clock.c struct clk_ops s5p_sclk_spdif_ops = { · line 280

Quoted 12 lines
arch/arm/plat-s5p/clock.c +12 -0
+
+	printk(KERN_WARNING "EPLL Rate changes from %lu to %lu\n",
+			clk->rate, rate);
+
+	clk->rate = rate;
+
+	return 0;
+}
+
+struct clk_ops pll46xx_epll_ops = {
+	.set_rate = pll46xx_epll_set_rate,
+	.get_rate = s5p_epll_get_rate,

I'm not sure we need .get_rate here.
Could you please test without this?

Review

Quoted 6 lines
arch/arm/plat-s5p/clock.c +2 -0
+};
+
 static struct clk *s5p_clks[] __initdata = {
 	&clk_ext_xtal_mux,
 	&clk_48m,
(quoted diff) +0 -0

b/arch/arm/plat-s5p/include/plat/pll.h

arch/arm/plat-s5p/include/plat/pll.h static inline unsigned long s5p_get_pll46xx(unsigned

Quoted 4 lines

index bf28fad..911a20e 100644

arch/arm/plat-s5p/include/plat/pll.h +0 -0
@@ -94,6 +94,9 @@ static inline unsigned long s5p_get_pll46xx(unsigned

long

Quoted 9 lines
arch/arm/plat-s5p/include/plat/pll.h +3 -0
 baseclk,
 	return result;
 }
 
+extern int pll46xx_epll_set_rate(struct clk *clk, unsigned long rate);
+extern struct clk_ops pll46xx_epll_ops;
+
 #define PLL90XX_MDIV_MASK	(0xFF)
 #define PLL90XX_PDIV_MASK	(0x3F)
Quoted 3 lines

#define PLL90XX_SDIV_MASK (0x7)
--
1.7.2.3

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

#13 lore raw

PATCH v2 3/3 ARM: EXYNOS4: Add EPLL clock operations

Hi Every one,

Quoted 9 lines · Kukjin Kim
Quoted 6 lines · Naveen Krishna Chatradhi

S5PV210 and EXYNOS4 uses similar PLL(PLL46XX) for EPLL. So, The EPLL set rate function is duplicated.

Note: Moved common code to plat-s5p, as commented by Kukjin Kim.

Since if you want to keep this in git log, this should be moved after below '---' :(

Thanks for pointing.

Quoted 158 lines
Quoted 5 lines

---
?arch/arm/mach-exynos4/clock.c ? ? ? ?| ? ?1 +
?arch/arm/mach-s5pv210/clock.c ? ? ? ?| ? 78

+---------------------------------
> ?arch/arm/plat-s5p/clock.c ? ? ? ? ? ?| ? 77
Quoted 151 lines

+++++++++++++++++++++++++++++++++
?arch/arm/plat-s5p/include/plat/pll.h | ? ?3 + ?4 files changed, 82 insertions(+), 77 deletions(-)

arch/arm/mach-exynos4/clock.c +1 -0
index feeb27e..7687087 100644
@@ -1294,6 +1294,7 @@ void __init_or_cpufreq exynos4_setup_clocks(void)
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? __raw_readl(S5P_VPLL_CON1), pll_4650);
 
 ? ? ? clk_fout_apll.ops = &exynos4_fout_apll_ops;
+ ? ? clk_fout_epll.ops = &pll46xx_epll_ops;
 ? ? ? clk_fout_mpll.rate = mpll;
 ? ? ? clk_fout_epll.rate = epll;
 ? ? ? clk_fout_vpll.rate = vpll;
arch/arm/mach-s5pv210/clock.c +0 -48
index ae72f87..dd77c2c 100644
@@ -979,82 +979,6 @@ static struct clksrc_clk *sysclks[] = {
 ? ? ? &clk_sclk_spdif,
 ?};
 
-static u32 epll_div[][6] = {
- ? ? { ?48000000, 0, 48, 3, 3, 0 },
- ? ? { ?96000000, 0, 48, 3, 2, 0 },
- ? ? { 144000000, 1, 72, 3, 2, 0 },
- ? ? { 192000000, 0, 48, 3, 1, 0 },
- ? ? { 288000000, 1, 72, 3, 1, 0 },
- ? ? { ?32750000, 1, 65, 3, 4, 35127 },
- ? ? { ?32768000, 1, 65, 3, 4, 35127 },
- ? ? { ?45158400, 0, 45, 3, 3, 10355 },
- ? ? { ?45000000, 0, 45, 3, 3, 10355 },
- ? ? { ?45158000, 0, 45, 3, 3, 10355 },
- ? ? { ?49125000, 0, 49, 3, 3, 9961 },
- ? ? { ?49152000, 0, 49, 3, 3, 9961 },
- ? ? { ?67737600, 1, 67, 3, 3, 48366 },
- ? ? { ?67738000, 1, 67, 3, 3, 48366 },
- ? ? { ?73800000, 1, 73, 3, 3, 47710 },
- ? ? { ?73728000, 1, 73, 3, 3, 47710 },
- ? ? { ?36000000, 1, 32, 3, 4, 0 },
- ? ? { ?60000000, 1, 60, 3, 3, 0 },
- ? ? { ?72000000, 1, 72, 3, 3, 0 },
- ? ? { ?80000000, 1, 80, 3, 3, 0 },
- ? ? { ?84000000, 0, 42, 3, 2, 0 },
- ? ? { ?50000000, 0, 50, 3, 3, 0 },
-};
-
-static int s5pv210_epll_set_rate(struct clk *clk, unsigned long rate)
-{
- ? ? unsigned int epll_con, epll_con_k;
- ? ? unsigned int i;
-
- ? ? /* Return if nothing changed */
- ? ? if (clk->rate == rate)
- ? ? ? ? ? ? return 0;
-
- ? ? epll_con = __raw_readl(S5P_EPLL_CON);
- ? ? epll_con_k = __raw_readl(S5P_EPLL_CON1);
-
- ? ? epll_con_k &= ~PLL46XX_KDIV_MASK;
- ? ? epll_con &= ~(1 << 27 |
- ? ? ? ? ? ? ? ? ? ? PLL46XX_MDIV_MASK << PLL46XX_MDIV_SHIFT |
- ? ? ? ? ? ? ? ? ? ? PLL46XX_PDIV_MASK << PLL46XX_PDIV_SHIFT |
- ? ? ? ? ? ? ? ? ? ? PLL46XX_SDIV_MASK << PLL46XX_SDIV_SHIFT);
-
- ? ? for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
- ? ? ? ? ? ? if (epll_div[i][0] == rate) {
- ? ? ? ? ? ? ? ? ? ? epll_con_k |= epll_div[i][5] << 0;
- ? ? ? ? ? ? ? ? ? ? epll_con |= (epll_div[i][1] << 27 |
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? epll_div[i][2] <<

PLL46XX_MDIV_SHIFT |
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? epll_div[i][3] << PLL46XX_PDIV_SHIFT |
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? epll_div[i][4] << PLL46XX_SDIV_SHIFT);
- ? ? ? ? ? ? ? ? ? ? break;
- ? ? ? ? ? ? }
- ? ? }

arch/arm/mach-s5pv210/clock.c +0 -23
-
- ? ? if (i == ARRAY_SIZE(epll_div)) {
- ? ? ? ? ? ? printk(KERN_ERR "%s: Invalid Clock EPLL Frequency\n",
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? __func__);
- ? ? ? ? ? ? return -EINVAL;
- ? ? }
-
- ? ? __raw_writel(epll_con, S5P_EPLL_CON);
- ? ? __raw_writel(epll_con_k, S5P_EPLL_CON1);
-
- ? ? printk(KERN_WARNING "EPLL Rate changes from %lu to %lu\n",
- ? ? ? ? ? ? ? ? ? ? clk->rate, rate);
-
- ? ? clk->rate = rate;
-
- ? ? return 0;
-}
-
-static struct clk_ops s5pv210_epll_ops = {
- ? ? .set_rate = s5pv210_epll_set_rate,
- ? ? .get_rate = s5p_epll_get_rate,
-};
-

?void __init_or_cpufreq s5pv210_setup_clocks(void) ?{
? ? ? struct clk *xtal_clk;

arch/arm/mach-s5pv210/clock.c +0 -0
@@ -1075,7 +999,7 @@ void __init_or_cpufreq s5pv210_setup_clocks(void)
 

? ? ? /* Set functions for clk_fout_epll */
? ? ? clk_fout_epll.enable = s5p_epll_enable;
- ? ? clk_fout_epll.ops = &s5pv210_epll_ops;
+ ? ? clk_fout_epll.ops = &pll46xx_epll_ops;

? ? ? printk(KERN_DEBUG "%s: registering clocks\n", __func__);

arch/arm/plat-s5p/clock.c +0 -0
index 02af235..2a4678d 100644
@@ -24,6 +24,7 @@

?#include <mach/regs-clock.h>

?#include <plat/clock.h>
+#include <plat/pll.h>
?#include <plat/clock-clksrc.h>
?#include <plat/s5p-clock.h>

arch/arm/plat-s5p/clock.c +20 -0
@@ -203,6 +204,82 @@ struct clk_ops s5p_sclk_spdif_ops = {
 ? ? ? .get_rate ? ? ? = s5p_spdif_get_rate,
 ?};
 
+static u32 epll_div[][6] = {
+ ? ? { ?48000000, 0, 48, 3, 3, 0 },
+ ? ? { ?96000000, 0, 48, 3, 2, 0 },
+ ? ? { 144000000, 1, 72, 3, 2, 0 },
+ ? ? { 192000000, 0, 48, 3, 1, 0 },
+ ? ? { 288000000, 1, 72, 3, 1, 0 },
+ ? ? { ?32750000, 1, 65, 3, 4, 35127 },
+ ? ? { ?32768000, 1, 65, 3, 4, 35127 },
+ ? ? { ?45158400, 0, 45, 3, 3, 10355 },
+ ? ? { ?45000000, 0, 45, 3, 3, 10355 },
+ ? ? { ?45158000, 0, 45, 3, 3, 10355 },
+ ? ? { ?49125000, 0, 49, 3, 3, 9961 },
+ ? ? { ?49152000, 0, 49, 3, 3, 9961 },
+ ? ? { ?67737600, 1, 67, 3, 3, 48366 },
+ ? ? { ?67738000, 1, 67, 3, 3, 48366 },
+ ? ? { ?73800000, 1, 73, 3, 3, 47710 },
+ ? ? { ?73728000, 1, 73, 3, 3, 47710 },
+ ? ? { ?36000000, 1, 32, 3, 4, 0 },
+ ? ? { ?60000000, 1, 60, 3, 3, 0 },
+ ? ? { ?72000000, 1, 72, 3, 3, 0 },
Quoted 8 lines

arch/arm/plat-s5p/clock.c struct clk_ops s5p_sclk_spdif_ops = { · line 230

Quoted 4 lines
arch/arm/plat-s5p/clock.c +4 -0
+ ? ? { ?80000000, 1, 80, 3, 3, 0 },
+ ? ? { ?84000000, 0, 42, 3, 2, 0 },
+ ? ? { ?50000000, 0, 50, 3, 3, 0 },
+};

Hmm, ok for now. But as Seungwhan Youn said, you have to know it can be changed according to input clock for EPLL when you add this into common plat-s5p.

As mentioned earlier, I've not found any generic formula for using across boards.
So, I dropped the plan for moving it to plat-s5p for all boards.

This patch only applies only for S5PV210 and EXYNOS4, The epll_div values are same as per the latest User Manuals for S5PV210 and EXYNOS4.

Sorry for the mess, attaching a patch for RFC have caused.

Quoted 6 lines

arch/arm/plat-s5p/clock.c struct clk_ops s5p_sclk_spdif_ops = { · line 232

Quoted 3 lines
arch/arm/plat-s5p/clock.c +2 -0
+
+int pll46xx_epll_set_rate(struct clk *clk, unsigned long rate)

How about to move this in plat-s5p/include/plat/pll.h like other pll helper functions?

Isn't it wrong for the helper functions to use raw_readl and raw_writel functions ??

Quoted 34 lines
Quoted 34 lines
arch/arm/plat-s5p/clock.c +22 -0
+{
+ ? ? unsigned int epll_con, epll_con_k;
+ ? ? unsigned int i;
+
+ ? ? /* Return if nothing changed */
+ ? ? if (clk->rate == rate)
+ ? ? ? ? ? ? return 0;
+
+ ? ? epll_con = __raw_readl(S5P_EPLL_CON);
+ ? ? epll_con_k = __raw_readl(S5P_EPLL_CON1);
+
+ ? ? epll_con_k &= ~PLL46XX_KDIV_MASK;
+ ? ? epll_con &= ~(1 << 27 |
+ ? ? ? ? ? ? ? ? ? ? PLL46XX_MDIV_MASK << PLL46XX_MDIV_SHIFT |
+ ? ? ? ? ? ? ? ? ? ? PLL46XX_PDIV_MASK << PLL46XX_PDIV_SHIFT |
+ ? ? ? ? ? ? ? ? ? ? PLL46XX_SDIV_MASK << PLL46XX_SDIV_SHIFT);
+
+ ? ? for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
+ ? ? ? ? ? ? if (epll_div[i][0] == rate) {
+ ? ? ? ? ? ? ? ? ? ? epll_con_k |= epll_div[i][5] << 0;
+ ? ? ? ? ? ? ? ? ? ? epll_con |= (epll_div[i][1] << 27 |
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? epll_div[i][2] <<

PLL46XX_MDIV_SHIFT |
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? epll_div[i][3] << PLL46XX_PDIV_SHIFT |
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? epll_div[i][4] << PLL46XX_SDIV_SHIFT);
+ ? ? ? ? ? ? ? ? ? ? break;
+ ? ? ? ? ? ? }
+ ? ? }
+
+ ? ? if (i == ARRAY_SIZE(epll_div)) {
+ ? ? ? ? ? ? printk(KERN_ERR "%s: Invalid Clock EPLL Frequency\n",

Quoted 8 lines
Quoted 6 lines

+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? __func__);
+ ? ? ? ? ? ? return -EINVAL;
+ ? ? }
+
+ ? ? __raw_writel(epll_con, S5P_EPLL_CON);
+ ? ? __raw_writel(epll_con_k, S5P_EPLL_CON1);

Basically, need to add check of pll locking after changing PLL value.

Yes, i understand.
It was a simple code movement, Will apply locking in next version of patch set.

Quoted 16 lines

arch/arm/plat-s5p/clock.c struct clk_ops s5p_sclk_spdif_ops = {

Quoted 13 lines
arch/arm/plat-s5p/clock.c +12 -0
+
+ ? ? printk(KERN_WARNING "EPLL Rate changes from %lu to %lu\n",
+ ? ? ? ? ? ? ? ? ? ? clk->rate, rate);
+
+ ? ? clk->rate = rate;
+
+ ? ? return 0;
+}
+
+struct clk_ops pll46xx_epll_ops = {
+ ? ? .set_rate = pll46xx_epll_set_rate,
+ ? ? .get_rate = s5p_epll_get_rate,

I'm not sure we need .get_rate here.
Could you please test without this?

I've followed the legacy code, get_rate is never used,. yes will remove in the next version.

Quoted 39 lines

Review

Quoted 7 lines
arch/arm/plat-s5p/clock.c +2 -0
+};
+

?static struct clk *s5p_clks[] __initdata = {
? ? ? &clk_ext_xtal_mux,
? ? ? &clk_48m,

(quoted diff) +0 -0

b/arch/arm/plat-s5p/include/plat/pll.h

arch/arm/plat-s5p/include/plat/pll.h static inline unsigned long s5p_get_pll46xx(unsigned

Quoted 4 lines

index bf28fad..911a20e 100644

arch/arm/plat-s5p/include/plat/pll.h +0 -0
@@ -94,6 +94,9 @@ static inline unsigned long s5p_get_pll46xx(unsigned

long

Quoted 9 lines
arch/arm/plat-s5p/include/plat/pll.h +3 -0
 baseclk,
 ? ? ? return result;
 ?}
 
+extern int pll46xx_epll_set_rate(struct clk *clk, unsigned long rate);
+extern struct clk_ops pll46xx_epll_ops;
+
 ?#define PLL90XX_MDIV_MASK ? ?(0xFF)
 ?#define PLL90XX_PDIV_MASK ? ?(0x3F)
Quoted 3 lines

?#define PLL90XX_SDIV_MASK ? ?(0x7)
--
1.7.2.3

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

--
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
Shine bright,
(: Nav :)
#14 lore raw

v2 cover ARM: Add SPDIF support for EXYNOS4

In reply to Naveen Krishna Chatradhi

Hi Everyone,

I would like to know if there are
any comments or modifications required in the following patchset.

Quoted 17 lines · Naveen Krishna Chatradhi

?o To Kukjin Kim, Sangbeom Kim, Jassi Brar and Seungwhan Youn

[PATCH v2 1/3] ARM: Samsung: Move duplicate code
?o This is a prerequisite for 2/3 and 3/3 patches thus mentioned as "v2". [PATCH v2 2/3] ARM: EXYNOS4: Add sclk_spdif clocks.
?o v1 patch is https://patchwork.kernel.org/patch/867882/
[PATCH v2 3/3] ARM: EXYNOS4: Add EPLL clock operations
?o v1 patch is https://patchwork.kernel.org/patch/867872/

Best Regards,
Naveen Krishna Chatradhi

--
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
Shine bright,
(: Nav :)