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
7 * Description: allow a console to be used for early printk
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,
38 #ifdef CONFIG_BFIN_JTAG_COMM
39 extern struct console *bfin_jc_early_init(void);
42 static struct console *early_console;
45 #define DEFAULT_PORT 0
46 #define DEFAULT_CFLAG CS8|B57600
48 /* Default console for early crashes */
49 #define DEFAULT_EARLY_PORT "serial,uart0,57600"
51 #ifdef CONFIG_SERIAL_CORE
52 /* What should get here is "0,57600" */
53 static struct console * __init earlyserial_init(char *buf)
57 unsigned int serial_port = DEFAULT_PORT;
58 unsigned int cflag = DEFAULT_CFLAG;
60 serial_port = simple_strtoul(buf, &buf, 10);
64 baud = simple_strtoul(buf, &buf, 10);
102 bit = simple_strtoul(buf, &buf, 10);
117 #ifdef CONFIG_SERIAL_BFIN
118 return bfin_earlyserial_init(serial_port, cflag);
126 int __init setup_early_printk(char *buf)
129 /* Crashing in here would be really bad, so check both the var
130 and the pointer before we start using it
138 if (early_console != NULL)
141 #ifdef CONFIG_SERIAL_BFIN
142 /* Check for Blackfin Serial */
143 if (!strncmp(buf, "serial,uart", 11)) {
145 early_console = earlyserial_init(buf);
149 #ifdef CONFIG_BFIN_JTAG_COMM
150 /* Check for Blackfin JTAG */
151 if (!strncmp(buf, "jtag", 4)) {
153 early_console = bfin_jc_early_init();
158 /* TODO: add framebuffer console support */
161 if (likely(early_console)) {
162 early_console->flags |= CON_BOOT;
164 register_console(early_console);
165 printk(KERN_INFO "early printk enabled on %s%d\n",
167 early_console->index);
174 * Set up a temporary Event Vector Table, so if something bad happens before
175 * the kernel is fully started, it doesn't vector off into somewhere we don't
179 asmlinkage void __init init_early_exception_vectors(void)
183 /* cannot program in software:
184 * evt0 - emulation (jtag)
187 bfin_write_EVT2(early_trap);
188 bfin_write_EVT3(early_trap);
189 bfin_write_EVT5(early_trap);
190 bfin_write_EVT6(early_trap);
191 bfin_write_EVT7(early_trap);
192 bfin_write_EVT8(early_trap);
193 bfin_write_EVT9(early_trap);
194 bfin_write_EVT10(early_trap);
195 bfin_write_EVT11(early_trap);
196 bfin_write_EVT12(early_trap);
197 bfin_write_EVT13(early_trap);
198 bfin_write_EVT14(early_trap);
199 bfin_write_EVT15(early_trap);
202 /* Set all the return from interrupt, exception, NMI to a known place
203 * so if we do a RETI, RETX or RETN by mistake - we go somewhere known
204 * Note - don't change RETS - we are in a subroutine, or
205 * RETE - since it might screw up if emulator is attached
207 asm("\tRETI = %0; RETX = %0; RETN = %0;\n"
208 : : "p"(early_trap));
212 asmlinkage void __init early_trap_c(struct pt_regs *fp, void *retaddr)
214 /* This can happen before the uart is initialized, so initialize
217 if (likely(early_console == NULL))
218 setup_early_printk(DEFAULT_EARLY_PORT);
222 dump_bfin_trace_buffer();
227 early_param("earlyprintk", setup_early_printk);