- Initial checkin of the freebios2 tree
[coreboot.git] / src / console / uart8250_console.c
1 #include <console/console.h>
2 #include <uart8250.h>
3 #include <pc80/mc146818rtc.h>
4
5 /* Base Address */
6 #ifndef TTYS0_BASE
7 #define TTYS0_BASE 0x3f8
8 #endif
9
10 #ifndef TTYS0_BAUD
11 #define TTYS0_BAUD 115200
12 #endif
13
14 #if ((115200%TTYS0_BAUD) != 0)
15 #error Bad ttys0 baud rate
16 #endif
17
18 #define TTYS0_DIV       (115200/TTYS0_BAUD)
19
20 /* Line Control Settings */
21 #ifndef TTYS0_LCS
22 /* Set 8bit, 1 stop bit, no parity */
23 #define TTYS0_LCS       0x3
24 #endif
25
26 #define UART_LCS        TTYS0_LCS
27
28 void ttyS0_init(void)
29 {
30         static unsigned char div[8]={1,2,3,6,12,24,48,96};
31         int b_index=0;
32         unsigned int divisor=TTYS0_DIV;
33
34         if(get_option(&b_index,"baud_rate")==0) {
35                 divisor=div[b_index];
36         }
37         uart8250_init(TTYS0_BASE, divisor, TTYS0_LCS);
38 }
39
40 void ttyS0_tx_byte(unsigned char data) 
41 {
42         uart8250_tx_byte(TTYS0_BASE, data);
43 }
44
45 static struct console_driver uart8250_console __console = {
46         .init    = ttyS0_init,
47         .tx_byte = ttyS0_tx_byte,
48 };
49