Felix Held | 153f92a | 2020-12-08 17:27:30 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <amdblocks/acpimmio.h> |
Felix Held | ba35f35 | 2022-10-18 20:43:00 +0200 | [diff] [blame] | 4 | #include <amdblocks/aoac.h> |
Zheng Bao | 9194760 | 2021-01-27 15:47:58 +0800 | [diff] [blame] | 5 | #include <amdblocks/espi.h> |
Zheng Bao | b0f00ed | 2021-03-16 15:28:49 +0800 | [diff] [blame] | 6 | #include <amdblocks/i2c.h> |
Karthikeyan Ramasubramanian | f62bbc8 | 2021-03-30 15:19:12 -0600 | [diff] [blame] | 7 | #include <amdblocks/lpc.h> |
| 8 | #include <amdblocks/pmlib.h> |
| 9 | #include <amdblocks/smbus.h> |
Felix Held | 8ebdbbc | 2022-10-18 20:52:42 +0200 | [diff] [blame] | 10 | #include <amdblocks/uart.h> |
Zheng Bao | b0f00ed | 2021-03-16 15:28:49 +0800 | [diff] [blame] | 11 | #include <soc/i2c.h> |
Felix Held | 153f92a | 2020-12-08 17:27:30 +0100 | [diff] [blame] | 12 | #include <soc/southbridge.h> |
Felix Held | 8a3d4d5 | 2021-01-13 03:06:21 +0100 | [diff] [blame] | 13 | #include <soc/uart.h> |
Felix Held | 153f92a | 2020-12-08 17:27:30 +0100 | [diff] [blame] | 14 | |
Zheng Bao | b0f00ed | 2021-03-16 15:28:49 +0800 | [diff] [blame] | 15 | #include "chip.h" |
| 16 | |
Zheng Bao | b0f00ed | 2021-03-16 15:28:49 +0800 | [diff] [blame] | 17 | |
Jeremy Soller | e14e66b | 2021-11-09 15:21:45 -0700 | [diff] [blame] | 18 | static void lpc_configure_decodes(void) |
| 19 | { |
| 20 | if (CONFIG(POST_IO) && (CONFIG_POST_IO_PORT == 0x80)) |
| 21 | lpc_enable_port80(); |
| 22 | } |
| 23 | |
Felix Held | 153f92a | 2020-12-08 17:27:30 +0100 | [diff] [blame] | 24 | /* Before console init */ |
| 25 | void fch_pre_init(void) |
| 26 | { |
Felix Held | 425e73d | 2021-09-20 16:31:33 +0200 | [diff] [blame] | 27 | /* Enable_acpimmio_decode_pm04 to enable the ACPIMMIO decode which is needed to access |
| 28 | the GPIO registers. */ |
| 29 | enable_acpimmio_decode_pm04(); |
Karthikeyan Ramasubramanian | 2d17ea4 | 2021-10-05 13:57:30 -0600 | [diff] [blame] | 30 | /* Setup SPI base by calling lpc_early_init before setting up eSPI. */ |
Zheng Bao | 3da5569 | 2021-01-26 18:30:18 +0800 | [diff] [blame] | 31 | lpc_early_init(); |
Felix Held | 4e379a2 | 2021-10-14 21:43:11 +0200 | [diff] [blame] | 32 | |
| 33 | /* Setup eSPI to enable port80 routing if the board is using eSPI and the eSPI |
| 34 | interface hasn't already been set up in verstage on PSP */ |
| 35 | if (CONFIG(SOC_AMD_COMMON_BLOCK_USE_ESPI) && !CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) |
| 36 | configure_espi_with_mb_hook(); |
| 37 | |
Jeremy Soller | e14e66b | 2021-11-09 15:21:45 -0700 | [diff] [blame] | 38 | if (!CONFIG(SOC_AMD_COMMON_BLOCK_USE_ESPI)) |
| 39 | lpc_configure_decodes(); |
| 40 | |
Karthikeyan Ramasubramanian | 0032bfa | 2021-07-28 23:53:20 -0600 | [diff] [blame] | 41 | fch_spi_early_init(); |
Felix Held | 153f92a | 2020-12-08 17:27:30 +0100 | [diff] [blame] | 42 | fch_smbus_init(); |
| 43 | fch_enable_cf9_io(); |
| 44 | fch_enable_legacy_io(); |
Raul E Rangel | b825acb | 2021-02-24 16:21:00 -0700 | [diff] [blame] | 45 | fch_disable_legacy_dma_io(); |
Felix Held | 62ef88f | 2020-12-08 23:18:19 +0100 | [diff] [blame] | 46 | enable_aoac_devices(); |
Felix Held | 8a3d4d5 | 2021-01-13 03:06:21 +0100 | [diff] [blame] | 47 | |
| 48 | /* |
| 49 | * On reset Range_0 defaults to enabled. We want to start with a clean |
| 50 | * slate to not have things unexpectedly enabled. |
| 51 | */ |
| 52 | clear_uart_legacy_config(); |
| 53 | |
| 54 | if (CONFIG(AMD_SOC_CONSOLE_UART)) |
| 55 | set_uart_config(CONFIG_UART_FOR_CONSOLE); |
Felix Held | 27b295b | 2021-03-25 01:20:41 +0100 | [diff] [blame] | 56 | |
| 57 | /* disable the keyboard reset function before mainboard GPIO setup */ |
| 58 | if (CONFIG(DISABLE_KEYBOARD_RESET_PIN)) |
| 59 | fch_disable_kb_rst(); |
Felix Held | 153f92a | 2020-12-08 17:27:30 +0100 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | /* After console init */ |
| 63 | void fch_early_init(void) |
| 64 | { |
Felix Held | 8db77d7 | 2021-08-30 18:20:34 +0200 | [diff] [blame] | 65 | reset_i2c_peripherals(); |
Karthikeyan Ramasubramanian | f62bbc8 | 2021-03-30 15:19:12 -0600 | [diff] [blame] | 66 | pm_set_power_failure_state(); |
Felix Held | 153f92a | 2020-12-08 17:27:30 +0100 | [diff] [blame] | 67 | fch_print_pmxc0_status(); |
Zheng Bao | 7b13e4e | 2021-03-16 16:13:56 +0800 | [diff] [blame] | 68 | i2c_soc_early_init(); |
Martin Roth | fd078d8 | 2021-08-11 13:27:45 -0600 | [diff] [blame] | 69 | show_spi_speeds_and_modes(); |
Zheng Bao | 9194760 | 2021-01-27 15:47:58 +0800 | [diff] [blame] | 70 | |
Raul E Rangel | 95b3dc3 | 2021-03-24 16:53:37 -0600 | [diff] [blame] | 71 | if (CONFIG(DISABLE_SPI_FLASH_ROM_SHARING)) |
| 72 | lpc_disable_spi_rom_sharing(); |
Felix Held | 153f92a | 2020-12-08 17:27:30 +0100 | [diff] [blame] | 73 | } |