2020-06-11 22:06:11 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <amdblocks/acpimmio.h>
|
2020-11-30 17:56:59 +01:00
|
|
|
#include <amdblocks/aoac.h>
|
2020-06-11 22:06:11 +02:00
|
|
|
#include <soc/southbridge.h>
|
|
|
|
#include <delay.h>
|
|
|
|
|
|
|
|
#define FCH_AOAC_UART_FOR_CONSOLE \
|
|
|
|
(CONFIG_UART_FOR_CONSOLE == 0 ? FCH_AOAC_DEV_UART0 \
|
|
|
|
: CONFIG_UART_FOR_CONSOLE == 1 ? FCH_AOAC_DEV_UART1 \
|
|
|
|
: CONFIG_UART_FOR_CONSOLE == 2 ? FCH_AOAC_DEV_UART2 \
|
|
|
|
: CONFIG_UART_FOR_CONSOLE == 3 ? FCH_AOAC_DEV_UART3 \
|
|
|
|
: -1)
|
2020-12-09 16:25:18 +01:00
|
|
|
#if CONFIG(AMD_SOC_CONSOLE_UART) && FCH_AOAC_UART_FOR_CONSOLE == -1
|
2020-06-11 22:06:11 +02:00
|
|
|
# error Unsupported UART_FOR_CONSOLE chosen
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Table of devices that need their AOAC registers enabled and waited
|
|
|
|
* upon (usually about .55 milliseconds). Instead of individual delays
|
|
|
|
* waiting for each device to become available, a single delay will be
|
|
|
|
* executed. The console UART is handled separately from this table.
|
|
|
|
*/
|
2020-11-30 20:26:38 +01:00
|
|
|
const static unsigned int aoac_devs[] = {
|
2020-06-11 22:06:11 +02:00
|
|
|
FCH_AOAC_DEV_AMBA,
|
|
|
|
FCH_AOAC_DEV_I2C2,
|
|
|
|
FCH_AOAC_DEV_I2C3,
|
|
|
|
FCH_AOAC_DEV_I2C4,
|
|
|
|
FCH_AOAC_DEV_ESPI,
|
|
|
|
};
|
|
|
|
|
2020-09-12 01:01:43 +02:00
|
|
|
void wait_for_aoac_enabled(unsigned int dev)
|
2020-06-11 22:06:11 +02:00
|
|
|
{
|
2020-06-12 00:53:57 +02:00
|
|
|
while (!is_aoac_device_enabled(dev))
|
|
|
|
udelay(100);
|
2020-06-11 22:06:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void enable_aoac_devices(void)
|
|
|
|
{
|
2020-09-12 01:01:43 +02:00
|
|
|
unsigned int i;
|
2020-06-11 22:06:11 +02:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(aoac_devs); i++)
|
|
|
|
power_on_aoac_device(aoac_devs[i]);
|
2020-06-12 00:53:57 +02:00
|
|
|
|
2020-12-09 16:25:18 +01:00
|
|
|
if (CONFIG(AMD_SOC_CONSOLE_UART))
|
2020-06-12 00:53:57 +02:00
|
|
|
power_on_aoac_device(FCH_AOAC_UART_FOR_CONSOLE);
|
2020-06-11 22:06:11 +02:00
|
|
|
|
|
|
|
/* Wait for AOAC devices to indicate power and clock OK */
|
2020-06-12 00:53:57 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(aoac_devs); i++)
|
|
|
|
wait_for_aoac_enabled(aoac_devs[i]);
|
|
|
|
|
2020-12-09 16:25:18 +01:00
|
|
|
if (CONFIG(AMD_SOC_CONSOLE_UART))
|
2020-06-12 00:53:57 +02:00
|
|
|
wait_for_aoac_enabled(FCH_AOAC_UART_FOR_CONSOLE);
|
2020-06-11 22:06:11 +02:00
|
|
|
}
|