2 * This file is part of the coreboot project.
4 * Copyright (C) 2008-2009 coresystems GmbH
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
23 #include <arch/romcc_io.h>
24 #include <console/console.h>
25 #include <cpu/x86/cache.h>
26 #include <cpu/x86/smm.h>
28 /* ********************* smi_util ************************* */
48 #ifndef CONFIG_TTYS0_BASE
49 #define CONFIG_TTYS0_BASE 0x3f8
52 #ifndef CONFIG_TTYS0_BAUD
53 #define CONFIG_TTYS0_BAUD 115200
56 #ifndef CONFIG_TTYS0_DIV
57 #define CONFIG_TTYS0_DIV (115200/CONFIG_TTYS0_BAUD)
60 /* Line Control Settings */
61 #ifndef CONFIG_TTYS0_LCS
62 /* Set 8bit, 1 stop bit, no parity */
63 #define CONFIG_TTYS0_LCS 0x3
66 #define UART_LCS CONFIG_TTYS0_LCS
68 static int uart_can_tx_byte(void)
70 return inb(CONFIG_TTYS0_BASE + UART_LSR) & 0x20;
73 static void uart_wait_to_tx_byte(void)
75 while(!uart_can_tx_byte())
79 static void uart_wait_until_sent(void)
81 while(!(inb(CONFIG_TTYS0_BASE + UART_LSR) & 0x40))
85 static void uart_tx_byte(unsigned char data)
87 uart_wait_to_tx_byte();
88 outb(data, CONFIG_TTYS0_BASE + UART_TBR);
89 /* Make certain the data clears the fifos */
90 uart_wait_until_sent();
93 void console_tx_flush(void)
95 uart_wait_to_tx_byte();
98 void console_tx_byte(unsigned char byte)
106 static void uart_init(void)
108 /* disable interrupts */
109 outb(0x0, CONFIG_TTYS0_BASE + UART_IER);
111 outb(0x01, CONFIG_TTYS0_BASE + UART_FCR);
112 /* Set Baud Rate Divisor to 12 ==> 115200 Baud */
113 outb(0x80 | UART_LCS, CONFIG_TTYS0_BASE + UART_LCR);
114 outb(CONFIG_TTYS0_DIV & 0xFF, CONFIG_TTYS0_BASE + UART_DLL);
115 outb((CONFIG_TTYS0_DIV >> 8) & 0xFF, CONFIG_TTYS0_BASE + UART_DLM);
116 outb(UART_LCS, CONFIG_TTYS0_BASE + UART_LCR);
120 void console_init(void)
123 console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
126 console_loglevel = 1;
130 /* ********************* smi_util ************************* */