| 1 |
|
| 2 |
|
| 3 |
#ifndef CONSOLE_UART_H |
| 4 |
#define CONSOLE_UART_H |
| 5 |
|
| 6 |
#include <stdint.h> |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
unsigned int uart_platform_refclk(void); |
| 11 |
|
| 12 |
#if CONFIG(UART_OVERRIDE_BAUDRATE) |
| 13 |
|
| 14 |
|
| 15 |
unsigned int get_uart_baudrate(void); |
| 16 |
#else |
| 17 |
static inline unsigned int get_uart_baudrate(void) |
| 18 |
{ |
| 19 |
return CONFIG_TTYS0_BAUD; |
| 20 |
} |
| 21 |
#endif |
| 22 |
|
| 23 |
#if CONFIG(OVERRIDE_UART_FOR_CONSOLE) |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
unsigned int get_uart_for_console(void); |
| 28 |
#else |
| 29 |
static inline unsigned int get_uart_for_console(void) |
| 30 |
{ |
| 31 |
return CONFIG_UART_FOR_CONSOLE; |
| 32 |
} |
| 33 |
#endif |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
unsigned int uart_baudrate_divisor(unsigned int baudrate, |
| 40 |
unsigned int refclk, unsigned int oversample); |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
unsigned int uart_input_clock_divider(void); |
| 46 |
|
| 47 |
|
| 48 |
void uart_bitbang_tx_byte(unsigned char data, void (*set_tx)(int line_state)); |
| 49 |
|
| 50 |
void uart_init(unsigned int idx); |
| 51 |
void uart_tx_byte(unsigned int idx, unsigned char data); |
| 52 |
void uart_tx_flush(unsigned int idx); |
| 53 |
unsigned char uart_rx_byte(unsigned int idx); |
| 54 |
|
| 55 |
uintptr_t uart_platform_base(unsigned int idx); |
| 56 |
|
| 57 |
static inline void *uart_platform_baseptr(unsigned int idx) |
| 58 |
{ |
| 59 |
return (void *)uart_platform_base(idx); |
| 60 |
} |
| 61 |
|
| 62 |
void oxford_remap(unsigned int new_base); |
| 63 |
|
| 64 |
#define __CONSOLE_SERIAL_ENABLE__ (CONFIG(CONSOLE_SERIAL) && \ |
| 65 |
(ENV_BOOTBLOCK || ENV_SEPARATE_ROMSTAGE || ENV_RAMSTAGE || ENV_SEPARATE_VERSTAGE \ |
| 66 |
|| ENV_POSTCAR || (ENV_SMM && CONFIG(DEBUG_SMI)))) |
| 67 |
|
| 68 |
#if __CONSOLE_SERIAL_ENABLE__ |
| 69 |
static inline void __uart_init(void) |
| 70 |
{ |
| 71 |
uart_init(get_uart_for_console()); |
| 72 |
} |
| 73 |
static inline void __uart_tx_byte(u8 data) |
| 74 |
{ |
| 75 |
uart_tx_byte(get_uart_for_console(), data); |
| 76 |
} |
| 77 |
static inline void __uart_tx_flush(void) |
| 78 |
{ |
| 79 |
uart_tx_flush(get_uart_for_console()); |
| 80 |
} |
| 81 |
#else |
| 82 |
static inline void __uart_init(void) {} |
| 83 |
static inline void __uart_tx_byte(u8 data) {} |
| 84 |
static inline void __uart_tx_flush(void) {} |
| 85 |
#endif |
| 86 |
|
| 87 |
#if CONFIG(GDB_STUB) && (ENV_ROMSTAGE_OR_BEFORE || ENV_RAMSTAGE) |
| 88 |
#define CONF_UART_FOR_GDB CONFIG_UART_FOR_CONSOLE |
| 89 |
static inline void __gdb_hw_init(void) { uart_init(CONF_UART_FOR_GDB); } |
| 90 |
static inline void __gdb_tx_byte(u8 data) |
| 91 |
{ |
| 92 |
uart_tx_byte(CONF_UART_FOR_GDB, data); |
| 93 |
} |
| 94 |
static inline void __gdb_tx_flush(void) { uart_tx_flush(CONF_UART_FOR_GDB); } |
| 95 |
static inline u8 __gdb_rx_byte(void) |
| 96 |
{ |
| 97 |
return uart_rx_byte(CONF_UART_FOR_GDB); |
| 98 |
} |
| 99 |
#endif |
| 100 |
|
| 101 |
#endif |