* [PATCH v2 0/3] i3c: dw-i3c: Enable support for dw-i3c controller NACK retry sysfs and DAT restore fix
@ 2025-11-21 6:21 adrianhoyin.ng
2025-11-21 6:21 ` [PATCH v2 1/3] i3c: add sysfs entry for Device NACK Retry count adrianhoyin.ng
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: adrianhoyin.ng @ 2025-11-21 6:21 UTC (permalink / raw)
To: alexandre.belloni, Frank.Li, linux-i3c, linux-kernel; +Cc: adrianhoyin.ng
From: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
This patch series adds a controller-wide sysfs attribute
dev_nack_retry_count for the DesignWare I3C controller, allowing runtime
control of the automatic retry mechanism when a device NACKs. Some I3C
slave devices may temporarily be busy and unable to respond immediately;
automatic retries improve robustness in such cases. Writes are clamped to
the hardware maximum of 3, and the value is applied to all active DAT
entries.
The series also fixes dw_i3c_master_restore_addrs() to preserve existing
DAT entry bits, preventing overwrites during runtime PM resume.
---
changelog:
v1->v2
* Drop dev_nack_retry_cnt binding and device tree changes.
* Update commit message for better clarity.
* Update to use controller wide sysfs attribute that configures
dev_nack_retry_cnt during runtime.
v1 patch link:
https://lore.kernel.org/all/cover.1762245890.git.adrianhoyin.ng@altera.com/
---
Adrian Ng Ho Yin (3):
i3c: add sysfs entry for Device NACK Retry count
i3c: dw: Add sysfs support for Device NACK Retry count
i3c: dw: Preserve DAT entry bits when restoring addresses
Documentation/ABI/testing/sysfs-bus-i3c | 11 ++++
drivers/i3c/master/dw-i3c-master.c | 70 ++++++++++++++++++++++++-
drivers/i3c/master/dw-i3c-master.h | 1 +
3 files changed, 80 insertions(+), 2 deletions(-)
--
2.49.GIT
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/3] i3c: add sysfs entry for Device NACK Retry count
2025-11-21 6:21 [PATCH v2 0/3] i3c: dw-i3c: Enable support for dw-i3c controller NACK retry sysfs and DAT restore fix adrianhoyin.ng
@ 2025-11-21 6:21 ` adrianhoyin.ng
2025-11-21 16:53 ` Frank Li
2025-11-21 6:21 ` [PATCH v2 2/3] i3c: dw: Add sysfs support " adrianhoyin.ng
2025-11-21 6:21 ` [PATCH v2 3/3] i3c: dw: Preserve DAT entry bits when restoring addresses adrianhoyin.ng
2 siblings, 1 reply; 7+ messages in thread
From: adrianhoyin.ng @ 2025-11-21 6:21 UTC (permalink / raw)
To: alexandre.belloni, Frank.Li, linux-i3c, linux-kernel; +Cc: adrianhoyin.ng
From: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
Document sysfs attribute dev_nack_retry_cnt that controls the number of
automatic retries performed by the DesignWare I3C controller when a target
device returns a NACK
Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
---
Documentation/ABI/testing/sysfs-bus-i3c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-bus-i3c b/Documentation/ABI/testing/sysfs-bus-i3c
index c812ab180ff4..d75339330067 100644
--- a/Documentation/ABI/testing/sysfs-bus-i3c
+++ b/Documentation/ABI/testing/sysfs-bus-i3c
@@ -161,3 +161,14 @@ Contact: linux-i3c@vger.kernel.org
Description:
These directories are just symbolic links to
/sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>.
+
+What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>/dev_nack_retry_count
+KernelVersion: 6.18
+Contact: linux-i3c@vger.kernel.org
+Description:
+ Expose the dev_nak_retry_count which controls the number of automatic
+ retries that will be performed by the controller when the target device
+ returns a NACK response. A value of 0 disables the automatic retries. A
+ max value of 3 can be configured.
+
+ Valid values: 0-3
--
2.49.GIT
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] i3c: dw: Add sysfs support for Device NACK Retry count
2025-11-21 6:21 [PATCH v2 0/3] i3c: dw-i3c: Enable support for dw-i3c controller NACK retry sysfs and DAT restore fix adrianhoyin.ng
2025-11-21 6:21 ` [PATCH v2 1/3] i3c: add sysfs entry for Device NACK Retry count adrianhoyin.ng
@ 2025-11-21 6:21 ` adrianhoyin.ng
2025-11-21 17:05 ` Frank Li
2025-11-21 6:21 ` [PATCH v2 3/3] i3c: dw: Preserve DAT entry bits when restoring addresses adrianhoyin.ng
2 siblings, 1 reply; 7+ messages in thread
From: adrianhoyin.ng @ 2025-11-21 6:21 UTC (permalink / raw)
To: alexandre.belloni, Frank.Li, linux-i3c, linux-kernel; +Cc: adrianhoyin.ng
From: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
The DesignWare I3C controller supports automatically retrying transactions
when a device NACKs. This is useful for slave devices that may be
temporarily busy and not ready to respond immediately.
Adds a controller-wide sysfs attribute, dev_nack_retry_count, to read or
adjust the retry count at runtime. Writes are clamped to the hardware
maximum of 3, and the updated value is programmed into all active DAT
entries.
Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
---
drivers/i3c/master/dw-i3c-master.c | 64 ++++++++++++++++++++++++++++++
drivers/i3c/master/dw-i3c-master.h | 1 +
2 files changed, 65 insertions(+)
diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index 9ceedf09c3b6..c43eba615d8a 100644
--- a/drivers/i3c/master/dw-i3c-master.c
+++ b/drivers/i3c/master/dw-i3c-master.c
@@ -204,8 +204,10 @@
#define EXTENDED_CAPABILITY 0xe8
#define SLAVE_CONFIG 0xec
+#define DW_I3C_DEV_NACK_RETRY_CNT_MAX 0x3
#define DEV_ADDR_TABLE_IBI_MDB BIT(12)
#define DEV_ADDR_TABLE_SIR_REJECT BIT(13)
+#define DEV_ADDR_TABLE_DEV_NACK_RETRY_CNT(x) (((x) << 29) & GENMASK(30, 29))
#define DEV_ADDR_TABLE_LEGACY_I2C_DEV BIT(31)
#define DEV_ADDR_TABLE_DYNAMIC_ADDR(x) (((x) << 16) & GENMASK(23, 16))
#define DEV_ADDR_TABLE_STATIC_ADDR(x) ((x) & GENMASK(6, 0))
@@ -295,6 +297,58 @@ to_dw_i3c_master(struct i3c_master_controller *master)
return container_of(master, struct dw_i3c_master, base);
}
+static ssize_t dev_nack_retry_count_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct dw_i3c_master *master = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%u\n", master->dev_nack_retry_cnt);
+}
+
+static ssize_t dev_nack_retry_count_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct dw_i3c_master *master = dev_get_drvdata(dev);
+ unsigned long val;
+ int ret, i;
+ u32 reg;
+
+ ret = kstrtoul(buf, 0, &val);
+ if (ret)
+ return ret;
+
+ if (val > DW_I3C_DEV_NACK_RETRY_CNT_MAX) {
+ dev_warn(dev, "Value %lu exceeds maximum %d, clamping to max\n",
+ val, DW_I3C_DEV_NACK_RETRY_CNT_MAX);
+ val = DW_I3C_DEV_NACK_RETRY_CNT_MAX;
+ }
+
+ master->dev_nack_retry_cnt = val;
+
+ /*
+ * Update DAT entries for all currently attached devices.
+ * We directly iterate through the master's device array.
+ */
+ for (i = 0; i < master->maxdevs; i++) {
+ /* Skip free/empty slots */
+ if (master->free_pos & BIT(i))
+ continue;
+
+ reg = readl(master->regs +
+ DEV_ADDR_TABLE_LOC(master->datstartaddr, i));
+ reg &= ~GENMASK(30, 29);
+ reg |= DEV_ADDR_TABLE_DEV_NACK_RETRY_CNT(val);
+ writel(reg, master->regs +
+ DEV_ADDR_TABLE_LOC(master->datstartaddr, i));
+ }
+
+ return count;
+}
+
+static DEVICE_ATTR_RW(dev_nack_retry_count);
+
static void dw_i3c_master_disable(struct dw_i3c_master *master)
{
writel(readl(master->regs + DEVICE_CTRL) & ~DEV_CTRL_ENABLE,
@@ -1032,6 +1086,7 @@ static int dw_i3c_master_attach_i3c_dev(struct i3c_dev_desc *dev)
data->index = pos;
master->devs[pos].addr = dev->info.dyn_addr ? : dev->info.static_addr;
master->free_pos &= ~BIT(pos);
+ master->dev_nack_retry_cnt = 0;
i3c_dev_set_master_data(dev, data);
writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr),
@@ -1598,6 +1653,12 @@ int dw_i3c_common_probe(struct dw_i3c_master *master,
if (ret)
goto err_disable_pm;
+ dev_set_drvdata(&master->base.dev, master);
+ ret = device_create_file(&master->base.dev, &dev_attr_dev_nack_retry_count);
+ if (ret)
+ dev_warn(&master->base.dev,
+ "Failed to create dev_nack_retry_count sysfs: %d\n", ret);
+
return 0;
err_disable_pm:
@@ -1617,6 +1678,9 @@ void dw_i3c_common_remove(struct dw_i3c_master *master)
cancel_work_sync(&master->hj_work);
i3c_master_unregister(&master->base);
+ device_remove_file(&master->base.dev, &dev_attr_dev_nack_retry_count);
+ dev_set_drvdata(&master->base.dev, NULL);
+
pm_runtime_disable(master->dev);
pm_runtime_set_suspended(master->dev);
pm_runtime_dont_use_autosuspend(master->dev);
diff --git a/drivers/i3c/master/dw-i3c-master.h b/drivers/i3c/master/dw-i3c-master.h
index c5cb695c16ab..c87a0e87bfd9 100644
--- a/drivers/i3c/master/dw-i3c-master.h
+++ b/drivers/i3c/master/dw-i3c-master.h
@@ -51,6 +51,7 @@ struct dw_i3c_master {
u32 i2c_fm_timing;
u32 i2c_fmp_timing;
u32 quirks;
+ u32 dev_nack_retry_cnt;
/*
* Per-device hardware data, used to manage the device address table
* (DAT)
--
2.49.GIT
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] i3c: dw: Preserve DAT entry bits when restoring addresses
2025-11-21 6:21 [PATCH v2 0/3] i3c: dw-i3c: Enable support for dw-i3c controller NACK retry sysfs and DAT restore fix adrianhoyin.ng
2025-11-21 6:21 ` [PATCH v2 1/3] i3c: add sysfs entry for Device NACK Retry count adrianhoyin.ng
2025-11-21 6:21 ` [PATCH v2 2/3] i3c: dw: Add sysfs support " adrianhoyin.ng
@ 2025-11-21 6:21 ` adrianhoyin.ng
2025-11-21 17:10 ` Frank Li
2 siblings, 1 reply; 7+ messages in thread
From: adrianhoyin.ng @ 2025-11-21 6:21 UTC (permalink / raw)
To: alexandre.belloni, Frank.Li, linux-i3c, linux-kernel; +Cc: adrianhoyin.ng
From: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
Update dw_i3c_master_restore_addrs() to preserve existing bits in each
Device Address Table (DAT) entry when restoring addresses. This prevents
overwriting configuration bits during PM runtime resumes.
Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
---
drivers/i3c/master/dw-i3c-master.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index c43eba615d8a..ac3c2d3136d0 100644
--- a/drivers/i3c/master/dw-i3c-master.c
+++ b/drivers/i3c/master/dw-i3c-master.c
@@ -1718,11 +1718,13 @@ static void dw_i3c_master_restore_addrs(struct dw_i3c_master *master)
if (master->free_pos & BIT(pos))
continue;
+ reg_val = readl(master->regs + DEV_ADDR_TABLE_LOC(master->datstartaddr, pos));
+
if (master->devs[pos].is_i2c_addr)
- reg_val = DEV_ADDR_TABLE_LEGACY_I2C_DEV |
+ reg_val |= DEV_ADDR_TABLE_LEGACY_I2C_DEV |
DEV_ADDR_TABLE_STATIC_ADDR(master->devs[pos].addr);
else
- reg_val = DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr);
+ reg_val |= DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr);
writel(reg_val, master->regs + DEV_ADDR_TABLE_LOC(master->datstartaddr, pos));
}
--
2.49.GIT
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/3] i3c: add sysfs entry for Device NACK Retry count
2025-11-21 6:21 ` [PATCH v2 1/3] i3c: add sysfs entry for Device NACK Retry count adrianhoyin.ng
@ 2025-11-21 16:53 ` Frank Li
0 siblings, 0 replies; 7+ messages in thread
From: Frank Li @ 2025-11-21 16:53 UTC (permalink / raw)
To: adrianhoyin.ng; +Cc: alexandre.belloni, linux-i3c, linux-kernel
On Fri, Nov 21, 2025 at 02:21:48PM +0800, adrianhoyin.ng@altera.com wrote:
> From: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
>
> Document sysfs attribute dev_nack_retry_cnt that controls the number of
> automatic retries performed by the DesignWare I3C controller when a target
> device returns a NACK
Maybe other controller also support this feature, remove 'DesignWare'.
Add
Exist only when I3C constroller support this feature.
Frank
>
> Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
> ---
> Documentation/ABI/testing/sysfs-bus-i3c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-i3c b/Documentation/ABI/testing/sysfs-bus-i3c
> index c812ab180ff4..d75339330067 100644
> --- a/Documentation/ABI/testing/sysfs-bus-i3c
> +++ b/Documentation/ABI/testing/sysfs-bus-i3c
> @@ -161,3 +161,14 @@ Contact: linux-i3c@vger.kernel.org
> Description:
> These directories are just symbolic links to
> /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>.
> +
> +What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>/dev_nack_retry_count
> +KernelVersion: 6.18
> +Contact: linux-i3c@vger.kernel.org
> +Description:
> + Expose the dev_nak_retry_count which controls the number of automatic
> + retries that will be performed by the controller when the target device
> + returns a NACK response. A value of 0 disables the automatic retries. A
> + max value of 3 can be configured.
> +
> + Valid values: 0-3
> --
> 2.49.GIT
>
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] i3c: dw: Add sysfs support for Device NACK Retry count
2025-11-21 6:21 ` [PATCH v2 2/3] i3c: dw: Add sysfs support " adrianhoyin.ng
@ 2025-11-21 17:05 ` Frank Li
0 siblings, 0 replies; 7+ messages in thread
From: Frank Li @ 2025-11-21 17:05 UTC (permalink / raw)
To: adrianhoyin.ng; +Cc: alexandre.belloni, linux-i3c, linux-kernel
On Fri, Nov 21, 2025 at 02:21:49PM +0800, adrianhoyin.ng@altera.com wrote:
> From: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
>
> The DesignWare I3C controller supports automatically retrying transactions
> when a device NACKs. This is useful for slave devices that may be
> temporarily busy and not ready to respond immediately.
>
> Adds a controller-wide sysfs attribute, dev_nack_retry_count, to read or
> adjust the retry count at runtime. Writes are clamped to the hardware
> maximum of 3, and the updated value is programmed into all active DAT
> entries.
>
> Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
> ---
> drivers/i3c/master/dw-i3c-master.c | 64 ++++++++++++++++++++++++++++++
> drivers/i3c/master/dw-i3c-master.h | 1 +
> 2 files changed, 65 insertions(+)
>
> diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
> index 9ceedf09c3b6..c43eba615d8a 100644
> --- a/drivers/i3c/master/dw-i3c-master.c
> +++ b/drivers/i3c/master/dw-i3c-master.c
> @@ -204,8 +204,10 @@
> #define EXTENDED_CAPABILITY 0xe8
> #define SLAVE_CONFIG 0xec
>
> +#define DW_I3C_DEV_NACK_RETRY_CNT_MAX 0x3
> #define DEV_ADDR_TABLE_IBI_MDB BIT(12)
> #define DEV_ADDR_TABLE_SIR_REJECT BIT(13)
> +#define DEV_ADDR_TABLE_DEV_NACK_RETRY_CNT(x) (((x) << 29) & GENMASK(30, 29))
> #define DEV_ADDR_TABLE_LEGACY_I2C_DEV BIT(31)
> #define DEV_ADDR_TABLE_DYNAMIC_ADDR(x) (((x) << 16) & GENMASK(23, 16))
> #define DEV_ADDR_TABLE_STATIC_ADDR(x) ((x) & GENMASK(6, 0))
> @@ -295,6 +297,58 @@ to_dw_i3c_master(struct i3c_master_controller *master)
> return container_of(master, struct dw_i3c_master, base);
> }
>
> +static ssize_t dev_nack_retry_count_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
keep consistent with other function's naming. Maybe "dw_i3c_master" too
long, add "dw_" prefix should be fine.
> +{
> + struct dw_i3c_master *master = dev_get_drvdata(dev);
> +
> + return sysfs_emit(buf, "%u\n", master->dev_nack_retry_cnt);
> +}
> +
> +static ssize_t dev_nack_retry_count_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct dw_i3c_master *master = dev_get_drvdata(dev);
> + unsigned long val;
> + int ret, i;
> + u32 reg;
> +
> + ret = kstrtoul(buf, 0, &val);
> + if (ret)
> + return ret;
> +
> + if (val > DW_I3C_DEV_NACK_RETRY_CNT_MAX) {
> + dev_warn(dev, "Value %lu exceeds maximum %d, clamping to max\n",
> + val, DW_I3C_DEV_NACK_RETRY_CNT_MAX);
> + val = DW_I3C_DEV_NACK_RETRY_CNT_MAX;
return err.
> + }
> +
> + master->dev_nack_retry_cnt = val;
> +
> + /*
> + * Update DAT entries for all currently attached devices.
> + * We directly iterate through the master's device array.
> + */
> + for (i = 0; i < master->maxdevs; i++) {
> + /* Skip free/empty slots */
> + if (master->free_pos & BIT(i))
> + continue;
> +
> + reg = readl(master->regs +
> + DEV_ADDR_TABLE_LOC(master->datstartaddr, i));
> + reg &= ~GENMASK(30, 29);
> + reg |= DEV_ADDR_TABLE_DEV_NACK_RETRY_CNT(val);
> + writel(reg, master->regs +
> + DEV_ADDR_TABLE_LOC(master->datstartaddr, i));
do you need lock here? In case data is transferring.
> + }
> +
> + return count;
> +}
> +
> +static DEVICE_ATTR_RW(dev_nack_retry_count);
> +
> static void dw_i3c_master_disable(struct dw_i3c_master *master)
> {
> writel(readl(master->regs + DEVICE_CTRL) & ~DEV_CTRL_ENABLE,
> @@ -1032,6 +1086,7 @@ static int dw_i3c_master_attach_i3c_dev(struct i3c_dev_desc *dev)
> data->index = pos;
> master->devs[pos].addr = dev->info.dyn_addr ? : dev->info.static_addr;
> master->free_pos &= ~BIT(pos);
> + master->dev_nack_retry_cnt = 0;
suppose needn't init to 0 here again, it is already 0 when alloc master.
> writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr),
> @@ -1598,6 +1653,12 @@ int dw_i3c_common_probe(struct dw_i3c_master *master,
> if (ret)
> goto err_disable_pm;
>
> + dev_set_drvdata(&master->base.dev, master);
> + ret = device_create_file(&master->base.dev, &dev_attr_dev_nack_retry_count);
> + if (ret)
> + dev_warn(&master->base.dev,
> + "Failed to create dev_nack_retry_count sysfs: %d\n", ret);
> +
> return 0;
>
> err_disable_pm:
> @@ -1617,6 +1678,9 @@ void dw_i3c_common_remove(struct dw_i3c_master *master)
> cancel_work_sync(&master->hj_work);
> i3c_master_unregister(&master->base);
>
> + device_remove_file(&master->base.dev, &dev_attr_dev_nack_retry_count);
> + dev_set_drvdata(&master->base.dev, NULL);
> +
> pm_runtime_disable(master->dev);
> pm_runtime_set_suspended(master->dev);
> pm_runtime_dont_use_autosuspend(master->dev);
> diff --git a/drivers/i3c/master/dw-i3c-master.h b/drivers/i3c/master/dw-i3c-master.h
> index c5cb695c16ab..c87a0e87bfd9 100644
> --- a/drivers/i3c/master/dw-i3c-master.h
> +++ b/drivers/i3c/master/dw-i3c-master.h
> @@ -51,6 +51,7 @@ struct dw_i3c_master {
> u32 i2c_fm_timing;
> u32 i2c_fmp_timing;
> u32 quirks;
> + u32 dev_nack_retry_cnt;
just one space between u32 and dev_nack_retry_cnt
Frank
> /*
> * Per-device hardware data, used to manage the device address table
> * (DAT)
> --
> 2.49.GIT
>
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] i3c: dw: Preserve DAT entry bits when restoring addresses
2025-11-21 6:21 ` [PATCH v2 3/3] i3c: dw: Preserve DAT entry bits when restoring addresses adrianhoyin.ng
@ 2025-11-21 17:10 ` Frank Li
0 siblings, 0 replies; 7+ messages in thread
From: Frank Li @ 2025-11-21 17:10 UTC (permalink / raw)
To: adrianhoyin.ng; +Cc: alexandre.belloni, linux-i3c, linux-kernel
On Fri, Nov 21, 2025 at 02:21:50PM +0800, adrianhoyin.ng@altera.com wrote:
> From: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
>
> Update dw_i3c_master_restore_addrs() to preserve existing bits in each
> Device Address Table (DAT) entry when restoring addresses. This prevents
> overwriting configuration bits during PM runtime resumes.
>
> Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
> ---
> drivers/i3c/master/dw-i3c-master.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
> index c43eba615d8a..ac3c2d3136d0 100644
> --- a/drivers/i3c/master/dw-i3c-master.c
> +++ b/drivers/i3c/master/dw-i3c-master.c
> @@ -1718,11 +1718,13 @@ static void dw_i3c_master_restore_addrs(struct dw_i3c_master *master)
> if (master->free_pos & BIT(pos))
> continue;
>
> + reg_val = readl(master->regs + DEV_ADDR_TABLE_LOC(master->datstartaddr, pos));
> +
> if (master->devs[pos].is_i2c_addr)
> - reg_val = DEV_ADDR_TABLE_LEGACY_I2C_DEV |
> + reg_val |= DEV_ADDR_TABLE_LEGACY_I2C_DEV |
> DEV_ADDR_TABLE_STATIC_ADDR(master->devs[pos].addr);
Suppose need clean addr field of reg_val before |=
address value may be wrong if addr feild is not 0 in DAT. Or you can make
sure it is zero.
Frank
> else
> - reg_val = DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr);
> + reg_val |= DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr);
>
> writel(reg_val, master->regs + DEV_ADDR_TABLE_LOC(master->datstartaddr, pos));
> }
> --
> 2.49.GIT
>
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-11-21 17:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-21 6:21 [PATCH v2 0/3] i3c: dw-i3c: Enable support for dw-i3c controller NACK retry sysfs and DAT restore fix adrianhoyin.ng
2025-11-21 6:21 ` [PATCH v2 1/3] i3c: add sysfs entry for Device NACK Retry count adrianhoyin.ng
2025-11-21 16:53 ` Frank Li
2025-11-21 6:21 ` [PATCH v2 2/3] i3c: dw: Add sysfs support " adrianhoyin.ng
2025-11-21 17:05 ` Frank Li
2025-11-21 6:21 ` [PATCH v2 3/3] i3c: dw: Preserve DAT entry bits when restoring addresses adrianhoyin.ng
2025-11-21 17:10 ` Frank Li
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).