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 <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/68768
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
This commit is contained in:
Arthur Heymans
2022-10-24 14:37:40 +02:00
committed by Felix Held
parent 5c38b234ef
commit 9948c521a6
19 changed files with 123 additions and 170 deletions

View File

@@ -35,15 +35,13 @@ unsigned char uart_rx_byte(unsigned int idx)
return read8(&regs->dr);
}
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 = uart_platform_base(CONFIG_UART_FOR_CONSOLE);
serial.baud = get_uart_baudrate();
serial.regwidth = 1;
serial.input_hertz = uart_platform_refclk();
lb_add_serial(&serial, data);
serial->type = LB_SERIAL_TYPE_MEMORY_MAPPED;
serial->baseaddr = uart_platform_base(CONFIG_UART_FOR_CONSOLE);
serial->baud = get_uart_baudrate();
serial->regwidth = 1;
serial->input_hertz = uart_platform_refclk();
lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data);
return CB_SUCCESS;
}

View File

@@ -100,7 +100,8 @@ unsigned int uart_input_clock_divider(void)
return 1;
}
void uart_fill_lb(void *data)
enum cb_err fill_lb_serial(struct lb_serial *serial)
{
return CB_ERR;
/* TODO */
}

View File

@@ -109,15 +109,13 @@ void uart_tx_flush(unsigned int idx)
uart8250_tx_flush(uart_platform_base(idx));
}
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_IO_MAPPED;
serial.baseaddr = uart_platform_base(CONFIG_UART_FOR_CONSOLE);
serial.baud = get_uart_baudrate();
serial.regwidth = 1;
serial.input_hertz = uart_platform_refclk();
lb_add_serial(&serial, data);
serial->type = LB_SERIAL_TYPE_IO_MAPPED;
serial->baseaddr = uart_platform_base(CONFIG_UART_FOR_CONSOLE);
serial->baud = get_uart_baudrate();
serial->regwidth = 1;
serial->input_hertz = uart_platform_refclk();
lb_add_console(LB_TAG_CONSOLE_SERIAL8250, data);
return CB_SUCCESS;
}

View File

@@ -133,20 +133,18 @@ void uart_tx_flush(unsigned int idx)
uart8250_mem_tx_flush(base);
}
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 = uart_platform_base(CONFIG_UART_FOR_CONSOLE);
if (!serial.baseaddr)
return;
serial.baud = get_uart_baudrate();
serial->type = LB_SERIAL_TYPE_MEMORY_MAPPED;
serial->baseaddr = uart_platform_base(CONFIG_UART_FOR_CONSOLE);
if (!serial->baseaddr)
return CB_ERR;
serial->baud = get_uart_baudrate();
if (CONFIG(DRIVERS_UART_8250MEM_32))
serial.regwidth = sizeof(uint32_t);
serial->regwidth = sizeof(uint32_t);
else
serial.regwidth = sizeof(uint8_t);
serial.input_hertz = uart_platform_refclk();
lb_add_serial(&serial, data);
serial->regwidth = sizeof(uint8_t);
serial->input_hertz = uart_platform_refclk();
lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data);
return CB_SUCCESS;
}