Skip to contentSkip to conversation

MIPS: add 8250/16550 serial early printk driver

PATCH Superseded Yoichi Yuasa 3 participants 6 messages Feb 5, 2010 – Feb 8, 2010 MIPS

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 MIPS: add 8250/16550 serial early printk driver

---
 arch/mips/Kconfig.debug              |    8 ++++
 arch/mips/include/asm/setup.h        |    9 ++++
 arch/mips/kernel/Makefile            |    1 +
 arch/mips/kernel/early_printk_8250.c |   68 ++++++++++++++++++++++++++++++++++
 4 files changed, 86 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/kernel/early_printk_8250.c
arch/mips/Kconfig.debug +8 -0
index 32a010d..f5d739c 100644
@@ -20,6 +20,14 @@ config EARLY_PRINTK
 	  doesn't cooperate with an X server. You should normally say N here,
 	  unless you want to debug such a crash.
 
+config EARLY_PRINTK_8250
+	bool "8250/16550 and compatible serial early printk driver"
+	depends on EARLY_PRINTK
+	default n
+	help
+	  If you say Y here, it will be possible to use a 8250/16550 serial
+	  port as the boot console.
+	
 config CMDLINE_BOOL
 	bool "Built-in kernel command line"
 	default n
arch/mips/include/asm/setup.h +9 -0
index 50511aa..7395b7f 100644
@@ -5,6 +5,15 @@
 
 #ifdef  __KERNEL__
 extern void setup_early_printk(void);
+
+#ifdef CONFIG_EARLY_PRINTK_8250
+extern void setup_8250_early_printk_port(unsigned long base,
+				unsigned int reg_shift, unsigned int timeout);
+#else
+static inline void setup_8250_early_printk_port(unsigned long base,
+				unsigned int reg_shift, unsigned int timeout) {}
+#endif
+
 #endif /* __KERNEL__ */
 
 #endif /* __SETUP_H */
arch/mips/kernel/Makefile +1 -0
index 9326af5..03fc037 100644
@@ -93,6 +93,7 @@ obj-$(CONFIG_GPIO_TXX9)		+= gpio_txx9.o
 
 obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
+obj-$(CONFIG_EARLY_PRINTK_8250)	+= early_printk_8250.o
 
 CFLAGS_cpu-bugs64.o	= $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
 
arch/mips/kernel/early_printk_8250.c new file +68 -0

68 lines not on this page · raw message

Signature · 1 line
1.6.6.1
#1 lore raw

PATCH 2/2 MIPS: Cobalt move to 8250/16550 serial early printk driver

---
 arch/mips/Kconfig          |    1 +
 arch/mips/cobalt/Makefile  |    1 -
 arch/mips/cobalt/console.c |   20 --------------------
 arch/mips/cobalt/setup.c   |    3 +++
 4 files changed, 4 insertions(+), 21 deletions(-)
 delete mode 100644 arch/mips/cobalt/console.c
arch/mips/Kconfig +1 -0
index 591ca0c..b848512 100644
@@ -90,6 +90,7 @@ config MIPS_COBALT
 	select CSRC_R4K
 	select CEVT_GT641XX
 	select DMA_NONCOHERENT
+	select EARLY_PRINTK_8250 if EARLY_PRINTK
 	select HW_HAS_PCI
 	select I8253
 	select I8259
arch/mips/cobalt/Makefile +0 -1
index 2379262..5cfe90f 100644
@@ -5,7 +5,6 @@
 obj-y := buttons.o irq.o lcd.o led.o reset.o rtc.o serial.o setup.o time.o
 
 obj-$(CONFIG_PCI)		+= pci.o
-obj-$(CONFIG_EARLY_PRINTK)	+= console.o
 obj-$(CONFIG_MTD_PHYSMAP)	+= mtd.o
 
 EXTRA_CFLAGS += -Werror
