From 880364040a856489bd2f40fec6c6c246e8e960a6 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Tue, 18 Oct 2022 20:22:48 +0200 Subject: [PATCH] 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 Change-Id: I813483bc0421043dc67c523f0ea2016a16a29f60 Reviewed-on: https://review.coreboot.org/c/coreboot/+/68538 Tested-by: build bot (Jenkins) Reviewed-by: Fred Reitberger --- src/soc/amd/stoneyridge/uart.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/soc/amd/stoneyridge/uart.c b/src/soc/amd/stoneyridge/uart.c index 3b6d49caea..9a8add077b 100644 --- a/src/soc/amd/stoneyridge/uart.c +++ b/src/soc/amd/stoneyridge/uart.c @@ -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) { - 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 uart_info[idx].base; + return ctrlr[idx].base; } 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; - gpio_configure_pads(uart_info[idx].mux, 2); + gpio_configure_pads(ctrlr[idx].mux, 2); }