Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/68768 )
Change subject: lib/coreboot_table: Simplify API to set up lb_serial ......................................................................
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 code provide the struct as a return value. 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 arthur@aheymans.xyz --- M src/drivers/uart/pl011.c M src/drivers/uart/sifive.c M src/drivers/uart/uart8250io.c M src/drivers/uart/uart8250mem.c M src/include/boot/coreboot_tables.h M src/lib/coreboot_table.c M src/mainboard/emulation/qemu-power8/uart.c M src/soc/mediatek/common/uart.c M src/soc/nvidia/tegra124/uart.c M src/soc/nvidia/tegra210/uart.c M src/soc/qualcomm/common/qupv3_uart.c M src/soc/qualcomm/common/uart_bitbang.c M src/soc/qualcomm/ipq40xx/uart.c M src/soc/qualcomm/ipq806x/uart.c M src/soc/qualcomm/qcs405/uart.c M src/soc/samsung/exynos5250/uart.c M src/soc/samsung/exynos5420/uart.c M src/soc/ti/am335x/uart.c 18 files changed, 66 insertions(+), 52 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/68/68768/1
diff --git a/src/drivers/uart/pl011.c b/src/drivers/uart/pl011.c index 3653262..a4a0aa4 100644 --- a/src/drivers/uart/pl011.c +++ b/src/drivers/uart/pl011.c @@ -35,7 +35,7 @@ return read8(®s->dr); }
-void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { struct lb_serial serial; serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; @@ -43,7 +43,6 @@ 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 serial; } diff --git a/src/drivers/uart/sifive.c b/src/drivers/uart/sifive.c index 31181aa..a9d3db8 100644 --- a/src/drivers/uart/sifive.c +++ b/src/drivers/uart/sifive.c @@ -100,7 +100,9 @@ return 1; }
-void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { + struct lb_serial = {}; + return lb_serial; /* TODO */ } diff --git a/src/drivers/uart/uart8250io.c b/src/drivers/uart/uart8250io.c index 79df37c..0bd9fcd 100644 --- a/src/drivers/uart/uart8250io.c +++ b/src/drivers/uart/uart8250io.c @@ -106,7 +106,7 @@ uart8250_tx_flush(uart_platform_base(idx)); }
-void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { struct lb_serial serial; serial.type = LB_SERIAL_TYPE_IO_MAPPED; @@ -114,7 +114,6 @@ 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_SERIAL8250, data); + return serial; } diff --git a/src/drivers/uart/uart8250mem.c b/src/drivers/uart/uart8250mem.c index 79e786b..34adefe 100644 --- a/src/drivers/uart/uart8250mem.c +++ b/src/drivers/uart/uart8250mem.c @@ -133,7 +133,7 @@ uart8250_mem_tx_flush(base); }
-void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { struct lb_serial serial; serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; @@ -146,7 +146,6 @@ else serial.regwidth = sizeof(uint8_t); serial.input_hertz = uart_platform_refclk(); - lb_add_serial(&serial, data);
- lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data); + return serial; } diff --git a/src/include/boot/coreboot_tables.h b/src/include/boot/coreboot_tables.h index 6188ce0..52958ba 100644 --- a/src/include/boot/coreboot_tables.h +++ b/src/include/boot/coreboot_tables.h @@ -19,8 +19,7 @@ void lb_add_gpios(struct lb_gpios *gpios, const struct lb_gpio *gpio_table, size_t count);
-void uart_fill_lb(void *data); -void lb_add_serial(struct lb_serial *serial, void *data); +struct lb_serial get_lb_serial(void); void lb_add_console(uint16_t consoletype, void *data);
enum cb_err lb_fill_pcie(struct lb_pcie *pcie); diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c index 4df7039..0d5c150 100644 --- a/src/lib/coreboot_table.c +++ b/src/lib/coreboot_table.c @@ -96,19 +96,23 @@ return mem; }
-void lb_add_serial(struct lb_serial *new_serial, void *data) +static void lb_add_serial(struct lb_header *header) { - struct lb_header *header = (struct lb_header *)data; struct lb_serial *serial; + struct lb_serial new_serial = get_lb_serial(); + /* Use the base address as a proxy for an invalid struct */ + if (new_serial.baseaddr == 0) + return;
serial = (struct lb_serial *)lb_new_record(header); + memcpy(serial, &new_serial, sizeof(*serial)); serial->tag = LB_TAG_SERIAL; serial->size = sizeof(*serial); - serial->type = new_serial->type; - serial->baseaddr = new_serial->baseaddr; - serial->baud = new_serial->baud; - serial->regwidth = new_serial->regwidth; - serial->input_hertz = new_serial->input_hertz; + if (serial->type == LB_SERIAL_TYPE_IO_MAPPED) + lb_add_console(LB_TAG_CONSOLE_SERIAL8250, header); + else + lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, header);; + }
void lb_add_console(uint16_t consoletype, void *data) @@ -492,7 +496,7 @@
/* Record the serial ports and consoles */ if (CONFIG(CONSOLE_SERIAL)) - uart_fill_lb(head); + lb_add_serial(head);
if (CONFIG(CONSOLE_USB)) lb_add_console(LB_TAG_CONSOLE_EHCI, head); diff --git a/src/mainboard/emulation/qemu-power8/uart.c b/src/mainboard/emulation/qemu-power8/uart.c index a2f9116..1feaf8c 100644 --- a/src/mainboard/emulation/qemu-power8/uart.c +++ b/src/mainboard/emulation/qemu-power8/uart.c @@ -28,7 +28,7 @@ { }
-void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { struct lb_serial serial;
@@ -37,7 +37,6 @@ serial.baud = 115200; serial.regwidth = 1; serial.input_hertz = uart_platform_refclk(); - lb_add_serial(&serial, data);
- lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data); + return serial; } diff --git a/src/soc/mediatek/common/uart.c b/src/soc/mediatek/common/uart.c index 11c3452..adcae07 100644 --- a/src/soc/mediatek/common/uart.c +++ b/src/soc/mediatek/common/uart.c @@ -159,7 +159,7 @@ mtk_uart_tx_flush(); }
-void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { struct lb_serial serial; serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; @@ -167,7 +167,6 @@ serial.baud = get_uart_baudrate(); serial.regwidth = 4; serial.input_hertz = UART_HZ; - lb_add_serial(&serial, data);
- lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data); + return serial; } diff --git a/src/soc/nvidia/tegra124/uart.c b/src/soc/nvidia/tegra124/uart.c index 77d6de2..23888d7 100644 --- a/src/soc/nvidia/tegra124/uart.c +++ b/src/soc/nvidia/tegra124/uart.c @@ -114,7 +114,7 @@ tegra124_uart_tx_flush(uart_ptr); }
-void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { struct lb_serial serial; serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; @@ -122,7 +122,6 @@ serial.baud = get_uart_baudrate(); serial.regwidth = 4; serial.input_hertz = uart_platform_refclk(); - lb_add_serial(&serial, data);
- lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data); + return serial; } diff --git a/src/soc/nvidia/tegra210/uart.c b/src/soc/nvidia/tegra210/uart.c index b2cdf67..35217a9 100644 --- a/src/soc/nvidia/tegra210/uart.c +++ b/src/soc/nvidia/tegra210/uart.c @@ -101,7 +101,7 @@ return tegra210_uart_rx_byte(); }
-void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { struct lb_serial serial; serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; @@ -109,7 +109,6 @@ serial.baud = get_uart_baudrate(); serial.regwidth = 4; serial.input_hertz = uart_platform_refclk(); - lb_add_serial(&serial, data);
- lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data); + return serial; } diff --git a/src/soc/qualcomm/common/qupv3_uart.c b/src/soc/qualcomm/common/qupv3_uart.c index 2086c1d..2348cd0 100644 --- a/src/soc/qualcomm/common/qupv3_uart.c +++ b/src/soc/qualcomm/common/qupv3_uart.c @@ -140,7 +140,7 @@ return (uintptr_t)qup[idx].regs; }
-void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { struct lb_serial serial = {0};
@@ -150,5 +150,5 @@ serial.regwidth = 4; serial.input_hertz = SRC_XO_HZ;
- lb_add_serial(&serial, data); + return serial; } diff --git a/src/soc/qualcomm/common/uart_bitbang.c b/src/soc/qualcomm/common/uart_bitbang.c index 943dcf8..54e1cb6 100644 --- a/src/soc/qualcomm/common/uart_bitbang.c +++ b/src/soc/qualcomm/common/uart_bitbang.c @@ -5,9 +5,10 @@ #include <boot/coreboot_tables.h> #include <soc/uart.h>
-void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { - + struct lb_serial serial = {}; + return serial; }
static void set_tx(int line_state) diff --git a/src/soc/qualcomm/ipq40xx/uart.c b/src/soc/qualcomm/ipq40xx/uart.c index c04a773..236ab64 100644 --- a/src/soc/qualcomm/ipq40xx/uart.c +++ b/src/soc/qualcomm/ipq40xx/uart.c @@ -256,7 +256,7 @@ }
/* TODO: Implement function */ -void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { struct lb_serial serial;
@@ -265,7 +265,6 @@ 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 serial; } diff --git a/src/soc/qualcomm/ipq806x/uart.c b/src/soc/qualcomm/ipq806x/uart.c index 15a0998..9459ddf 100644 --- a/src/soc/qualcomm/ipq806x/uart.c +++ b/src/soc/qualcomm/ipq806x/uart.c @@ -368,6 +368,8 @@ }
/* TODO: Implement function */ -void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { + struct lb_serial serial = {}; + return serial; } diff --git a/src/soc/qualcomm/qcs405/uart.c b/src/soc/qualcomm/qcs405/uart.c index 007a980..527567e 100644 --- a/src/soc/qualcomm/qcs405/uart.c +++ b/src/soc/qualcomm/qcs405/uart.c @@ -257,7 +257,7 @@ } #endif
-void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { struct lb_serial serial;
@@ -266,7 +266,6 @@ 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 serial; } diff --git a/src/soc/samsung/exynos5250/uart.c b/src/soc/samsung/exynos5250/uart.c index 7943651..5907f8d3 100644 --- a/src/soc/samsung/exynos5250/uart.c +++ b/src/soc/samsung/exynos5250/uart.c @@ -132,7 +132,7 @@ exynos5_uart_tx_flush(uart); }
-void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { struct lb_serial serial; serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; @@ -140,7 +140,6 @@ serial.baud = get_uart_baudrate(); serial.regwidth = 4; serial.input_hertz = uart_platform_refclk(); - lb_add_serial(&serial, data);
- lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data); + return serial; } diff --git a/src/soc/samsung/exynos5420/uart.c b/src/soc/samsung/exynos5420/uart.c index 1268183..45974fa 100644 --- a/src/soc/samsung/exynos5420/uart.c +++ b/src/soc/samsung/exynos5420/uart.c @@ -123,7 +123,7 @@ /* Exynos5250 implements this too. */ }
-void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { struct lb_serial serial; serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; @@ -131,7 +131,6 @@ serial.baud = get_uart_baudrate(); serial.regwidth = 4; serial.input_hertz = uart_platform_refclk(); - lb_add_serial(&serial, data);
- lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data); + return serial; } diff --git a/src/soc/ti/am335x/uart.c b/src/soc/ti/am335x/uart.c index 136d785..12fa0c5 100644 --- a/src/soc/ti/am335x/uart.c +++ b/src/soc/ti/am335x/uart.c @@ -170,7 +170,7 @@ { }
-void uart_fill_lb(void *data) +struct lb_serial get_lb_serial(void) { struct lb_serial serial; serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; @@ -178,7 +178,6 @@ serial.baud = get_uart_baudrate(); serial.regwidth = 2; serial.input_hertz = uart_platform_refclk(); - lb_add_serial(&serial, data);
- lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data); + return serial; }