Skip to contentSkip to conversation

ARM: S5P6442: Add clock support for S5P6442

PATCH Superseded Kukjin Kim 3 participants 6 messages Feb 2, 2010 – Feb 4, 2010

Subsystems (3)
lore
Share & tools
lore

Kukjin Kim

author
#0 lore raw

PATCH v3 2/7 ARM: S5P6442: Add clock support for S5P6442

This patch adds clock support for S5P6442. This patch adds the clock register definitions and the various system clocks in S5P6442.

---
 arch/arm/mach-s5p6442/Makefile                  |    2 +-
 arch/arm/mach-s5p6442/clock.c                   |  422 +++++++++++++++++++++++
 arch/arm/mach-s5p6442/include/mach/pwm-clock.h  |   69 ++++
 arch/arm/mach-s5p6442/include/mach/regs-clock.h |  103 ++++++
 arch/arm/mach-s5p6442/include/mach/tick.h       |   26 ++
 5 files changed, 621 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-s5p6442/Makefile
 create mode 100644 arch/arm/mach-s5p6442/clock.c
 create mode 100644 arch/arm/mach-s5p6442/include/mach/pwm-clock.h
 create mode 100644 arch/arm/mach-s5p6442/include/mach/regs-clock.h
 create mode 100644 arch/arm/mach-s5p6442/include/mach/tick.h
arch/arm/mach-s5p6442/Makefile +1 -1
index 0a45d01..f1b3e75 100644
@@ -12,7 +12,7 @@ obj-				:=
 
 # Core support for S5P6442 system
 
-obj-$(CONFIG_CPU_S5P6442)	+= cpu.o init.o
+obj-$(CONFIG_CPU_S5P6442)	+= cpu.o init.o clock.o
 
 # machine support
 
arch/arm/mach-s5p6442/clock.c new file +422 -0

422 lines not on this page · raw message

arch/arm/mach-s5p6442/include/mach/pwm-clock.h new file +69 -0

69 lines not on this page · raw message

arch/arm/mach-s5p6442/include/mach/regs-clock.h new file +103 -0

103 lines not on this page · raw message

arch/arm/mach-s5p6442/include/mach/tick.h new file +26 -0
new file mode 100644
index 0000000..e1d4cab
@@ -0,0 +1,26 @@
+/* linux/arch/arm/mach-s5p6442/include/mach/tick.h
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com/
+ *
+ * Based on arch/arm/mach-s3c6400/include/mach/tick.h
+ *
+ * S5P6442 - Timer tick support definitions
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#ifndef __ASM_ARCH_TICK_H
+#define __ASM_ARCH_TICK_H __FILE__
+
+static inline u32 s3c24xx_ostimer_pending(void)
+{
+	u32 pend = __raw_readl(VA_VIC0 + VIC_RAW_STATUS);
+	return pend & (1 << (IRQ_TIMER4_VIC - S5P_IRQ_VIC0(0)));
+}
+
+#define TICK_MAX	(0xffffffff)
+
+#endif /* __ASM_ARCH_TICK_H */
Signature · 1 line
1.6.2.5
#1 lore raw

PATCH v3 2/7 ARM: S5P6442: Add clock support for S5P6442

Review

Quoted 11 lines

This patch adds clock support for S5P6442. This patch adds the clock register definitions and the various system clocks in S5P6442.

(quoted diff) +8 -0
+static struct clksrc_clk clk_mout_epll = {
+ ? ? ? .clk ? ?= {
+ ? ? ? ? ? ? ? .name ? ? ? ? ? = "mout_epll",
+ ? ? ? ? ? ? ? .id ? ? ? ? ? ? = -1,
+ ? ? ? },
+ ? ? ? .sources ? ? ? ?= &clk_src_epll,
+ ? ? ? .reg_src ? ? ? ?= { .reg = S5P_CLK_SRC0, .shift = 8, .size = 1 },
+};

