summaryrefslogtreecommitdiffstats
path: root/arch/ppc/boot/ns16550.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1999-02-15 02:15:32 +0000
committerRalf Baechle <ralf@linux-mips.org>1999-02-15 02:15:32 +0000
commit86464aed71025541805e7b1515541aee89879e33 (patch)
treee01a457a4912a8553bc65524aa3125d51f29f810 /arch/ppc/boot/ns16550.c
parent88f99939ecc6a95a79614574cb7d95ffccfc3466 (diff)
Merge with Linux 2.2.1.
Diffstat (limited to 'arch/ppc/boot/ns16550.c')
-rw-r--r--arch/ppc/boot/ns16550.c56
1 files changed, 56 insertions, 0 deletions
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);
+}
+
+
+