commented early_printk patch because of rejects.
[linux-flexiantxendom0-3.2.10.git] / arch / mips / lasat / setup.c
1 /*
2  * Carsten Langgaard, carstenl@mips.com
3  * Copyright (C) 1999 MIPS Technologies, Inc.  All rights reserved.
4  *
5  * Thomas Horsten <thh@lasat.com>
6  * Copyright (C) 2000 LASAT Networks A/S.
7  *
8  * Brian Murphy <brian@murphy.dk>
9  *
10  *  This program is free software; you can distribute it and/or modify it
11  *  under the terms of the GNU General Public License (Version 2) as
12  *  published by the Free Software Foundation.
13  *
14  *  This program is distributed in the hope it will be useful, but WITHOUT
15  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17  *  for more details.
18  *
19  *  You should have received a copy of the GNU General Public License along
20  *  with this program; if not, write to the Free Software Foundation, Inc.,
21  *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
22  *
23  * Lasat specific setup.
24  */
25 #include <linux/config.h>
26 #include <linux/init.h>
27 #include <linux/sched.h>
28 #include <linux/pci.h>
29 #include <linux/ide.h>
30
31 #include <linux/interrupt.h>
32 #include <asm/time.h>
33
34 #include <asm/cpu.h>
35 #include <asm/bootinfo.h>
36 #include <asm/irq.h>
37 #include <asm/lasat/lasat.h>
38
39 #include <linux/tty.h>
40 #include <linux/serial.h>
41 #include <linux/serial_core.h>
42 #include <asm/serial.h>
43 #include <asm/lasat/serial.h>
44
45 #ifdef CONFIG_PICVUE
46 #include <linux/notifier.h>
47 #endif
48
49 #include "ds1603.h"
50 #include "at93c.h"
51 #include <asm/lasat/ds1603.h>
52 #include <asm/lasat/picvue.h>
53 #include <asm/lasat/eeprom.h>
54
55 #include "prom.h"
56
57 int lasat_command_line = 0;
58 void lasatint_init(void);
59
60 #ifdef CONFIG_BLK_DEV_IDE
61 extern struct ide_ops std_ide_ops;
62 extern struct ide_ops *ide_ops;
63 #endif
64
65 extern char arcs_cmdline[CL_SIZE];
66
67 extern void lasat_reboot_setup(void);
68 extern void pcisetup(void);
69 extern void edhac_init(void *, void *, void *);
70 extern void addrflt_init(void);
71
72 struct lasat_misc lasat_misc_info[N_MACHTYPES] = {
73         {(void *)KSEG1ADDR(0x1c840000), (void *)KSEG1ADDR(0x1c800000), 2},
74         {(void *)KSEG1ADDR(0x11080000), (void *)KSEG1ADDR(0x11000000), 6}
75 };
76
77 struct lasat_misc *lasat_misc = NULL;
78
79 #ifdef CONFIG_DS1603
80 static struct ds_defs ds_defs[N_MACHTYPES] = {
81         { (void *)DS1603_REG_100, (void *)DS1603_REG_100,
82                 DS1603_RST_100, DS1603_CLK_100, DS1603_DATA_100,
83                 DS1603_DATA_SHIFT_100, 0, 0 },
84         { (void *)DS1603_REG_200, (void *)DS1603_DATA_REG_200,
85                 DS1603_RST_200, DS1603_CLK_200, DS1603_DATA_200,
86                 DS1603_DATA_READ_SHIFT_200, 1, 2000 }
87 };
88 #endif
89
90 #ifdef CONFIG_PICVUE
91 #include "picvue.h"
92 static struct pvc_defs pvc_defs[N_MACHTYPES] = {
93         { (void *)PVC_REG_100, PVC_DATA_SHIFT_100, PVC_DATA_M_100,
94                 PVC_E_100, PVC_RW_100, PVC_RS_100 },
95         { (void *)PVC_REG_200, PVC_DATA_SHIFT_200, PVC_DATA_M_200,
96                 PVC_E_200, PVC_RW_200, PVC_RS_200 }
97 };
98 #endif
99
100 static int lasat_panic_display(struct notifier_block *this,
101                              unsigned long event, void *ptr)
102 {
103 #ifdef CONFIG_PICVUE
104         unsigned char *string = ptr;
105         if (string == NULL)
106                 string = "Kernel Panic";
107         pvc_dump_string(string);
108 #endif
109         return NOTIFY_DONE;
110 }
111
112 static int lasat_panic_prom_monitor(struct notifier_block *this,
113                              unsigned long event, void *ptr)
114 {
115         prom_monitor();
116         return NOTIFY_DONE;
117 }
118
119 static struct notifier_block lasat_panic_block[] = 
120 {
121         { lasat_panic_display, NULL, INT_MAX },
122         { lasat_panic_prom_monitor, NULL, INT_MIN }
123 };
124
125 #ifdef CONFIG_BLK_DEV_IDE
126 static int lasat_ide_default_irq(ide_ioreg_t base) {
127         return 0;
128 }
129
130 static ide_ioreg_t lasat_ide_default_io_base(int index) {
131         return 0;
132 }
133 #endif
134
135 static void lasat_time_init(void)
136 {
137         mips_counter_frequency = lasat_board_info.li_cpu_hz / 2;
138 }
139
140 static void lasat_timer_setup(struct irqaction *irq)
141 {
142
143         write_c0_compare(
144                 read_c0_count() + 
145                 mips_counter_frequency / HZ);
146         change_c0_status(ST0_IM, IE_IRQ0 | IE_IRQ5);
147 }
148
149 #define MIPS_CPU_TIMER_IRQ 7
150 asmlinkage void lasat_timer_interrupt(struct pt_regs *regs)
151 {
152         ll_timer_interrupt(MIPS_CPU_TIMER_IRQ, regs);
153 }
154
155 #define DYNAMIC_SERIAL_INIT
156 #ifdef DYNAMIC_SERIAL_INIT
157 void __init serial_init(void)
158 {
159 #ifdef CONFIG_SERIAL_8250
160         struct uart_port s;
161
162         memset(&s, 0, sizeof(s));
163
164         s.flags = STD_COM_FLAGS|UPF_RESOURCES;
165         s.iotype = SERIAL_IO_MEM;
166
167         if (mips_machtype == MACH_LASAT_100) {
168                 s.uartclk = LASAT_BASE_BAUD_100 * 16;
169                 s.irq = LASATINT_UART_100;
170                 s.regshift = LASAT_UART_REGS_SHIFT_100;
171                 s.membase = (char *)KSEG1ADDR(LASAT_UART_REGS_BASE_100);
172         } else {
173                 s.uartclk = LASAT_BASE_BAUD_200 * 16;
174                 s.irq = LASATINT_UART_200;
175                 s.regshift = LASAT_UART_REGS_SHIFT_200;
176                 s.membase = (char *)KSEG1ADDR(LASAT_UART_REGS_BASE_200);
177         }
178
179         if (early_serial_setup(&s) != 0)
180                 printk(KERN_ERR "Serial setup failed!\n");
181 #endif
182 }
183 #endif
184
185 void __init lasat_setup(void)
186 {
187         int i;
188         lasat_misc  = &lasat_misc_info[mips_machtype];
189 #ifdef CONFIG_PICVUE
190         picvue = &pvc_defs[mips_machtype];
191 #endif
192
193         /* Set up panic notifier */
194         for (i = 0; i < sizeof(lasat_panic_block) / sizeof(struct notifier_block); i++)
195                 notifier_chain_register(&panic_notifier_list, &lasat_panic_block[i]);
196
197 #ifdef CONFIG_BLK_DEV_IDE
198         ide_ops = &std_ide_ops;
199         ide_ops->ide_default_irq = &lasat_ide_default_irq;
200         ide_ops->ide_default_io_base = &lasat_ide_default_io_base;
201 #endif
202
203         lasat_reboot_setup();
204
205         board_time_init = lasat_time_init;
206         board_timer_setup = lasat_timer_setup;
207
208 #ifdef CONFIG_DS1603
209         ds1603 = &ds_defs[mips_machtype];
210         rtc_get_time = ds1603_read;
211         rtc_set_time = ds1603_set;
212 #endif
213
214 #ifdef DYNAMIC_SERIAL_INIT
215         serial_init();
216 #endif
217         /* Switch from prom exception handler to normal mode */
218         change_c0_status(ST0_BEV,0);
219
220         prom_printf("Lasat specific initialization complete\n");
221 }
222
223