This appears not to be used, is this implemented in another patch?

Roel

#2 lore raw

PATCH v3 2/7 ARM: S5P6442: Add clock support for S5P6442

Quoted 13 lines · roel kluin

Review

Quoted 11 lines

This patch adds clock support for S5P6442. This patch adds the clock register definitions and the various system clocks in S5P6442.

(quoted diff) +8 -0
+static struct clksrc_clk clk_mout_epll = {
+ ? ? ? .clk ? ?= {
+ ? ? ? ? ? ? ? .name ? ? ? ? ? = "mout_epll",
+ ? ? ? ? ? ? ? .id ? ? ? ? ? ? = -1,
+ ? ? ? },
+ ? ? ? .sources ? ? ? ?= &clk_src_epll,
+ ? ? ? .reg_src ? ? ? ?= { .reg = S5P_CLK_SRC0, .shift = 8, .size = 1 },
+};

This appears not to be used, is this implemented in another patch?

It is, please ignore.

Roel

#3 lore raw

PATCH v3 2/7 ARM: S5P6442: Add clock support for S5P6442

In reply to roel kluin
Quoted 13 lines · roel kluin

Review

Quoted 11 lines

This patch adds clock support for S5P6442. This patch adds the clock register definitions and the various system clocks in S5P6442.

(quoted diff) +8 -0
+static struct clksrc_clk clk_mout_epll = {
+ ? ? ? .clk ? ?= {
+ ? ? ? ? ? ? ? .name ? ? ? ? ? = "mout_epll",
+ ? ? ? ? ? ? ? .id ? ? ? ? ? ? = -1,
+ ? ? ? },
+ ? ? ? .sources ? ? ? ?= &clk_src_epll,
+ ? ? ? .reg_src ? ? ? ?= { .reg = S5P_CLK_SRC0, .shift = 8, .size = 1 },
+};

This appears not to be used, is this implemented in another patch?

Not sure, although I'm not going to argue about it if it isn't.

This new version is better than trying to deal with the switch() statements which initialised the base hclk values.

Quoted 5 lines

Roel
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Signature · 5 lines
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.
#4 lore raw

PATCH v3 2/7 ARM: S5P6442: Add clock support for S5P6442

In reply to Kukjin Kim
Quoted 8 lines · Kukjin Kim

This patch adds clock support for S5P6442. This patch adds the clock register definitions and the various system clocks in S5P6442.

arch/arm/mach-s5p6442/clock.c line 21

Quoted 9 lines
arch/arm/mach-s5p6442/clock.c new file +9 -0
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/errno.h>
+#include <linux/err.h>
+#include <linux/clk.h>
+#include <linux/sysdev.h>
+#include <linux/io.h>

interested to see if these two files are needed in the include, I don't think we've actually got an IO functions or use of sysdev atm.

Quoted 12 lines
arch/arm/mach-s5p6442/clock.c new file +12 -0
+#include <mach/map.h>
+
+#include <plat/cpu-freq.h>
+#include <mach/regs-clock.h>
+#include <plat/clock.h>
+#include <plat/cpu.h>
+#include <plat/pll.h>
+#include <plat/s5p-clock.h>
+#include <plat/clock-clksrc.h>
+#include <plat/s5p6442.h>
+
+static struct clk clk_dout_p0clk = {

arch/arm/mach-s5p6442/clock.c line 50

Quoted 10 lines
arch/arm/mach-s5p6442/clock.c new file +10 -0
+	.name		= "dout_p0clk",
+	.id		= -1,
+	.parent		= &clk_dout_d0clk,
+};
+
+static struct clk clk_dout_p1clk = {
+	.name		= "dout_p1clk",
+	.id		= -1,
+	.parent		= &clk_dout_d1clk,
+};

do we really need these clocks in the way? either #define them if the naming is really important. if they get implemented later then we can deal with that then.

