Felix Held | fbfb906 | 2021-12-15 19:35:00 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <amdblocks/aoac.h> |
| 4 | #include <delay.h> |
| 5 | #include <soc/aoac_defs.h> |
| 6 | #include <soc/southbridge.h> |
| 7 | #include <types.h> |
| 8 | |
| 9 | /* |
| 10 | * Table of devices that need their AOAC registers enabled and waited |
| 11 | * upon (usually about .55 milliseconds). Instead of individual delays |
| 12 | * waiting for each device to become available, a single delay will be |
| 13 | * executed. |
| 14 | */ |
| 15 | static const unsigned int aoac_devs[] = { |
| 16 | FCH_AOAC_DEV_UART0 + CONFIG_UART_FOR_CONSOLE * 2, |
| 17 | FCH_AOAC_DEV_AMBA, |
| 18 | FCH_AOAC_DEV_I2C0, |
| 19 | FCH_AOAC_DEV_I2C1, |
| 20 | FCH_AOAC_DEV_I2C2, |
| 21 | FCH_AOAC_DEV_I2C3, |
| 22 | }; |
| 23 | |
Matt DeVillier | 66ff4fb | 2023-08-08 12:28:03 -0500 | [diff] [blame^] | 24 | void wait_for_aoac_enabled(unsigned int dev) |
| 25 | { |
| 26 | while (!is_aoac_device_enabled(dev)) |
| 27 | udelay(100); |
| 28 | } |
| 29 | |
Felix Held | fbfb906 | 2021-12-15 19:35:00 +0100 | [diff] [blame] | 30 | void enable_aoac_devices(void) |
| 31 | { |
| 32 | bool status; |
| 33 | int i; |
| 34 | |
| 35 | for (i = 0; i < ARRAY_SIZE(aoac_devs); i++) |
| 36 | power_on_aoac_device(aoac_devs[i]); |
| 37 | |
| 38 | /* Wait for AOAC devices to indicate power and clock OK */ |
| 39 | do { |
| 40 | udelay(100); |
| 41 | status = true; |
| 42 | for (i = 0; i < ARRAY_SIZE(aoac_devs); i++) |
| 43 | status &= is_aoac_device_enabled(aoac_devs[i]); |
| 44 | } while (!status); |
| 45 | } |