aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2007-04-29 04:32:51 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2007-04-30 10:24:54 -0400
commit84c981ffb371828ad6d1d220f076453b54734302 (patch)
tree43c85aef8399847ee07e9525099a0a0f9fe6b628
parent7dcad376e85b6eff56f29ee21e10e1fe855f1ed7 (diff)
[ARM] 4343/1: iop13xx: automatically detect the internal bus frequency
Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mach-iop13xx/iq81340mc.c4
-rw-r--r--arch/arm/mach-iop13xx/iq81340sc.c4
-rw-r--r--include/asm-arm/arch-iop13xx/iop13xx.h1
-rw-r--r--include/asm-arm/arch-iop13xx/time.h56
4 files changed, 63 insertions, 2 deletions
diff --git a/arch/arm/mach-iop13xx/iq81340mc.c b/arch/arm/mach-iop13xx/iq81340mc.c
index a519d707571c..1ae08cc04b48 100644
--- a/arch/arm/mach-iop13xx/iq81340mc.c
+++ b/arch/arm/mach-iop13xx/iq81340mc.c
@@ -79,7 +79,9 @@ static void __init iq81340mc_init(void)
79 79
80static void __init iq81340mc_timer_init(void) 80static void __init iq81340mc_timer_init(void)
81{ 81{
82 iop_init_time(400000000); 82 unsigned long bus_freq = iop13xx_core_freq() / iop13xx_xsi_bus_ratio();
83 printk(KERN_DEBUG "%s: bus frequency: %lu\n", __FUNCTION__, bus_freq);
84 iop_init_time(bus_freq);
83} 85}
84 86
85static struct sys_timer iq81340mc_timer = { 87static struct sys_timer iq81340mc_timer = {
diff --git a/arch/arm/mach-iop13xx/iq81340sc.c b/arch/arm/mach-iop13xx/iq81340sc.c
index 0e71fbcabe00..0f8801406f23 100644
--- a/arch/arm/mach-iop13xx/iq81340sc.c
+++ b/arch/arm/mach-iop13xx/iq81340sc.c
@@ -81,7 +81,9 @@ static void __init iq81340sc_init(void)
81 81
82static void __init iq81340sc_timer_init(void) 82static void __init iq81340sc_timer_init(void)
83{ 83{
84 iop_init_time(400000000); 84 unsigned long bus_freq = iop13xx_core_freq() / iop13xx_xsi_bus_ratio();
85 printk(KERN_DEBUG "%s: bus frequency: %lu\n", __FUNCTION__, bus_freq);
86 iop_init_time(bus_freq);
85} 87}
86 88
87static struct sys_timer iq81340sc_timer = { 89static struct sys_timer iq81340sc_timer = {
diff --git a/include/asm-arm/arch-iop13xx/iop13xx.h b/include/asm-arm/arch-iop13xx/iop13xx.h
index 2d1e23ba67c6..c8762ae8f628 100644
--- a/include/asm-arm/arch-iop13xx/iop13xx.h
+++ b/include/asm-arm/arch-iop13xx/iop13xx.h
@@ -455,4 +455,5 @@ static inline int iop13xx_cpu_id(void)
455#define IOP13XX_PBI_BAR1 IOP13XX_PBI_OFFSET(0x10) 455#define IOP13XX_PBI_BAR1 IOP13XX_PBI_OFFSET(0x10)
456#define IOP13XX_PBI_LR1 IOP13XX_PBI_OFFSET(0x14) 456#define IOP13XX_PBI_LR1 IOP13XX_PBI_OFFSET(0x14)
457 457
458#define IOP13XX_PROCESSOR_FREQ IOP13XX_REG_ADDR32(0x2180)
458#endif /* _IOP13XX_HW_H_ */ 459#endif /* _IOP13XX_HW_H_ */
diff --git a/include/asm-arm/arch-iop13xx/time.h b/include/asm-arm/arch-iop13xx/time.h
index 77a837a02dec..49213d9d7cad 100644
--- a/include/asm-arm/arch-iop13xx/time.h
+++ b/include/asm-arm/arch-iop13xx/time.h
@@ -7,9 +7,65 @@
7#define IOP_TMR_PRIVILEGED 0x08 7#define IOP_TMR_PRIVILEGED 0x08
8#define IOP_TMR_RATIO_1_1 0x00 8#define IOP_TMR_RATIO_1_1 0x00
9 9
10#define IOP13XX_XSI_FREQ_RATIO_MASK (3 << 19)
11#define IOP13XX_XSI_FREQ_RATIO_2 (0 << 19)
12#define IOP13XX_XSI_FREQ_RATIO_3 (1 << 19)
13#define IOP13XX_XSI_FREQ_RATIO_4 (2 << 19)
14#define IOP13XX_CORE_FREQ_MASK (7 << 16)
15#define IOP13XX_CORE_FREQ_600 (0 << 16)
16#define IOP13XX_CORE_FREQ_667 (1 << 16)
17#define IOP13XX_CORE_FREQ_800 (2 << 16)
18#define IOP13XX_CORE_FREQ_933 (3 << 16)
19#define IOP13XX_CORE_FREQ_1000 (4 << 16)
20#define IOP13XX_CORE_FREQ_1200 (5 << 16)
21
10void iop_init_time(unsigned long tickrate); 22void iop_init_time(unsigned long tickrate);
11unsigned long iop_gettimeoffset(void); 23unsigned long iop_gettimeoffset(void);
12 24
25static inline unsigned long iop13xx_core_freq(void)
26{
27 unsigned long freq = __raw_readl(IOP13XX_PROCESSOR_FREQ);
28 freq &= IOP13XX_CORE_FREQ_MASK;
29 switch (freq) {
30 case IOP13XX_CORE_FREQ_600:
31 return 600000000;
32 case IOP13XX_CORE_FREQ_667:
33 return 667000000;
34 case IOP13XX_CORE_FREQ_800:
35 return 800000000;
36 case IOP13XX_CORE_FREQ_933:
37 return 933000000;
38 case IOP13XX_CORE_FREQ_1000:
39 return 1000000000;
40 case IOP13XX_CORE_FREQ_1200:
41 return 1200000000;
42 default:
43 printk("%s: warning unknown frequency, defaulting to 800Mhz\n",
44 __FUNCTION__);
45 }
46
47 return 800000000;
48}
49
50static inline unsigned long iop13xx_xsi_bus_ratio(void)
51{
52 unsigned long ratio = __raw_readl(IOP13XX_PROCESSOR_FREQ);
53 ratio &= IOP13XX_XSI_FREQ_RATIO_MASK;
54 switch (ratio) {
55 case IOP13XX_XSI_FREQ_RATIO_2:
56 return 2;
57 case IOP13XX_XSI_FREQ_RATIO_3:
58 return 3;
59 case IOP13XX_XSI_FREQ_RATIO_4:
60 return 4;
61 default:
62 printk("%s: warning unknown ratio, defaulting to 2\n",
63 __FUNCTION__);
64 }
65
66 return 2;
67}
68
13static inline void write_tmr0(u32 val) 69static inline void write_tmr0(u32 val)
14{ 70{
15 asm volatile("mcr p6, 0, %0, c0, c9, 0" : : "r" (val)); 71 asm volatile("mcr p6, 0, %0, c0, c9, 0" : : "r" (val));