blob: 9e99da227dca0884513c42c34bf02d23051d6f3f [file] [log] [blame]
Felix Held153f92a2020-12-08 17:27:30 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <amdblocks/acpimmio.h>
Felix Heldba35f352022-10-18 20:43:00 +02004#include <amdblocks/aoac.h>
Zheng Bao91947602021-01-27 15:47:58 +08005#include <amdblocks/espi.h>
Zheng Baob0f00ed2021-03-16 15:28:49 +08006#include <amdblocks/i2c.h>
Karthikeyan Ramasubramanianf62bbc82021-03-30 15:19:12 -06007#include <amdblocks/lpc.h>
8#include <amdblocks/pmlib.h>
9#include <amdblocks/smbus.h>
Felix Held8ebdbbc2022-10-18 20:52:42 +020010#include <amdblocks/uart.h>
Zheng Baob0f00ed2021-03-16 15:28:49 +080011#include <soc/i2c.h>
Felix Held153f92a2020-12-08 17:27:30 +010012#include <soc/southbridge.h>
Felix Held8a3d4d52021-01-13 03:06:21 +010013#include <soc/uart.h>
Felix Held153f92a2020-12-08 17:27:30 +010014
Zheng Baob0f00ed2021-03-16 15:28:49 +080015#include "chip.h"
16
Zheng Baob0f00ed2021-03-16 15:28:49 +080017
Jeremy Sollere14e66b2021-11-09 15:21:45 -070018static void lpc_configure_decodes(void)
19{
20 if (CONFIG(POST_IO) && (CONFIG_POST_IO_PORT == 0x80))
21 lpc_enable_port80();
22}
23
Felix Held153f92a2020-12-08 17:27:30 +010024/* Before console init */
25void fch_pre_init(void)
26{
Felix Held425e73d2021-09-20 16:31:33 +020027 /* Enable_acpimmio_decode_pm04 to enable the ACPIMMIO decode which is needed to access
28 the GPIO registers. */
29 enable_acpimmio_decode_pm04();
Karthikeyan Ramasubramanian2d17ea42021-10-05 13:57:30 -060030 /* Setup SPI base by calling lpc_early_init before setting up eSPI. */
Zheng Bao3da55692021-01-26 18:30:18 +080031 lpc_early_init();
Felix Held4e379a22021-10-14 21:43:11 +020032
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 Sollere14e66b2021-11-09 15:21:45 -070038 if (!CONFIG(SOC_AMD_COMMON_BLOCK_USE_ESPI))
39 lpc_configure_decodes();
40
Karthikeyan Ramasubramanian0032bfa2021-07-28 23:53:20 -060041 fch_spi_early_init();
Felix Held153f92a2020-12-08 17:27:30 +010042 fch_smbus_init();
43 fch_enable_cf9_io();
44 fch_enable_legacy_io();
Raul E Rangelb825acb2021-02-24 16:21:00 -070045 fch_disable_legacy_dma_io();
Felix Held62ef88f2020-12-08 23:18:19 +010046 enable_aoac_devices();
Felix Held8a3d4d52021-01-13 03:06:21 +010047
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 Held27b295b2021-03-25 01:20:41 +010056
57 /* disable the keyboard reset function before mainboard GPIO setup */
58 if (CONFIG(DISABLE_KEYBOARD_RESET_PIN))
59 fch_disable_kb_rst();
Felix Held153f92a2020-12-08 17:27:30 +010060}
61
62/* After console init */
63void fch_early_init(void)
64{
Felix Held8db77d72021-08-30 18:20:34 +020065 reset_i2c_peripherals();
Karthikeyan Ramasubramanianf62bbc82021-03-30 15:19:12 -060066 pm_set_power_failure_state();
Felix Held153f92a2020-12-08 17:27:30 +010067 fch_print_pmxc0_status();
Zheng Bao7b13e4e2021-03-16 16:13:56 +080068 i2c_soc_early_init();
Martin Rothfd078d82021-08-11 13:27:45 -060069 show_spi_speeds_and_modes();
Zheng Bao91947602021-01-27 15:47:58 +080070
Raul E Rangel95b3dc32021-03-24 16:53:37 -060071 if (CONFIG(DISABLE_SPI_FLASH_ROM_SHARING))
72 lpc_disable_spi_rom_sharing();
Felix Held153f92a2020-12-08 17:27:30 +010073}