blob: f504f79176fc76f4f2fc09a2568009a638e4bc81 [file] [log] [blame]
Martin Rothf95a11e2022-10-21 16:43:08 -06001/* SPDX-License-Identifier: GPL-2.0-only */
2
3/* TODO: Update for Glinda */
4
5#include <amdblocks/acpimmio.h>
6#include <amdblocks/aoac.h>
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>
12#include <amdblocks/uart.h>
13#include <soc/i2c.h>
14#include <soc/southbridge.h>
15#include <soc/uart.h>
16
17#include "chip.h"
18
19/* Before console init */
20void fch_pre_init(void)
21{
22 /* Enable_acpimmio_decode_pm04 to enable the ACPIMMIO decode which is needed to access
23 the GPIO registers. */
24 enable_acpimmio_decode_pm04();
25 /* Setup SPI base by calling lpc_early_init before setting up eSPI. */
26 lpc_early_init();
27
28 /* Setup eSPI to enable port80 routing if the board is using eSPI and the eSPI
29 interface hasn't already been set up in verstage on PSP */
30 if (CONFIG(SOC_AMD_COMMON_BLOCK_USE_ESPI) && !CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK))
31 configure_espi_with_mb_hook();
32
33 fch_spi_early_init();
34 fch_smbus_init();
35 fch_enable_cf9_io();
36 fch_enable_legacy_io();
37 fch_disable_legacy_dma_io();
38 enable_aoac_devices();
39
40 /*
41 * On reset Range_0 defaults to enabled. We want to start with a clean
42 * slate to not have things unexpectedly enabled.
43 */
44 clear_uart_legacy_config();
45
46 if (CONFIG(AMD_SOC_CONSOLE_UART))
47 set_uart_config(CONFIG_UART_FOR_CONSOLE);
48
49 /* disable the keyboard reset function before mainboard GPIO setup */
50 if (CONFIG(DISABLE_KEYBOARD_RESET_PIN))
51 fch_disable_kb_rst();
52}
53
54/* After console init */
55void fch_early_init(void)
56{
57 reset_i2c_peripherals();
58 pm_set_power_failure_state();
59 fch_print_pmxc0_status();
60 i2c_soc_early_init();
61 show_spi_speeds_and_modes();
62
63 if (CONFIG(DISABLE_SPI_FLASH_ROM_SHARING))
64 lpc_disable_spi_rom_sharing();
65}