tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / include / console / uart.h
blob7da0e87ea9f60386f36aff46f7f5cfede782885d
1 /*
2 * This file is part of the coreboot project.
4 * Copyright (C) 2012 The ChromiumOS Authors. All rights reserved.
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.
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.
16 #ifndef CONSOLE_UART_H
17 #define CONSOLE_UART_H
19 #include <rules.h>
20 #include <stdint.h>
22 /* Return the clock frequency UART uses as reference clock for
23 * baudrate generator. */
24 unsigned int uart_platform_refclk(void);
26 /* Return the baudrate determined from option_table, or when that is
27 * not used, CONFIG_TTYS0_BAUD.
29 unsigned int default_baudrate(void);
31 /* Returns the divisor value for a given baudrate.
32 * The formula to satisfy is:
33 * refclk / divisor = baudrate * oversample
35 unsigned int uart_baudrate_divisor(unsigned int baudrate,
36 unsigned int refclk, unsigned int oversample);
39 void uart_init(int idx);
40 void uart_tx_byte(int idx, unsigned char data);
41 void uart_tx_flush(int idx);
42 unsigned char uart_rx_byte(int idx);
44 uintptr_t uart_platform_base(int idx);
46 #if !defined(__ROMCC__)
47 static inline void *uart_platform_baseptr(int idx)
49 return (void *)uart_platform_base(idx);
52 void oxford_remap(unsigned int new_base);
54 #define __CONSOLE_SERIAL_ENABLE__ CONFIG_CONSOLE_SERIAL && \
55 (ENV_BOOTBLOCK || ENV_ROMSTAGE || ENV_RAMSTAGE || ENV_VERSTAGE || \
56 ENV_SECMON || (ENV_SMM && CONFIG_DEBUG_SMI))
58 #if __CONSOLE_SERIAL_ENABLE__
59 static inline void __uart_init(void) { uart_init(CONFIG_UART_FOR_CONSOLE); }
60 static inline void __uart_tx_byte(u8 data) { uart_tx_byte(CONFIG_UART_FOR_CONSOLE, data); }
61 static inline void __uart_tx_flush(void) { uart_tx_flush(CONFIG_UART_FOR_CONSOLE); }
62 #else
63 static inline void __uart_init(void) {}
64 static inline void __uart_tx_byte(u8 data) {}
65 static inline void __uart_tx_flush(void) {}
66 #endif
68 #if CONFIG_GDB_STUB && (ENV_ROMSTAGE || ENV_RAMSTAGE)
69 #define CONFIG_UART_FOR_GDB CONFIG_UART_FOR_CONSOLE
70 static inline void __gdb_hw_init(void) { uart_init(CONFIG_UART_FOR_GDB); }
71 static inline void __gdb_tx_byte(u8 data) { uart_tx_byte(CONFIG_UART_FOR_GDB, data); }
72 static inline void __gdb_tx_flush(void) { uart_tx_flush(CONFIG_UART_FOR_GDB); }
73 static inline u8 __gdb_rx_byte(void) { return uart_rx_byte(CONFIG_UART_FOR_GDB); }
74 #endif
76 #endif /* __ROMCC__ */
78 #endif /* CONSOLE_UART_H */