add port definition for mcf UART driver
[linux-2.6/next.git] / arch / blackfin / kernel / early_printk.c
blob6ec518a81113c2571df593dd6fe6f2e08c7a24ec
1 /*
2 * File: arch/blackfin/kernel/early_printk.c
3 * Based on: arch/x86_64/kernel/early_printk.c
4 * Author: Robin Getz <rgetz@blackfin.uclinux.org
6 * Created: 14Aug2007
7 * Description: allow a console to be used for early printk
9 * Modified:
10 * Copyright 2004-2007 Analog Devices Inc.
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
25 #include <linux/kernel.h>
26 #include <linux/init.h>
27 #include <linux/serial_core.h>
28 #include <linux/console.h>
29 #include <linux/string.h>
30 #include <asm/blackfin.h>
31 #include <asm/irq_handler.h>
32 #include <asm/early_printk.h>
34 #ifdef CONFIG_SERIAL_BFIN
35 extern struct console *bfin_earlyserial_init(unsigned int port,
36 unsigned int cflag);
37 #endif
39 static struct console *early_console;
41 /* Default console */
42 #define DEFAULT_PORT 0
43 #define DEFAULT_CFLAG CS8|B57600
45 /* Default console for early crashes */
46 #define DEFAULT_EARLY_PORT "serial,uart0,57600"
48 #ifdef CONFIG_SERIAL_CORE
49 /* What should get here is "0,57600" */
50 static struct console * __init earlyserial_init(char *buf)
52 int baud, bit;
53 char parity;
54 unsigned int serial_port = DEFAULT_PORT;
55 unsigned int cflag = DEFAULT_CFLAG;
57 serial_port = simple_strtoul(buf, &buf, 10);
58 buf++;
60 cflag = 0;
61 baud = simple_strtoul(buf, &buf, 10);
62 switch (baud) {
63 case 1200:
64 cflag |= B1200;
65 break;
66 case 2400:
67 cflag |= B2400;
68 break;
69 case 4800:
70 cflag |= B4800;
71 break;
72 case 9600:
73 cflag |= B9600;
74 break;
75 case 19200:
76 cflag |= B19200;
77 break;
78 case 38400:
79 cflag |= B38400;
80 break;
81 case 115200:
82 cflag |= B115200;
83 break;
84 default:
85 cflag |= B57600;
88 parity = buf[0];
89 buf++;
90 switch (parity) {
91 case 'e':
92 cflag |= PARENB;
93 break;
94 case 'o':
95 cflag |= PARODD;
96 break;
99 bit = simple_strtoul(buf, &buf, 10);
100 switch (bit) {
101 case 5:
102 cflag |= CS5;
103 break;
104 case 6:
105 cflag |= CS5;
106 break;
107 case 7:
108 cflag |= CS5;
109 break;
110 default:
111 cflag |= CS8;
114 #ifdef CONFIG_SERIAL_BFIN
115 return bfin_earlyserial_init(serial_port, cflag);
116 #else
117 return NULL;
118 #endif
121 #endif
123 int __init setup_early_printk(char *buf)
126 /* Crashing in here would be really bad, so check both the var
127 and the pointer before we start using it
129 if (!buf)
130 return 0;
132 if (!*buf)
133 return 0;
135 if (early_console != NULL)
136 return 0;
138 #ifdef CONFIG_SERIAL_BFIN
139 /* Check for Blackfin Serial */
140 if (!strncmp(buf, "serial,uart", 11)) {
141 buf += 11;
142 early_console = earlyserial_init(buf);
144 #endif
145 #ifdef CONFIG_FB
146 /* TODO: add framebuffer console support */
147 #endif
149 if (likely(early_console)) {
150 early_console->flags |= CON_BOOT;
152 register_console(early_console);
153 printk(KERN_INFO "early printk enabled on %s%d\n",
154 early_console->name,
155 early_console->index);
158 return 0;
162 * Set up a temporary Event Vector Table, so if something bad happens before
163 * the kernel is fully started, it doesn't vector off into somewhere we don't
164 * know
167 asmlinkage void __init init_early_exception_vectors(void)
169 SSYNC();
171 /* cannot program in software:
172 * evt0 - emulation (jtag)
173 * evt1 - reset
175 bfin_write_EVT2(early_trap);
176 bfin_write_EVT3(early_trap);
177 bfin_write_EVT5(early_trap);
178 bfin_write_EVT6(early_trap);
179 bfin_write_EVT7(early_trap);
180 bfin_write_EVT8(early_trap);
181 bfin_write_EVT9(early_trap);
182 bfin_write_EVT10(early_trap);
183 bfin_write_EVT11(early_trap);
184 bfin_write_EVT12(early_trap);
185 bfin_write_EVT13(early_trap);
186 bfin_write_EVT14(early_trap);
187 bfin_write_EVT15(early_trap);
188 CSYNC();
190 /* Set all the return from interupt, exception, NMI to a known place
191 * so if we do a RETI, RETX or RETN by mistake - we go somewhere known
192 * Note - don't change RETS - we are in a subroutine, or
193 * RETE - since it might screw up if emulator is attached
195 asm("\tRETI = %0; RETX = %0; RETN = %0;\n"
196 : : "p"(early_trap));
200 asmlinkage void __init early_trap_c(struct pt_regs *fp, void *retaddr)
202 /* This can happen before the uart is initialized, so initialize
203 * the UART now
205 if (likely(early_console == NULL))
206 setup_early_printk(DEFAULT_EARLY_PORT);
208 dump_bfin_regs(fp, retaddr);
209 dump_bfin_trace_buffer();
211 panic("Died early");
214 early_param("earlyprintk", setup_early_printk);