3 Copyright 2004 Broadcom Corp. All Rights Reserved.
5 This program is free software; you can distribute it and/or modify it
6 under the terms of the GNU General Public License (Version 2) as
7 published by the Free Software Foundation.
9 This program is distributed in the hope it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
20 * Setup time for Broadcom 963xx MIPS boards
23 #include <linux/autoconf.h>
24 #include <linux/init.h>
25 #include <linux/kernel_stat.h>
26 #include <linux/sched.h>
27 #include <linux/spinlock.h>
28 #include <linux/interrupt.h>
29 #include <linux/module.h>
30 #include <linux/time.h>
31 #include <linux/timex.h>
33 #include <asm/mipsregs.h>
34 #include <asm/ptrace.h>
35 #include <asm/div64.h>
38 #include <6348_map_part.h>
39 #include <6348_intr.h>
40 #include <bcm_map_part.h>
43 static unsigned long r4k_offset
; /* Amount to increment compare reg each time */
44 static unsigned long r4k_cur
; /* What counter should be at next timer irq */
46 /* *********************************************************************
48 * Calculate the BCM6348 CPU speed by reading the PLL strap register
49 * and applying the following formula:
50 * cpu_clk = (.25 * 64MHz freq) * (N1 + 1) * (N2 + 2) / (M1_CPU + 1)
55 ********************************************************************* */
57 static inline unsigned long __init
calculateCpuSpeed(void)
59 u32 pllStrap
= PERF
->PllStrap
;
60 int n1
= (pllStrap
& PLL_N1_MASK
) >> PLL_N1_SHFT
;
61 int n2
= (pllStrap
& PLL_N2_MASK
) >> PLL_N2_SHFT
;
62 int m1cpu
= (pllStrap
& PLL_M1_CPU_MASK
) >> PLL_M1_CPU_SHFT
;
64 return (16 * (n1
+ 1) * (n2
+ 2) / (m1cpu
+ 1)) * 1000000;
68 static inline unsigned long __init
cal_r4koff(void)
70 mips_hpt_frequency
= calculateCpuSpeed() / 2;
71 return (mips_hpt_frequency
/ HZ
);
76 * There are a lot of conceptually broken versions of the MIPS timer interrupt
77 * handler floating around. This one is rather different, but the algorithm
78 * is provably more robust.
81 irqreturn_t
brcm_timer_interrupt(struct pt_regs
*regs
)
83 int irq
= MIPS_TIMER_INT
;
86 kstat_this_cpu
.irqs
[irq
]++;
88 timer_interrupt(irq
, regs
);
94 void __init
plat_time_init(void)
96 unsigned int est_freq
, flags
;
97 local_irq_save(flags
);
99 printk("calculating r4koff... ");
100 r4k_offset
= cal_r4koff();
101 printk("%08lx(%d)\n", r4k_offset
, (int)r4k_offset
);
103 est_freq
= 2 * r4k_offset
* HZ
;
104 est_freq
+= 5000; /* round */
105 est_freq
-= est_freq
% 10000;
106 printk("CPU frequency %d.%02d MHz\n", est_freq
/ 1000000,
107 (est_freq
% 1000000) * 100 / 1000000);
108 local_irq_restore(flags
);
112 void __init
plat_timer_setup(struct irqaction
*irq
)
114 r4k_cur
= (read_c0_count() + r4k_offset
);
115 write_c0_compare(r4k_cur
);
116 set_c0_status(IE_IRQ5
);
This page took 0.053225 seconds and 5 git commands to generate.