[SRU][J:linux-bluefield][PATCH v1 1/4] Revert "UBUNTU: SAUCE: i2c-mlxbf: Repeated start support"
Chris Babroski
cbabroski at nvidia.com
Wed Aug 6 18:03:11 UTC 2025
BugLink: https://bugs.launchpad.net/bugs/2119651
This reverts commit b0770ba4a9b7ae94b85d0f5f29e752c402158a1b.
Signed-off-by: Chris Babroski <cbabroski at nvidia.com>
---
drivers/i2c/busses/i2c-mlxbf.c | 77 ++++++++++++++--------------------
1 file changed, 32 insertions(+), 45 deletions(-)
diff --git a/drivers/i2c/busses/i2c-mlxbf.c b/drivers/i2c/busses/i2c-mlxbf.c
index 9014fd1c39f0..27caa4711acc 100644
--- a/drivers/i2c/busses/i2c-mlxbf.c
+++ b/drivers/i2c/busses/i2c-mlxbf.c
@@ -1,7 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
-// SPDX-FileCopyrightText: Copyright (c) 2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
-
-/* Mellanox BlueField I2C bus driver */
+/*
+ * Mellanox BlueField I2C bus driver
+ *
+ * Copyright (C) 2020 Mellanox Technologies, Ltd.
+ */
#include <linux/acpi.h>
#include <linux/bitfield.h>
@@ -196,7 +198,6 @@
#define MLXBF_I2C_MASK_8 GENMASK(7, 0)
#define MLXBF_I2C_MASK_16 GENMASK(15, 0)
-#define MLXBF_I2C_MASK_32 GENMASK(31, 0)
#define MLXBF_I2C_MST_ADDR_OFFSET 0x200
@@ -222,7 +223,8 @@
#define MLXBF_I2C_MASTER_STOP_BIT BIT(3) /* Control stop. */
#define MLXBF_I2C_MASTER_ENABLE \
- (MLXBF_I2C_MASTER_LOCK_BIT | MLXBF_I2C_MASTER_BUSY_BIT | MLXBF_I2C_MASTER_START_BIT)
+ (MLXBF_I2C_MASTER_LOCK_BIT | MLXBF_I2C_MASTER_BUSY_BIT | \
+ MLXBF_I2C_MASTER_START_BIT | MLXBF_I2C_MASTER_STOP_BIT)
#define MLXBF_I2C_MASTER_ENABLE_WRITE \
(MLXBF_I2C_MASTER_ENABLE | MLXBF_I2C_MASTER_CTL_WRITE_BIT)
@@ -336,7 +338,6 @@ enum {
MLXBF_I2C_F_SMBUS_BLOCK = BIT(5),
MLXBF_I2C_F_SMBUS_PEC = BIT(6),
MLXBF_I2C_F_SMBUS_PROCESS_CALL = BIT(7),
- MLXBF_I2C_F_WRITE_WITHOUT_STOP = BIT(8),
};
/* Mellanox BlueField chip type. */
@@ -695,19 +696,16 @@ static void mlxbf_i2c_smbus_read_data(struct mlxbf_i2c_priv *priv,
}
static int mlxbf_i2c_smbus_enable(struct mlxbf_i2c_priv *priv, u8 slave,
- u8 len, u8 block_en, u8 pec_en, bool read, bool no_stop)
+ u8 len, u8 block_en, u8 pec_en, bool read)
{
- u32 command = 0;
+ u32 command;
/* Set Master GW control word. */
- if (!no_stop)
- command |= MLXBF_I2C_MASTER_STOP_BIT;
-
if (read) {
- command |= MLXBF_I2C_MASTER_ENABLE_READ;
+ command = MLXBF_I2C_MASTER_ENABLE_READ;
command |= rol32(len, MLXBF_I2C_MASTER_READ_SHIFT);
} else {
- command |= MLXBF_I2C_MASTER_ENABLE_WRITE;
+ command = MLXBF_I2C_MASTER_ENABLE_WRITE;
command |= rol32(len, MLXBF_I2C_MASTER_WRITE_SHIFT);
}
command |= rol32(slave, MLXBF_I2C_MASTER_SLV_ADDR_SHIFT);
@@ -742,11 +740,9 @@ mlxbf_i2c_smbus_start_transaction(struct mlxbf_i2c_priv *priv,
u8 op_idx, data_idx, data_len, write_len, read_len;
struct mlxbf_i2c_smbus_operation *operation;
u8 read_en, write_en, block_en, pec_en;
- bool write_wo_stop = false;
- u8 slave, addr;
+ u8 slave, flags, addr;
u8 *read_buf;
int ret = 0;
- u32 flags;
if (request->operation_cnt > MLXBF_I2C_SMBUS_MAX_OP_CNT)
return -EINVAL;
@@ -805,16 +801,7 @@ mlxbf_i2c_smbus_start_transaction(struct mlxbf_i2c_priv *priv,
memcpy(data_desc + data_idx,
operation->buffer, operation->length);
data_idx += operation->length;
-
- /*
- * The stop condition can be skipped when writing on the bus
- * to implement a repeated start condition on the next read
- * as required for several SMBus and I2C operations.
- */
- if (flags & MLXBF_I2C_F_WRITE_WITHOUT_STOP)
- write_wo_stop = true;
}
-
/*
* We assume that read operations are performed only once per
* SMBus transaction. *TBD* protect this statement so it won't
@@ -840,7 +827,7 @@ mlxbf_i2c_smbus_start_transaction(struct mlxbf_i2c_priv *priv,
if (write_en) {
ret = mlxbf_i2c_smbus_enable(priv, slave, write_len, block_en,
- pec_en, 0, write_wo_stop);
+ pec_en, 0);
if (ret)
goto out_unlock;
}
@@ -850,7 +837,7 @@ mlxbf_i2c_smbus_start_transaction(struct mlxbf_i2c_priv *priv,
mlxbf_i2c_smbus_write_data(priv, (const u8 *)&addr, 1,
MLXBF_I2C_MASTER_DATA_DESC_ADDR, true);
ret = mlxbf_i2c_smbus_enable(priv, slave, read_len, block_en,
- pec_en, 1, false);
+ pec_en, 1);
if (!ret) {
/* Get Master GW data descriptor. */
mlxbf_i2c_smbus_read_data(priv, data_desc, read_len + 1,
@@ -955,9 +942,6 @@ mlxbf_i2c_smbus_i2c_block_func(struct mlxbf_i2c_smbus_request *request,
request->operation[0].flags |= pec_check ? MLXBF_I2C_F_SMBUS_PEC : 0;
request->operation[0].buffer = command;
- if (read)
- request->operation[0].flags |= MLXBF_I2C_F_WRITE_WITHOUT_STOP;
-
/*
* As specified in the standard, the max number of bytes to read/write
* per block operation is 32 bytes. In Golan code, the controller can
@@ -1198,8 +1182,7 @@ static void mlxbf_i2c_set_timings(struct mlxbf_i2c_priv *priv,
MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_16);
writel(timer, priv->timer->io + MLXBF_I2C_SMBUS_THIGH_MAX_TBUF);
- timer = mlxbf_i2c_set_timer(priv, timings->timeout, false,
- MLXBF_I2C_MASK_32, MLXBF_I2C_SHIFT_0);
+ timer = timings->timeout;
writel(timer, priv->timer->io + MLXBF_I2C_SMBUS_SCL_LOW_TIMEOUT);
}
@@ -1209,7 +1192,11 @@ enum mlxbf_i2c_timings_config {
MLXBF_I2C_TIMING_CONFIG_1000KHZ,
};
-/* Timing values are in nanoseconds */
+/*
+ * Note that the mlxbf_i2c_timings->timeout value is not related to the
+ * bus frequency, it is impacted by the time it takes the driver to
+ * complete data transmission before transaction abort.
+ */
static const struct mlxbf_i2c_timings mlxbf_i2c_timings[] = {
[MLXBF_I2C_TIMING_CONFIG_100KHZ] = {
.scl_high = 4810,
@@ -1224,8 +1211,8 @@ static const struct mlxbf_i2c_timings mlxbf_i2c_timings[] = {
.scl_fall = 50,
.hold_data = 300,
.buf = 20000,
- .thigh_max = 50000,
- .timeout = 35000000
+ .thigh_max = 5000,
+ .timeout = 106500
},
[MLXBF_I2C_TIMING_CONFIG_400KHZ] = {
.scl_high = 1011,
@@ -1240,24 +1227,24 @@ static const struct mlxbf_i2c_timings mlxbf_i2c_timings[] = {
.scl_fall = 50,
.hold_data = 300,
.buf = 20000,
- .thigh_max = 50000,
- .timeout = 35000000
+ .thigh_max = 5000,
+ .timeout = 106500
},
[MLXBF_I2C_TIMING_CONFIG_1000KHZ] = {
- .scl_high = 383,
- .scl_low = 460,
+ .scl_high = 600,
+ .scl_low = 1300,
.hold_start = 600,
- .setup_start = 260,
- .setup_stop = 260,
- .setup_data = 50,
+ .setup_start = 600,
+ .setup_stop = 600,
+ .setup_data = 100,
.sda_rise = 50,
.sda_fall = 50,
.scl_rise = 50,
.scl_fall = 50,
.hold_data = 300,
- .buf = 500,
- .thigh_max = 50000,
- .timeout = 35000000
+ .buf = 20000,
+ .thigh_max = 5000,
+ .timeout = 106500
}
};
--
2.34.1
More information about the kernel-team
mailing list