ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / mips / sibyte / swarm / setup.c
1 /*
2  * Copyright (C) 2000, 2001, 2002, 2003 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/config.h>
24 #include <linux/spinlock.h>
25 #include <linux/mm.h>
26 #include <linux/bootmem.h>
27 #include <linux/blkdev.h>
28 #include <linux/init.h>
29
30 #include <asm/irq.h>
31 #include <asm/io.h>
32 #include <asm/bootinfo.h>
33 #include <asm/mipsregs.h>
34 #include <asm/reboot.h>
35 #include <asm/time.h>
36 #include <asm/traps.h>
37 #include <asm/pci_channel.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 void sb1250_setup(void);
44
45 extern int xicor_probe(void);
46 extern int xicor_set_time(unsigned long);
47 extern unsigned long xicor_get_time(void);
48
49 extern int m41t81_probe(void);
50 extern int m41t81_set_time(unsigned long);
51 extern unsigned long m41t81_get_time(void);
52
53 const char *get_system_type(void)
54 {
55         return "SiByte " SIBYTE_BOARD_NAME;
56 }
57
58 void __init swarm_timer_setup(struct irqaction *irq)
59 {
60         /*
61          * we don't set up irqaction, because we will deliver timer
62          * interrupts through low-level (direct) meachanism.
63          */
64
65         /* We only need to setup the generic timer */
66         sb1250_time_init();
67 }
68
69 int swarm_be_handler(struct pt_regs *regs, int is_fixup)
70 {
71         if (!is_fixup && (regs->cp0_cause & 4)) {
72                 /* Data bus error - print PA */
73 #ifdef CONFIG_MIPS64
74                 printk("DBE physical address: %010lx\n",
75                        __read_64bit_c0_register($26, 1));
76 #else
77                 printk("DBE physical address: %010llx\n",
78                        __read_64bit_c0_split($26, 1));
79 #endif
80         }
81         return (is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL);
82 }
83
84 static int __init swarm_setup(void)
85 {
86         extern int panic_timeout;
87
88         sb1250_setup();
89
90         panic_timeout = 5;  /* For debug.  */
91
92         board_timer_setup = swarm_timer_setup;
93         board_be_handler = swarm_be_handler;
94
95         if (xicor_probe()) {
96                 printk("swarm setup: Xicor 1241 RTC detected.\n");
97                 rtc_get_time = xicor_get_time;
98                 rtc_set_time = xicor_set_time;
99         }
100  
101         if (m41t81_probe()) {
102                 printk("swarm setup: M41T81 RTC detected.\n");
103                 rtc_get_time = m41t81_get_time;
104                 rtc_set_time = m41t81_set_time;
105         }
106
107         printk("This kernel optimized for "
108 #ifdef CONFIG_SIMULATION
109                "simulation"
110 #else
111                "board"
112 #endif
113                " runs "
114 #ifdef CONFIG_SIBYTE_CFE
115                "with"
116 #else
117                "without"
118 #endif
119                " CFE\n");
120
121 #ifdef CONFIG_VT
122         screen_info = (struct screen_info) {
123                 0, 0,           /* orig-x, orig-y */
124                 0,              /* unused */
125                 52,             /* orig_video_page */
126                 3,              /* orig_video_mode */
127                 80,             /* orig_video_cols */
128                 4626, 3, 9,     /* unused, ega_bx, unused */
129                 25,             /* orig_video_lines */
130                 0x22,           /* orig_video_isVGA */
131                 16              /* orig_video_points */
132        };
133        /* XXXKW for CFE, get lines/cols from environment */
134 #endif
135
136         return 0;
137 }
138
139 early_initcall(swarm_setup);
140
141 #ifdef LEDS_PHYS
142
143 #ifdef CONFIG_SIBYTE_CARMEL
144 /* XXXKW need to detect Monterey/LittleSur/etc */
145 #undef LEDS_PHYS
146 #define LEDS_PHYS MLEDS_PHYS
147 #endif
148
149 #define setled(index, c) \
150   ((unsigned char *)(IOADDR(LEDS_PHYS)+0x20))[(3-(index))<<3] = (c)
151 void setleds(char *str)
152 {
153         int i;
154         for (i = 0; i < 4; i++) {
155                 if (!str[i]) {
156                         setled(i, ' ');
157                 } else {
158                         setled(i, str[i]);
159                 }
160         }
161 }
162 #endif