5 #include <linux/types.h>
6 #include <linux/serial.h>
7 #include <linux/serial_reg.h>
8 #include <asm/serial.h>
10 #if defined(CONFIG_XILINX_VIRTEX)
11 #include <platforms/4xx/xparameters/xparameters.h>
16 #define SERIAL_BAUD 9600
18 extern unsigned long ISA_io
;
20 static struct serial_state rs_table
[RS_TABLE_SIZE
] = {
21 SERIAL_PORT_DFNS
/* Defined in <asm/serial.h> */
26 unsigned long serial_init(int chan
, void *ignored
)
28 unsigned long com_port
, base_baud
;
29 unsigned char lcr
, dlm
;
31 /* We need to find out which type io we're expecting. If it's
32 * 'SERIAL_IO_PORT', we get an offset from the isa_io_base.
33 * If it's 'SERIAL_IO_MEM', we can the exact location. -- Tom */
34 switch (rs_table
[chan
].io_type
) {
36 com_port
= rs_table
[chan
].port
;
39 com_port
= (unsigned long)rs_table
[chan
].iomem_base
;
42 /* We can't deal with it. */
46 /* How far apart the registers are. */
47 shift
= rs_table
[chan
].iomem_reg_shift
;
49 base_baud
= rs_table
[chan
].baud_base
;
52 lcr
= inb(com_port
+ (UART_LCR
<< shift
));
53 /* Access baud rate */
54 outb(com_port
+ (UART_LCR
<< shift
), 0x80);
55 dlm
= inb(com_port
+ (UART_DLM
<< shift
));
57 * Test if serial port is unconfigured.
58 * We assume that no-one uses less than 110 baud or
59 * less than 7 bits per character these days.
63 if ((dlm
<= 4) && (lcr
& 2))
64 /* port is configured, put the old LCR back */
65 outb(com_port
+ (UART_LCR
<< shift
), lcr
);
68 outb(com_port
+ (UART_DLL
<< shift
),
69 (base_baud
/ SERIAL_BAUD
) & 0xFF);
70 outb(com_port
+ (UART_DLM
<< shift
),
71 (base_baud
/ SERIAL_BAUD
) >> 8);
72 /* 8 data, 1 stop, no parity */
73 outb(com_port
+ (UART_LCR
<< shift
), 0x03);
75 outb(com_port
+ (UART_MCR
<< shift
), 0x03);
77 /* Clear & enable FIFOs */
78 outb(com_port
+ (UART_FCR
<< shift
), 0x07);
84 serial_putc(unsigned long com_port
, unsigned char c
)
86 while ((inb(com_port
+ (UART_LSR
<< shift
)) & UART_LSR_THRE
) == 0)
92 serial_getc(unsigned long com_port
)
94 while ((inb(com_port
+ (UART_LSR
<< shift
)) & UART_LSR_DR
) == 0)
100 serial_tstc(unsigned long com_port
)
102 return ((inb(com_port
+ (UART_LSR
<< shift
)) & UART_LSR_DR
) != 0);