arch/mips/cobalt/console.c deleted +0 -20
deleted file mode 100644
index d1ba701..0000000
@@ -1,20 +0,0 @@
-/*
- * (C) P. Horton 2006
- */
-#include <linux/io.h>
-#include <linux/serial_reg.h>
-
-#include <cobalt.h>
-
-#define UART_BASE	((void __iomem *)CKSEG1ADDR(0x1c800000))
-
-void prom_putchar(char c)
-{
-	if (cobalt_board_id <= COBALT_BRD_ID_QUBE1)
-		return;
-
-	while (!(readb(UART_BASE + UART_LSR) & UART_LSR_THRE))
-		;
-
-	writeb(c, UART_BASE + UART_TX);
-}
arch/mips/cobalt/setup.c +3 -0
index ec3b2c4..9a8c2fe 100644
@@ -17,6 +17,7 @@
 
 #include <asm/bootinfo.h>
 #include <asm/reboot.h>
+#include <asm/setup.h>
 #include <asm/gt64120.h>
 
 #include <cobalt.h>
@@ -112,6 +113,8 @@ void __init prom_init(void)
 	}
 
 	add_memory_region(0x0, memsz, BOOT_MEM_RAM);
+
+	setup_8250_early_printk_port(CKSEG1ADDR(0x1c800000), 0, 0);
 }
 
 void __init prom_free_prom_memory(void)
Signature · 1 line
1.6.6.1
#2 lore raw
In reply to Yoichi Yuasa
Quoted 14 lines · Yoichi Yuasa
---
 arch/mips/Kconfig.debug              |    8 ++++
 arch/mips/include/asm/setup.h        |    9 ++++
 arch/mips/kernel/Makefile            |    1 +
 arch/mips/kernel/early_printk_8250.c |   68 ++++++++++++++++++++++++++++++++++
 4 files changed, 86 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/kernel/early_printk_8250.c
arch/mips/Kconfig.debug +0 -0
index 32a010d..f5d739c 100644

arch/mips/Kconfig.debug config EARLY_PRINTK · line 23

Quoted 5 lines
arch/mips/Kconfig.debug +1 -0
@@ -20,6 +20,14 @@ config EARLY_PRINTK
 	  doesn't cooperate with an X server. You should normally say N here,
 	  unless you want to debug such a crash.
 
+config EARLY_PRINTK_8250
[..]

have you looked at drivers/serial/8250_early.c ? It looks like it was invented for some sort of early console on 8250 devices...

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]
#3 lore raw
Quoted 18 lines · On Sat, 6 Feb 2010 13:16:22 +0100 Thomas Bogendoerfer…
Quoted 17 lines · Yoichi Yuasa
---
 arch/mips/Kconfig.debug              |    8 ++++
 arch/mips/include/asm/setup.h        |    9 ++++
 arch/mips/kernel/Makefile            |    1 +
 arch/mips/kernel/early_printk_8250.c |   68 ++++++++++++++++++++++++++++++++++
 4 files changed, 86 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/kernel/early_printk_8250.c
arch/mips/Kconfig.debug +0 -0
index 32a010d..f5d739c 100644
@@ -20,6 +20,14 @@ config EARLY_PRINTK
 	  doesn't cooperate with an X server. You should normally say N here,
 	  unless you want to debug such a crash.
 
Quoted 4 lines

arch/mips/Kconfig.debug config EARLY_PRINTK · line 23

Quoted 2 lines
arch/mips/Kconfig.debug +1 -0
+config EARLY_PRINTK_8250
[..]

have you looked at drivers/serial/8250_early.c ?

Yes, I have.

Quoted 2 lines

It looks like it
was invented for some sort of early console on 8250 devices...

The early printk is registered at the early boot stage(in setup_arch()).

Yoichi

#4 lore raw
In reply to Yoichi Yuasa

Hello.

Quoted 2 lines · Yoichi Yuasa

[...]

Quoted 7 lines
arch/mips/Kconfig.debug +0 -0
index 32a010d..f5d739c 100644
@@ -20,6 +20,14 @@ config EARLY_PRINTK
 	  doesn't cooperate with an X server. You should normally say N here,
 	  unless you want to debug such a crash.

arch/mips/Kconfig.debug config EARLY_PRINTK · line 31

