blob: 53ba88f1b903a5379d4574ec6570d10a40d100b2 [file] [log] [blame]
Arthur Heymans4da9d6b42023-07-13 14:19:09 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <stdint.h>
4#include <amdblocks/acpimmio.h>
5#include <amdblocks/aoac.h>
6#include <soc/aoac_defs.h>
7#include <soc/southbridge.h>
8#include <delay.h>
9
10#define FCH_AOAC_UART_FOR_CONSOLE \
11 (CONFIG_UART_FOR_CONSOLE == 0 ? FCH_AOAC_DEV_UART0 \
12 : CONFIG_UART_FOR_CONSOLE == 1 ? FCH_AOAC_DEV_UART1 \
13 : CONFIG_UART_FOR_CONSOLE == 2 ? FCH_AOAC_DEV_UART2 \
14 : -1)
15#if CONFIG(AMD_SOC_CONSOLE_UART) && FCH_AOAC_UART_FOR_CONSOLE == -1
16# error Unsupported UART_FOR_CONSOLE chosen
17#endif
18
19void wait_for_aoac_enabled(unsigned int dev)
20{
21 while (!is_aoac_device_enabled(dev))
22 udelay(100);
23}
24
25void enable_aoac_devices(void)
26{
27 if (CONFIG(AMD_SOC_CONSOLE_UART))
28 power_on_aoac_device(FCH_AOAC_UART_FOR_CONSOLE);
29
30 if (CONFIG(AMD_SOC_CONSOLE_UART))
31 wait_for_aoac_enabled(FCH_AOAC_UART_FOR_CONSOLE);
32}