blob: 67da10794e95ac01f198aa7428866e54b5b29fbe [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
Kyösti Mälkki21333f92014-02-14 10:04:31 +020014void console_hw_init(void)
Stefan Reinauer5a1f5972010-03-31 14:34:40 +000015{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020016 __cbmemc_init();
17 __spkmodem_init();
18 __qemu_debugcon_init();
19
20 __uart_init();
21 __ne2k_init();
22 __usbdebug_init();
Martin Roth3a543182015-09-28 15:27:24 -060023 __spiconsole_init();
Youness Alaouic4b4ff32017-05-11 10:36:29 -040024 __flashconsole_init();
Jeremy Soller52785ab2020-07-22 06:40:28 -060025 __system76_ec_init();
Stefan Reinauer5a1f5972010-03-31 14:34:40 +000026}
Kyösti Mälkkifd956242014-02-03 17:04:22 +020027
Kyösti Mälkkifd956242014-02-03 17:04:22 +020028void console_tx_byte(unsigned char byte)
29{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020030 __cbmemc_tx_byte(byte);
31 __spkmodem_tx_byte(byte);
32 __qemu_debugcon_tx_byte(byte);
33
Kyösti Mälkkid4a72f72015-05-13 20:20:00 +030034 /* Some consoles want newline conversion
35 * to keep terminals happy.
36 */
37 if (byte == '\n') {
38 __uart_tx_byte('\r');
39 __usb_tx_byte('\r');
40 }
41
Kyösti Mälkkif3390862014-02-26 15:19:04 +020042 __uart_tx_byte(byte);
43 __ne2k_tx_byte(byte);
44 __usb_tx_byte(byte);
Martin Roth3a543182015-09-28 15:27:24 -060045 __spiconsole_tx_byte(byte);
Youness Alaouic4b4ff32017-05-11 10:36:29 -040046 __flashconsole_tx_byte(byte);
Jeremy Soller52785ab2020-07-22 06:40:28 -060047 __system76_ec_tx_byte(byte);
Kyösti Mälkkifd956242014-02-03 17:04:22 +020048}
49
50void console_tx_flush(void)
51{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020052 __uart_tx_flush();
53 __ne2k_tx_flush();
54 __usb_tx_flush();
Youness Alaouic4b4ff32017-05-11 10:36:29 -040055 __flashconsole_tx_flush();
Jeremy Soller52785ab2020-07-22 06:40:28 -060056 __system76_ec_tx_flush();
Kyösti Mälkki40760722014-02-27 19:30:18 +020057}
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030058
Lee Leahy219c3322016-08-09 08:59:30 -070059void console_write_line(uint8_t *buffer, size_t number_of_bytes)
60{
61 /* Finish displaying all of the console data if requested */
62 if (number_of_bytes == 0) {
63 console_tx_flush();
64 return;
65 }
66
67 /* Output the console data */
68 while (number_of_bytes--)
69 console_tx_byte(*buffer++);
70}
71
Julius Wernercd49cce2019-03-05 16:53:33 -080072#if CONFIG(GDB_STUB) && (ENV_ROMSTAGE || ENV_RAMSTAGE)
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030073void gdb_hw_init(void)
74{
75 __gdb_hw_init();
76}
77
78void gdb_tx_byte(unsigned char byte)
79{
80 __gdb_tx_byte(byte);
81}
82
83void gdb_tx_flush(void)
84{
85 __gdb_tx_flush();
86}
87
88unsigned char gdb_rx_byte(void)
89{
90 return __gdb_rx_byte();
91}
92#endif