Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / arch / mips / tx4938 / common / setup.c
1 /*
2  * linux/arch/mips/tx4938/common/setup.c
3  *
4  * common tx4938 setup routines
5  *
6  * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
7  * terms of the GNU General Public License version 2. This program is
8  * licensed "as is" without any warranty of any kind, whether express
9  * or implied.
10  *
11  * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
12  */
13
14 #include <linux/errno.h>
15 #include <linux/init.h>
16 #include <linux/kernel_stat.h>
17 #include <linux/module.h>
18 #include <linux/signal.h>
19 #include <linux/sched.h>
20 #include <linux/types.h>
21 #include <linux/interrupt.h>
22 #include <linux/ioport.h>
23 #include <linux/timex.h>
24 #include <linux/slab.h>
25 #include <linux/random.h>
26 #include <linux/irq.h>
27 #include <asm/bitops.h>
28 #include <asm/bootinfo.h>
29 #include <asm/io.h>
30 #include <asm/irq.h>
31 #include <asm/mipsregs.h>
32 #include <asm/system.h>
33 #include <asm/time.h>
34 #include <asm/time.h>
35 #include <asm/tx4938/rbtx4938.h>
36
37 extern void toshiba_rbtx4938_setup(void);
38 extern void rbtx4938_time_init(void);
39
40 void __init tx4938_setup(void);
41 void __init tx4938_time_init(void);
42 void dump_cp0(char *key);
43
44 void (*__wbflush) (void);
45
46 static void
47 tx4938_write_buffer_flush(void)
48 {
49         mmiowb();
50
51         __asm__ __volatile__(
52                 ".set   push\n\t"
53                 ".set   noreorder\n\t"
54                 "lw     $0,%0\n\t"
55                 "nop\n\t"
56                 ".set   pop"
57                 : /* no output */
58                 : "m" (*(int *)KSEG1)
59                 : "memory");
60 }
61
62 void __init
63 plat_mem_setup(void)
64 {
65         board_time_init = tx4938_time_init;
66         __wbflush = tx4938_write_buffer_flush;
67         toshiba_rbtx4938_setup();
68 }
69
70 void __init
71 tx4938_time_init(void)
72 {
73         rbtx4938_time_init();
74 }
75
76 void __init plat_timer_setup(struct irqaction *irq)
77 {
78         u32 count;
79         u32 c1;
80         u32 c2;
81
82         setup_irq(TX4938_IRQ_CPU_TIMER, irq);
83
84         c1 = read_c0_count();
85         count = c1 + (mips_hpt_frequency / HZ);
86         write_c0_compare(count);
87         c2 = read_c0_count();
88 }