aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShiraz Hashim <shiraz.hashim@st.com>2011-02-16 01:40:32 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-03-09 04:49:44 -0500
commit5c881d9ae9480171f01921585e1893863d7ab421 (patch)
tree1f25afe829901e5cfc79d21d4b99b005b1e8b69c
parent53688c51e412b7fd642e5c8eb8ba8ee19744c4ea (diff)
ARM: 6737/1: SPEAr: formalized timer support
Move platform specific timer initialization code is moved into platform specific files. Reviewed-by: Jamie Iles <jamie@jamieiles.com> Reviewed-by: Stanley Miao <stanley.miao@windriver.com> Signed-off-by: Shiraz Hashim <shiraz.hashim@st.com> Signed-off-by: Rajeev Kumar <rajeev-dlh.kumar@st.com> Signed-off-by: Viresh Kumar <viresh.kumar@st.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mach-spear3xx/include/mach/generic.h3
-rw-r--r--arch/arm/mach-spear3xx/spear300_evb.c2
-rw-r--r--arch/arm/mach-spear3xx/spear310_evb.c2
-rw-r--r--arch/arm/mach-spear3xx/spear320_evb.c2
-rw-r--r--arch/arm/mach-spear3xx/spear3xx.c32
-rw-r--r--arch/arm/mach-spear6xx/include/mach/generic.h3
-rw-r--r--arch/arm/mach-spear6xx/spear600_evb.c2
-rw-r--r--arch/arm/mach-spear6xx/spear6xx.c31
-rw-r--r--arch/arm/plat-spear/time.c21
9 files changed, 78 insertions, 20 deletions
diff --git a/arch/arm/mach-spear3xx/include/mach/generic.h b/arch/arm/mach-spear3xx/include/mach/generic.h
index c16d2f8025e9..e7d2de84e9a5 100644
--- a/arch/arm/mach-spear3xx/include/mach/generic.h
+++ b/arch/arm/mach-spear3xx/include/mach/generic.h
@@ -33,10 +33,11 @@
33/* Add spear3xx family device structure declarations here */ 33/* Add spear3xx family device structure declarations here */
34extern struct amba_device gpio_device; 34extern struct amba_device gpio_device;
35extern struct amba_device uart_device; 35extern struct amba_device uart_device;
36extern struct sys_timer spear_sys_timer; 36extern struct sys_timer spear3xx_timer;
37 37
38/* Add spear3xx family function declarations here */ 38/* Add spear3xx family function declarations here */
39void __init clk_init(void); 39void __init clk_init(void);
40void __init spear_setup_timer(void);
40void __init spear3xx_map_io(void); 41void __init spear3xx_map_io(void);
41void __init spear3xx_init_irq(void); 42void __init spear3xx_init_irq(void);
42void __init spear3xx_init(void); 43void __init spear3xx_init(void);
diff --git a/arch/arm/mach-spear3xx/spear300_evb.c b/arch/arm/mach-spear3xx/spear300_evb.c
index 2c90663e5c71..cd23c98b2ffd 100644
--- a/arch/arm/mach-spear3xx/spear300_evb.c
+++ b/arch/arm/mach-spear3xx/spear300_evb.c
@@ -71,6 +71,6 @@ MACHINE_START(SPEAR300, "ST-SPEAR300-EVB")
71 .boot_params = 0x00000100, 71 .boot_params = 0x00000100,
72 .map_io = spear3xx_map_io, 72 .map_io = spear3xx_map_io,
73 .init_irq = spear3xx_init_irq, 73 .init_irq = spear3xx_init_irq,
74 .timer = &spear_sys_timer, 74 .timer = &spear3xx_timer,
75 .init_machine = spear300_evb_init, 75 .init_machine = spear300_evb_init,
76MACHINE_END 76MACHINE_END
diff --git a/arch/arm/mach-spear3xx/spear310_evb.c b/arch/arm/mach-spear3xx/spear310_evb.c
index 4e55e553a2cf..385543108262 100644
--- a/arch/arm/mach-spear3xx/spear310_evb.c
+++ b/arch/arm/mach-spear3xx/spear310_evb.c
@@ -78,6 +78,6 @@ MACHINE_START(SPEAR310, "ST-SPEAR310-EVB")
78 .boot_params = 0x00000100, 78 .boot_params = 0x00000100,
79 .map_io = spear3xx_map_io, 79 .map_io = spear3xx_map_io,
80 .init_irq = spear3xx_init_irq, 80 .init_irq = spear3xx_init_irq,
81 .timer = &spear_sys_timer, 81 .timer = &spear3xx_timer,
82 .init_machine = spear310_evb_init, 82 .init_machine = spear310_evb_init,
83MACHINE_END 83MACHINE_END
diff --git a/arch/arm/mach-spear3xx/spear320_evb.c b/arch/arm/mach-spear3xx/spear320_evb.c
index 7083a06df9b6..4a7ce35fdf8c 100644
--- a/arch/arm/mach-spear3xx/spear320_evb.c
+++ b/arch/arm/mach-spear3xx/spear320_evb.c
@@ -75,6 +75,6 @@ MACHINE_START(SPEAR320, "ST-SPEAR320-EVB")
75 .boot_params = 0x00000100, 75 .boot_params = 0x00000100,
76 .map_io = spear3xx_map_io, 76 .map_io = spear3xx_map_io,
77 .init_irq = spear3xx_init_irq, 77 .init_irq = spear3xx_init_irq,
78 .timer = &spear_sys_timer, 78 .timer = &spear3xx_timer,
79 .init_machine = spear320_evb_init, 79 .init_machine = spear320_evb_init,
80MACHINE_END 80MACHINE_END
diff --git a/arch/arm/mach-spear3xx/spear3xx.c b/arch/arm/mach-spear3xx/spear3xx.c
index faf87097767d..e12a06c3b85b 100644
--- a/arch/arm/mach-spear3xx/spear3xx.c
+++ b/arch/arm/mach-spear3xx/spear3xx.c
@@ -523,5 +523,35 @@ struct pmx_dev pmx_plgpio_45_46_49_50 = {
523 .mode_count = ARRAY_SIZE(pmx_plgpio_45_46_49_50_modes), 523 .mode_count = ARRAY_SIZE(pmx_plgpio_45_46_49_50_modes),
524 .enb_on_reset = 1, 524 .enb_on_reset = 1,
525}; 525};
526#endif /* CONFIG_MACH_SPEAR310 || CONFIG_MACH_SPEAR320 */
526 527
527#endif 528static void __init spear3xx_timer_init(void)
529{
530 char pclk_name[] = "pll3_48m_clk";
531 struct clk *gpt_clk, *pclk;
532
533 /* get the system timer clock */
534 gpt_clk = clk_get_sys("gpt0", NULL);
535 if (IS_ERR(gpt_clk)) {
536 pr_err("%s:couldn't get clk for gpt\n", __func__);
537 BUG();
538 }
539
540 /* get the suitable parent clock for timer*/
541 pclk = clk_get(NULL, pclk_name);
542 if (IS_ERR(pclk)) {
543 pr_err("%s:couldn't get %s as parent for gpt\n",
544 __func__, pclk_name);
545 BUG();
546 }
547
548 clk_set_parent(gpt_clk, pclk);
549 clk_put(gpt_clk);
550 clk_put(pclk);
551
552 spear_setup_timer();
553}
554
555struct sys_timer spear3xx_timer = {
556 .init = spear3xx_timer_init,
557};
diff --git a/arch/arm/mach-spear6xx/include/mach/generic.h b/arch/arm/mach-spear6xx/include/mach/generic.h
index 16205a538756..e5967ededdc3 100644
--- a/arch/arm/mach-spear6xx/include/mach/generic.h
+++ b/arch/arm/mach-spear6xx/include/mach/generic.h
@@ -31,9 +31,10 @@
31/* Add spear6xx family device structure declarations here */ 31/* Add spear6xx family device structure declarations here */
32extern struct amba_device gpio_device[]; 32extern struct amba_device gpio_device[];
33extern struct amba_device uart_device[]; 33extern struct amba_device uart_device[];
34extern struct sys_timer spear_sys_timer; 34extern struct sys_timer spear6xx_timer;
35 35
36/* Add spear6xx family function declarations here */ 36/* Add spear6xx family function declarations here */
37void __init spear_setup_timer(void);
37void __init spear6xx_map_io(void); 38void __init spear6xx_map_io(void);
38void __init spear6xx_init_irq(void); 39void __init spear6xx_init_irq(void);
39void __init spear6xx_init(void); 40void __init spear6xx_init(void);
diff --git a/arch/arm/mach-spear6xx/spear600_evb.c b/arch/arm/mach-spear6xx/spear600_evb.c
index daff8d04f7b6..b0ed0dfe9b01 100644
--- a/arch/arm/mach-spear6xx/spear600_evb.c
+++ b/arch/arm/mach-spear6xx/spear600_evb.c
@@ -46,6 +46,6 @@ MACHINE_START(SPEAR600, "ST-SPEAR600-EVB")
46 .boot_params = 0x00000100, 46 .boot_params = 0x00000100,
47 .map_io = spear6xx_map_io, 47 .map_io = spear6xx_map_io,
48 .init_irq = spear6xx_init_irq, 48 .init_irq = spear6xx_init_irq,
49 .timer = &spear_sys_timer, 49 .timer = &spear6xx_timer,
50 .init_machine = spear600_evb_init, 50 .init_machine = spear600_evb_init,
51MACHINE_END 51MACHINE_END
diff --git a/arch/arm/mach-spear6xx/spear6xx.c b/arch/arm/mach-spear6xx/spear6xx.c
index f2fe14e8471d..9cd3a688f6dc 100644
--- a/arch/arm/mach-spear6xx/spear6xx.c
+++ b/arch/arm/mach-spear6xx/spear6xx.c
@@ -155,3 +155,34 @@ void __init spear6xx_map_io(void)
155 /* This will initialize clock framework */ 155 /* This will initialize clock framework */
156 clk_init(); 156 clk_init();
157} 157}
158
159static void __init spear6xx_timer_init(void)
160{
161 char pclk_name[] = "pll3_48m_clk";
162 struct clk *gpt_clk, *pclk;
163
164 /* get the system timer clock */
165 gpt_clk = clk_get_sys("gpt0", NULL);
166 if (IS_ERR(gpt_clk)) {
167 pr_err("%s:couldn't get clk for gpt\n", __func__);
168 BUG();
169 }
170
171 /* get the suitable parent clock for timer*/
172 pclk = clk_get(NULL, pclk_name);
173 if (IS_ERR(pclk)) {
174 pr_err("%s:couldn't get %s as parent for gpt\n",
175 __func__, pclk_name);
176 BUG();
177 }
178
179 clk_set_parent(gpt_clk, pclk);
180 clk_put(gpt_clk);
181 clk_put(pclk);
182
183 spear_setup_timer();
184}
185
186struct sys_timer spear6xx_timer = {
187 .init = spear6xx_timer_init,
188};
diff --git a/arch/arm/plat-spear/time.c b/arch/arm/plat-spear/time.c
index 839c88df9994..100672fa48e1 100644
--- a/arch/arm/plat-spear/time.c
+++ b/arch/arm/plat-spear/time.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/arm/plat-spear/time.c 2 * arch/arm/plat-spear/time.c
3 * 3 *
4 * Copyright (C) 2009 ST Microelectronics 4 * Copyright (C) 2010 ST Microelectronics
5 * Shiraz Hashim<shiraz.hashim@st.com> 5 * Shiraz Hashim<shiraz.hashim@st.com>
6 * 6 *
7 * This file is licensed under the terms of the GNU General Public 7 * This file is licensed under the terms of the GNU General Public
@@ -211,7 +211,7 @@ static void __init spear_clockevent_init(void)
211 211
212void __init spear_setup_timer(void) 212void __init spear_setup_timer(void)
213{ 213{
214 struct clk *pll3_clk; 214 int ret;
215 215
216 if (!request_mem_region(SPEAR_GPT0_BASE, SZ_1K, "gpt0")) { 216 if (!request_mem_region(SPEAR_GPT0_BASE, SZ_1K, "gpt0")) {
217 pr_err("%s:cannot get IO addr\n", __func__); 217 pr_err("%s:cannot get IO addr\n", __func__);
@@ -230,26 +230,21 @@ void __init spear_setup_timer(void)
230 goto err_iomap; 230 goto err_iomap;
231 } 231 }
232 232
233 pll3_clk = clk_get(NULL, "pll3_48m_clk"); 233 ret = clk_enable(gpt_clk);
234 if (!pll3_clk) { 234 if (ret < 0) {
235 pr_err("%s:couldn't get PLL3 as parent for gpt\n", __func__); 235 pr_err("%s:couldn't enable gpt clock\n", __func__);
236 goto err_iomap; 236 goto err_clk;
237 } 237 }
238 238
239 clk_set_parent(gpt_clk, pll3_clk);
240
241 spear_clockevent_init(); 239 spear_clockevent_init();
242 spear_clocksource_init(); 240 spear_clocksource_init();
243 241
244 return; 242 return;
245 243
244err_clk:
245 clk_put(gpt_clk);
246err_iomap: 246err_iomap:
247 iounmap(gpt_base); 247 iounmap(gpt_base);
248
249err_mem: 248err_mem:
250 release_mem_region(SPEAR_GPT0_BASE, SZ_1K); 249 release_mem_region(SPEAR_GPT0_BASE, SZ_1K);
251} 250}
252
253struct sys_timer spear_sys_timer = {
254 .init = spear_setup_timer,
255};