Quoted 10 lines
arch/mips/Kconfig.debug +8 -0
 
+config EARLY_PRINTK_8250
+	bool "8250/16550 and compatible serial early printk driver"
+	depends on EARLY_PRINTK
+	default n
+	help
+	  If you say Y here, it will be possible to use a 8250/16550 serial
+	  port as the boot console.
+	
 

Tab not needed here.

Quoted 60 lines
arch/mips/include/asm/setup.h +9 -0
index 50511aa..7395b7f 100644
@@ -5,6 +5,15 @@
 
 #ifdef  __KERNEL__
 extern void setup_early_printk(void);
+
+#ifdef CONFIG_EARLY_PRINTK_8250
+extern void setup_8250_early_printk_port(unsigned long base,
+				unsigned int reg_shift, unsigned int timeout);
+#else
+static inline void setup_8250_early_printk_port(unsigned long base,
+				unsigned int reg_shift, unsigned int timeout) {}
+#endif
+
 #endif /* __KERNEL__ */
 
 #endif /* __SETUP_H */
arch/mips/kernel/Makefile +1 -0
index 9326af5..03fc037 100644
@@ -93,6 +93,7 @@ obj-$(CONFIG_GPIO_TXX9)		+= gpio_txx9.o
 
 obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
+obj-$(CONFIG_EARLY_PRINTK_8250)	+= early_printk_8250.o
 
 CFLAGS_cpu-bugs64.o	= $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
 
arch/mips/kernel/early_printk_8250.c new file +21 -0
new file mode 100644
index 0000000..6faf8fd
@@ -0,0 +1,68 @@
+/*
+ *  8250/16550-type serial ports prom_putchar()
+ *
+ *  Copyright (C) 2010  Yoichi Yuasa <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <linux/io.h>
+#include <linux/serial_core.h>

arch/mips/kernel/early_printk_8250.c line 31

Quoted 10 lines
arch/mips/kernel/early_printk_8250.c new file +10 -0
+#include <linux/serial_reg.h>
+
+static unsigned long serial8250_base;
+static unsigned int serial8250_reg_shift;
+static unsigned int serial8250_tx_timeout;
+
+void setup_8250_early_printk_port(unsigned long base, unsigned int reg_shift,
+				  unsigned int timeout)
+{
+	serial8250_base = base;

Why not declare 'serial8250_base' as 'void __iomem *' and only cast
once, here?

WBR, Sergei

#5 lore raw

Hello Sergei,

Quoted 7 lines · On Mon, 08 Feb 2010 12:58:08 +0300 Sergei Shtylyov <[email protected]> wrote:

Hello.

Quoted 2 lines · Yoichi Yuasa

[...]

Quoted 11 lines

arch/mips/Kconfig.debug config EARLY_PRINTK · line 30

Quoted 9 lines
arch/mips/Kconfig.debug +8 -0
+config EARLY_PRINTK_8250
+	bool "8250/16550 and compatible serial early printk driver"
+	depends on EARLY_PRINTK
+	default n
+	help
+	  If you say Y here, it will be possible to use a 8250/16550 serial
+	  port as the boot console.
+	

Tab not needed here.

thanks

Quoted 5 lines
Quoted 5 lines
arch/mips/kernel/early_printk_8250.c new file +0 -0
new file mode 100644
index 0000000..6faf8fd

[...]

Quoted 4 lines
Quoted 4 lines
arch/mips/kernel/early_printk_8250.c new file +4 -0
+static unsigned long serial8250_base;
+static unsigned int serial8250_reg_shift;
+static unsigned int serial8250_tx_timeout;
+
Quoted 8 lines

arch/mips/kernel/early_printk_8250.c line 31

Quoted 5 lines
arch/mips/kernel/early_printk_8250.c new file +4 -0
+void setup_8250_early_printk_port(unsigned long base, unsigned int reg_shift,
+				  unsigned int timeout)
+{
+	serial8250_base = base;

Why not declare 'serial8250_base' as 'void __iomem *' and only cast
once, here?

You're right. I'll update it.

Thanks,

Yoichi