Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | /* TODO: Check if this is still correct */ |
| 4 | |
| 5 | #include <amdblocks/acpimmio.h> |
Felix Held | ba35f35 | 2022-10-18 20:43:00 +0200 | [diff] [blame] | 6 | #include <amdblocks/aoac.h> |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 7 | #include <amdblocks/espi.h> |
| 8 | #include <amdblocks/i2c.h> |
| 9 | #include <amdblocks/lpc.h> |
| 10 | #include <amdblocks/pmlib.h> |
| 11 | #include <amdblocks/smbus.h> |
Martin Roth | 300338f | 2022-10-14 14:55:25 -0600 | [diff] [blame] | 12 | #include <amdblocks/stb.h> |
Felix Held | 8ebdbbc | 2022-10-18 20:52:42 +0200 | [diff] [blame] | 13 | #include <amdblocks/uart.h> |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 14 | #include <soc/i2c.h> |
| 15 | #include <soc/southbridge.h> |
| 16 | #include <soc/uart.h> |
| 17 | |
| 18 | #include "chip.h" |
| 19 | |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 20 | /* Before console init */ |
| 21 | void fch_pre_init(void) |
| 22 | { |
| 23 | /* Enable_acpimmio_decode_pm04 to enable the ACPIMMIO decode which is needed to access |
| 24 | the GPIO registers. */ |
| 25 | enable_acpimmio_decode_pm04(); |
| 26 | /* Setup SPI base by calling lpc_early_init before setting up eSPI. */ |
| 27 | lpc_early_init(); |
| 28 | |
Karthikeyan Ramasubramanian | 1527a12 | 2022-08-12 12:14:38 -0600 | [diff] [blame] | 29 | /* Setup eSPI to enable port80 routing if the board is using eSPI and the eSPI |
| 30 | interface hasn't already been set up in verstage on PSP */ |
| 31 | if (CONFIG(SOC_AMD_COMMON_BLOCK_USE_ESPI) && !CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 32 | configure_espi_with_mb_hook(); |
| 33 | |
| 34 | fch_spi_early_init(); |
| 35 | fch_smbus_init(); |
| 36 | fch_enable_cf9_io(); |
| 37 | fch_enable_legacy_io(); |
| 38 | fch_disable_legacy_dma_io(); |
| 39 | enable_aoac_devices(); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 40 | |
| 41 | /* |
| 42 | * On reset Range_0 defaults to enabled. We want to start with a clean |
| 43 | * slate to not have things unexpectedly enabled. |
| 44 | */ |
| 45 | clear_uart_legacy_config(); |
| 46 | |
| 47 | if (CONFIG(AMD_SOC_CONSOLE_UART)) |
| 48 | set_uart_config(CONFIG_UART_FOR_CONSOLE); |
| 49 | |
| 50 | /* disable the keyboard reset function before mainboard GPIO setup */ |
| 51 | if (CONFIG(DISABLE_KEYBOARD_RESET_PIN)) |
| 52 | fch_disable_kb_rst(); |
| 53 | } |
| 54 | |
| 55 | /* After console init */ |
| 56 | void fch_early_init(void) |
| 57 | { |
Martin Roth | 300338f | 2022-10-14 14:55:25 -0600 | [diff] [blame] | 58 | if (CONFIG(WRITE_STB_BUFFER_TO_CONSOLE)) |
| 59 | write_stb_to_console(); |
| 60 | |
Felix Held | 8db77d7 | 2021-08-30 18:20:34 +0200 | [diff] [blame] | 61 | reset_i2c_peripherals(); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 62 | pm_set_power_failure_state(); |
| 63 | fch_print_pmxc0_status(); |
| 64 | i2c_soc_early_init(); |
| 65 | show_spi_speeds_and_modes(); |
| 66 | |
| 67 | if (CONFIG(DISABLE_SPI_FLASH_ROM_SHARING)) |
| 68 | lpc_disable_spi_rom_sharing(); |
| 69 | } |