Merge master.kernel.org:/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog
[pandora-kernel.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 __init tx4938_timer_setup(struct irqaction *irq);
43 void dump_cp0(char *key);
44
45 void (*__wbflush) (void);
46
47 static void
48 tx4938_write_buffer_flush(void)
49 {
50         mmiowb();
51
52         __asm__ __volatile__(
53                 ".set   push\n\t"
54                 ".set   noreorder\n\t"
55                 "lw     $0,%0\n\t"
56                 "nop\n\t"
57                 ".set   pop"
58                 : /* no output */
59                 : "m" (*(int *)KSEG1)
60                 : "memory");
61 }
62
63 void __init
64 plat_mem_setup(void)
65 {
66         board_time_init = tx4938_time_init;
67         board_timer_setup = tx4938_timer_setup;
68         __wbflush = tx4938_write_buffer_flush;
69         toshiba_rbtx4938_setup();
70 }
71
72 void __init
73 tx4938_time_init(void)
74 {
75         rbtx4938_time_init();
76 }
77
78 void __init
79 tx4938_timer_setup(struct irqaction *irq)
80 {
81         u32 count;
82         u32 c1;
83         u32 c2;
84
85         setup_irq(TX4938_IRQ_CPU_TIMER, irq);
86
87         c1 = read_c0_count();
88         count = c1 + (mips_hpt_frequency / HZ);
89         write_c0_compare(count);
90         c2 = read_c0_count();
91 }