aboutsummaryrefslogtreecommitdiff
path: root/src/soc/amd/stoneyridge/uart.c
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2022-10-18 20:22:48 +0200
committerFelix Held <felix-coreboot@felixheld.de>2022-10-20 16:45:48 +0000
commit880364040a856489bd2f40fec6c6c246e8e960a6 (patch)
treedcfd879e9a61cca2f43a74b253292ba0dbc9bbd1 /src/soc/amd/stoneyridge/uart.c
parent957e232277072dfd9998d19c948fb9c1870ef4e3 (diff)
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>
Diffstat (limited to 'src/soc/amd/stoneyridge/uart.c')
-rw-r--r--src/soc/amd/stoneyridge/uart.c20
1 files 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);
}