From: Minkyu Kang Date: Thu, 19 Aug 2010 11:25:58 +0000 (+0900) Subject: s5p: clock: seperate the pclk to uart clock and pwm clock X-Git-Tag: JH02_20100820~43 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2244c5eea09de2a63438d5cb784e175f7a898e9f;p=kernel%2Fu-boot.git s5p: clock: seperate the pclk to uart clock and pwm clock Signed-off-by: Minkyu Kang --- diff --git a/arch/arm/cpu/armv7/s5p-common/timer.c b/arch/arm/cpu/armv7/s5p-common/timer.c index ba231e4..2bafddd 100644 --- a/arch/arm/cpu/armv7/s5p-common/timer.c +++ b/arch/arm/cpu/armv7/s5p-common/timer.c @@ -74,7 +74,7 @@ int timer_init(void) if (count_value == 0) { /* reset initial value */ /* count_value = 2085937.5(HZ) (per 1 sec)*/ - count_value = get_pclk() / ((PRESCALER_1 + 1) * + count_value = get_pwm_clk() / ((PRESCALER_1 + 1) * (MUX_DIV_2 + 1)); /* count_value / 100 = 20859.375(HZ) (per 10 msec) */ diff --git a/arch/arm/cpu/armv7/s5pc1xx/clock.c b/arch/arm/cpu/armv7/s5pc1xx/clock.c index 6d0cc74..98a27e5 100644 --- a/arch/arm/cpu/armv7/s5pc1xx/clock.c +++ b/arch/arm/cpu/armv7/s5pc1xx/clock.c @@ -38,8 +38,8 @@ #define CONFIG_SYS_CLK_FREQ_C110 24000000 #endif -unsigned long (*get_uclk)(int dev_index); -unsigned long (*get_pclk)(void); +unsigned long (*get_uart_clk)(int dev_index); +unsigned long (*get_pwm_clk)(void); unsigned long (*get_arm_clk)(void); unsigned long (*get_pll_clk)(int); @@ -299,9 +299,21 @@ static unsigned long s5pc100_get_pclk(void) } /* s5pc1xx: return uart clock frequency */ -static unsigned long s5pc1xx_get_uclk(int dev_index) +static unsigned long s5pc1xx_get_uart_clk(int dev_index) { - return get_pclk(); + if (cpu_is_s5pc110()) + return s5pc110_get_pclk(); + else + return s5pc100_get_pclk(); +} + +/* s5pc1xx: return pwm clock frequency */ +static unsigned long s5pc1xx_get_pwm_clk(void) +{ + if (cpu_is_s5pc110()) + return s5pc110_get_pclk(); + else + return s5pc100_get_pclk(); } void s5p_clock_init(void) @@ -309,11 +321,10 @@ void s5p_clock_init(void) if (cpu_is_s5pc110()) { get_pll_clk = s5pc110_get_pll_clk; get_arm_clk = s5pc110_get_arm_clk; - get_pclk = s5pc110_get_pclk; } else { get_pll_clk = s5pc100_get_pll_clk; get_arm_clk = s5pc100_get_arm_clk; - get_pclk = s5pc100_get_pclk; } - get_uclk = s5pc1xx_get_uclk; + get_uart_clk = s5pc1xx_get_uart_clk; + get_pwm_clk = s5pc1xx_get_pwm_clk; } diff --git a/arch/arm/cpu/armv7/s5pc2xx/clock.c b/arch/arm/cpu/armv7/s5pc2xx/clock.c index 7c19c20..9eee7a5 100644 --- a/arch/arm/cpu/armv7/s5pc2xx/clock.c +++ b/arch/arm/cpu/armv7/s5pc2xx/clock.c @@ -30,8 +30,8 @@ #define CONFIG_SYS_CLK_FREQ_C210 24000000 #endif -unsigned long (*get_uclk)(int dev_index); -unsigned long (*get_pclk)(void); +unsigned long (*get_uart_clk)(int dev_index); +unsigned long (*get_pwm_clk)(void); unsigned long (*get_arm_clk)(void); unsigned long (*get_pll_clk)(int); @@ -40,7 +40,7 @@ static unsigned long s5pc210_get_pll_clk(int pllreg) { struct s5pc210_clock *clk = (struct s5pc210_clock *)samsung_get_base_clock(); - unsigned long r, m, p, s, k, mask, fout; + unsigned long r, m, p, s, k = 0, mask, fout; unsigned int freq; switch (pllreg) { @@ -120,37 +120,60 @@ static unsigned long s5pc210_get_arm_clk(void) return dout_apll; } -/* s5pc210: return peripheral clock frequency */ -static unsigned long s5pc210_get_pclk(void) +/* s5pc210: return pwm clock frequency */ +static unsigned long s5pc210_get_pwm_clk(void) { - return get_pll_clk(MPLL); + struct s5pc210_clock *clk = + (struct s5pc210_clock *)samsung_get_base_clock(); + unsigned long pclk, sclk; + unsigned int sel; + unsigned int ratio; + + sel = readl(&clk->src_peril0); + sel = (sel >> 24) & 0xf; + + if (sel == 0x6) + sclk = get_pll_clk(MPLL); + else if (sel == 0x7) + sclk = get_pll_clk(EPLL); + else if (sel == 0x8) + sclk = get_pll_clk(VPLL); + else + return 0; + + ratio = readl(&clk->div_peril3); + ratio = ratio & 0xf; + + pclk = sclk / (ratio + 1); + + return pclk; } /* s5pc210: return uart clock frequency */ -static unsigned long s5pc210_get_uclk(int dev_index) +static unsigned long s5pc210_get_uart_clk(int dev_index) { struct s5pc210_clock *clk = (struct s5pc210_clock *)samsung_get_base_clock(); unsigned long uclk, sclk; - unsigned int uart_sel; - unsigned int uart_ratio; + unsigned int sel; + unsigned int ratio; - uart_sel = readl(&clk->src_peril0); - uart_sel = (uart_sel >> (dev_index << 2)) & 0xf; + sel = readl(&clk->src_peril0); + sel = (sel >> (dev_index << 2)) & 0xf; - if (uart_sel == 0x6) + if (sel == 0x6) sclk = get_pll_clk(MPLL); - else if (uart_sel == 0x7) + else if (sel == 0x7) sclk = get_pll_clk(EPLL); - else if (uart_sel == 0x8) + else if (sel == 0x8) sclk = get_pll_clk(VPLL); else return 0; - uart_ratio = readl(&clk->div_peril0); - uart_ratio = (uart_ratio >> (dev_index << 2)) & 0xf; + ratio = readl(&clk->div_peril0); + ratio = (ratio >> (dev_index << 2)) & 0xf; - uclk = sclk / (uart_ratio + 1); + uclk = sclk / (ratio + 1); return uclk; } @@ -160,7 +183,7 @@ void s5p_clock_init(void) if (cpu_is_s5pc210()) { get_pll_clk = s5pc210_get_pll_clk; get_arm_clk = s5pc210_get_arm_clk; - get_pclk = s5pc210_get_pclk; - get_uclk = s5pc210_get_uclk; + get_uart_clk = s5pc210_get_uart_clk; + get_pwm_clk = s5pc210_get_pwm_clk; } } diff --git a/arch/arm/include/asm/arch-s5pc1xx/clk.h b/arch/arm/include/asm/arch-s5pc1xx/clk.h index b4df07d..3488eb7 100644 --- a/arch/arm/include/asm/arch-s5pc1xx/clk.h +++ b/arch/arm/include/asm/arch-s5pc1xx/clk.h @@ -33,7 +33,7 @@ void s5p_clock_init(void); extern unsigned long (*get_pll_clk)(int pllreg); extern unsigned long (*get_arm_clk)(void); -extern unsigned long (*get_pclk)(void); -extern unsigned long (*get_uclk)(int dev_index); +extern unsigned long (*get_pwm_clk)(void); +extern unsigned long (*get_uart_clk)(int dev_index); #endif diff --git a/arch/arm/include/asm/arch-s5pc2xx/clk.h b/arch/arm/include/asm/arch-s5pc2xx/clk.h index ced6c3b..3258812 100644 --- a/arch/arm/include/asm/arch-s5pc2xx/clk.h +++ b/arch/arm/include/asm/arch-s5pc2xx/clk.h @@ -32,7 +32,7 @@ void s5p_clock_init(void); extern unsigned long (*get_pll_clk)(int pllreg); extern unsigned long (*get_arm_clk)(void); -extern unsigned long (*get_pclk)(void); -extern unsigned long (*get_uclk)(int dev_index); +extern unsigned long (*get_pwm_clk)(void); +extern unsigned long (*get_uart_clk)(int dev_index); #endif diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c index 41c931a..140eb2d 100644 --- a/drivers/serial/serial_s5p.c +++ b/drivers/serial/serial_s5p.c @@ -63,7 +63,7 @@ void serial_setbrg_dev(const int dev_index) { DECLARE_GLOBAL_DATA_PTR; struct s5p_uart *const uart = s5p_get_base_uart(dev_index); - u32 uclk = get_uclk(dev_index); + u32 uclk = get_uart_clk(dev_index); u32 baudrate = gd->baudrate; u32 val;