Stefan Reinauer | 509f772 | 2012-12-07 17:31:37 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2012 The ChromiumOS Authors. All rights reserved. |
| 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 |
Stefan Reinauer | 509f772 | 2012-12-07 17:31:37 -0800 | [diff] [blame] | 18 | */ |
| 19 | |
Kyösti Mälkki | 1d7541f | 2014-02-17 21:34:42 +0200 | [diff] [blame] | 20 | #ifndef CONSOLE_UART_H |
| 21 | #define CONSOLE_UART_H |
Stefan Reinauer | 509f772 | 2012-12-07 17:31:37 -0800 | [diff] [blame] | 22 | |
Kyösti Mälkki | 0567c91 | 2014-02-14 10:31:38 +0200 | [diff] [blame] | 23 | #include <stdint.h> |
| 24 | |
Kyösti Mälkki | 3ee1668 | 2014-02-17 19:37:52 +0200 | [diff] [blame] | 25 | /* Return the clock frequency UART uses as reference clock for |
| 26 | * baudrate generator. */ |
| 27 | unsigned int uart_platform_refclk(void); |
| 28 | |
| 29 | /* Return the baudrate determined from option_table, or when that is |
| 30 | * not used, CONFIG_TTYS0_BAUD. |
| 31 | */ |
| 32 | unsigned int default_baudrate(void); |
| 33 | |
| 34 | /* Returns the divisor value for a given baudrate. |
| 35 | * The formula to satisfy is: |
| 36 | * refclk / divisor = baudrate * oversample |
| 37 | */ |
| 38 | unsigned int uart_baudrate_divisor(unsigned int baudrate, |
| 39 | unsigned int refclk, unsigned int oversample); |
| 40 | |
| 41 | |
Kyösti Mälkki | 4770749 | 2014-02-15 07:53:18 +0200 | [diff] [blame] | 42 | void uart_init(void); |
Stefan Reinauer | 509f772 | 2012-12-07 17:31:37 -0800 | [diff] [blame] | 43 | void uart_tx_byte(unsigned char data); |
| 44 | void uart_tx_flush(void); |
Kyösti Mälkki | 4770749 | 2014-02-15 07:53:18 +0200 | [diff] [blame] | 45 | unsigned char uart_rx_byte(void); |
| 46 | int uart_can_rx_byte(void); |
Stefan Reinauer | 509f772 | 2012-12-07 17:31:37 -0800 | [diff] [blame] | 47 | |
Kyösti Mälkki | 2b95da0 | 2014-02-15 10:19:23 +0200 | [diff] [blame] | 48 | unsigned int uart_platform_base(int idx); |
David Hendricks | fdcef1a | 2013-02-15 19:29:12 -0800 | [diff] [blame] | 49 | uint32_t uartmem_getbaseaddr(void); |
David Hendricks | fdcef1a | 2013-02-15 19:29:12 -0800 | [diff] [blame] | 50 | |
Kyösti Mälkki | c2610a4 | 2014-02-24 20:51:30 +0200 | [diff] [blame^] | 51 | #if !defined(__ROMCC__) |
| 52 | static inline void *uart_platform_baseptr(int idx) |
| 53 | { |
| 54 | return (void *)uart_platform_base(idx); |
| 55 | } |
| 56 | #endif |
| 57 | |
Kyösti Mälkki | 1d7541f | 2014-02-17 21:34:42 +0200 | [diff] [blame] | 58 | void oxford_init(void); |
Kyösti Mälkki | 2b95da0 | 2014-02-15 10:19:23 +0200 | [diff] [blame] | 59 | void oxford_remap(unsigned int new_base); |
Kyösti Mälkki | 1d7541f | 2014-02-17 21:34:42 +0200 | [diff] [blame] | 60 | |
| 61 | #endif /* CONSOLE_UART_H */ |