blob: 499a336efbbbe314fe30a9652fb50deaae27fc64 [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>
Elyes Haouasa1f245c2022-10-02 12:22:54 +02008#include <console/spi.h>
Edward O'Callaghan0ddb8262014-06-17 18:37:08 +10009#include <console/spkmodem.h>
10#include <console/streams.h>
Elyes Haouasa1f245c2022-10-02 12:22:54 +020011#include <console/system76_ec.h>
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +020012#include <console/uart.h>
13#include <console/usb.h>
Elyes Haouasa1f245c2022-10-02 12:22:54 +020014#include <types.h>
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +020015
Julius Werner266041f2022-02-03 17:25:44 -080016/* Note: when adding a new console, make sure you update the definition of
17 HAS_ONLY_FAST_CONSOLES in <console.h>! */
Kyösti Mälkki21333f92014-02-14 10:04:31 +020018void console_hw_init(void)
Stefan Reinauer5a1f5972010-03-31 14:34:40 +000019{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020020 __cbmemc_init();
21 __spkmodem_init();
22 __qemu_debugcon_init();
23
24 __uart_init();
25 __ne2k_init();
26 __usbdebug_init();
Martin Roth3a543182015-09-28 15:27:24 -060027 __spiconsole_init();
Youness Alaouic4b4ff32017-05-11 10:36:29 -040028 __flashconsole_init();
Jeremy Soller52785ab2020-07-22 06:40:28 -060029 __system76_ec_init();
Husni Faizf634aed2022-09-09 17:46:56 +053030 __i2c_smbus_console_init();
Stefan Reinauer5a1f5972010-03-31 14:34:40 +000031}
Kyösti Mälkkifd956242014-02-03 17:04:22 +020032
Julius Werner7cd8ba62022-01-21 15:15:29 -080033void console_interactive_tx_byte(unsigned char byte, void *data_unused)
Kyösti Mälkkifd956242014-02-03 17:04:22 +020034{
Kyösti Mälkkid4a72f72015-05-13 20:20:00 +030035 if (byte == '\n') {
Julius Werner7cd8ba62022-01-21 15:15:29 -080036 /* Some consoles want newline conversion to keep terminals happy. */
Kyösti Mälkkid4a72f72015-05-13 20:20:00 +030037 __uart_tx_byte('\r');
38 __usb_tx_byte('\r');
Husni Faizf634aed2022-09-09 17:46:56 +053039 __i2c_smbus_console_tx_byte('\r');
Kyösti Mälkkid4a72f72015-05-13 20:20:00 +030040 }
41
Julius Werner7cd8ba62022-01-21 15:15:29 -080042 __spkmodem_tx_byte(byte);
43 __qemu_debugcon_tx_byte(byte);
Kyösti Mälkkif3390862014-02-26 15:19:04 +020044 __uart_tx_byte(byte);
45 __ne2k_tx_byte(byte);
46 __usb_tx_byte(byte);
Martin Roth3a543182015-09-28 15:27:24 -060047 __spiconsole_tx_byte(byte);
Jeremy Soller52785ab2020-07-22 06:40:28 -060048 __system76_ec_tx_byte(byte);
Husni Faizf634aed2022-09-09 17:46:56 +053049 __i2c_smbus_console_tx_byte(byte);
Kyösti Mälkkifd956242014-02-03 17:04:22 +020050}
51
Julius Werner7cd8ba62022-01-21 15:15:29 -080052void console_stored_tx_byte(unsigned char byte, void *data_unused)
53{
54 __flashconsole_tx_byte(byte);
55 __cbmemc_tx_byte(byte);
56}
57
58void console_tx_byte(unsigned char byte)
59{
60 console_interactive_tx_byte(byte, NULL);
61 console_stored_tx_byte(byte, NULL);
62}
63
Kyösti Mälkkifd956242014-02-03 17:04:22 +020064void console_tx_flush(void)
65{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020066 __uart_tx_flush();
67 __ne2k_tx_flush();
68 __usb_tx_flush();
Youness Alaouic4b4ff32017-05-11 10:36:29 -040069 __flashconsole_tx_flush();
Jeremy Soller52785ab2020-07-22 06:40:28 -060070 __system76_ec_tx_flush();
Kyösti Mälkki40760722014-02-27 19:30:18 +020071}
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030072
Lee Leahy219c3322016-08-09 08:59:30 -070073void console_write_line(uint8_t *buffer, size_t number_of_bytes)
74{
75 /* Finish displaying all of the console data if requested */
76 if (number_of_bytes == 0) {
77 console_tx_flush();
78 return;
79 }
80
81 /* Output the console data */
82 while (number_of_bytes--)
83 console_tx_byte(*buffer++);
84}
85
Julius Wernercd49cce2019-03-05 16:53:33 -080086#if CONFIG(GDB_STUB) && (ENV_ROMSTAGE || ENV_RAMSTAGE)
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030087void gdb_hw_init(void)
88{
89 __gdb_hw_init();
90}
91
92void gdb_tx_byte(unsigned char byte)
93{
94 __gdb_tx_byte(byte);
95}
96
97void gdb_tx_flush(void)
98{
99 __gdb_tx_flush();
100}
101
102unsigned char gdb_rx_byte(void)
103{
104 return __gdb_rx_byte();
105}
106#endif