1 commit 0a76092a63809a0e72e3e9552acadf42869c0293
2 Author: Yoichi Yuasa <yuasa@linux-mips.org>
3 Date: Mon Feb 8 20:59:39 2010 +0900
5 MIPS: Add 8250/16550 serial early printk driver
7 Signed-off-by: Yoichi Yuasa <yuasa@linux-mips.org>
8 Cc: linux-mips <linux-mips@linux-mips.org>
9 Patchwork: https://patchwork.linux-mips.org/patch/947/
10 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
12 --- a/arch/mips/Kconfig.debug
13 +++ b/arch/mips/Kconfig.debug
14 @@ -20,6 +20,14 @@ config EARLY_PRINTK
15 doesn't cooperate with an X server. You should normally say N here,
16 unless you want to debug such a crash.
18 +config EARLY_PRINTK_8250
19 + bool "8250/16550 and compatible serial early printk driver"
20 + depends on EARLY_PRINTK
23 + If you say Y here, it will be possible to use a 8250/16550 serial
24 + port as the boot console.
27 bool "Built-in kernel command line"
29 --- a/arch/mips/include/asm/setup.h
30 +++ b/arch/mips/include/asm/setup.h
33 extern void setup_early_printk(void);
35 +#ifdef CONFIG_EARLY_PRINTK_8250
36 +extern void setup_8250_early_printk_port(unsigned long base,
37 + unsigned int reg_shift, unsigned int timeout);
39 +static inline void setup_8250_early_printk_port(unsigned long base,
40 + unsigned int reg_shift, unsigned int timeout) {}
43 extern void set_handler(unsigned long offset, void *addr, unsigned long len);
44 extern void set_uncached_handler(unsigned long offset, void *addr, unsigned long len);
46 --- a/arch/mips/kernel/Makefile
47 +++ b/arch/mips/kernel/Makefile
48 @@ -84,6 +84,7 @@ obj-$(CONFIG_GPIO_TXX9) += gpio_txx9.o
49 obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o
50 obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
51 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
52 +obj-$(CONFIG_EARLY_PRINTK_8250) += early_printk_8250.o
53 obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o
54 obj-$(CONFIG_MIPS_MACHINE) += mips_machine.o
57 +++ b/arch/mips/kernel/early_printk_8250.c
60 + * 8250/16550-type serial ports prom_putchar()
62 + * Copyright (C) 2010 Yoichi Yuasa <yuasa@linux-mips.org>
64 + * This program is free software; you can redistribute it and/or modify
65 + * it under the terms of the GNU General Public License as published by
66 + * the Free Software Foundation; either version 2 of the License, or
67 + * (at your option) any later version.
69 + * This program is distributed in the hope that it will be useful,
70 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
71 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72 + * GNU General Public License for more details.
74 + * You should have received a copy of the GNU General Public License
75 + * along with this program; if not, write to the Free Software
76 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
78 +#include <linux/io.h>
79 +#include <linux/serial_core.h>
80 +#include <linux/serial_reg.h>
82 +static void __iomem *serial8250_base;
83 +static unsigned int serial8250_reg_shift;
84 +static unsigned int serial8250_tx_timeout;
86 +void setup_8250_early_printk_port(unsigned long base, unsigned int reg_shift,
87 + unsigned int timeout)
89 + serial8250_base = (void __iomem *)base;
90 + serial8250_reg_shift = reg_shift;
91 + serial8250_tx_timeout = timeout;
94 +static inline u8 serial_in(int offset)
96 + return readb(serial8250_base + (offset << serial8250_reg_shift));
99 +static inline void serial_out(int offset, char value)
101 + writeb(value, serial8250_base + (offset << serial8250_reg_shift));
104 +void prom_putchar(char c)
106 + unsigned int timeout;
109 + if (!serial8250_base)
112 + timeout = serial8250_tx_timeout;
113 + bits = UART_LSR_TEMT | UART_LSR_THRE;
116 + status = serial_in(UART_LSR);
118 + if (--timeout == 0)
120 + } while ((status & bits) != bits);
123 + serial_out(UART_TX, c);