patch-2.4.10 linux/arch/ppc/boot/common/ns16550.c
Next file: linux/arch/ppc/boot/common/ofcommon.c
Previous file: linux/arch/ppc/boot/common/misc-simple.c
Back to the patch index
Back to the overall index
- Lines: 115
- Date:
Tue Aug 28 06:58:33 2001
- Orig file:
v2.4.9/linux/arch/ppc/boot/common/ns16550.c
- Orig date:
Thu May 24 15:02:06 2001
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/common/ns16550.c linux/arch/ppc/boot/common/ns16550.c
@@ -1,5 +1,5 @@
/*
- * BK Id: SCCS/s.ns16550.c 1.7 05/18/01 06:20:29 patch
+ * BK Id: SCCS/s.ns16550.c 1.9 07/30/01 17:19:40 trini
*/
/*
* COM1 NS16550 support
@@ -10,12 +10,9 @@
#include <linux/serial_reg.h>
#include <asm/serial.h>
-/* Some machines, such as ones with a PReP memory map, initally have
- * their serial port at an offset of 0x80000000 from where they are
- * in <asm/serial.h>. This tries to take that into account. */
-#ifndef IOOFFSET
-#define IOOFFSET 0
-#endif
+extern void outb(int port, unsigned char val);
+extern unsigned char inb(int port);
+extern unsigned long ISA_io;
static struct serial_state rs_table[RS_TABLE_SIZE] = {
SERIAL_PORT_DFNS /* Defined in <asm/serial.h> */
@@ -23,58 +20,67 @@
static int shift;
-volatile unsigned long serial_init(int chan) {
+unsigned long serial_init(int chan) {
unsigned long com_port;
- /* Get the base, and add any offset we need to deal with. */
- com_port = rs_table[chan].port + IOOFFSET;
+ /* We need to find out which type io we're expecting. If it's
+ * 'SERIAL_IO_PORT', we get an offset from the isa_io_base.
+ * If it's 'SERIAL_IO_MEM', we can the exact location. -- Tom */
+ switch (rs_table[chan].io_type) {
+ case SERIAL_IO_PORT:
+ com_port = rs_table[chan].port;
+ break;
+ case SERIAL_IO_MEM:
+ com_port = (unsigned long)rs_table[chan].iomem_base;
+ break;
+ default:
+ /* We can't deal with it. */
+ return -1;
+ }
/* How far apart the registers are. */
shift = rs_table[chan].iomem_reg_shift;
/* See if port is present */
- *((unsigned char *)com_port + (UART_LCR << shift)) = 0x00;
- *((unsigned char *)com_port + (UART_IER << shift)) = 0x00;
+ outb(com_port + (UART_LCR << shift), 0x00);
+ outb(com_port + (UART_IER << shift), 0x00);
/* Access baud rate */
- *((unsigned char *)com_port + (UART_LCR << shift)) = 0x00;
+ outb(com_port + (UART_LCR << shift), 0x80);
#ifdef CONFIG_SERIAL_CONSOLE_NONSTD
/* Input clock. */
- *((unsigned char *)com_port + (UART_DLL << shift)) =
- (BASE_BAUD / CONFIG_SERIAL_CONSOLE_BAUD);
- *((unsigned char *)com_port + (UART_DLM << shift)) =
- (BASE_BAUD / CONFIG_SERIAL_CONSOLE_BAUD) >> 8;
+ outb(com_port + (UART_DLL << shift),
+ (BASE_BAUD / CONFIG_SERIAL_CONSOLE_BAUD));
+ outb(com_port + (UART_DLM << shift),
+ (BASE_BAUD / CONFIG_SERIAL_CONSOLE_BAUD) >> 8);
#endif
/* 8 data, 1 stop, no parity */
- *((unsigned char *)com_port + (UART_LCR << shift)) = 0x03;
+ outb(com_port + (UART_LCR << shift), 0x03);
/* RTS/DTR */
- *((unsigned char *)com_port + (UART_MCR << shift)) = 0x03;
+ outb(com_port + (UART_MCR << shift), 0x03);
/* Clear & enable FIFOs */
- *((unsigned char *)com_port + (UART_FCR << shift)) = 0x07;
+ outb(com_port + (UART_FCR << shift), 0x07);
return (com_port);
}
void
-serial_putc(volatile unsigned long com_port, unsigned char c)
+serial_putc(unsigned long com_port, unsigned char c)
{
- while ((*((volatile unsigned char *)com_port + (UART_LSR << shift)) &
- UART_LSR_THRE) == 0)
+ while ((inb(com_port + (UART_LSR << shift)) & UART_LSR_THRE) == 0)
;
- *(volatile unsigned char *)com_port = c;
+ outb(com_port, c);
}
unsigned char
-serial_getc(volatile unsigned long com_port)
+serial_getc(unsigned long com_port)
{
- while ((*((volatile unsigned char *)com_port + (UART_LSR << shift))
- & UART_LSR_DR) == 0)
+ while ((inb(com_port + (UART_LSR << shift)) & UART_LSR_DR) == 0)
;
- return (*(volatile unsigned char *)com_port);
+ return inb(com_port);
}
int
-serial_tstc(volatile unsigned long com_port)
+serial_tstc(unsigned long com_port)
{
- return ((*((volatile unsigned char *)com_port + (UART_LSR << shift))
- & UART_LSR_DR) != 0);
+ return ((inb(com_port + (UART_LSR << shift)) & UART_LSR_DR) != 0);
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)