From 86464aed71025541805e7b1515541aee89879e33 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 15 Feb 1999 02:15:32 +0000 Subject: Merge with Linux 2.2.1. --- arch/ppc/boot/Makefile | 3 +++ arch/ppc/boot/misc.c | 36 +++++++++++++++++++++++++++++-- arch/ppc/boot/ns16550.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ arch/ppc/boot/ns16550.h | 34 ++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 arch/ppc/boot/ns16550.c create mode 100644 arch/ppc/boot/ns16550.h (limited to 'arch/ppc/boot') diff --git a/arch/ppc/boot/Makefile b/arch/ppc/boot/Makefile index fde1ad4c6..da4945fd7 100644 --- a/arch/ppc/boot/Makefile +++ b/arch/ppc/boot/Makefile @@ -48,6 +48,9 @@ OBJECTS += mbxtty.o CFLAGS += -DCONFIG_MBX else OBJECTS += vreset.o kbd.o + ifeq ($(CONFIG_SERIAL_CONSOLE),y) + OBJECTS += ns16550.o + endif endif all: zImage diff --git a/arch/ppc/boot/misc.c b/arch/ppc/boot/misc.c index 42cb533da..470e1e4a9 100644 --- a/arch/ppc/boot/misc.c +++ b/arch/ppc/boot/misc.c @@ -1,7 +1,7 @@ /* * misc.c * - * $Id: misc.c,v 1.52 1998/09/19 01:21:24 cort Exp $ + * $Id: misc.c,v 1.53 1998/12/15 17:40:15 cort Exp $ * * Adapted for PowerPC by Gary Thomas * @@ -12,7 +12,7 @@ #include #include "../coffboot/zlib.h" #include "asm/residual.h" -#include +#include #include #include #include @@ -23,6 +23,10 @@ #ifdef CONFIG_FADS #include #endif +#if defined(CONFIG_SERIAL_CONSOLE) && !defined(CONFIG_MBX) +#include "ns16550.h" +struct NS16550 *com_port; +#endif /* CONFIG_SERIAL_CONSOLE */ /* * Please send me load/board info and such data for hardware not @@ -42,6 +46,7 @@ char *end_avail; * save here and pass to the kernel (command line and board info). * On the MBX we grab some known memory holes to hold this information. */ +char cmd_preset[] = "console=tty0 console=ttyS0,9600n8"; char cmd_buf[256]; char *cmd_line = cmd_buf; @@ -108,12 +113,19 @@ static void scroll() tstc(void) { +#if defined(CONFIG_SERIAL_CONSOLE) && !defined(CONFIG_MBX) + return (CRT_tstc() || NS16550_tstc(com_port)); +#else return (CRT_tstc() ); +#endif /* CONFIG_SERIAL_CONSOLE */ } getc(void) { while (1) { +#if defined(CONFIG_SERIAL_CONSOLE) && !defined(CONFIG_MBX) + if (NS16550_tstc(com_port)) return (NS16550_getc(com_port)); +#endif /* CONFIG_SERIAL_CONSOLE */ if (CRT_tstc()) return (CRT_getc()); } } @@ -123,6 +135,11 @@ putc(const char c) { int x,y; +#if defined(CONFIG_SERIAL_CONSOLE) && !defined(CONFIG_MBX) + NS16550_putc(com_port, c); + if ( c == '\n' ) NS16550_putc(com_port, '\r'); +#endif /* CONFIG_SERIAL_CONSOLE */ + x = orig_x; y = orig_y; @@ -162,12 +179,21 @@ void puts(const char *s) y = orig_y; while ( ( c = *s++ ) != '\0' ) { +#if defined(CONFIG_SERIAL_CONSOLE) && !defined(CONFIG_MBX) + NS16550_putc(com_port, c); + if ( c == '\n' ) NS16550_putc(com_port, '\r'); +#endif /* CONFIG_SERIAL_CONSOLE */ + if ( c == '\n' ) { x = 0; if ( ++y >= lines ) { scroll(); y--; } + } else if (c == '\b') { + if (x > 0) { + x--; + } } else { vidmem [ ( x + cols * y ) * 2 ] = c; if ( ++x >= cols ) { @@ -358,6 +384,10 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, R _put_MSR(_get_MSR() & ~0x0030); vga_init(0xC0000000); +#if defined(CONFIG_SERIAL_CONSOLE) && !defined(CONFIG_MBX) + com_port = (struct NS16550 *)NS16550_init(0); +#endif /* CONFIG_SERIAL_CONSOLE */ + if (residual) memcpy(hold_residual,residual,sizeof(RESIDUAL)); #else /* CONFIG_MBX */ @@ -510,6 +540,8 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, R puts("\nLinux/PPC load: "); timer = 0; cp = cmd_line; + memcpy (cmd_line, cmd_preset, sizeof(cmd_preset)); + while ( *cp ) putc(*cp++); while (timer++ < 5*1000) { if (tstc()) { while ((ch = getc()) != '\n' && ch != '\r') { diff --git a/arch/ppc/boot/ns16550.c b/arch/ppc/boot/ns16550.c new file mode 100644 index 000000000..db0b94d03 --- /dev/null +++ b/arch/ppc/boot/ns16550.c @@ -0,0 +1,56 @@ +/* + * COM1 NS16550 support + */ + +#include "ns16550.h" +typedef struct NS16550 *NS16550_t; + +const NS16550_t COM_PORTS[] = { (NS16550_t) COM1, + (NS16550_t) COM2, + (NS16550_t) COM3, + (NS16550_t) COM4 }; + +volatile struct NS16550 * +NS16550_init(int chan) +{ + volatile struct NS16550 *com_port; + volatile unsigned char xx; + com_port = (struct NS16550 *) COM_PORTS[chan]; + /* See if port is present */ + com_port->lcr = 0x00; + com_port->ier = 0xFF; +#if 0 + if (com_port->ier != 0x0F) return ((struct NS16550 *)0); +#endif + com_port->ier = 0x00; + com_port->lcr = 0x80; /* Access baud rate */ + com_port->dll = 0xc; /* 9600 baud */ + com_port->dlm = 0xc >> 8; + com_port->lcr = 0x03; /* 8 data, 1 stop, no parity */ + com_port->mcr = 0x03; /* RTS/DTR */ + com_port->fcr = 0x07; /* Clear & enable FIFOs */ + return (com_port); +} + + +NS16550_putc(volatile struct NS16550 *com_port, unsigned char c) +{ + volatile int i; + while ((com_port->lsr & LSR_THRE) == 0) ; + com_port->thr = c; +} + +unsigned char +NS16550_getc(volatile struct NS16550 *com_port) +{ + while ((com_port->lsr & LSR_DR) == 0) ; + return (com_port->rbr); +} + +NS16550_tstc(volatile struct NS16550 *com_port) +{ + return ((com_port->lsr & LSR_DR) != 0); +} + + + diff --git a/arch/ppc/boot/ns16550.h b/arch/ppc/boot/ns16550.h new file mode 100644 index 000000000..4baf4c1c5 --- /dev/null +++ b/arch/ppc/boot/ns16550.h @@ -0,0 +1,34 @@ +/* + * NS16550 Serial Port + */ + +struct NS16550 + { + unsigned char rbr; /* 0 */ + unsigned char ier; /* 1 */ + unsigned char fcr; /* 2 */ + unsigned char lcr; /* 3 */ + unsigned char mcr; /* 4 */ + unsigned char lsr; /* 5 */ + unsigned char msr; /* 6 */ + unsigned char scr; /* 7 */ + }; + +#define thr rbr +#define iir fcr +#define dll rbr +#define dlm ier + +#define LSR_DR 0x01 /* Data ready */ +#define LSR_OE 0x02 /* Overrun */ +#define LSR_PE 0x04 /* Parity error */ +#define LSR_FE 0x08 /* Framing error */ +#define LSR_BI 0x10 /* Break */ +#define LSR_THRE 0x20 /* Xmit holding register empty */ +#define LSR_TEMT 0x40 /* Xmitter empty */ +#define LSR_ERR 0x80 /* Error */ + +#define COM1 0x800003F8 +#define COM2 0x800002F8 +#define COM3 0x800003F8 +#define COM4 0x80000388 -- cgit v1.2.3