Skip to content

Commit e981364

Browse files
cbabroskiAndi Shyti
authored andcommitted
i2c-mlxbf: Improve I2C bus timing configuration
Update the I2C bus timing configuration on BlueField to match the configuration recommended and verified by the HW team. I2C block read failures were found on BlueField 3 during communication with a device that requires the use of repeated start conditions. Testing showed that these failures were caused by the I2C transaction getting aborted early due to a short bus "timeout" configuration value. This value determines how long the clock can be held low before the I2C transaction is aborted. Upon further inspection, it was also found that other I2C bus timing configuration values used by the kernel driver do not match the configuration that is recommended by the HW team and used in the BlueField BSP I2C drivers. Signed-off-by: Chris Babroski <cbabroski@nvidia.com> Reviewed-by: Asmaa Mnebhi <asmaa@nvidia.com> Reviewed-by: Khalil Blaiech <kblaiech@nvidia.com> Link: https://lore.kernel.org/r/20250506193059.321345-2-cbabroski@nvidia.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
1 parent 6bdc662 commit e981364

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

drivers/i2c/busses/i2c-mlxbf.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198

199199
#define MLXBF_I2C_MASK_8 GENMASK(7, 0)
200200
#define MLXBF_I2C_MASK_16 GENMASK(15, 0)
201+
#define MLXBF_I2C_MASK_32 GENMASK(31, 0)
201202

202203
#define MLXBF_I2C_MST_ADDR_OFFSET 0x200
203204

@@ -1149,7 +1150,8 @@ static void mlxbf_i2c_set_timings(struct mlxbf_i2c_priv *priv,
11491150
MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_16);
11501151
writel(timer, priv->timer->io + MLXBF_I2C_SMBUS_THIGH_MAX_TBUF);
11511152

1152-
timer = timings->timeout;
1153+
timer = mlxbf_i2c_set_timer(priv, timings->timeout, false,
1154+
MLXBF_I2C_MASK_32, MLXBF_I2C_SHIFT_0);
11531155
writel(timer, priv->timer->io + MLXBF_I2C_SMBUS_SCL_LOW_TIMEOUT);
11541156
}
11551157

@@ -1159,11 +1161,7 @@ enum mlxbf_i2c_timings_config {
11591161
MLXBF_I2C_TIMING_CONFIG_1000KHZ,
11601162
};
11611163

1162-
/*
1163-
* Note that the mlxbf_i2c_timings->timeout value is not related to the
1164-
* bus frequency, it is impacted by the time it takes the driver to
1165-
* complete data transmission before transaction abort.
1166-
*/
1164+
/* Timing values are in nanoseconds */
11671165
static const struct mlxbf_i2c_timings mlxbf_i2c_timings[] = {
11681166
[MLXBF_I2C_TIMING_CONFIG_100KHZ] = {
11691167
.scl_high = 4810,
@@ -1178,8 +1176,8 @@ static const struct mlxbf_i2c_timings mlxbf_i2c_timings[] = {
11781176
.scl_fall = 50,
11791177
.hold_data = 300,
11801178
.buf = 20000,
1181-
.thigh_max = 5000,
1182-
.timeout = 106500
1179+
.thigh_max = 50000,
1180+
.timeout = 35000000
11831181
},
11841182
[MLXBF_I2C_TIMING_CONFIG_400KHZ] = {
11851183
.scl_high = 1011,
@@ -1194,24 +1192,24 @@ static const struct mlxbf_i2c_timings mlxbf_i2c_timings[] = {
11941192
.scl_fall = 50,
11951193
.hold_data = 300,
11961194
.buf = 20000,
1197-
.thigh_max = 5000,
1198-
.timeout = 106500
1195+
.thigh_max = 50000,
1196+
.timeout = 35000000
11991197
},
12001198
[MLXBF_I2C_TIMING_CONFIG_1000KHZ] = {
1201-
.scl_high = 600,
1202-
.scl_low = 1300,
1199+
.scl_high = 383,
1200+
.scl_low = 460,
12031201
.hold_start = 600,
1204-
.setup_start = 600,
1205-
.setup_stop = 600,
1206-
.setup_data = 100,
1202+
.setup_start = 260,
1203+
.setup_stop = 260,
1204+
.setup_data = 50,
12071205
.sda_rise = 50,
12081206
.sda_fall = 50,
12091207
.scl_rise = 50,
12101208
.scl_fall = 50,
12111209
.hold_data = 300,
1212-
.buf = 20000,
1213-
.thigh_max = 5000,
1214-
.timeout = 106500
1210+
.buf = 500,
1211+
.thigh_max = 50000,
1212+
.timeout = 35000000
12151213
}
12161214
};
12171215

0 commit comments

Comments
 (0)