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