blob: bb9d3747d3515a0f83c4762c5daec22bd8ea6870 [file] [log] [blame]
Angel Ponsb706ab32020-04-02 23:48:09 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Eric Biederman8ca8d762003-04-22 19:02:15 +00002
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +02003#include <console/cbmem_console.h>
Elyes Haouasa1f245c2022-10-02 12:22:54 +02004#include <console/flash.h>
5#include <console/i2c_smbus.h>
Edward O'Callaghan0ddb8262014-06-17 18:37:08 +10006#include <console/ne2k.h>
7#include <console/qemu_debugcon.h>
Fred Reitbergera02176d2023-02-01 16:00:54 -05008#include <console/simnow.h>
Elyes Haouasa1f245c2022-10-02 12:22:54 +02009#include <console/spi.h>
Edward O'Callaghan0ddb8262014-06-17 18:37:08 +100010#include <console/spkmodem.h>
11#include <console/streams.h>
Elyes Haouasa1f245c2022-10-02 12:22:54 +020012#include <console/system76_ec.h>
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +020013#include <console/uart.h>
14#include <console/usb.h>
Elyes Haouasa1f245c2022-10-02 12:22:54 +020015#include <types.h>
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +020016
Julius Werner266041f2022-02-03 17:25:44 -080017/* Note: when adding a new console, make sure you update the definition of
18 HAS_ONLY_FAST_CONSOLES in <console.h>! */
Kyösti Mälkki21333f92014-02-14 10:04:31 +020019void console_hw_init(void)
Stefan Reinauer5a1f5972010-03-31 14:34:40 +000020{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020021 __cbmemc_init();
22 __spkmodem_init();
23 __qemu_debugcon_init();
24
25 __uart_init();
26 __ne2k_init();
27 __usbdebug_init();
Martin Roth3a543182015-09-28 15:27:24 -060028 __spiconsole_init();
Youness Alaouic4b4ff32017-05-11 10:36:29 -040029 __flashconsole_init();
Jeremy Soller52785ab2020-07-22 06:40:28 -060030 __system76_ec_init();
Husni Faizf634aed2022-09-09 17:46:56 +053031 __i2c_smbus_console_init();
Fred Reitbergera02176d2023-02-01 16:00:54 -050032 __simnow_console_init();
Stefan Reinauer5a1f5972010-03-31 14:34:40 +000033}
Kyösti Mälkkifd956242014-02-03 17:04:22 +020034
Julius Werner7cd8ba62022-01-21 15:15:29 -080035void console_interactive_tx_byte(unsigned char byte, void *data_unused)
Kyösti Mälkkifd956242014-02-03 17:04:22 +020036{
Kyösti Mälkkid4a72f72015-05-13 20:20:00 +030037 if (byte == '\n') {
Julius Werner7cd8ba62022-01-21 15:15:29 -080038 /* Some consoles want newline conversion to keep terminals happy. */
Kyösti Mälkkid4a72f72015-05-13 20:20:00 +030039 __uart_tx_byte('\r');
40 __usb_tx_byte('\r');
Husni Faizf634aed2022-09-09 17:46:56 +053041 __i2c_smbus_console_tx_byte('\r');
Kyösti Mälkkid4a72f72015-05-13 20:20:00 +030042 }
43
Julius Werner7cd8ba62022-01-21 15:15:29 -080044 __spkmodem_tx_byte(byte);
45 __qemu_debugcon_tx_byte(byte);
Kyösti Mälkkif3390862014-02-26 15:19:04 +020046 __uart_tx_byte(byte);
47 __ne2k_tx_byte(byte);
48 __usb_tx_byte(byte);
Martin Roth3a543182015-09-28 15:27:24 -060049 __spiconsole_tx_byte(byte);
Jeremy Soller52785ab2020-07-22 06:40:28 -060050 __system76_ec_tx_byte(byte);
Husni Faizf634aed2022-09-09 17:46:56 +053051 __i2c_smbus_console_tx_byte(byte);
Fred Reitbergera02176d2023-02-01 16:00:54 -050052 __simnow_console_tx_byte(byte);
Kyösti Mälkkifd956242014-02-03 17:04:22 +020053}
54
Julius Werner7cd8ba62022-01-21 15:15:29 -080055void console_stored_tx_byte(unsigned char byte, void *data_unused)
56{
57 __flashconsole_tx_byte(byte);
58 __cbmemc_tx_byte(byte);
59}
60
61void console_tx_byte(unsigned char byte)
62{
63 console_interactive_tx_byte(byte, NULL);
64 console_stored_tx_byte(byte, NULL);
65}
66
Kyösti Mälkkifd956242014-02-03 17:04:22 +020067void console_tx_flush(void)
68{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020069 __uart_tx_flush();
70 __ne2k_tx_flush();
71 __usb_tx_flush();
Youness Alaouic4b4ff32017-05-11 10:36:29 -040072 __flashconsole_tx_flush();
Jeremy Soller52785ab2020-07-22 06:40:28 -060073 __system76_ec_tx_flush();
Kyösti Mälkki40760722014-02-27 19:30:18 +020074}
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030075
Lee Leahy219c3322016-08-09 08:59:30 -070076void console_write_line(uint8_t *buffer, size_t number_of_bytes)
77{
78 /* Finish displaying all of the console data if requested */
79 if (number_of_bytes == 0) {
80 console_tx_flush();
81 return;
82 }
83
84 /* Output the console data */
85 while (number_of_bytes--)
86 console_tx_byte(*buffer++);
87}
88
Arthur Heymans2fba4762023-11-06 15:33:23 +010089#if CONFIG(GDB_STUB) && (ENV_ROMSTAGE_OR_BEFORE || ENV_RAMSTAGE)
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030090void gdb_hw_init(void)
91{
92 __gdb_hw_init();
93}
94
95void gdb_tx_byte(unsigned char byte)
96{
97 __gdb_tx_byte(byte);
98}
99
100void gdb_tx_flush(void)
101{
102 __gdb_tx_flush();
103}
104
105unsigned char gdb_rx_byte(void)
106{
107 return __gdb_rx_byte();
108}
109#endif