9e7336c7c81471cf8f105c8421816132cbfc9654
[linux-2.6.git] / arch / mips / sibyte / swarm / setup.c
1 /*
2  * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation
3  * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  */
19
20 /*
21  * Setup code for the SWARM board
22  */
23
24 #include <linux/config.h>
25 #include <linux/spinlock.h>
26 #include <linux/mm.h>
27 #include <linux/bootmem.h>
28 #include <linux/blkdev.h>
29 #include <linux/init.h>
30 #include <linux/tty.h>
31 #include <linux/initrd.h>
32
33 #include <asm/irq.h>
34 #include <asm/io.h>
35 #include <asm/bootinfo.h>
36 #include <asm/mipsregs.h>
37 #include <asm/reboot.h>
38 #include <asm/time.h>
39 #include <asm/traps.h>
40 #include <asm/sibyte/sb1250.h>
41 #include <asm/sibyte/sb1250_regs.h>
42 #include <asm/sibyte/sb1250_genbus.h>
43 #include <asm/sibyte/board.h>
44
45 extern void sb1250_setup(void);
46
47 extern int xicor_probe(void);
48 extern int xicor_set_time(unsigned long);
49 extern unsigned long xicor_get_time(void);
50
51 extern int m41t81_probe(void);
52 extern int m41t81_set_time(unsigned long);
53 extern unsigned long m41t81_get_time(void);
54
55 const char *get_system_type(void)
56 {
57         return "SiByte " SIBYTE_BOARD_NAME;
58 }
59
60 void __init swarm_timer_setup(struct irqaction *irq)
61 {
62         /*
63          * we don't set up irqaction, because we will deliver timer
64          * interrupts through low-level (direct) meachanism.
65          */
66
67         /* We only need to setup the generic timer */
68         sb1250_time_init();
69 }
70
71 int swarm_be_handler(struct pt_regs *regs, int is_fixup)
72 {
73         if (!is_fixup && (regs->cp0_cause & 4)) {
74                 /* Data bus error - print PA */
75 #ifdef CONFIG_MIPS64
76                 printk("DBE physical address: %010lx\n",
77                        __read_64bit_c0_register($26, 1));
78 #else
79                 printk("DBE physical address: %010llx\n",
80                        __read_64bit_c0_split($26, 1));
81 #endif
82         }
83         return (is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL);
84 }
85
86 static int __init swarm_setup(void)
87 {
88         extern int panic_timeout;
89
90         sb1250_setup();
91
92         panic_timeout = 5;  /* For debug.  */
93
94         board_timer_setup = swarm_timer_setup;
95         board_be_handler = swarm_be_handler;
96
97         if (xicor_probe()) {
98                 printk("swarm setup: Xicor 1241 RTC detected.\n");
99                 rtc_get_time = xicor_get_time;
100                 rtc_set_time = xicor_set_time;
101         }
102  
103         if (m41t81_probe()) {
104                 printk("swarm setup: M41T81 RTC detected.\n");
105                 rtc_get_time = m41t81_get_time;
106                 rtc_set_time = m41t81_set_time;
107         }
108
109         printk("This kernel optimized for "
110 #ifdef CONFIG_SIMULATION
111                "simulation"
112 #else
113                "board"
114 #endif
115                " runs "
116 #ifdef CONFIG_SIBYTE_CFE
117                "with"
118 #else
119                "without"
120 #endif
121                " CFE\n");
122
123 #ifdef CONFIG_VT
124         screen_info = (struct screen_info) {
125                 0, 0,           /* orig-x, orig-y */
126                 0,              /* unused */
127                 52,             /* orig_video_page */
128                 3,              /* orig_video_mode */
129                 80,             /* orig_video_cols */
130                 4626, 3, 9,     /* unused, ega_bx, unused */
131                 25,             /* orig_video_lines */
132                 0x22,           /* orig_video_isVGA */
133                 16              /* orig_video_points */
134        };
135        /* XXXKW for CFE, get lines/cols from environment */
136 #endif
137
138         return 0;
139 }
140
141 early_initcall(swarm_setup);
142
143 #ifdef LEDS_PHYS
144
145 #ifdef CONFIG_SIBYTE_CARMEL
146 /* XXXKW need to detect Monterey/LittleSur/etc */
147 #undef LEDS_PHYS
148 #define LEDS_PHYS MLEDS_PHYS
149 #endif
150
151 #define setled(index, c) \
152   ((unsigned char *)(IOADDR(LEDS_PHYS)+0x20))[(3-(index))<<3] = (c)
153 void setleds(char *str)
154 {
155         int i;
156         for (i = 0; i < 4; i++) {
157                 if (!str[i]) {
158                         setled(i, ' ');
159                 } else {
160                         setled(i, str[i]);
161                 }
162         }
163 }
164 #endif