From: ende.tan@starfivetech.com
To: linux-i2c@vger.kernel.org
Cc: jarkko.nikula@linux.intel.com, andriy.shevchenko@linux.intel.com,
mika.westerberg@linux.intel.com, jsd@semihalf.com,
andi.shyti@kernel.org, linux-kernel@vger.kernel.org,
leyfoon.tan@starfivetech.com, endeneer@gmail.com,
Tan En De <ende.tan@starfivetech.com>
Subject: [v2,1/1] i2c: designware: Add SMBus Quick Command support
Date: Sat, 12 Apr 2025 17:34:14 +0800 [thread overview]
Message-ID: <20250412093414.39351-1-ende.tan@starfivetech.com> (raw)
From: Tan En De <ende.tan@starfivetech.com>
Add support for SMBus Quick Read and Quick Write commands.
Signed-off-by: Tan En De <ende.tan@starfivetech.com>
---
v1 -> v2: Removed redundant check of tx_limit and rx_limit
---
drivers/i2c/busses/i2c-designware-core.h | 4 ++++
drivers/i2c/busses/i2c-designware-master.c | 18 +++++++++++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index 347843b4f5dd..91f17181ece1 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -40,6 +40,8 @@
#define DW_IC_DATA_CMD_DAT GENMASK(7, 0)
#define DW_IC_DATA_CMD_FIRST_DATA_BYTE BIT(11)
+#define DW_IC_DATA_CMD_STOP BIT(9)
+#define DW_IC_DATA_CMD_CMD BIT(8)
/*
* Registers offset
@@ -123,7 +125,9 @@
#define DW_IC_ERR_TX_ABRT 0x1
+#define DW_IC_TAR_SMBUS_QUICK_CMD BIT(16)
#define DW_IC_TAR_10BITADDR_MASTER BIT(12)
+#define DW_IC_TAR_SPECIAL BIT(11)
#define DW_IC_COMP_PARAM_1_SPEED_MODE_HIGH (BIT(2) | BIT(3))
#define DW_IC_COMP_PARAM_1_SPEED_MODE_MASK GENMASK(3, 2)
diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index c5394229b77f..a67add117e44 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -268,6 +268,10 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
regmap_update_bits(dev->map, DW_IC_CON, DW_IC_CON_10BITADDR_MASTER,
ic_con);
+ /* i2c-core-smbus.c: Only I2C_SMBUS_QUICK has msg[0].len = 0 */
+ if (dev->msgs[0].len == 0)
+ ic_tar |= DW_IC_TAR_SMBUS_QUICK_CMD | DW_IC_TAR_SPECIAL;
+
/*
* Set the slave (target) address and enable 10-bit addressing mode
* if applicable.
@@ -474,6 +478,16 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
regmap_read(dev->map, DW_IC_RXFLR, &flr);
rx_limit = dev->rx_fifo_depth - flr;
+ /* i2c-core-smbus.c: Only I2C_SMBUS_QUICK has msg[0].len = 0 */
+ if (buf_len == 0) {
+ regmap_write(
+ dev->map, DW_IC_DATA_CMD,
+ *buf | DW_IC_DATA_CMD_STOP |
+ ((msgs[dev->msg_write_idx].flags & I2C_M_RD) ?
+ DW_IC_DATA_CMD_CMD : 0)
+ );
+ }
+
while (buf_len > 0 && tx_limit > 0 && rx_limit > 0) {
u32 cmd = 0;
@@ -919,7 +933,9 @@ void i2c_dw_configure_master(struct dw_i2c_dev *dev)
{
struct i2c_timings *t = &dev->timings;
- dev->functionality = I2C_FUNC_10BIT_ADDR | DW_IC_DEFAULT_FUNCTIONALITY;
+ dev->functionality = I2C_FUNC_10BIT_ADDR |
+ I2C_FUNC_SMBUS_QUICK |
+ DW_IC_DEFAULT_FUNCTIONALITY;
dev->master_cfg = DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
DW_IC_CON_RESTART_EN;
--
2.34.1
next reply other threads:[~2025-04-12 10:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-12 9:34 ende.tan [this message]
2025-04-14 6:55 ` [v2,1/1] i2c: designware: Add SMBus Quick Command support Andy Shevchenko
2025-04-14 8:43 ` Wolfram Sang
2025-04-14 9:02 ` Wolfram Sang
2025-04-14 9:18 ` Jarkko Nikula
2025-04-14 14:16 ` Jarkko Nikula
2025-04-20 3:44 ` EnDe Tan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250412093414.39351-1-ende.tan@starfivetech.com \
--to=ende.tan@starfivetech.com \
--cc=andi.shyti@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=endeneer@gmail.com \
--cc=jarkko.nikula@linux.intel.com \
--cc=jsd@semihalf.com \
--cc=leyfoon.tan@starfivetech.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).