reversed mapping of serial console, because of change in sgiserial.c
[linux-2.6/linux-mips.git] / arch / mips / sgi / kernel / setup.c
blob99cd9946f9f1dfe141ce155ce043b377edc1012b
1 /* $Id: setup.c,v 1.15 1998/09/26 12:25:03 tsbogend Exp $
3 * setup.c: SGI specific setup, including init of the feature struct.
5 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
6 * Copyright (C) 1997, 1998 Ralf Baechle (ralf@gnu.org)
7 */
8 #include <linux/init.h>
9 #include <linux/kbd_ll.h>
10 #include <linux/kernel.h>
11 #include <linux/kdev_t.h>
12 #include <linux/types.h>
13 #include <linux/console.h>
14 #include <linux/sched.h>
15 #include <linux/mc146818rtc.h>
17 #include <asm/addrspace.h>
18 #include <asm/bcache.h>
19 #include <asm/keyboard.h>
20 #include <asm/irq.h>
21 #include <asm/reboot.h>
22 #include <asm/sgialib.h>
23 #include <asm/sgi.h>
24 #include <asm/sgimc.h>
25 #include <asm/sgihpc.h>
26 #include <asm/sgint23.h>
28 extern struct rtc_ops indy_rtc_ops;
29 void indy_reboot_setup(void);
31 static volatile struct hpc_keyb *sgi_kh = (struct hpc_keyb *) (KSEG1 + 0x1fbd9800 + 64);
33 #define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */
35 static unsigned char sgi_read_input(void)
37 return sgi_kh->data;
40 static void sgi_write_output(unsigned char val)
42 int status;
44 do {
45 status = sgi_kh->command;
46 } while (status & KBD_STAT_IBF);
47 sgi_kh->data = val;
50 static void sgi_write_command(unsigned char val)
52 int status;
54 do {
55 status = sgi_kh->command;
56 } while (status & KBD_STAT_IBF);
57 sgi_kh->command = val;
60 static unsigned char sgi_read_status(void)
62 return sgi_kh->command;
65 __initfunc(static void sgi_keyboard_setup(void))
67 kbd_read_input = sgi_read_input;
68 kbd_write_output = sgi_write_output;
69 kbd_write_command = sgi_write_command;
70 kbd_read_status = sgi_read_status;
72 request_irq(SGI_KEYBOARD_IRQ, keyboard_interrupt,
73 0, "keyboard", NULL);
75 /* Dirty hack, this get's called as a callback from the keyboard
76 driver. We piggyback the initialization of the front panel
77 button handling on it even though they're technically not
78 related with the keyboard driver in any way. Doing it from
79 indy_setup wouldn't work since kmalloc isn't initialized yet. */
80 indy_reboot_setup();
83 __initfunc(static void sgi_irq_setup(void))
85 sgint_init();
88 __initfunc(void sgi_setup(void))
90 #ifdef CONFIG_SERIAL_CONSOLE
91 char *ctype;
92 #endif
94 irq_setup = sgi_irq_setup;
95 keyboard_setup = sgi_keyboard_setup;
97 /* Init the INDY HPC I/O controller. Need to call this before
98 * fucking with the memory controller because it needs to know the
99 * boardID and whether this is a Guiness or a FullHouse machine.
101 sgihpc_init();
103 /* Init INDY memory controller. */
104 sgimc_init();
106 /* Now enable boardcaches, if any. */
107 indy_sc_init();
109 #ifdef CONFIG_SERIAL_CONSOLE
110 /* ARCS console environment variable is set to "g?" for
111 * graphics console, it is set to "d" for the first serial
112 * line and "d2" for the second serial line.
114 ctype = prom_getenv("console");
115 if(*ctype == 'd') {
116 if(*(ctype+1)=='2')
117 console_setup ("ttyS1");
118 else
119 console_setup ("ttyS0");
121 #endif
123 #ifdef CONFIG_VT
124 conswitchp = &newport_con;
125 #endif
126 rtc_ops = &indy_rtc_ops;