blob: f37f120f821b39f1372ff776c1be42bbec4b3123 [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>
Edward O'Callaghan0ddb8262014-06-17 18:37:08 +10004#include <console/ne2k.h>
5#include <console/qemu_debugcon.h>
6#include <console/spkmodem.h>
7#include <console/streams.h>
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +02008#include <console/uart.h>
9#include <console/usb.h>
Martin Roth3a543182015-09-28 15:27:24 -060010#include <console/spi.h>
Youness Alaouic4b4ff32017-05-11 10:36:29 -040011#include <console/flash.h>
Jeremy Soller52785ab2020-07-22 06:40:28 -060012#include <console/system76_ec.h>
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +020013
Julius Werner266041f2022-02-03 17:25:44 -080014/* Note: when adding a new console, make sure you update the definition of
15 HAS_ONLY_FAST_CONSOLES in <console.h>! */
Kyösti Mälkki21333f92014-02-14 10:04:31 +020016void console_hw_init(void)
Stefan Reinauer5a1f5972010-03-31 14:34:40 +000017{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020018 __cbmemc_init();
19 __spkmodem_init();
20 __qemu_debugcon_init();
21
22 __uart_init();
23 __ne2k_init();
24 __usbdebug_init();
Martin Roth3a543182015-09-28 15:27:24 -060025 __spiconsole_init();
Youness Alaouic4b4ff32017-05-11 10:36:29 -040026 __flashconsole_init();
Jeremy Soller52785ab2020-07-22 06:40:28 -060027 __system76_ec_init();
Stefan Reinauer5a1f5972010-03-31 14:34:40 +000028}
Kyösti Mälkkifd956242014-02-03 17:04:22 +020029
Julius Werner7cd8ba62022-01-21 15:15:29 -080030void console_interactive_tx_byte(unsigned char byte, void *data_unused)
Kyösti Mälkkifd956242014-02-03 17:04:22 +020031{
Kyösti Mälkkid4a72f72015-05-13 20:20:00 +030032 if (byte == '\n') {
Julius Werner7cd8ba62022-01-21 15:15:29 -080033 /* Some consoles want newline conversion to keep terminals happy. */
Kyösti Mälkkid4a72f72015-05-13 20:20:00 +030034 __uart_tx_byte('\r');
35 __usb_tx_byte('\r');
36 }
37
Julius Werner7cd8ba62022-01-21 15:15:29 -080038 __spkmodem_tx_byte(byte);
39 __qemu_debugcon_tx_byte(byte);
Kyösti Mälkkif3390862014-02-26 15:19:04 +020040 __uart_tx_byte(byte);
41 __ne2k_tx_byte(byte);
42 __usb_tx_byte(byte);
Martin Roth3a543182015-09-28 15:27:24 -060043 __spiconsole_tx_byte(byte);
Jeremy Soller52785ab2020-07-22 06:40:28 -060044 __system76_ec_tx_byte(byte);
Kyösti Mälkkifd956242014-02-03 17:04:22 +020045}
46
Julius Werner7cd8ba62022-01-21 15:15:29 -080047void console_stored_tx_byte(unsigned char byte, void *data_unused)
48{
49 __flashconsole_tx_byte(byte);
50 __cbmemc_tx_byte(byte);
51}
52
53void console_tx_byte(unsigned char byte)
54{
55 console_interactive_tx_byte(byte, NULL);
56 console_stored_tx_byte(byte, NULL);
57}
58
Kyösti Mälkkifd956242014-02-03 17:04:22 +020059void console_tx_flush(void)
60{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020061 __uart_tx_flush();
62 __ne2k_tx_flush();
63 __usb_tx_flush();
Youness Alaouic4b4ff32017-05-11 10:36:29 -040064 __flashconsole_tx_flush();
Jeremy Soller52785ab2020-07-22 06:40:28 -060065 __system76_ec_tx_flush();
Kyösti Mälkki40760722014-02-27 19:30:18 +020066}
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030067
Lee Leahy219c3322016-08-09 08:59:30 -070068void console_write_line(uint8_t *buffer, size_t number_of_bytes)
69{
70 /* Finish displaying all of the console data if requested */
71 if (number_of_bytes == 0) {
72 console_tx_flush();
73 return;
74 }
75
76 /* Output the console data */
77 while (number_of_bytes--)
78 console_tx_byte(*buffer++);
79}
80
Julius Wernercd49cce2019-03-05 16:53:33 -080081#if CONFIG(GDB_STUB) && (ENV_ROMSTAGE || ENV_RAMSTAGE)
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030082void gdb_hw_init(void)
83{
84 __gdb_hw_init();
85}
86
87void gdb_tx_byte(unsigned char byte)
88{
89 __gdb_tx_byte(byte);
90}
91
92void gdb_tx_flush(void)
93{
94 __gdb_tx_flush();
95}
96
97unsigned char gdb_rx_byte(void)
98{
99 return __gdb_rx_byte();
100}
101#endif