]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
i3c: master: Add sysfs option to rescan bus via entdaa
authorDavid Nyström <david.nystrom@est.tech>
Thu, 19 Feb 2026 20:58:03 +0000 (21:58 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Sun, 12 Apr 2026 14:32:11 +0000 (16:32 +0200)
Allow userspace to request dynamic address assignment, which is
useful for i3cdev devices with broken hot-join support.
This will assign dynamic addresses to all devices on the I3C bus
which are currently unassigned.

Signed-off-by: David Nyström <david.nystrom@est.tech>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Meagan Lloyd <meaganlloyd@linux.microsoft.com>
Link: https://patch.msgid.link/20260219-i3c_rescan-v6-1-b81d6cc3cb30@est.tech
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Documentation/ABI/testing/sysfs-bus-i3c
drivers/i3c/master.c

index c1e048957a0103dc6e76f8b607a48e98d61419d7..19f5cf8b1b1149a642473d7513bbeb5162a21d3d 100644 (file)
@@ -172,3 +172,23 @@ Description:
                the automatic retries. Exist only when I3C constroller supports
                this retry on nack feature.
 
+What:          /sys/bus/i3c/devices/i3c-<bus-id>/do_daa
+KernelVersion:  7.0
+Contact:       linux-i3c@vger.kernel.org
+Description:
+               Write-only attribute that triggers a Dynamic Address Assignment
+               (DAA) procedure which discovers new I3C devices on the bus.
+               Writing a boolean true value (1, y, yes, true, on) to this
+               attribute causes the master controller to perform DAA, which
+               includes broadcasting an ENTDAA (Enter Dynamic Address Assignment)
+               Common Command Code (CCC) on the bus. Writing a false value
+               returns -EINVAL.
+
+               This is useful for discovering I3C devices that were not present
+               during initial bus initialization and are unable to issue
+               Hot-Join. Only devices without a currently assigned dynamic address
+               will respond to the ENTDAA broadcast and be assigned addresses.
+
+               Note that this mechanism is distinct from Hot-Join, since this is
+               controller-initiated discovery, while Hot-Join is device-initiated
+               method to provoke controller discovery procedure.
index 9e6be49bebb2c638c7e6ab65254d823656f31367..53b34b4f44a2d3dc32fbbef2034f1f858e800469 100644 (file)
@@ -758,6 +758,32 @@ static ssize_t dev_nack_retry_count_store(struct device *dev,
 
 static DEVICE_ATTR_RW(dev_nack_retry_count);
 
+static ssize_t do_daa_store(struct device *dev,
+                           struct device_attribute *attr,
+                           const char *buf, size_t count)
+{
+       struct i3c_master_controller *master = dev_to_i3cmaster(dev);
+       bool val;
+       int ret;
+
+       if (kstrtobool(buf, &val))
+               return -EINVAL;
+
+       if (!val)
+               return -EINVAL;
+
+       if (!master->init_done)
+               return -EAGAIN;
+
+       ret = i3c_master_do_daa(master);
+       if (ret)
+               return ret;
+
+       return count;
+}
+
+static DEVICE_ATTR_WO(do_daa);
+
 static struct attribute *i3c_masterdev_attrs[] = {
        &dev_attr_mode.attr,
        &dev_attr_current_master.attr,
@@ -769,6 +795,7 @@ static struct attribute *i3c_masterdev_attrs[] = {
        &dev_attr_dynamic_address.attr,
        &dev_attr_hdrcap.attr,
        &dev_attr_hotjoin.attr,
+       &dev_attr_do_daa.attr,
        NULL,
 };
 ATTRIBUTE_GROUPS(i3c_masterdev);