soc/amd/stoneyridge/uart: introduce and use soc_get_uart_ctrlr_info

Introduce and use soc_get_uart_ctrlr_info to access the uart_info array
to further decouple uart_info from the code as preparation to factor out
most of the code to a common implementation.

Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: I813483bc0421043dc67c523f0ea2016a16a29f60
Reviewed-on: https://review.coreboot.org/c/coreboot/+/68538
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com>
This commit is contained in:
Felix Held 2022-10-18 20:22:48 +02:00
parent 957e232277
commit 880364040a
1 changed files with 16 additions and 4 deletions

View File

@ -20,18 +20,30 @@ static const struct soc_uart_ctrlr_info uart_info[] = {
} }, } },
}; };
static const struct soc_uart_ctrlr_info *soc_get_uart_ctrlr_info(size_t *num_ctrlrs)
{
*num_ctrlrs = ARRAY_SIZE(uart_info);
return uart_info;
}
uintptr_t get_uart_base(unsigned int idx) uintptr_t get_uart_base(unsigned int idx)
{ {
if (idx >= ARRAY_SIZE(uart_info)) size_t num_ctrlrs;
const struct soc_uart_ctrlr_info *ctrlr = soc_get_uart_ctrlr_info(&num_ctrlrs);
if (idx >= num_ctrlrs)
return 0; return 0;
return uart_info[idx].base; return ctrlr[idx].base;
} }
void set_uart_config(unsigned int idx) void set_uart_config(unsigned int idx)
{ {
if (idx >= ARRAY_SIZE(uart_info)) size_t num_ctrlrs;
const struct soc_uart_ctrlr_info *ctrlr = soc_get_uart_ctrlr_info(&num_ctrlrs);
if (idx >= num_ctrlrs)
return; return;
gpio_configure_pads(uart_info[idx].mux, 2); gpio_configure_pads(ctrlr[idx].mux, 2);
} }