Angel Pons | b706ab3 | 2020-04-02 23:48:09 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 2 | |
Kyösti Mälkki | 1d7541f | 2014-02-17 21:34:42 +0200 | [diff] [blame] | 3 | #include <console/cbmem_console.h> |
Elyes Haouas | a1f245c | 2022-10-02 12:22:54 +0200 | [diff] [blame] | 4 | #include <console/flash.h> |
| 5 | #include <console/i2c_smbus.h> |
Edward O'Callaghan | 0ddb826 | 2014-06-17 18:37:08 +1000 | [diff] [blame] | 6 | #include <console/ne2k.h> |
| 7 | #include <console/qemu_debugcon.h> |
Fred Reitberger | a02176d | 2023-02-01 16:00:54 -0500 | [diff] [blame] | 8 | #include <console/simnow.h> |
Elyes Haouas | a1f245c | 2022-10-02 12:22:54 +0200 | [diff] [blame] | 9 | #include <console/spi.h> |
Edward O'Callaghan | 0ddb826 | 2014-06-17 18:37:08 +1000 | [diff] [blame] | 10 | #include <console/spkmodem.h> |
| 11 | #include <console/streams.h> |
Elyes Haouas | a1f245c | 2022-10-02 12:22:54 +0200 | [diff] [blame] | 12 | #include <console/system76_ec.h> |
Kyösti Mälkki | 1d7541f | 2014-02-17 21:34:42 +0200 | [diff] [blame] | 13 | #include <console/uart.h> |
| 14 | #include <console/usb.h> |
Elyes Haouas | a1f245c | 2022-10-02 12:22:54 +0200 | [diff] [blame] | 15 | #include <types.h> |
Kyösti Mälkki | 1d7541f | 2014-02-17 21:34:42 +0200 | [diff] [blame] | 16 | |
Julius Werner | 266041f | 2022-02-03 17:25:44 -0800 | [diff] [blame] | 17 | /* Note: when adding a new console, make sure you update the definition of |
| 18 | HAS_ONLY_FAST_CONSOLES in <console.h>! */ |
Kyösti Mälkki | 21333f9 | 2014-02-14 10:04:31 +0200 | [diff] [blame] | 19 | void console_hw_init(void) |
Stefan Reinauer | 5a1f597 | 2010-03-31 14:34:40 +0000 | [diff] [blame] | 20 | { |
Kyösti Mälkki | f339086 | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 21 | __cbmemc_init(); |
| 22 | __spkmodem_init(); |
| 23 | __qemu_debugcon_init(); |
| 24 | |
| 25 | __uart_init(); |
| 26 | __ne2k_init(); |
| 27 | __usbdebug_init(); |
Martin Roth | 3a54318 | 2015-09-28 15:27:24 -0600 | [diff] [blame] | 28 | __spiconsole_init(); |
Youness Alaoui | c4b4ff3 | 2017-05-11 10:36:29 -0400 | [diff] [blame] | 29 | __flashconsole_init(); |
Jeremy Soller | 52785ab | 2020-07-22 06:40:28 -0600 | [diff] [blame] | 30 | __system76_ec_init(); |
Husni Faiz | f634aed | 2022-09-09 17:46:56 +0530 | [diff] [blame] | 31 | __i2c_smbus_console_init(); |
Fred Reitberger | a02176d | 2023-02-01 16:00:54 -0500 | [diff] [blame] | 32 | __simnow_console_init(); |
Stefan Reinauer | 5a1f597 | 2010-03-31 14:34:40 +0000 | [diff] [blame] | 33 | } |
Kyösti Mälkki | fd95624 | 2014-02-03 17:04:22 +0200 | [diff] [blame] | 34 | |
Julius Werner | 7cd8ba6 | 2022-01-21 15:15:29 -0800 | [diff] [blame] | 35 | void console_interactive_tx_byte(unsigned char byte, void *data_unused) |
Kyösti Mälkki | fd95624 | 2014-02-03 17:04:22 +0200 | [diff] [blame] | 36 | { |
Kyösti Mälkki | d4a72f7 | 2015-05-13 20:20:00 +0300 | [diff] [blame] | 37 | if (byte == '\n') { |
Julius Werner | 7cd8ba6 | 2022-01-21 15:15:29 -0800 | [diff] [blame] | 38 | /* Some consoles want newline conversion to keep terminals happy. */ |
Kyösti Mälkki | d4a72f7 | 2015-05-13 20:20:00 +0300 | [diff] [blame] | 39 | __uart_tx_byte('\r'); |
| 40 | __usb_tx_byte('\r'); |
Husni Faiz | f634aed | 2022-09-09 17:46:56 +0530 | [diff] [blame] | 41 | __i2c_smbus_console_tx_byte('\r'); |
Kyösti Mälkki | d4a72f7 | 2015-05-13 20:20:00 +0300 | [diff] [blame] | 42 | } |
| 43 | |
Julius Werner | 7cd8ba6 | 2022-01-21 15:15:29 -0800 | [diff] [blame] | 44 | __spkmodem_tx_byte(byte); |
| 45 | __qemu_debugcon_tx_byte(byte); |
Kyösti Mälkki | f339086 | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 46 | __uart_tx_byte(byte); |
| 47 | __ne2k_tx_byte(byte); |
| 48 | __usb_tx_byte(byte); |
Martin Roth | 3a54318 | 2015-09-28 15:27:24 -0600 | [diff] [blame] | 49 | __spiconsole_tx_byte(byte); |
Jeremy Soller | 52785ab | 2020-07-22 06:40:28 -0600 | [diff] [blame] | 50 | __system76_ec_tx_byte(byte); |
Husni Faiz | f634aed | 2022-09-09 17:46:56 +0530 | [diff] [blame] | 51 | __i2c_smbus_console_tx_byte(byte); |
Fred Reitberger | a02176d | 2023-02-01 16:00:54 -0500 | [diff] [blame] | 52 | __simnow_console_tx_byte(byte); |
Kyösti Mälkki | fd95624 | 2014-02-03 17:04:22 +0200 | [diff] [blame] | 53 | } |
| 54 | |
Julius Werner | 7cd8ba6 | 2022-01-21 15:15:29 -0800 | [diff] [blame] | 55 | void console_stored_tx_byte(unsigned char byte, void *data_unused) |
| 56 | { |
| 57 | __flashconsole_tx_byte(byte); |
| 58 | __cbmemc_tx_byte(byte); |
| 59 | } |
| 60 | |
| 61 | void 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älkki | fd95624 | 2014-02-03 17:04:22 +0200 | [diff] [blame] | 67 | void console_tx_flush(void) |
| 68 | { |
Kyösti Mälkki | f339086 | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 69 | __uart_tx_flush(); |
| 70 | __ne2k_tx_flush(); |
| 71 | __usb_tx_flush(); |
Youness Alaoui | c4b4ff3 | 2017-05-11 10:36:29 -0400 | [diff] [blame] | 72 | __flashconsole_tx_flush(); |
Jeremy Soller | 52785ab | 2020-07-22 06:40:28 -0600 | [diff] [blame] | 73 | __system76_ec_tx_flush(); |
Kyösti Mälkki | 4076072 | 2014-02-27 19:30:18 +0200 | [diff] [blame] | 74 | } |
Kyösti Mälkki | f2f7f03 | 2014-04-04 15:05:28 +0300 | [diff] [blame] | 75 | |
Lee Leahy | 219c332 | 2016-08-09 08:59:30 -0700 | [diff] [blame] | 76 | void 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 Heymans | 2fba476 | 2023-11-06 15:33:23 +0100 | [diff] [blame] | 89 | #if CONFIG(GDB_STUB) && (ENV_ROMSTAGE_OR_BEFORE || ENV_RAMSTAGE) |
Kyösti Mälkki | f2f7f03 | 2014-04-04 15:05:28 +0300 | [diff] [blame] | 90 | void gdb_hw_init(void) |
| 91 | { |
| 92 | __gdb_hw_init(); |
| 93 | } |
| 94 | |
| 95 | void gdb_tx_byte(unsigned char byte) |
| 96 | { |
| 97 | __gdb_tx_byte(byte); |
| 98 | } |
| 99 | |
| 100 | void gdb_tx_flush(void) |
| 101 | { |
| 102 | __gdb_tx_flush(); |
| 103 | } |
| 104 | |
| 105 | unsigned char gdb_rx_byte(void) |
| 106 | { |
| 107 | return __gdb_rx_byte(); |
| 108 | } |
| 109 | #endif |