blob: f7adbecadf761ef6e54ac4760528344d75441577 [file] [log] [blame]
Angel Ponsae593872020-04-04 18:50:57 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Chris Ching6fc39d42017-12-20 16:06:03 -07002
Marshall Dawsonf42344a2019-05-02 12:53:00 -06003#include <amdblocks/acpimmio.h>
Karthikeyan Ramasubramanian0dbea482021-03-08 23:23:50 -07004#include <amdblocks/i2c.h>
Chris Ching6fc39d42017-12-20 16:06:03 -07005#include <soc/iomap.h>
Marshall Dawsonf42344a2019-05-02 12:53:00 -06006#include <soc/i2c.h>
Justin TerAvest13101a72018-01-24 14:23:12 -07007#include "chip.h"
Zheng Bao533fc4d2021-10-30 21:31:04 +08008#include <drivers/i2c/designware/dw_i2c.h>
Justin TerAvest13101a72018-01-24 14:23:12 -07009
Fred Reitberger13831222022-10-17 11:49:55 -040010/* Table to switch SCL pins to outputs to initially reset the I2C peripherals */
11static 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),
16};
17
Karthikeyan Ramasubramanian4f87ae12021-03-18 23:16:29 -060018static const struct soc_i2c_ctrlr_info i2c_ctrlr[] = {
Felix Heldd1da9572021-10-15 16:29:22 +020019 { I2C_MASTER_MODE, APU_I2C0_BASE, "I2CA" },
20 { I2C_MASTER_MODE, APU_I2C1_BASE, "I2CB" },
21 { I2C_MASTER_MODE, APU_I2C2_BASE, "I2CC" },
22 { I2C_MASTER_MODE, APU_I2C3_BASE, "I2CD" },
Aaron Durbin2b2c65c2018-01-08 10:48:05 -070023};
Chris Ching6fc39d42017-12-20 16:06:03 -070024
Fred Reitberger13831222022-10-17 11:49:55 -040025void reset_i2c_peripherals(void)
26{
27 const struct soc_amd_stoneyridge_config *cfg = config_of_soc();
28 struct soc_i2c_peripheral_reset_info reset_info;
29
30 reset_info.i2c_scl_reset_mask = cfg->i2c_scl_reset & GPIO_I2C_MASK;
31 reset_info.i2c_scl = i2c_scl_pins;
32 reset_info.num_pins = ARRAY_SIZE(i2c_scl_pins);
33 sb_reset_i2c_peripherals(&reset_info);
34}
35
Karthikeyan Ramasubramanian4f87ae12021-03-18 23:16:29 -060036const struct soc_i2c_ctrlr_info *soc_get_i2c_ctrlr_info(size_t *num_ctrlrs)
Chris Ching6fc39d42017-12-20 16:06:03 -070037{
Karthikeyan Ramasubramanian4f87ae12021-03-18 23:16:29 -060038 *num_ctrlrs = ARRAY_SIZE(i2c_ctrlr);
39 return i2c_ctrlr;
Chris Ching6fc39d42017-12-20 16:06:03 -070040}
Justin TerAvest13101a72018-01-24 14:23:12 -070041
Karthikeyan Ramasubramanian4f87ae12021-03-18 23:16:29 -060042const struct dw_i2c_bus_config *soc_get_i2c_bus_config(size_t *num_buses)
Aaron Durbinde3e84c2018-01-29 17:44:58 -070043{
Karthikeyan Ramasubramanian4f87ae12021-03-18 23:16:29 -060044 const struct soc_amd_stoneyridge_config *config = config_of_soc();
Aaron Durbinde3e84c2018-01-29 17:44:58 -070045
Karthikeyan Ramasubramanian4f87ae12021-03-18 23:16:29 -060046 *num_buses = ARRAY_SIZE(config->i2c);
47 return config->i2c;
Justin TerAvest13101a72018-01-24 14:23:12 -070048}
Zheng Bao533fc4d2021-10-30 21:31:04 +080049
50void soc_i2c_misc_init(unsigned int bus, const struct dw_i2c_bus_config *cfg)
51{
52 /* Do nothing. */
53}