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>
diff --git a/src/soc/amd/stoneyridge/uart.c b/src/soc/amd/stoneyridge/uart.c
index 3b6d49c..9a8add0 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 *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);
}