mb/google/brya/var/orisa: Update Type C DisplayPort HPD Configuration
[coreboot2.git] / src / soc / amd / phoenix / i2c.c
blobe069c230d41e3de870a9716766d1b3318eeddf3b
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <amdblocks/i2c.h>
4 #include <console/console.h>
5 #include <soc/i2c.h>
6 #include <soc/southbridge.h>
7 #include <static.h>
8 #include "chip.h"
10 /* Table to switch SCL pins to outputs to initially reset the I2C peripherals */
11 static const struct soc_i2c_scl_pin i2c_scl_pins[] = {
12 I2C_RESET_SCL_PIN(I2C0_SCL_PIN, GPIO_I2C0_SCL),
13 I2C_RESET_SCL_PIN(I2C1_SCL_PIN, GPIO_I2C1_SCL),
14 I2C_RESET_SCL_PIN(I2C2_SCL_PIN, GPIO_I2C2_SCL),
15 I2C_RESET_SCL_PIN(I2C3_SCL_PIN, GPIO_I2C3_SCL),
18 #if ENV_X86
19 static const struct soc_i2c_ctrlr_info i2c_ctrlr[I2C_CTRLR_COUNT] = {
20 { I2C_MASTER_MODE, APU_I2C0_BASE, "I2C0" },
21 { I2C_MASTER_MODE, APU_I2C1_BASE, "I2C1" },
22 { I2C_MASTER_MODE, APU_I2C2_BASE, "I2C2" },
23 { I2C_MASTER_MODE, APU_I2C3_BASE, "I2C3" }
25 #else
26 static struct soc_i2c_ctrlr_info i2c_ctrlr[I2C_CTRLR_COUNT] = {
27 { I2C_MASTER_MODE, 0, "" },
28 { I2C_MASTER_MODE, 0, "" },
29 { I2C_MASTER_MODE, 0, "" },
30 { I2C_MASTER_MODE, 0, "" }
33 void i2c_set_bar(unsigned int bus, uintptr_t bar)
35 if (bus >= ARRAY_SIZE(i2c_ctrlr)) {
36 printk(BIOS_ERR, "i2c index out of bounds: %u.", bus);
37 return;
40 i2c_ctrlr[bus].bar = bar;
42 #endif
44 void reset_i2c_peripherals(void)
46 const struct soc_amd_phoenix_config *cfg = config_of_soc();
47 struct soc_i2c_peripheral_reset_info reset_info;
49 reset_info.i2c_scl_reset_mask = cfg->i2c_scl_reset & GPIO_I2C_MASK;
50 reset_info.i2c_scl = i2c_scl_pins;
51 reset_info.num_pins = ARRAY_SIZE(i2c_scl_pins);
52 sb_reset_i2c_peripherals(&reset_info);
55 void soc_i2c_misc_init(unsigned int bus, const struct dw_i2c_bus_config *cfg)
57 const struct soc_amd_phoenix_config *config = config_of_soc();
59 if (bus >= ARRAY_SIZE(config->i2c_pad))
60 return;
62 fch_i23c_pad_init(bus, cfg->speed, &config->i2c_pad[bus]);
65 const struct soc_i2c_ctrlr_info *soc_get_i2c_ctrlr_info(size_t *num_ctrlrs)
67 *num_ctrlrs = ARRAY_SIZE(i2c_ctrlr);
68 return i2c_ctrlr;
71 const struct dw_i2c_bus_config *soc_get_i2c_bus_config(size_t *num_buses)
73 const struct soc_amd_phoenix_config *config = config_of_soc();
75 *num_buses = ARRAY_SIZE(config->i2c);
76 return config->i2c;