Quoted 18 lines
arch/arm/mach-s5p6442/clock.c new file +18 -0
+void __init_or_cpufreq s5p6442_setup_clocks(void)
+{
+	struct clk *xtal_clk;
+	struct clk *arm_clk;
+	struct clk *hclkd0_clk;
+	struct clk *hclkd1_clk;
+	struct clk *pclkd0_clk;
+	struct clk *pclkd1_clk;
+
+	unsigned long xtal;
+	unsigned long arm;
+	unsigned long hclkd0 = 0;
+	unsigned long hclkd1 = 0;
+	unsigned long pclkd0 = 0;
+	unsigned long pclkd1 = 0;
+
+	unsigned long apll;
+	unsigned long mpll;

arch/arm/mach-s5p6442/clock.c line 299

Quoted 10 lines
arch/arm/mach-s5p6442/clock.c new file +10 -0
+	unsigned long epll;
+	unsigned int ptr;
+
+	printk(KERN_DEBUG "%s: registering clocks\n", __func__);
+
+	xtal_clk = clk_get(NULL, "xtal");
+	BUG_ON(IS_ERR(xtal_clk));
+
+	xtal = clk_get_rate(xtal_clk);
+	clk_put(xtal_clk);

tbh, either make a function to do the clk_get,BUG,clk_put or simply use the clock structures we have in the file.

Quoted 38 lines
arch/arm/mach-s5p6442/clock.c new file +38 -0
+	printk(KERN_DEBUG "%s: xtal is %ld\n", __func__, xtal);
+
+	apll = s5p_get_pll45xx(xtal, __raw_readl(S5P_APLL_CON), pll_4508);
+	mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P_MPLL_CON), pll_4502);
+	epll = s5p_get_pll45xx(xtal, __raw_readl(S5P_EPLL_CON), pll_4500);
+
+	printk(KERN_INFO "S5P6440: PLL settings, A=%ld, M=%ld, E=%ld",
+			apll, mpll, epll);
+
+	clk_fout_apll.rate = apll;
+	clk_fout_mpll.rate = mpll;
+	clk_fout_epll.rate = epll;
+
+	for (ptr = 0; ptr < ARRAY_SIZE(init_parents); ptr++)
+		s3c_set_clksrc(init_parents[ptr], true);
+
+	for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
+		s3c_set_clksrc(&clksrcs[ptr], true);
+
+	arm_clk = clk_get(NULL, "dout_apll");
+	BUG_ON(IS_ERR(arm_clk));
+
+	arm = clk_get_rate(arm_clk);
+	clk_put(arm_clk);
+
+	hclkd0_clk = clk_get(NULL, "dout_d0clk");
+	BUG_ON(IS_ERR(hclkd0_clk));
+
+	hclkd0 = clk_get_rate(hclkd0_clk);
+	clk_put(hclkd0_clk);
+
+	pclkd0_clk = clk_get(NULL, "dout_p0clk");
+	BUG_ON(IS_ERR(pclkd0_clk));
+
+	pclkd0 = clk_get_rate(pclkd0_clk);
+	clk_put(pclkd0_clk);
+
+	hclkd1_clk = clk_get(NULL, "dout_d1clk");

arch/arm/mach-s5p6442/clock.c line 348

Quoted 10 lines
arch/arm/mach-s5p6442/clock.c new file +10 -0
+	BUG_ON(IS_ERR(hclkd1_clk));
+
+	hclkd1 = clk_get_rate(hclkd1_clk);
+	clk_put(hclkd1_clk);
+
+	pclkd1_clk = clk_get(NULL, "dout_p1clk");
+	BUG_ON(IS_ERR(pclkd1_clk));
+
+	pclkd1 = clk_get_rate(pclkd1_clk);
+	clk_put(pclkd1_clk);

see above comment.

