soc/intel/alderlake: Add ADL-P 4+4 with 28W TDP
[coreboot.git] / src / drivers / i2c / designware / dw_i2c.h
blob464facfeedf46363b8002137d9e2d7a5f0043a25
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef __DRIVERS_I2C_DESIGNWARE_I2C_H__
4 #define __DRIVERS_I2C_DESIGNWARE_I2C_H__
6 #include <device/device.h>
7 #include <device/i2c.h>
8 #include <types.h>
10 #if CONFIG(DRIVERS_I2C_DESIGNWARE_DEBUG)
11 #define DW_I2C_DEBUG BIOS_DEBUG
13 #else
14 #define DW_I2C_DEBUG BIOS_NEVER
16 #endif // CONFIG_DRIVERS_I2C_DESIGNWARE_DEBUG
19 * Timing values are in units of clock period, with the clock speed
20 * provided by the SOC in CONFIG_DRIVERS_I2C_DESIGNWARE_CLOCK_MHZ
21 * Automatic configuration is done based on requested speed, but the
22 * values may need tuned depending on the board and the number of
23 * devices present on the bus.
25 struct dw_i2c_speed_config {
26 enum i2c_speed speed;
27 /* SCL high and low period count */
28 uint16_t scl_lcnt;
29 uint16_t scl_hcnt;
31 * SDA hold time should be 300ns in standard and fast modes
32 * and long enough for deterministic logic level change in
33 * fast-plus and high speed modes.
35 * [15:0] SDA TX Hold Time
36 * [23:16] SDA RX Hold Time
38 uint32_t sda_hold;
42 * This I2C controller has support for 3 independent speed configs but can
43 * support both FAST_PLUS and HIGH speeds through the same set of speed
44 * config registers. These are treated separately so the speed config values
45 * can be provided via ACPI to the OS.
47 #define DW_I2C_SPEED_CONFIG_COUNT 4
49 struct dw_i2c_bus_config {
50 /* Bus should be enabled prior to ramstage with temporary base */
51 int early_init;
52 /* Bus speed in Hz, default is I2C_SPEED_FAST (400 KHz) */
53 enum i2c_speed speed;
54 /* If rise_time_ns is non-zero the calculations for lcnt and hcnt
55 * registers take into account the times of the bus. However, if
56 * there is a match in speed_config those register values take
57 * precedence. */
58 int rise_time_ns;
59 int fall_time_ns;
60 int data_hold_time_ns;
61 /* Specific bus speed configuration */
62 struct dw_i2c_speed_config speed_config[DW_I2C_SPEED_CONFIG_COUNT];
65 /* Functions to be implemented by SoC code */
67 /* Get base address for early init of I2C controllers. */
68 uintptr_t dw_i2c_get_soc_early_base(unsigned int bus);
71 * Map given I2C bus number to devfn.
72 * Return value:
73 * -1 = error
74 * otherwise, devfn(>=0) corresponding to I2C bus number.
76 int dw_i2c_soc_devfn_to_bus(unsigned int devfn);
79 * Map given bus number to a I2C Controller.
80 * Return value:
81 * -1 = error
82 * otherwise, devfn(>=0) corresponding to I2C bus number.
84 int dw_i2c_soc_bus_to_devfn(unsigned int bus);
87 * SoC implemented callback for getting I2C bus configuration.
89 * Returns NULL if i2c config is not found
91 const struct dw_i2c_bus_config *dw_i2c_get_soc_cfg(unsigned int bus);
93 /* Get I2C controller base address */
94 uintptr_t dw_i2c_base_address(unsigned int bus);
97 * Initialize this bus controller and set the speed
99 enum cb_err dw_i2c_init(unsigned int bus, const struct dw_i2c_bus_config *bcfg);
102 * Generate speed config based on clock
104 enum cb_err dw_i2c_gen_speed_config(uintptr_t dw_i2c_addr,
105 enum i2c_speed speed,
106 const struct dw_i2c_bus_config *bcfg,
107 struct dw_i2c_speed_config *config);
110 * Map an i2c host controller device to a logical bus number.
111 * Return value:
112 * -1 = failure
113 * >=0 = logical bus number
115 int dw_i2c_soc_dev_to_bus(const struct device *dev);
118 * Common device_operations implementation to initialize the i2c host
119 * controller.
121 void dw_i2c_dev_init(struct device *dev);
124 * Common device_operations implementation to fill ACPI SSDT table for i2c
125 * host controller.
127 void dw_i2c_acpi_fill_ssdt(const struct device *dev);
130 * Common device_operations implementation for i2c host controller ops.
132 extern const struct i2c_bus_operations dw_i2c_bus_ops;
134 #endif /* __DRIVERS_I2C_DESIGNWARE_I2C_H__ */