diff options
author | Julius Werner <jwerner@chromium.org> | 2018-04-24 16:33:58 -0700 |
---|---|---|
committer | Julius Werner <jwerner@chromium.org> | 2018-04-26 01:19:13 +0000 |
commit | 1732dcb90ce7e3863c7be28ec9275dd98d4faded (patch) | |
tree | e410bb46370608dace1a14631c7cae3e8a6d76af /src/include/console | |
parent | a695a736b4b8a9549e3384b4ec66b148f547d16c (diff) |
drivers/uart: Add helper function to allow bit-banging
In some cases it may be useful to be able to bitbang a UART, such as
during early bring-up when a driver for the actual controller isn't
available yet. On some platforms we may even want to use this
permanently, such as on the SDM845 where the hardware UART controller
needs to have firmware loaded and is thus unavailable for most of the
bootblock.
This patch adds some helper code that makes it easy to implement this on
a platform, you just have to pass it a function to control the Tx pin
state and it will do the rest. It relies on the mono_time API and is
thus bound to microsecond timing granularity, but that seems to be
barely good enough for 115200 baud if the bit times are calculated
carefully.
Change-Id: If7dcecc7b8a95ec15f456efd2ec1f1e0dde239b4
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/25812
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/include/console')
-rw-r--r-- | src/include/console/uart.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/include/console/uart.h b/src/include/console/uart.h index 3bd390e75b..2e9c7b815c 100644 --- a/src/include/console/uart.h +++ b/src/include/console/uart.h @@ -46,6 +46,9 @@ unsigned int uart_baudrate_divisor(unsigned int baudrate, */ unsigned int uart_input_clock_divider(void); +/* Bitbang out one byte on an 8n1 UART through the output function set_tx(). */ +void uart_bitbang_tx_byte(unsigned char data, void (*set_tx)(int line_state)); + void uart_init(int idx); void uart_tx_byte(int idx, unsigned char data); void uart_tx_flush(int idx); |