aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-clps711x
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2012-08-21 12:59:35 -0400
committerArnd Bergmann <arnd@arndb.de>2012-09-28 15:14:07 -0400
commit61ae48c3cb6bcffd1c7e18164c3d103eb62f06aa (patch)
tree6419848a83d20121ea6ee4515421bc3702f95c2f /arch/arm/mach-clps711x
parent55d512e245bc7699a8800e23df1a24195dd08217 (diff)
ARM: clps711x: Added simple clock framework
Modern CPUs from CLPS711X-line can operate at frequencies other than 73 MHz. This patch adds simple clock framework for handling all possible CPU rates. Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Diffstat (limited to 'arch/arm/mach-clps711x')
-rw-r--r--arch/arm/mach-clps711x/common.c89
-rw-r--r--arch/arm/mach-clps711x/include/mach/timex.h23
2 files changed, 74 insertions, 38 deletions
diff --git a/arch/arm/mach-clps711x/common.c b/arch/arm/mach-clps711x/common.c
index f15293bd797..509243d89a3 100644
--- a/arch/arm/mach-clps711x/common.c
+++ b/arch/arm/mach-clps711x/common.c
@@ -19,24 +19,25 @@
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */ 21 */
22#include <linux/kernel.h> 22#include <linux/io.h>
23#include <linux/mm.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/interrupt.h> 24#include <linux/interrupt.h>
26#include <linux/io.h>
27#include <linux/irq.h> 25#include <linux/irq.h>
28#include <linux/sched.h> 26#include <linux/clk.h>
27#include <linux/clkdev.h>
28#include <linux/clk-provider.h>
29 29
30#include <asm/sizes.h> 30#include <asm/sizes.h>
31#include <mach/hardware.h>
32#include <asm/irq.h>
33#include <asm/leds.h>
34#include <asm/pgtable.h>
35#include <asm/page.h>
36#include <asm/mach/map.h> 31#include <asm/mach/map.h>
37#include <asm/mach/time.h> 32#include <asm/mach/time.h>
38#include <asm/system_misc.h> 33#include <asm/system_misc.h>
39 34
35#include <mach/hardware.h>
36
37static struct clk *clk_pll, *clk_bus, *clk_uart, *clk_timerl, *clk_timerh,
38 *clk_tint, *clk_spi;
39static unsigned long latch;
40
40/* 41/*
41 * This maps the generic CLPS711x registers 42 * This maps the generic CLPS711x registers
42 */ 43 */
@@ -166,8 +167,8 @@ void __init clps711x_init_irq(void)
166static unsigned long clps711x_gettimeoffset(void) 167static unsigned long clps711x_gettimeoffset(void)
167{ 168{
168 unsigned long hwticks; 169 unsigned long hwticks;
169 hwticks = LATCH - (clps_readl(TC2D) & 0xffff); /* since last underflow */ 170 hwticks = latch - (clps_readl(TC2D) & 0xffff);
170 return (hwticks * (tick_nsec / 1000)) / LATCH; 171 return (hwticks * (tick_nsec / 1000)) / latch;
171} 172}
172 173
173/* 174/*
@@ -185,15 +186,71 @@ static struct irqaction clps711x_timer_irq = {
185 .handler = p720t_timer_interrupt, 186 .handler = p720t_timer_interrupt,
186}; 187};
187 188
189static void add_fixed_clk(struct clk *clk, const char *name, int rate)
190{
191 clk = clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate);
192 clk_register_clkdev(clk, name, NULL);
193}
194
188static void __init clps711x_timer_init(void) 195static void __init clps711x_timer_init(void)
189{ 196{
190 unsigned int syscon; 197 int osc, ext, pll, cpu, bus, timl, timh, uart, spi;
198 u32 tmp;
199
200 osc = 3686400;
201 ext = 13000000;
202
203 tmp = clps_readl(PLLR) >> 24;
204 if (tmp)
205 pll = (osc * tmp) / 2;
206 else
207 pll = 73728000; /* Default value */
208
209 tmp = clps_readl(SYSFLG2);
210 if (tmp & SYSFLG2_CKMODE) {
211 cpu = ext;
212 bus = cpu;
213 spi = 135400;
214 } else {
215 cpu = pll;
216 if (cpu >= 36864000)
217 bus = cpu / 2;
218 else
219 bus = 36864000 / 2;
220 spi = cpu / 576;
221 }
222
223 uart = bus / 10;
224
225 if (tmp & SYSFLG2_CKMODE) {
226 tmp = clps_readl(SYSCON2);
227 if (tmp & SYSCON2_OSTB)
228 timh = ext / 26;
229 else
230 timh = 541440;
231 } else
232 timh = cpu / 144;
233
234 timl = timh / 256;
235
236 /* All clocks are fixed */
237 add_fixed_clk(clk_pll, "pll", pll);
238 add_fixed_clk(clk_bus, "bus", bus);
239 add_fixed_clk(clk_uart, "uart", uart);
240 add_fixed_clk(clk_timerl, "timer_lf", timl);
241 add_fixed_clk(clk_timerh, "timer_hf", timh);
242 add_fixed_clk(clk_tint, "tint", 64);
243 add_fixed_clk(clk_spi, "spi", spi);
244
245 pr_info("CPU frequency set at %i Hz.\n", cpu);
246
247 latch = (timh + HZ / 2) / HZ;
191 248
192 syscon = clps_readl(SYSCON1); 249 tmp = clps_readl(SYSCON1);
193 syscon |= SYSCON1_TC2S | SYSCON1_TC2M; 250 tmp |= SYSCON1_TC2S | SYSCON1_TC2M;
194 clps_writel(syscon, SYSCON1); 251 clps_writel(tmp, SYSCON1);
195 252
196 clps_writel(LATCH-1, TC2D); /* 512kHz / 100Hz - 1 */ 253 clps_writel(latch - 1, TC2D);
197 254
198 setup_irq(IRQ_TC2OI, &clps711x_timer_irq); 255 setup_irq(IRQ_TC2OI, &clps711x_timer_irq);
199} 256}
diff --git a/arch/arm/mach-clps711x/include/mach/timex.h b/arch/arm/mach-clps711x/include/mach/timex.h
index ac8823ccff9..de6fd192d1c 100644
--- a/arch/arm/mach-clps711x/include/mach/timex.h
+++ b/arch/arm/mach-clps711x/include/mach/timex.h
@@ -1,23 +1,2 @@
1/* 1/* Bogus value */
2 * arch/arm/mach-clps711x/include/mach/timex.h
3 *
4 * Prospector 720T architecture timex specifications
5 *
6 * Copyright (C) 2000 Deep Blue Solutions Ltd.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#define CLOCK_TICK_RATE 512000 2#define CLOCK_TICK_RATE 512000