blob: a9aec09df0377aa6279b46c26cf59aa4e7262cd2 [file] [log] [blame]
Felix Held3c44c622022-01-10 20:57:29 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
3/* TODO: Check if this is still correct */
4
5#include <amdblocks/acpimmio.h>
Felix Heldba35f352022-10-18 20:43:00 +02006#include <amdblocks/aoac.h>
Felix Held3c44c622022-01-10 20:57:29 +01007#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 Roth300338f2022-10-14 14:55:25 -060012#include <amdblocks/stb.h>
Felix Held8ebdbbc2022-10-18 20:52:42 +020013#include <amdblocks/uart.h>
Felix Held3c44c622022-01-10 20:57:29 +010014#include <soc/i2c.h>
15#include <soc/southbridge.h>
16#include <soc/uart.h>
17
18#include "chip.h"
19
Felix Held3c44c622022-01-10 20:57:29 +010020/* Before console init */
21void 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 Ramasubramanian1527a122022-08-12 12:14:38 -060029 /* 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 Held3c44c622022-01-10 20:57:29 +010032 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 Held3c44c622022-01-10 20:57:29 +010040
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 */
56void fch_early_init(void)
57{
Martin Roth300338f2022-10-14 14:55:25 -060058 if (CONFIG(WRITE_STB_BUFFER_TO_CONSOLE))
59 write_stb_to_console();
60
Felix Held8db77d72021-08-30 18:20:34 +020061 reset_i2c_peripherals();
Felix Held3c44c622022-01-10 20:57:29 +010062 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}