Felix Held | 187f59a | 2020-12-08 02:25:05 +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> |
Felix Held | 187f59a | 2020-12-08 02:25:05 +0100 | [diff] [blame] | 5 | #include <amdblocks/espi.h> |
Karthikeyan Ramasubramanian | 0dbea48 | 2021-03-08 23:23:50 -0700 | [diff] [blame] | 6 | #include <amdblocks/i2c.h> |
Felix Held | 187f59a | 2020-12-08 02:25:05 +0100 | [diff] [blame] | 7 | #include <amdblocks/lpc.h> |
Felix Held | bbb8c04 | 2021-04-13 19:36:53 +0200 | [diff] [blame] | 8 | #include <amdblocks/pmlib.h> |
Felix Held | 187f59a | 2020-12-08 02:25:05 +0100 | [diff] [blame] | 9 | #include <amdblocks/smbus.h> |
| 10 | #include <amdblocks/spi.h> |
Felix Held | 8ebdbbc | 2022-10-18 20:52:42 +0200 | [diff] [blame] | 11 | #include <amdblocks/uart.h> |
Felix Held | 187f59a | 2020-12-08 02:25:05 +0100 | [diff] [blame] | 12 | #include <soc/i2c.h> |
| 13 | #include <soc/southbridge.h> |
| 14 | #include <soc/uart.h> |
| 15 | #include <types.h> |
| 16 | |
Karthikeyan Ramasubramanian | 0dbea48 | 2021-03-08 23:23:50 -0700 | [diff] [blame] | 17 | #include "chip.h" |
| 18 | |
Felix Held | 187f59a | 2020-12-08 02:25:05 +0100 | [diff] [blame] | 19 | static void lpc_configure_decodes(void) |
| 20 | { |
| 21 | if (CONFIG(POST_IO) && (CONFIG_POST_IO_PORT == 0x80)) |
| 22 | lpc_enable_port80(); |
| 23 | } |
| 24 | |
| 25 | /* Before console init */ |
| 26 | void fch_pre_init(void) |
| 27 | { |
Felix Held | 425e73d | 2021-09-20 16:31:33 +0200 | [diff] [blame] | 28 | /* Enable_acpimmio_decode_pm04 to enable the ACPIMMIO decode which is needed to access |
| 29 | the GPIO registers. */ |
| 30 | enable_acpimmio_decode_pm04(); |
Karthikeyan Ramasubramanian | 2d17ea4 | 2021-10-05 13:57:30 -0600 | [diff] [blame] | 31 | /* Setup SPI base by calling lpc_early_init before setting up eSPI. */ |
Felix Held | 187f59a | 2020-12-08 02:25:05 +0100 | [diff] [blame] | 32 | lpc_early_init(); |
Felix Held | 4e379a2 | 2021-10-14 21:43:11 +0200 | [diff] [blame] | 33 | |
| 34 | /* Setup eSPI to enable port80 routing if the board is using eSPI and the eSPI |
| 35 | interface hasn't already been set up in verstage on PSP */ |
| 36 | if (CONFIG(SOC_AMD_COMMON_BLOCK_USE_ESPI) && !CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) |
| 37 | configure_espi_with_mb_hook(); |
Felix Held | 187f59a | 2020-12-08 02:25:05 +0100 | [diff] [blame] | 38 | |
| 39 | if (!CONFIG(SOC_AMD_COMMON_BLOCK_USE_ESPI)) |
| 40 | lpc_configure_decodes(); |
| 41 | |
| 42 | fch_spi_early_init(); |
Felix Held | 187f59a | 2020-12-08 02:25:05 +0100 | [diff] [blame] | 43 | fch_smbus_init(); |
| 44 | fch_enable_cf9_io(); |
| 45 | fch_enable_legacy_io(); |
| 46 | enable_aoac_devices(); |
Felix Held | 187f59a | 2020-12-08 02:25:05 +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 | |
Felix Held | 0dfaf33 | 2020-12-09 16:25:18 +0100 | [diff] [blame] | 54 | if (CONFIG(AMD_SOC_CONSOLE_UART)) |
Felix Held | 187f59a | 2020-12-08 02:25:05 +0100 | [diff] [blame] | 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 | 187f59a | 2020-12-08 02:25:05 +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(); |
Felix Held | bbb8c04 | 2021-04-13 19:36:53 +0200 | [diff] [blame] | 66 | pm_set_power_failure_state(); |
Felix Held | 187f59a | 2020-12-08 02:25:05 +0100 | [diff] [blame] | 67 | fch_print_pmxc0_status(); |
| 68 | i2c_soc_early_init(); |
Martin Roth | fd078d8 | 2021-08-11 13:27:45 -0600 | [diff] [blame] | 69 | show_spi_speeds_and_modes(); |
Felix Held | 187f59a | 2020-12-08 02:25:05 +0100 | [diff] [blame] | 70 | |
| 71 | if (CONFIG(DISABLE_SPI_FLASH_ROM_SHARING)) |
| 72 | lpc_disable_spi_rom_sharing(); |
Felix Held | 187f59a | 2020-12-08 02:25:05 +0100 | [diff] [blame] | 73 | } |