aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-s3c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/plat-s3c')
-rw-r--r--arch/arm/plat-s3c/Kconfig12
-rw-r--r--arch/arm/plat-s3c/clock.c10
-rw-r--r--arch/arm/plat-s3c/include/plat/clock.h16
-rw-r--r--arch/arm/plat-s3c/include/plat/cpu.h2
-rw-r--r--arch/arm/plat-s3c/include/plat/debug-macro.S2
-rw-r--r--arch/arm/plat-s3c/include/plat/devs.h1
-rw-r--r--arch/arm/plat-s3c/include/plat/map-base.h (renamed from arch/arm/plat-s3c/include/plat/map.h)0
-rw-r--r--arch/arm/plat-s3c/include/plat/regs-serial.h14
-rw-r--r--arch/arm/plat-s3c/include/plat/regs-timer.h11
-rw-r--r--arch/arm/plat-s3c/include/plat/uncompress.h2
-rw-r--r--arch/arm/plat-s3c/pwm-clock.c71
-rw-r--r--arch/arm/plat-s3c/time.c81
12 files changed, 140 insertions, 82 deletions
diff --git a/arch/arm/plat-s3c/Kconfig b/arch/arm/plat-s3c/Kconfig
index 10c1dd3cd46..adb9060ec91 100644
--- a/arch/arm/plat-s3c/Kconfig
+++ b/arch/arm/plat-s3c/Kconfig
@@ -6,8 +6,8 @@
6 6
7config PLAT_S3C 7config PLAT_S3C
8 bool 8 bool
9 depends on ARCH_S3C2410 9 depends on ARCH_S3C2410 || ARCH_S3C24A0 || ARCH_S3C64XX
10 default y if ARCH_S3C2410 10 default y
11 select NO_IOPORT 11 select NO_IOPORT
12 help 12 help
13 Base platform code for any Samsung S3C device 13 Base platform code for any Samsung S3C device
@@ -16,24 +16,24 @@ config PLAT_S3C
16 16
17config CPU_LLSERIAL_S3C2410_ONLY 17config CPU_LLSERIAL_S3C2410_ONLY
18 bool 18 bool
19 depends on ARCH_S3C2410 19 depends on PLAT_S3C
20 default y if CPU_LLSERIAL_S3C2410 && !CPU_LLSERIAL_S3C2440 20 default y if CPU_LLSERIAL_S3C2410 && !CPU_LLSERIAL_S3C2440
21 21
22config CPU_LLSERIAL_S3C2440_ONLY 22config CPU_LLSERIAL_S3C2440_ONLY
23 bool 23 bool
24 depends on ARCH_S3C2410 24 depends on PLAT_S3C
25 default y if CPU_LLSERIAL_S3C2440 && !CPU_LLSERIAL_S3C2410 25 default y if CPU_LLSERIAL_S3C2440 && !CPU_LLSERIAL_S3C2410
26 26
27config CPU_LLSERIAL_S3C2410 27config CPU_LLSERIAL_S3C2410
28 bool 28 bool
29 depends on ARCH_S3C2410 29 depends on PLAT_S3C
30 help 30 help
31 Selected if there is an S3C2410 (or register compatible) serial 31 Selected if there is an S3C2410 (or register compatible) serial
32 low-level implementation needed 32 low-level implementation needed
33 33
34config CPU_LLSERIAL_S3C2440 34config CPU_LLSERIAL_S3C2440
35 bool 35 bool
36 depends on ARCH_S3C2410 36 depends on PLAT_S3C
37 help 37 help
38 Selected if there is an S3C2440 (or register compatible) serial 38 Selected if there is an S3C2440 (or register compatible) serial
39 low-level implementation needed 39 low-level implementation needed
diff --git a/arch/arm/plat-s3c/clock.c b/arch/arm/plat-s3c/clock.c
index da7ac07c7a0..1054d18828f 100644
--- a/arch/arm/plat-s3c/clock.c
+++ b/arch/arm/plat-s3c/clock.c
@@ -239,6 +239,16 @@ struct clk clk_xtal = {
239 .ctrlbit = 0, 239 .ctrlbit = 0,
240}; 240};
241 241
242struct clk clk_ext = {
243 .name = "ext",
244 .id = -1,
245};
246
247struct clk clk_epll = {
248 .name = "epll",
249 .id = -1,
250};
251
242struct clk clk_mpll = { 252struct clk clk_mpll = {
243 .name = "mpll", 253 .name = "mpll",
244 .id = -1, 254 .id = -1,
diff --git a/arch/arm/plat-s3c/include/plat/clock.h b/arch/arm/plat-s3c/include/plat/clock.h
index d871609738f..a10622eed43 100644
--- a/arch/arm/plat-s3c/include/plat/clock.h
+++ b/arch/arm/plat-s3c/include/plat/clock.h
@@ -45,7 +45,13 @@ extern struct clk clk_h;
45extern struct clk clk_p; 45extern struct clk clk_p;
46extern struct clk clk_mpll; 46extern struct clk clk_mpll;
47extern struct clk clk_upll; 47extern struct clk clk_upll;
48extern struct clk clk_epll;
48extern struct clk clk_xtal; 49extern struct clk clk_xtal;
50extern struct clk clk_ext;
51
52/* S3C64XX specific clocks */
53extern struct clk clk_27m;
54extern struct clk clk_48m;
49 55
50/* exports for arch/arm/mach-s3c2410 56/* exports for arch/arm/mach-s3c2410
51 * 57 *
@@ -61,6 +67,8 @@ extern int s3c24xx_register_clocks(struct clk **clk, int nr_clks);
61 67
62extern int s3c24xx_register_baseclocks(unsigned long xtal); 68extern int s3c24xx_register_baseclocks(unsigned long xtal);
63 69
70extern void s3c64xx_register_clocks(void);
71
64extern void s3c24xx_setup_clocks(unsigned long fclk, 72extern void s3c24xx_setup_clocks(unsigned long fclk,
65 unsigned long hclk, 73 unsigned long hclk,
66 unsigned long pclk); 74 unsigned long pclk);
@@ -70,3 +78,11 @@ extern void s3c2412_setup_clocks(void);
70extern void s3c244x_setup_clocks(void); 78extern void s3c244x_setup_clocks(void);
71extern void s3c2443_setup_clocks(void); 79extern void s3c2443_setup_clocks(void);
72 80
81/* S3C64XX specific functions and clocks */
82
83extern int s3c64xx_sclk_ctrl(struct clk *clk, int enable);
84
85/* Init for pwm clock code */
86
87extern void s3c_pwmclk_init(void);
88
diff --git a/arch/arm/plat-s3c/include/plat/cpu.h b/arch/arm/plat-s3c/include/plat/cpu.h
index 011157ea871..e62ae0fcfe5 100644
--- a/arch/arm/plat-s3c/include/plat/cpu.h
+++ b/arch/arm/plat-s3c/include/plat/cpu.h
@@ -44,8 +44,10 @@ extern void s3c_init_cpu(unsigned long idcode,
44/* core initialisation functions */ 44/* core initialisation functions */
45 45
46extern void s3c24xx_init_irq(void); 46extern void s3c24xx_init_irq(void);
47extern void s3c64xx_init_irq(u32 vic0, u32 vic1);
47 48
48extern void s3c24xx_init_io(struct map_desc *mach_desc, int size); 49extern void s3c24xx_init_io(struct map_desc *mach_desc, int size);
50extern void s3c64xx_init_io(struct map_desc *mach_desc, int size);
49 51
50extern void s3c24xx_init_uarts(struct s3c2410_uartcfg *cfg, int no); 52extern void s3c24xx_init_uarts(struct s3c2410_uartcfg *cfg, int no);
51 53
diff --git a/arch/arm/plat-s3c/include/plat/debug-macro.S b/arch/arm/plat-s3c/include/plat/debug-macro.S
index 4aa7e2e6c00..3634d4e3708 100644
--- a/arch/arm/plat-s3c/include/plat/debug-macro.S
+++ b/arch/arm/plat-s3c/include/plat/debug-macro.S
@@ -20,7 +20,7 @@
20 .endm 20 .endm
21 21
22#ifndef fifo_level 22#ifndef fifo_level
23#define fifo_level fifo_level_s3c2410 23#define fifo_level fifo_level_s3c2440
24#endif 24#endif
25 25
26 .macro fifo_full_s3c2440 rd, rx 26 .macro fifo_full_s3c2440 rd, rx
diff --git a/arch/arm/plat-s3c/include/plat/devs.h b/arch/arm/plat-s3c/include/plat/devs.h
index badaac9d64a..a689c7c5ac2 100644
--- a/arch/arm/plat-s3c/include/plat/devs.h
+++ b/arch/arm/plat-s3c/include/plat/devs.h
@@ -17,6 +17,7 @@ struct s3c24xx_uart_resources {
17}; 17};
18 18
19extern struct s3c24xx_uart_resources s3c2410_uart_resources[]; 19extern struct s3c24xx_uart_resources s3c2410_uart_resources[];
20extern struct s3c24xx_uart_resources s3c64xx_uart_resources[];
20 21
21extern struct platform_device *s3c24xx_uart_devs[]; 22extern struct platform_device *s3c24xx_uart_devs[];
22extern struct platform_device *s3c24xx_uart_src[]; 23extern struct platform_device *s3c24xx_uart_src[];
diff --git a/arch/arm/plat-s3c/include/plat/map.h b/arch/arm/plat-s3c/include/plat/map-base.h
index b84289d32a5..b84289d32a5 100644
--- a/arch/arm/plat-s3c/include/plat/map.h
+++ b/arch/arm/plat-s3c/include/plat/map-base.h
diff --git a/arch/arm/plat-s3c/include/plat/regs-serial.h b/arch/arm/plat-s3c/include/plat/regs-serial.h
index a0daa647b92..3ca28585cf8 100644
--- a/arch/arm/plat-s3c/include/plat/regs-serial.h
+++ b/arch/arm/plat-s3c/include/plat/regs-serial.h
@@ -77,6 +77,12 @@
77#define S3C2440_UCON_FCLK (3<<10) 77#define S3C2440_UCON_FCLK (3<<10)
78#define S3C2443_UCON_EPLL (3<<10) 78#define S3C2443_UCON_EPLL (3<<10)
79 79
80#define S3C6400_UCON_CLKMASK (3<<10)
81#define S3C6400_UCON_PCLK (0<<10)
82#define S3C6400_UCON_PCLK2 (2<<10)
83#define S3C6400_UCON_UCLK0 (1<<10)
84#define S3C6400_UCON_UCLK1 (3<<10)
85
80#define S3C2440_UCON2_FCLK_EN (1<<15) 86#define S3C2440_UCON2_FCLK_EN (1<<15)
81#define S3C2440_UCON0_DIVMASK (15 << 12) 87#define S3C2440_UCON0_DIVMASK (15 << 12)
82#define S3C2440_UCON1_DIVMASK (15 << 12) 88#define S3C2440_UCON1_DIVMASK (15 << 12)
@@ -149,6 +155,14 @@
149#define S3C2410_UFSTAT_RXMASK (15<<0) 155#define S3C2410_UFSTAT_RXMASK (15<<0)
150#define S3C2410_UFSTAT_RXSHIFT (0) 156#define S3C2410_UFSTAT_RXSHIFT (0)
151 157
158/* UFSTAT S3C24A0 */
159#define S3C24A0_UFSTAT_TXFULL (1 << 14)
160#define S3C24A0_UFSTAT_RXFULL (1 << 6)
161#define S3C24A0_UFSTAT_TXMASK (63 << 8)
162#define S3C24A0_UFSTAT_TXSHIFT (8)
163#define S3C24A0_UFSTAT_RXMASK (63)
164#define S3C24A0_UFSTAT_RXSHIFT (0)
165
152/* UFSTAT S3C2443 same as S3C2440 */ 166/* UFSTAT S3C2443 same as S3C2440 */
153#define S3C2440_UFSTAT_TXFULL (1<<14) 167#define S3C2440_UFSTAT_TXFULL (1<<14)
154#define S3C2440_UFSTAT_RXFULL (1<<6) 168#define S3C2440_UFSTAT_RXFULL (1<<6)
diff --git a/arch/arm/plat-s3c/include/plat/regs-timer.h b/arch/arm/plat-s3c/include/plat/regs-timer.h
index cc0eedd53e3..d097d92f8cc 100644
--- a/arch/arm/plat-s3c/include/plat/regs-timer.h
+++ b/arch/arm/plat-s3c/include/plat/regs-timer.h
@@ -10,7 +10,6 @@
10 * S3C2410 Timer configuration 10 * S3C2410 Timer configuration
11*/ 11*/
12 12
13
14#ifndef __ASM_ARCH_REGS_TIMER_H 13#ifndef __ASM_ARCH_REGS_TIMER_H
15#define __ASM_ARCH_REGS_TIMER_H 14#define __ASM_ARCH_REGS_TIMER_H
16 15
@@ -21,6 +20,8 @@
21#define S3C2410_TCFG1 S3C_TIMERREG(0x04) 20#define S3C2410_TCFG1 S3C_TIMERREG(0x04)
22#define S3C2410_TCON S3C_TIMERREG(0x08) 21#define S3C2410_TCON S3C_TIMERREG(0x08)
23 22
23#define S3C64XX_TINT_CSTAT S3C_TIMERREG(0x44)
24
24#define S3C2410_TCFG_PRESCALER0_MASK (255<<0) 25#define S3C2410_TCFG_PRESCALER0_MASK (255<<0)
25#define S3C2410_TCFG_PRESCALER1_MASK (255<<8) 26#define S3C2410_TCFG_PRESCALER1_MASK (255<<8)
26#define S3C2410_TCFG_PRESCALER1_SHIFT (8) 27#define S3C2410_TCFG_PRESCALER1_SHIFT (8)
@@ -72,6 +73,14 @@
72#define S3C2410_TCFG1_MUX_TCLK (4<<0) 73#define S3C2410_TCFG1_MUX_TCLK (4<<0)
73#define S3C2410_TCFG1_MUX_MASK (15<<0) 74#define S3C2410_TCFG1_MUX_MASK (15<<0)
74 75
76#define S3C64XX_TCFG1_MUX_DIV1 (0<<0)
77#define S3C64XX_TCFG1_MUX_DIV2 (1<<0)
78#define S3C64XX_TCFG1_MUX_DIV4 (2<<0)
79#define S3C64XX_TCFG1_MUX_DIV8 (3<<0)
80#define S3C64XX_TCFG1_MUX_DIV16 (4<<0)
81#define S3C64XX_TCFG1_MUX_TCLK (5<<0) /* 3 sets of TCLK */
82#define S3C64XX_TCFG1_MUX_MASK (15<<0)
83
75#define S3C2410_TCFG1_SHIFT(x) ((x) * 4) 84#define S3C2410_TCFG1_SHIFT(x) ((x) * 4)
76 85
77/* for each timer, we have an count buffer, an compare buffer and 86/* for each timer, we have an count buffer, an compare buffer and
diff --git a/arch/arm/plat-s3c/include/plat/uncompress.h b/arch/arm/plat-s3c/include/plat/uncompress.h
index 2c39a309aeb..6061de87f22 100644
--- a/arch/arm/plat-s3c/include/plat/uncompress.h
+++ b/arch/arm/plat-s3c/include/plat/uncompress.h
@@ -37,7 +37,7 @@ static void arch_detect_cpu(void);
37/* how many bytes we allow into the FIFO at a time in FIFO mode */ 37/* how many bytes we allow into the FIFO at a time in FIFO mode */
38#define FIFO_MAX (14) 38#define FIFO_MAX (14)
39 39
40#define uart_base S3C24XX_PA_UART + (0x4000*CONFIG_S3C_LOWLEVEL_UART_PORT) 40#define uart_base S3C_PA_UART + (S3C_UART_OFFSET * CONFIG_S3C_LOWLEVEL_UART_PORT)
41 41
42static __inline__ void 42static __inline__ void
43uart_wr(unsigned int reg, unsigned int val) 43uart_wr(unsigned int reg, unsigned int val)
diff --git a/arch/arm/plat-s3c/pwm-clock.c b/arch/arm/plat-s3c/pwm-clock.c
index e07d82891a9..a318215ab53 100644
--- a/arch/arm/plat-s3c/pwm-clock.c
+++ b/arch/arm/plat-s3c/pwm-clock.c
@@ -14,20 +14,20 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/list.h> 15#include <linux/list.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/log2.h>
17#include <linux/clk.h> 18#include <linux/clk.h>
18#include <linux/err.h> 19#include <linux/err.h>
19#include <linux/io.h> 20#include <linux/io.h>
20 21
21#include <mach/hardware.h> 22#include <mach/hardware.h>
23#include <mach/map.h>
22#include <asm/irq.h> 24#include <asm/irq.h>
23 25
24#include <mach/regs-clock.h>
25#include <mach/regs-gpio.h>
26
27#include <plat/clock.h> 26#include <plat/clock.h>
28#include <plat/cpu.h> 27#include <plat/cpu.h>
29 28
30#include <plat/regs-timer.h> 29#include <plat/regs-timer.h>
30#include <mach/pwm-clock.h>
31 31
32/* Each of the timers 0 through 5 go through the following 32/* Each of the timers 0 through 5 go through the following
33 * clock tree, with the inputs depending on the timers. 33 * clock tree, with the inputs depending on the timers.
@@ -168,11 +168,6 @@ static inline struct pwm_tdiv_clk *to_tdiv(struct clk *clk)
168 return container_of(clk, struct pwm_tdiv_clk, clk); 168 return container_of(clk, struct pwm_tdiv_clk, clk);
169} 169}
170 170
171static inline unsigned long tcfg_to_divisor(unsigned long tcfg1)
172{
173 return 1 << (1 + tcfg1);
174}
175
176static unsigned long clk_pwm_tdiv_get_rate(struct clk *clk) 171static unsigned long clk_pwm_tdiv_get_rate(struct clk *clk)
177{ 172{
178 unsigned long tcfg1 = __raw_readl(S3C2410_TCFG1); 173 unsigned long tcfg1 = __raw_readl(S3C2410_TCFG1);
@@ -181,7 +176,7 @@ static unsigned long clk_pwm_tdiv_get_rate(struct clk *clk)
181 tcfg1 >>= S3C2410_TCFG1_SHIFT(clk->id); 176 tcfg1 >>= S3C2410_TCFG1_SHIFT(clk->id);
182 tcfg1 &= S3C2410_TCFG1_MUX_MASK; 177 tcfg1 &= S3C2410_TCFG1_MUX_MASK;
183 178
184 if (tcfg1 == S3C2410_TCFG1_MUX_TCLK) 179 if (pwm_cfg_src_is_tclk(tcfg1))
185 divisor = to_tdiv(clk)->divisor; 180 divisor = to_tdiv(clk)->divisor;
186 else 181 else
187 divisor = tcfg_to_divisor(tcfg1); 182 divisor = tcfg_to_divisor(tcfg1);
@@ -198,7 +193,9 @@ static unsigned long clk_pwm_tdiv_round_rate(struct clk *clk,
198 parent_rate = clk_get_rate(clk->parent); 193 parent_rate = clk_get_rate(clk->parent);
199 divisor = parent_rate / rate; 194 divisor = parent_rate / rate;
200 195
201 if (divisor <= 2) 196 if (divisor <= 1 && pwm_tdiv_has_div1())
197 divisor = 1;
198 else if (divisor <= 2)
202 divisor = 2; 199 divisor = 2;
203 else if (divisor <= 4) 200 else if (divisor <= 4)
204 divisor = 4; 201 divisor = 4;
@@ -212,25 +209,7 @@ static unsigned long clk_pwm_tdiv_round_rate(struct clk *clk,
212 209
213static unsigned long clk_pwm_tdiv_bits(struct pwm_tdiv_clk *divclk) 210static unsigned long clk_pwm_tdiv_bits(struct pwm_tdiv_clk *divclk)
214{ 211{
215 unsigned long bits; 212 return pwm_tdiv_div_bits(divclk->divisor);
216
217 switch (divclk->divisor) {
218 case 2:
219 bits = S3C2410_TCFG1_MUX_DIV2;
220 break;
221 case 4:
222 bits = S3C2410_TCFG1_MUX_DIV4;
223 break;
224 case 8:
225 bits = S3C2410_TCFG1_MUX_DIV8;
226 break;
227 case 16:
228 default:
229 bits = S3C2410_TCFG1_MUX_DIV16;
230 break;
231 }
232
233 return bits;
234} 213}
235 214
236static void clk_pwm_tdiv_update(struct pwm_tdiv_clk *divclk) 215static void clk_pwm_tdiv_update(struct pwm_tdiv_clk *divclk)
@@ -271,7 +250,7 @@ static int clk_pwm_tdiv_set_rate(struct clk *clk, unsigned long rate)
271 /* Update the current MUX settings if we are currently 250 /* Update the current MUX settings if we are currently
272 * selected as the clock source for this clock. */ 251 * selected as the clock source for this clock. */
273 252
274 if (tcfg1 != S3C2410_TCFG1_MUX_TCLK) 253 if (!pwm_cfg_src_is_tclk(tcfg1))
275 clk_pwm_tdiv_update(divclk); 254 clk_pwm_tdiv_update(divclk);
276 255
277 return 0; 256 return 0;
@@ -358,7 +337,7 @@ static int clk_pwm_tin_set_parent(struct clk *clk, struct clk *parent)
358 unsigned long shift = S3C2410_TCFG1_SHIFT(id); 337 unsigned long shift = S3C2410_TCFG1_SHIFT(id);
359 338
360 if (parent == s3c24xx_pwmclk_tclk(id)) 339 if (parent == s3c24xx_pwmclk_tclk(id))
361 bits = S3C2410_TCFG1_MUX_TCLK << shift; 340 bits = S3C_TCFG1_MUX_TCLK << shift;
362 else if (parent == s3c24xx_pwmclk_tdiv(id)) 341 else if (parent == s3c24xx_pwmclk_tdiv(id))
363 bits = clk_pwm_tdiv_bits(to_tdiv(parent)) << shift; 342 bits = clk_pwm_tdiv_bits(to_tdiv(parent)) << shift;
364 else 343 else
@@ -420,7 +399,7 @@ static __init int clk_pwm_tin_register(struct clk *pwm)
420 tcfg1 >>= S3C2410_TCFG1_SHIFT(id); 399 tcfg1 >>= S3C2410_TCFG1_SHIFT(id);
421 tcfg1 &= S3C2410_TCFG1_MUX_MASK; 400 tcfg1 &= S3C2410_TCFG1_MUX_MASK;
422 401
423 if (tcfg1 == S3C2410_TCFG1_MUX_TCLK) 402 if (pwm_cfg_src_is_tclk(tcfg1))
424 parent = s3c24xx_pwmclk_tclk(id); 403 parent = s3c24xx_pwmclk_tclk(id);
425 else 404 else
426 parent = s3c24xx_pwmclk_tdiv(id); 405 parent = s3c24xx_pwmclk_tdiv(id);
@@ -428,7 +407,16 @@ static __init int clk_pwm_tin_register(struct clk *pwm)
428 return clk_set_parent(pwm, parent); 407 return clk_set_parent(pwm, parent);
429} 408}
430 409
431static __init int s3c24xx_pwmclk_init(void) 410/**
411 * s3c_pwmclk_init() - initialise pwm clocks
412 *
413 * Initialise and register the clocks which provide the inputs for the
414 * pwm timer blocks.
415 *
416 * Note, this call is required by the time core, so must be called after
417 * the base clocks are added and before any of the initcalls are run.
418 */
419__init void s3c_pwmclk_init(void)
432{ 420{
433 struct clk *clk_timers; 421 struct clk *clk_timers;
434 unsigned int clk; 422 unsigned int clk;
@@ -437,7 +425,7 @@ static __init int s3c24xx_pwmclk_init(void)
437 clk_timers = clk_get(NULL, "timers"); 425 clk_timers = clk_get(NULL, "timers");
438 if (IS_ERR(clk_timers)) { 426 if (IS_ERR(clk_timers)) {
439 printk(KERN_ERR "%s: no parent clock\n", __func__); 427 printk(KERN_ERR "%s: no parent clock\n", __func__);
440 return -EINVAL; 428 return;
441 } 429 }
442 430
443 for (clk = 0; clk < ARRAY_SIZE(clk_timer_scaler); clk++) { 431 for (clk = 0; clk < ARRAY_SIZE(clk_timer_scaler); clk++) {
@@ -445,7 +433,7 @@ static __init int s3c24xx_pwmclk_init(void)
445 ret = s3c24xx_register_clock(&clk_timer_scaler[clk]); 433 ret = s3c24xx_register_clock(&clk_timer_scaler[clk]);
446 if (ret < 0) { 434 if (ret < 0) {
447 printk(KERN_ERR "error adding pwm scaler%d clock\n", clk); 435 printk(KERN_ERR "error adding pwm scaler%d clock\n", clk);
448 goto err; 436 return;
449 } 437 }
450 } 438 }
451 439
@@ -453,7 +441,7 @@ static __init int s3c24xx_pwmclk_init(void)
453 ret = s3c24xx_register_clock(&clk_timer_tclk[clk]); 441 ret = s3c24xx_register_clock(&clk_timer_tclk[clk]);
454 if (ret < 0) { 442 if (ret < 0) {
455 printk(KERN_ERR "error adding pww tclk%d\n", clk); 443 printk(KERN_ERR "error adding pww tclk%d\n", clk);
456 goto err; 444 return;
457 } 445 }
458 } 446 }
459 447
@@ -461,7 +449,7 @@ static __init int s3c24xx_pwmclk_init(void)
461 ret = clk_pwm_tdiv_register(clk); 449 ret = clk_pwm_tdiv_register(clk);
462 if (ret < 0) { 450 if (ret < 0) {
463 printk(KERN_ERR "error adding pwm%d tdiv clock\n", clk); 451 printk(KERN_ERR "error adding pwm%d tdiv clock\n", clk);
464 goto err; 452 return;
465 } 453 }
466 } 454 }
467 455
@@ -469,14 +457,7 @@ static __init int s3c24xx_pwmclk_init(void)
469 ret = clk_pwm_tin_register(&clk_tin[clk]); 457 ret = clk_pwm_tin_register(&clk_tin[clk]);
470 if (ret < 0) { 458 if (ret < 0) {
471 printk(KERN_ERR "error adding pwm%d tin clock\n", clk); 459 printk(KERN_ERR "error adding pwm%d tin clock\n", clk);
472 goto err; 460 return;
473 } 461 }
474 } 462 }
475
476 return 0;
477
478 err:
479 return ret;
480} 463}
481
482arch_initcall(s3c24xx_pwmclk_init);
diff --git a/arch/arm/plat-s3c/time.c b/arch/arm/plat-s3c/time.c
index c6861a05a29..3b27b29da47 100644
--- a/arch/arm/plat-s3c/time.c
+++ b/arch/arm/plat-s3c/time.c
@@ -26,6 +26,7 @@
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/clk.h> 27#include <linux/clk.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/platform_device.h>
29 30
30#include <asm/system.h> 31#include <asm/system.h>
31#include <asm/leds.h> 32#include <asm/leds.h>
@@ -36,6 +37,7 @@
36#include <plat/regs-timer.h> 37#include <plat/regs-timer.h>
37#include <mach/regs-irq.h> 38#include <mach/regs-irq.h>
38#include <asm/mach/time.h> 39#include <asm/mach/time.h>
40#include <mach/tick.h>
39 41
40#include <plat/clock.h> 42#include <plat/clock.h>
41#include <plat/cpu.h> 43#include <plat/cpu.h>
@@ -43,6 +45,10 @@
43static unsigned long timer_startval; 45static unsigned long timer_startval;
44static unsigned long timer_usec_ticks; 46static unsigned long timer_usec_ticks;
45 47
48#ifndef TICK_MAX
49#define TICK_MAX (0xffff)
50#endif
51
46#define TIMER_USEC_SHIFT 16 52#define TIMER_USEC_SHIFT 16
47 53
48/* we use the shifted arithmetic to work out the ratio of timer ticks 54/* we use the shifted arithmetic to work out the ratio of timer ticks
@@ -91,12 +97,9 @@ static inline unsigned long timer_ticks_to_usec(unsigned long ticks)
91 * IRQs are disabled before entering here from do_gettimeofday() 97 * IRQs are disabled before entering here from do_gettimeofday()
92 */ 98 */
93 99
94#define SRCPND_TIMER4 (1<<(IRQ_TIMER4 - IRQ_EINT0))
95
96static unsigned long s3c2410_gettimeoffset (void) 100static unsigned long s3c2410_gettimeoffset (void)
97{ 101{
98 unsigned long tdone; 102 unsigned long tdone;
99 unsigned long irqpend;
100 unsigned long tval; 103 unsigned long tval;
101 104
102 /* work out how many ticks have gone since last timer interrupt */ 105 /* work out how many ticks have gone since last timer interrupt */
@@ -106,8 +109,7 @@ static unsigned long s3c2410_gettimeoffset (void)
106 109
107 /* check to see if there is an interrupt pending */ 110 /* check to see if there is an interrupt pending */
108 111
109 irqpend = __raw_readl(S3C2410_SRCPND); 112 if (s3c24xx_ostimer_pending()) {
110 if (irqpend & SRCPND_TIMER4) {
111 /* re-read the timer, and try and fix up for the missed 113 /* re-read the timer, and try and fix up for the missed
112 * interrupt. Note, the interrupt may go off before the 114 * interrupt. Note, the interrupt may go off before the
113 * timer has re-loaded from wrapping. 115 * timer has re-loaded from wrapping.
@@ -146,6 +148,10 @@ static struct irqaction s3c2410_timer_irq = {
146 machine_is_anubis() || \ 148 machine_is_anubis() || \
147 machine_is_osiris()) 149 machine_is_osiris())
148 150
151static struct clk *tin;
152static struct clk *tdiv;
153static struct clk *timerclk;
154
149/* 155/*
150 * Set up timer interrupt, and return the current time in seconds. 156 * Set up timer interrupt, and return the current time in seconds.
151 * 157 *
@@ -159,13 +165,7 @@ static void s3c2410_timer_setup (void)
159 unsigned long tcfg1; 165 unsigned long tcfg1;
160 unsigned long tcfg0; 166 unsigned long tcfg0;
161 167
162 tcnt = 0xffff; /* default value for tcnt */ 168 tcnt = TICK_MAX; /* default value for tcnt */
163
164 /* read the current timer configuration bits */
165
166 tcon = __raw_readl(S3C2410_TCON);
167 tcfg1 = __raw_readl(S3C2410_TCFG1);
168 tcfg0 = __raw_readl(S3C2410_TCFG0);
169 169
170 /* configure the system for whichever machine is in use */ 170 /* configure the system for whichever machine is in use */
171 171
@@ -174,11 +174,13 @@ static void s3c2410_timer_setup (void)
174 timer_usec_ticks = timer_mask_usec_ticks(1, 12000000); 174 timer_usec_ticks = timer_mask_usec_ticks(1, 12000000);
175 tcnt = 12000000 / HZ; 175 tcnt = 12000000 / HZ;
176 176
177 tcfg1 = __raw_readl(S3C2410_TCFG1);
177 tcfg1 &= ~S3C2410_TCFG1_MUX4_MASK; 178 tcfg1 &= ~S3C2410_TCFG1_MUX4_MASK;
178 tcfg1 |= S3C2410_TCFG1_MUX4_TCLK1; 179 tcfg1 |= S3C2410_TCFG1_MUX4_TCLK1;
180 __raw_writel(tcfg1, S3C2410_TCFG1);
179 } else { 181 } else {
180 unsigned long pclk; 182 unsigned long pclk;
181 struct clk *clk; 183 struct clk *tscaler;
182 184
183 /* for the h1940 (and others), we use the pclk from the core 185 /* for the h1940 (and others), we use the pclk from the core
184 * to generate the timer values. since values around 50 to 186 * to generate the timer values. since values around 50 to
@@ -189,29 +191,25 @@ static void s3c2410_timer_setup (void)
189 * (8.45 ticks per usec) 191 * (8.45 ticks per usec)
190 */ 192 */
191 193
192 /* this is used as default if no other timer can be found */ 194 pclk = clk_get_rate(timerclk);
193
194 clk = clk_get(NULL, "timers");
195 if (IS_ERR(clk))
196 panic("failed to get clock for system timer");
197
198 clk_enable(clk);
199
200 pclk = clk_get_rate(clk);
201 195
202 /* configure clock tick */ 196 /* configure clock tick */
203 197
204 timer_usec_ticks = timer_mask_usec_ticks(6, pclk); 198 timer_usec_ticks = timer_mask_usec_ticks(6, pclk);
205 199
206 tcfg1 &= ~S3C2410_TCFG1_MUX4_MASK; 200 tscaler = clk_get_parent(tdiv);
207 tcfg1 |= S3C2410_TCFG1_MUX4_DIV2;
208 201
209 tcfg0 &= ~S3C2410_TCFG_PRESCALER1_MASK; 202 clk_set_rate(tscaler, pclk / 3);
210 tcfg0 |= ((6 - 1) / 2) << S3C2410_TCFG_PRESCALER1_SHIFT; 203 clk_set_rate(tdiv, pclk / 6);
204 clk_set_parent(tin, tdiv);
211 205
212 tcnt = (pclk / 6) / HZ; 206 tcnt = clk_get_rate(tin) / HZ;
213 } 207 }
214 208
209 tcon = __raw_readl(S3C2410_TCON);
210 tcfg0 = __raw_readl(S3C2410_TCFG0);
211 tcfg1 = __raw_readl(S3C2410_TCFG1);
212
215 /* timers reload after counting zero, so reduce the count by 1 */ 213 /* timers reload after counting zero, so reduce the count by 1 */
216 214
217 tcnt--; 215 tcnt--;
@@ -220,7 +218,7 @@ static void s3c2410_timer_setup (void)
220 tcon, tcnt, tcfg0, tcfg1, timer_usec_ticks); 218 tcon, tcnt, tcfg0, tcfg1, timer_usec_ticks);
221 219
222 /* check to see if timer is within 16bit range... */ 220 /* check to see if timer is within 16bit range... */
223 if (tcnt > 0xffff) { 221 if (tcnt > TICK_MAX) {
224 panic("setup_timer: HZ is too small, cannot configure timer!"); 222 panic("setup_timer: HZ is too small, cannot configure timer!");
225 return; 223 return;
226 } 224 }
@@ -247,8 +245,35 @@ static void s3c2410_timer_setup (void)
247 __raw_writel(tcon, S3C2410_TCON); 245 __raw_writel(tcon, S3C2410_TCON);
248} 246}
249 247
248static void __init s3c2410_timer_resources(void)
249{
250 struct platform_device tmpdev;
251
252 tmpdev.dev.bus = &platform_bus_type;
253 tmpdev.id = 4;
254
255 timerclk = clk_get(NULL, "timers");
256 if (IS_ERR(timerclk))
257 panic("failed to get clock for system timer");
258
259 clk_enable(timerclk);
260
261 if (!use_tclk1_12()) {
262 tin = clk_get(&tmpdev.dev, "pwm-tin");
263 if (IS_ERR(tin))
264 panic("failed to get pwm-tin clock for system timer");
265
266 tdiv = clk_get(&tmpdev.dev, "pwm-tdiv");
267 if (IS_ERR(tdiv))
268 panic("failed to get pwm-tdiv clock for system timer");
269 }
270
271 clk_enable(tin);
272}
273
250static void __init s3c2410_timer_init(void) 274static void __init s3c2410_timer_init(void)
251{ 275{
276 s3c2410_timer_resources();
252 s3c2410_timer_setup(); 277 s3c2410_timer_setup();
253 setup_irq(IRQ_TIMER4, &s3c2410_timer_irq); 278 setup_irq(IRQ_TIMER4, &s3c2410_timer_irq);
254} 279}