| 1 |
|
| 2 |
|
| 3 |
#ifndef AMD_COMMON_BLOCK_I2C_H |
| 4 |
#define AMD_COMMON_BLOCK_I2C_H |
| 5 |
|
| 6 |
#include <amdblocks/gpio.h> |
| 7 |
#include <device/i2c.h> |
| 8 |
#include <drivers/i2c/designware/dw_i2c.h> |
| 9 |
#include <types.h> |
| 10 |
|
| 11 |
|
| 12 |
enum i2c_ctrlr_mode { |
| 13 |
I2C_MASTER_MODE, |
| 14 |
I2C_PERIPHERAL_MODE, |
| 15 |
}; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
struct soc_i2c_ctrlr_info { |
| 23 |
enum i2c_ctrlr_mode mode; |
| 24 |
uintptr_t bar; |
| 25 |
const char *acpi_name; |
| 26 |
}; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
struct soc_i2c_scl_pin { |
| 34 |
struct soc_amd_gpio pin; |
| 35 |
uint8_t pin_mask; |
| 36 |
}; |
| 37 |
|
| 38 |
|
| 39 |
#define I2C_RESET_SCL_PIN(pin_name, pin_mask_value) \ |
| 40 |
{ \ |
| 41 |
.pin = PAD_CFG_STRUCT(pin_name, pin_name ## _IOMUX_GPIOxx, PAD_OUTPUT(HIGH)), \ |
| 42 |
.pin_mask = pin_mask_value, \ |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
struct soc_i2c_peripheral_reset_info { |
| 54 |
uint8_t i2c_scl_reset_mask; |
| 55 |
const struct soc_i2c_scl_pin *i2c_scl; |
| 56 |
size_t num_pins; |
| 57 |
}; |
| 58 |
|
| 59 |
enum i2c_pad_rx_level { |
| 60 |
I2C_PAD_RX_NO_CHANGE, |
| 61 |
I2C_PAD_RX_OFF, |
| 62 |
I2C_PAD_RX_3_3V, |
| 63 |
I2C_PAD_RX_1_8V, |
| 64 |
I2C_PAD_RX_1_1V, |
| 65 |
I3C_PAD_RX_NO_CHANGE, |
| 66 |
I3C_PAD_RX_1_8V, |
| 67 |
I3C_PAD_RX_1_1V, |
| 68 |
}; |
| 69 |
|
| 70 |
struct i2c_pad_control { |
| 71 |
enum i2c_pad_rx_level rx_level; |
| 72 |
}; |
| 73 |
|
| 74 |
struct soc_i3c_ctrlr_info { |
| 75 |
uintptr_t bar; |
| 76 |
const char *acpi_name; |
| 77 |
}; |
| 78 |
|
| 79 |
void fch_i2c_pad_init(unsigned int bus, |
| 80 |
enum i2c_speed speed, |
| 81 |
const struct i2c_pad_control *ctrl); |
| 82 |
|
| 83 |
void fch_i23c_pad_init(unsigned int bus, |
| 84 |
enum i2c_speed speed, |
| 85 |
const struct i2c_pad_control *ctrl); |
| 86 |
|
| 87 |
|
| 88 |
void soc_i2c_misc_init(unsigned int bus, const struct dw_i2c_bus_config *cfg); |
| 89 |
|
| 90 |
|
| 91 |
const struct soc_i2c_ctrlr_info *soc_get_i2c_ctrlr_info(size_t *num_ctrlrs); |
| 92 |
|
| 93 |
|
| 94 |
const struct dw_i2c_bus_config *soc_get_i2c_bus_config(size_t *num_buses); |
| 95 |
|
| 96 |
|
| 97 |
void i2c_soc_early_init(void); |
| 98 |
|
| 99 |
|
| 100 |
void i2c_soc_init(void); |
| 101 |
|
| 102 |
|
| 103 |
void sb_reset_i2c_peripherals(const struct soc_i2c_peripheral_reset_info *reset_info); |
| 104 |
|
| 105 |
|
| 106 |
const struct soc_i3c_ctrlr_info *soc_get_i3c_ctrlr_info(size_t *num_ctrlrs); |
| 107 |
|
| 108 |
#endif |