Quoted 63 lines
arch/arm/mach-s5p6442/clock.c new file +63 -0
+	printk(KERN_INFO "S5P6442: HCLKD0=%ld, HCLKD1=%ld, PCLKD0=%ld, PCLKD1=%ld\n",
+			hclkd0, hclkd1, pclkd0, pclkd1);
+
+	/* For backward compatibility */
+	clk_f.rate = arm;
+	clk_h.rate = hclkd1;
+	clk_p.rate = pclkd1;
+
+	clk_dout_p1clk.rate = clk_p.rate;
+}
+
+static struct clk init_clocks[] = {
+	{
+		.name		= "systimer",
+		.id		= -1,
+		.parent		= &clk_dout_p1clk,
+		.enable		= s5p6442_clk_ip3_ctrl,
+		.ctrlbit	= (1<<16),
+	}, {
+		.name		= "uart",
+		.id		= 0,
+		.parent		= &clk_dout_p1clk,
+		.enable		= s5p6442_clk_ip3_ctrl,
+		.ctrlbit	= (1<<17),
+	}, {
+		.name		= "uart",
+		.id		= 1,
+		.parent		= &clk_dout_p1clk,
+		.enable		= s5p6442_clk_ip3_ctrl,
+		.ctrlbit	= (1<<18),
+	}, {
+		.name		= "uart",
+		.id		= 2,
+		.parent		= &clk_dout_p1clk,
+		.enable		= s5p6442_clk_ip3_ctrl,
+		.ctrlbit	= (1<<19),
+	}, {
+		.name		= "timers",
+		.id		= -1,
+		.parent		= &clk_dout_p1clk,
+		.enable		= s5p6442_clk_ip3_ctrl,
+		.ctrlbit	= (1<<23),
+	},
+};
+
+static struct clk *clks[] __initdata = {
+	&clk_ext,
+	&clk_epll,
+	&clk_mout_apll.clk,
+	&clk_mout_mpll.clk,
+	&clk_mout_epll.clk,
+	&clk_mout_arm.clk,
+	&clk_mout_d0.clk,
+	&clk_mout_d0sync.clk,
+	&clk_mout_d1.clk,
+	&clk_mout_d1sync.clk,
+	&clk_dout_apll,
+	&clk_dout_a2m,
+	&clk_dout_d0clk,
+	&clk_dout_p0clk,
+	&clk_dout_d1clk,
+	&clk_dout_p1clk,
+};

arch/arm/mach-s5p6442/clock.c line 422

Quoted 10 lines
arch/arm/mach-s5p6442/clock.c new file +10 -0
+
+void __init s5p6442_register_clocks(void)
+{
+	s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
+
+	s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
+	s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
+
+	s3c_pwmclk_init();
+}

Did you clean the unused definitions out of the clock register file too?

Signature · 4 lines
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.
author
#5 lore raw

PATCH v3 2/7 ARM: S5P6442: Add clock support for S5P6442

Quoted 9 lines · Ben Dooks
Quoted 6 lines · Kukjin Kim

This patch adds clock support for S5P6442. This patch adds the clock register definitions and the various system clocks in S5P6442.

Quoted 12 lines

arch/arm/mach-s5p6442/clock.c line 21

Quoted 9 lines
arch/arm/mach-s5p6442/clock.c new file +9 -0
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/errno.h>
+#include <linux/err.h>
+#include <linux/clk.h>
+#include <linux/sysdev.h>
+#include <linux/io.h>

interested to see if these two files are needed in the include, I don't think we've actually got an IO functions or use of sysdev atm.

Hmm...I think, we need IO functions for read SFR. And I will remove sysdev.h as your comments.

