Stefan Reinauer | 85b0fa1 | 2010-12-17 00:08:21 +0000 | [diff] [blame] | 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 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 20 | #include <console/console.h> |
| 21 | #include <uart8250.h> |
| 22 | #include <pc80/mc146818rtc.h> |
| 23 | |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 24 | static void ttyS0_init(void) |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 25 | { |
Stefan Reinauer | f349d55 | 2011-04-22 02:17:26 +0000 | [diff] [blame] | 26 | uart_init(); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 27 | } |
| 28 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 29 | static void ttyS0_tx_byte(unsigned char data) |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 30 | { |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 31 | uart8250_tx_byte(CONFIG_TTYS0_BASE, data); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 32 | } |
| 33 | |
Kevin O'Connor | a68555f | 2011-07-09 20:22:21 -0400 | [diff] [blame] | 34 | static void ttyS0_tx_flush(void) |
| 35 | { |
| 36 | uart8250_tx_flush(CONFIG_TTYS0_BASE); |
| 37 | } |
| 38 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 39 | static unsigned char ttyS0_rx_byte(void) |
Greg Watson | e54d55b | 2004-03-13 03:40:51 +0000 | [diff] [blame] | 40 | { |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 41 | return uart8250_rx_byte(CONFIG_TTYS0_BASE); |
Greg Watson | e54d55b | 2004-03-13 03:40:51 +0000 | [diff] [blame] | 42 | } |
| 43 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 44 | static int ttyS0_tst_byte(void) |
Greg Watson | e54d55b | 2004-03-13 03:40:51 +0000 | [diff] [blame] | 45 | { |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 46 | return uart8250_can_rx_byte(CONFIG_TTYS0_BASE); |
Greg Watson | e54d55b | 2004-03-13 03:40:51 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Stefan Reinauer | bf873e4 | 2007-10-24 14:42:12 +0000 | [diff] [blame] | 49 | static const struct console_driver uart8250_console __console = { |
Stefan Reinauer | 85b0fa1 | 2010-12-17 00:08:21 +0000 | [diff] [blame] | 50 | .init = ttyS0_init, |
| 51 | .tx_byte = ttyS0_tx_byte, |
Kevin O'Connor | a68555f | 2011-07-09 20:22:21 -0400 | [diff] [blame] | 52 | .tx_flush = ttyS0_tx_flush, |
Stefan Reinauer | 85b0fa1 | 2010-12-17 00:08:21 +0000 | [diff] [blame] | 53 | .rx_byte = ttyS0_rx_byte, |
Greg Watson | e54d55b | 2004-03-13 03:40:51 +0000 | [diff] [blame] | 54 | .tst_byte = ttyS0_tst_byte, |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 55 | }; |