Skip to content

Commit ba11dc8

Browse files
GTLin08nashif
authored andcommitted
ITE: drivers/i2c: Add the property of I2C data hold time
Add a property to adjust the I2C data hold time which will pass the SI test. Signed-off-by: Tim Lin <[email protected]>
1 parent 1d128f1 commit ba11dc8

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

drivers/i2c/i2c_ite_enhance.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ struct i2c_enhance_config {
7171
/* I2C alternate configuration */
7272
const struct pinctrl_dev_config *pcfg;
7373
uint8_t prescale_scl_low;
74+
uint8_t data_hold_time;
7475
uint32_t clock_gate_offset;
7576
bool target_enable;
7677
bool target_pio_mode;
@@ -1145,6 +1146,7 @@ static int i2c_enhance_init(const struct device *dev)
11451146
struct i2c_enhance_data *data = dev->data;
11461147
const struct i2c_enhance_config *config = dev->config;
11471148
uint8_t *base = config->base;
1149+
uint8_t data_hold_time = config->data_hold_time;
11481150
uint32_t bitrate_cfg;
11491151
int error, status;
11501152

@@ -1196,6 +1198,10 @@ static int i2c_enhance_init(const struct device *dev)
11961198
(IT8XXX2_SMB_SMB45CHS &= ~GENMASK(6, 4));
11971199
}
11981200

1201+
/* Set I2C data hold time. */
1202+
IT8XXX2_I2C_DHTR(base) = (IT8XXX2_I2C_DHTR(base) & ~GENMASK(2, 0)) |
1203+
(data_hold_time - 3);
1204+
11991205
/* Set clock frequency for I2C ports */
12001206
if (config->bitrate == I2C_BITRATE_STANDARD ||
12011207
config->bitrate == I2C_BITRATE_FAST ||
@@ -1453,6 +1459,7 @@ BUILD_ASSERT(IS_ENABLED(CONFIG_I2C_TARGET_BUFFER_MODE),
14531459
.scl_gpios = GPIO_DT_SPEC_INST_GET(inst, scl_gpios), \
14541460
.sda_gpios = GPIO_DT_SPEC_INST_GET(inst, sda_gpios), \
14551461
.prescale_scl_low = DT_INST_PROP_OR(inst, prescale_scl_low, 0), \
1462+
.data_hold_time = DT_INST_PROP_OR(inst, data_hold_time, 0), \
14561463
.clock_gate_offset = DT_INST_PROP(inst, clock_gate_offset), \
14571464
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
14581465
.target_enable = DT_INST_PROP(inst, target_enable), \

dts/bindings/i2c/ite,enhance-i2c.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ properties:
1818
SCL cycle = 2 * (psr + prescale_tweak + 2) *
1919
SMBus clock cycle
2020
21+
data-hold-time:
22+
type: int
23+
default: 3
24+
enum:
25+
- 3
26+
- 4
27+
- 5
28+
- 6
29+
- 7
30+
- 8
31+
- 9
32+
- 10
33+
description: |
34+
This option is used to configure the data hold time of the I2C.
35+
The unit is number of SMB clock cycles. The time calculation
36+
is (data-hold-time / smb_clk) seconds.
37+
2138
target-enable:
2239
type: boolean
2340
description: |

0 commit comments

Comments
 (0)