Quoted 18 lines
Quoted 18 lines
arch/arm/mach-s5p6442/clock.c new file +18 -0
+#include <mach/map.h>
+
+#include <plat/cpu-freq.h>
+#include <mach/regs-clock.h>
+#include <plat/clock.h>
+#include <plat/cpu.h>
+#include <plat/pll.h>
+#include <plat/s5p-clock.h>
+#include <plat/clock-clksrc.h>
+#include <plat/s5p6442.h>
+
+static struct clk clk_dout_p0clk = {
+	.name		= "dout_p0clk",
+	.id		= -1,
+	.parent		= &clk_dout_d0clk,
+};
+
+static struct clk clk_dout_p1clk = {
Quoted 8 lines

arch/arm/mach-s5p6442/clock.c line 195

Quoted 4 lines
arch/arm/mach-s5p6442/clock.c new file +4 -0
+	.name		= "dout_p1clk",
+	.id		= -1,
+	.parent		= &clk_dout_d1clk,
+};

do we really need these clocks in the way? either #define them if the naming is really important. if they get implemented later then we can deal with that then.

Ok, you're right.
I will change it.

Quoted 23 lines
Quoted 23 lines
arch/arm/mach-s5p6442/clock.c new file +23 -0
+void __init_or_cpufreq s5p6442_setup_clocks(void)
+{
+	struct clk *xtal_clk;
+	struct clk *arm_clk;
+	struct clk *hclkd0_clk;
+	struct clk *hclkd1_clk;
+	struct clk *pclkd0_clk;
+	struct clk *pclkd1_clk;
+
+	unsigned long xtal;
+	unsigned long arm;
+	unsigned long hclkd0 = 0;
+	unsigned long hclkd1 = 0;
+	unsigned long pclkd0 = 0;
+	unsigned long pclkd1 = 0;
+
+	unsigned long apll;
+	unsigned long mpll;
+	unsigned long epll;
+	unsigned int ptr;
+
+	printk(KERN_DEBUG "%s: registering clocks\n", __func__);
+
Quoted 8 lines

arch/arm/mach-s5p6442/clock.c line 299

Quoted 5 lines
arch/arm/mach-s5p6442/clock.c new file +5 -0
+	xtal_clk = clk_get(NULL, "xtal");
+	BUG_ON(IS_ERR(xtal_clk));
+
+	xtal = clk_get_rate(xtal_clk);
+	clk_put(xtal_clk);

tbh, either make a function to do the clk_get,BUG,clk_put or simply use the clock structures we have in the file.

Ok, I'll change it.

Quoted 42 lines
Quoted 42 lines
arch/arm/mach-s5p6442/clock.c new file +42 -0
+	printk(KERN_DEBUG "%s: xtal is %ld\n", __func__, xtal);
+
+	apll = s5p_get_pll45xx(xtal, __raw_readl(S5P_APLL_CON), pll_4508);
+	mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P_MPLL_CON), pll_4502);
+	epll = s5p_get_pll45xx(xtal, __raw_readl(S5P_EPLL_CON), pll_4500);
+
+	printk(KERN_INFO "S5P6440: PLL settings, A=%ld, M=%ld, E=%ld",
+			apll, mpll, epll);
+
+	clk_fout_apll.rate = apll;
+	clk_fout_mpll.rate = mpll;
+	clk_fout_epll.rate = epll;
+
+	for (ptr = 0; ptr < ARRAY_SIZE(init_parents); ptr++)
+		s3c_set_clksrc(init_parents[ptr], true);
+
+	for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
+		s3c_set_clksrc(&clksrcs[ptr], true);
+
+	arm_clk = clk_get(NULL, "dout_apll");
+	BUG_ON(IS_ERR(arm_clk));
+
+	arm = clk_get_rate(arm_clk);
+	clk_put(arm_clk);
+
+	hclkd0_clk = clk_get(NULL, "dout_d0clk");
+	BUG_ON(IS_ERR(hclkd0_clk));
+
+	hclkd0 = clk_get_rate(hclkd0_clk);
+	clk_put(hclkd0_clk);
+
+	pclkd0_clk = clk_get(NULL, "dout_p0clk");
+	BUG_ON(IS_ERR(pclkd0_clk));
+
+	pclkd0 = clk_get_rate(pclkd0_clk);
+	clk_put(pclkd0_clk);
+
+	hclkd1_clk = clk_get(NULL, "dout_d1clk");
+	BUG_ON(IS_ERR(hclkd1_clk));
+
+	hclkd1 = clk_get_rate(hclkd1_clk);
+	clk_put(hclkd1_clk);
Quoted 8 lines

