From 9948c521a63148e49d850d2ac760f245007908a3 Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Mon, 24 Oct 2022 14:37:40 +0200 Subject: lib/coreboot_table: Simplify API to set up lb_serial Instead of having callbacks into serial console code to set up the coreboot table have the coreboot table code call IP specific code to get serial information. This makes it easier to reuse the information as the return value can be used in a different context (e.g. when filling in a FDT). This also removes boilerplate code to set up lb_console entries by setting entry based on the type in struct lb_uart. Change-Id: I6c08a88fb5fc035eb28d0becf19471c709c8043d Signed-off-by: Arthur Heymans Reviewed-on: https://review.coreboot.org/c/coreboot/+/68768 Tested-by: build bot (Jenkins) Reviewed-by: Hung-Te Lin --- src/soc/qualcomm/common/qupv3_uart.c | 16 +++++++--------- src/soc/qualcomm/common/uart_bitbang.c | 4 ++-- src/soc/qualcomm/ipq40xx/uart.c | 17 +++++++---------- src/soc/qualcomm/ipq806x/uart.c | 3 ++- src/soc/qualcomm/qcs405/uart.c | 17 +++++++---------- 5 files changed, 25 insertions(+), 32 deletions(-) (limited to 'src/soc/qualcomm') diff --git a/src/soc/qualcomm/common/qupv3_uart.c b/src/soc/qualcomm/common/qupv3_uart.c index 2086c1df70..f4ff53b8b1 100644 --- a/src/soc/qualcomm/common/qupv3_uart.c +++ b/src/soc/qualcomm/common/qupv3_uart.c @@ -140,15 +140,13 @@ uintptr_t uart_platform_base(unsigned int idx) return (uintptr_t)qup[idx].regs; } -void uart_fill_lb(void *data) +enum cb_err fill_lb_serial(struct lb_serial *serial) { - struct lb_serial serial = {0}; + serial->type = LB_SERIAL_TYPE_MEMORY_MAPPED; + serial->baseaddr = (uint32_t)uart_platform_base(CONFIG_UART_FOR_CONSOLE); + serial->baud = get_uart_baudrate(); + serial->regwidth = 4; + serial->input_hertz = SRC_XO_HZ; - serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; - serial.baseaddr = (uint32_t)uart_platform_base(CONFIG_UART_FOR_CONSOLE); - serial.baud = get_uart_baudrate(); - serial.regwidth = 4; - serial.input_hertz = SRC_XO_HZ; - - lb_add_serial(&serial, data); + return CB_SUCCESS; } diff --git a/src/soc/qualcomm/common/uart_bitbang.c b/src/soc/qualcomm/common/uart_bitbang.c index 943dcf8a06..d6447f1f18 100644 --- a/src/soc/qualcomm/common/uart_bitbang.c +++ b/src/soc/qualcomm/common/uart_bitbang.c @@ -5,9 +5,9 @@ #include #include -void uart_fill_lb(void *data) +enum cb_err fill_lb_serial(struct lb_serial *serial) { - + return CB_ERR; } static void set_tx(int line_state) diff --git a/src/soc/qualcomm/ipq40xx/uart.c b/src/soc/qualcomm/ipq40xx/uart.c index c04a773bce..45dc09af35 100644 --- a/src/soc/qualcomm/ipq40xx/uart.c +++ b/src/soc/qualcomm/ipq40xx/uart.c @@ -256,16 +256,13 @@ uint8_t uart_rx_byte(unsigned int idx) } /* TODO: Implement function */ -void uart_fill_lb(void *data) +enum cb_err fill_lb_serial(struct lb_serial *serial) { - struct lb_serial serial; + serial->type = LB_SERIAL_TYPE_MEMORY_MAPPED; + serial->baseaddr = (uint32_t)UART1_DM_BASE; + serial->baud = get_uart_baudrate(); + serial->regwidth = 1; + serial->input_hertz = uart_platform_refclk(); - serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; - serial.baseaddr = (uint32_t)UART1_DM_BASE; - serial.baud = get_uart_baudrate(); - serial.regwidth = 1; - serial.input_hertz = uart_platform_refclk(); - lb_add_serial(&serial, data); - - lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data); + return CB_SUCCESS; } diff --git a/src/soc/qualcomm/ipq806x/uart.c b/src/soc/qualcomm/ipq806x/uart.c index 15a0998fb5..6d69edc991 100644 --- a/src/soc/qualcomm/ipq806x/uart.c +++ b/src/soc/qualcomm/ipq806x/uart.c @@ -368,6 +368,7 @@ uint8_t uart_rx_byte(unsigned int idx) } /* TODO: Implement function */ -void uart_fill_lb(void *data) +enum cb_err fill_lb_serial(struct lb_serial *serial) { + return CB_ERR; } diff --git a/src/soc/qualcomm/qcs405/uart.c b/src/soc/qualcomm/qcs405/uart.c index 007a98093f..16c71b4205 100644 --- a/src/soc/qualcomm/qcs405/uart.c +++ b/src/soc/qualcomm/qcs405/uart.c @@ -257,16 +257,13 @@ uint8_t uart_rx_byte(unsigned int idx) } #endif -void uart_fill_lb(void *data) +enum cb_err fill_lb_serial(struct lb_serial *serial) { - struct lb_serial serial; + serial->type = LB_SERIAL_TYPE_MEMORY_MAPPED; + serial->baseaddr = (uint64_t)UART2_DM_BASE; + serial->baud = get_uart_baudrate(); + serial->regwidth = 1; + serial->input_hertz = uart_platform_refclk(); - serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; - serial.baseaddr = (uint64_t)UART2_DM_BASE; - serial.baud = get_uart_baudrate(); - serial.regwidth = 1; - serial.input_hertz = uart_platform_refclk(); - lb_add_serial(&serial, data); - - lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data); + return CB_SUCCESS; } -- cgit v1.2.3