Felix Held | 3bdbdb7 | 2022-02-02 22:55:34 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <amdblocks/acpimmio.h> |
| 4 | #include <amdblocks/i2c.h> |
| 5 | #include <console/console.h> |
| 6 | #include <types.h> |
| 7 | #include "i23c_pad_def.h" |
| 8 | |
| 9 | void fch_i23c_pad_init(unsigned int bus, |
| 10 | enum i2c_speed speed, |
| 11 | const struct i2c_pad_control *ctrl) |
| 12 | { |
| 13 | uint32_t pad_ctrl; |
| 14 | |
| 15 | pad_ctrl = misc_read32(MISC_I23C_PAD_CTRL(bus)); |
| 16 | |
| 17 | pad_ctrl &= ~I23C_PAD_CTRL_MODE_I3C_I2C_MASK; |
| 18 | pad_ctrl |= I23C_PAD_CTRL_MODE_I2C; |
| 19 | |
| 20 | switch (ctrl->rx_level) { |
| 21 | case I2C_PAD_RX_NO_CHANGE: |
| 22 | /* Default is enabled and thresholds for 1.8V operation */ |
| 23 | break; |
| 24 | case I2C_PAD_RX_OFF: |
| 25 | pad_ctrl &= ~I23C_PAD_CTRL_RX_SEL_MASK; |
| 26 | pad_ctrl |= I23C_PAD_CTRL_RX_SEL_OFF; |
| 27 | pad_ctrl &= ~I23C_PAD_CTRL_MODE_1_8V_1_1V_MASK; |
| 28 | pad_ctrl |= I23C_PAD_CTRL_MODE_1_8V; |
| 29 | break; |
| 30 | case I2C_PAD_RX_1_8V: |
| 31 | pad_ctrl &= ~I23C_PAD_CTRL_RX_SEL_MASK; |
| 32 | pad_ctrl |= I23C_PAD_CTRL_RX_SEL_ON; |
| 33 | pad_ctrl &= ~I23C_PAD_CTRL_MODE_1_8V_1_1V_MASK; |
| 34 | pad_ctrl |= I23C_PAD_CTRL_MODE_1_8V; |
| 35 | break; |
| 36 | case I2C_PAD_RX_1_1V: |
| 37 | pad_ctrl &= ~I23C_PAD_CTRL_RX_SEL_MASK; |
| 38 | pad_ctrl |= I23C_PAD_CTRL_RX_SEL_ON; |
| 39 | pad_ctrl &= ~I23C_PAD_CTRL_MODE_1_8V_1_1V_MASK; |
| 40 | pad_ctrl |= I23C_PAD_CTRL_MODE_1_1V; |
| 41 | break; |
| 42 | default: |
| 43 | printk(BIOS_WARNING, "Invalid I2C/I3C pad RX level for bus %u\n", bus); |
| 44 | break; |
| 45 | } |
| 46 | |
Felix Held | 3bdbdb7 | 2022-02-02 22:55:34 +0100 | [diff] [blame] | 47 | misc_write32(MISC_I23C_PAD_CTRL(bus), pad_ctrl); |
| 48 | } |