arch/arm/mach-s5p6442/clock.c line 348

Quoted 6 lines
arch/arm/mach-s5p6442/clock.c new file +6 -0
+
+	pclkd1_clk = clk_get(NULL, "dout_p1clk");
+	BUG_ON(IS_ERR(pclkd1_clk));
+
+	pclkd1 = clk_get_rate(pclkd1_clk);
+	clk_put(pclkd1_clk);

see above comment.

Ok, I will change, but in the pclkd0 and pclkd1 case, I used clk_get, clk_get_rate and clk_put.
Because I'm not sure how to get the clk structure name from clksrcs.

Quoted 68 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	printk(KERN_INFO "S5P6442: HCLKD0=%ld, HCLKD1=%ld, PCLKD0=%ld,

PCLKD1=%ld\n",

Quoted 66 lines
arch/arm/mach-s5p6442/clock.c new file +66 -0
+			hclkd0, hclkd1, pclkd0, pclkd1);
+
+	/* For backward compatibility */
+	clk_f.rate = arm;
+	clk_h.rate = hclkd1;
+	clk_p.rate = pclkd1;
+
+	clk_dout_p1clk.rate = clk_p.rate;
+}
+
+static struct clk init_clocks[] = {
+	{
+		.name		= "systimer",
+		.id		= -1,
+		.parent		= &clk_dout_p1clk,
+		.enable		= s5p6442_clk_ip3_ctrl,
+		.ctrlbit	= (1<<16),
+	}, {
+		.name		= "uart",
+		.id		= 0,
+		.parent		= &clk_dout_p1clk,
+		.enable		= s5p6442_clk_ip3_ctrl,
+		.ctrlbit	= (1<<17),
+	}, {
+		.name		= "uart",
+		.id		= 1,
+		.parent		= &clk_dout_p1clk,
+		.enable		= s5p6442_clk_ip3_ctrl,
+		.ctrlbit	= (1<<18),
+	}, {
+		.name		= "uart",
+		.id		= 2,
+		.parent		= &clk_dout_p1clk,
+		.enable		= s5p6442_clk_ip3_ctrl,
+		.ctrlbit	= (1<<19),
+	}, {
+		.name		= "timers",
+		.id		= -1,
+		.parent		= &clk_dout_p1clk,
+		.enable		= s5p6442_clk_ip3_ctrl,
+		.ctrlbit	= (1<<23),
+	},
+};
+
+static struct clk *clks[] __initdata = {
+	&clk_ext,
+	&clk_epll,
+	&clk_mout_apll.clk,
+	&clk_mout_mpll.clk,
+	&clk_mout_epll.clk,
+	&clk_mout_arm.clk,
+	&clk_mout_d0.clk,
+	&clk_mout_d0sync.clk,
+	&clk_mout_d1.clk,
+	&clk_mout_d1sync.clk,
+	&clk_dout_apll,
+	&clk_dout_a2m,
+	&clk_dout_d0clk,
+	&clk_dout_p0clk,
+	&clk_dout_d1clk,
+	&clk_dout_p1clk,
+};
+
+void __init s5p6442_register_clocks(void)
+{
+	s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
Quoted 8 lines

arch/arm/mach-s5p6442/clock.c line 422

Quoted 6 lines
arch/arm/mach-s5p6442/clock.c new file +6 -0
+
+	s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
+	s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
+
+	s3c_pwmclk_init();
+}

Did you clean the unused definitions out of the clock register file too?

Ok, I'll change it.

Actually, I sent updated patch just now.
One more time, please review it.

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, System LSI Division, SAMSUNG ELECTRONICS CO., LTD.