drop one more version of doing serial uart output differently.
[coreboot.git] / src / console / uart8250_console.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2003 Eric Biederman
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19
20 #include <console/console.h>
21 #include <uart8250.h>
22 #include <pc80/mc146818rtc.h>
23
24 static void ttyS0_init(void)
25 {
26         static const unsigned char div[8] = { 1, 2, 3, 6, 12, 24, 48, 96 };
27         int b_index = 0;
28         unsigned int divisor = CONFIG_TTYS0_DIV;
29
30         if (get_option(&b_index, "baud_rate") == 0) {
31                 divisor = div[b_index];
32         }
33         uart8250_init(CONFIG_TTYS0_BASE, divisor);
34 }
35
36 static void ttyS0_tx_byte(unsigned char data)
37 {
38         uart8250_tx_byte(CONFIG_TTYS0_BASE, data);
39 }
40
41 static unsigned char ttyS0_rx_byte(void)
42 {
43         return uart8250_rx_byte(CONFIG_TTYS0_BASE);
44 }
45
46 static int ttyS0_tst_byte(void)
47 {
48         return uart8250_can_rx_byte(CONFIG_TTYS0_BASE);
49 }
50
51 static const struct console_driver uart8250_console __console = {
52         .init     = ttyS0_init,
53         .tx_byte  = ttyS0_tx_byte,
54         .rx_byte  = ttyS0_rx_byte,
55         .tst_byte = ttyS0_tst_byte,
56 };