blob: fdfa17aad30ea7dc8661c0caaa14e34f8e019c0b [file] [log] [blame]
Felix Held153f92a2020-12-08 17:27:30 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <amdblocks/acpimmio.h>
Zheng Bao91947602021-01-27 15:47:58 +08004#include <amdblocks/espi.h>
Zheng Baob0f00ed2021-03-16 15:28:49 +08005#include <amdblocks/i2c.h>
Karthikeyan Ramasubramanianf62bbc82021-03-30 15:19:12 -06006#include <amdblocks/lpc.h>
7#include <amdblocks/pmlib.h>
8#include <amdblocks/smbus.h>
Felix Held153f92a2020-12-08 17:27:30 +01009#include <console/console.h>
Zheng Baob0f00ed2021-03-16 15:28:49 +080010#include <soc/i2c.h>
Felix Held153f92a2020-12-08 17:27:30 +010011#include <soc/southbridge.h>
Felix Held8a3d4d52021-01-13 03:06:21 +010012#include <soc/uart.h>
Felix Held153f92a2020-12-08 17:27:30 +010013
Zheng Baob0f00ed2021-03-16 15:28:49 +080014#include "chip.h"
15
16/* This table is for the initial conversion of all SCL pins to input with no pull. */
17static const struct soc_i2c_scl_pin i2c_scl_pins[] = {
18 { PAD_GPI(I2C0_SCL_PIN, PULL_NONE), GPIO_I2C0_SCL },
19 { PAD_GPI(I2C1_SCL_PIN, PULL_NONE), GPIO_I2C1_SCL },
20 { PAD_GPI(I2C2_SCL_PIN, PULL_NONE), GPIO_I2C2_SCL },
21 { PAD_GPI(I2C3_SCL_PIN, PULL_NONE), GPIO_I2C3_SCL },
22};
23
24static void reset_i2c_peripherals(void)
25{
26 const struct soc_amd_cezanne_config *cfg = config_of_soc();
27 struct soc_i2c_peripheral_reset_info reset_info;
28
29 reset_info.i2c_scl_reset_mask = cfg->i2c_scl_reset & GPIO_I2C_MASK;
30 reset_info.i2c_scl = i2c_scl_pins;
31 reset_info.num_pins = ARRAY_SIZE(i2c_scl_pins);
32 sb_reset_i2c_peripherals(&reset_info);
33}
34
Felix Held153f92a2020-12-08 17:27:30 +010035/* Before console init */
36void fch_pre_init(void)
37{
Zheng Bao3da55692021-01-26 18:30:18 +080038 lpc_early_init();
39
Felix Held153f92a2020-12-08 17:27:30 +010040 enable_acpimmio_decode_pm04();
41 fch_smbus_init();
42 fch_enable_cf9_io();
43 fch_enable_legacy_io();
Raul E Rangelb825acb2021-02-24 16:21:00 -070044 fch_disable_legacy_dma_io();
Felix Held62ef88f2020-12-08 23:18:19 +010045 enable_aoac_devices();
Zheng Baob0f00ed2021-03-16 15:28:49 +080046 reset_i2c_peripherals();
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{
Karthikeyan Ramasubramanianf62bbc82021-03-30 15:19:12 -060065 pm_set_power_failure_state();
Felix Held153f92a2020-12-08 17:27:30 +010066 fch_print_pmxc0_status();
Zheng Bao7b13e4e2021-03-16 16:13:56 +080067 i2c_soc_early_init();
Zheng Bao91947602021-01-27 15:47:58 +080068
Raul E Rangel95b3dc32021-03-24 16:53:37 -060069 if (CONFIG(DISABLE_SPI_FLASH_ROM_SHARING))
70 lpc_disable_spi_rom_sharing();
71
Raul E Rangelb95f8482021-04-02 13:47:09 -060072 if (CONFIG(SOC_AMD_COMMON_BLOCK_USE_ESPI))
Zheng Bao91947602021-01-27 15:47:58 +080073 espi_setup();
Felix Held153f92a2020-12-08 17:27:30 +010074}