Skip to content

Commit 8ea0b60

Browse files
nysanalexandrebelloni
authored andcommitted
i3c: master: Add sysfs option to rescan bus via entdaa
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>
1 parent 335c21a commit 8ea0b60

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

Documentation/ABI/testing/sysfs-bus-i3c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,23 @@ Description:
172172
the automatic retries. Exist only when I3C constroller supports
173173
this retry on nack feature.
174174

175+
What: /sys/bus/i3c/devices/i3c-<bus-id>/do_daa
176+
KernelVersion: 7.0
177+
Contact: linux-i3c@vger.kernel.org
178+
Description:
179+
Write-only attribute that triggers a Dynamic Address Assignment
180+
(DAA) procedure which discovers new I3C devices on the bus.
181+
Writing a boolean true value (1, y, yes, true, on) to this
182+
attribute causes the master controller to perform DAA, which
183+
includes broadcasting an ENTDAA (Enter Dynamic Address Assignment)
184+
Common Command Code (CCC) on the bus. Writing a false value
185+
returns -EINVAL.
186+
187+
This is useful for discovering I3C devices that were not present
188+
during initial bus initialization and are unable to issue
189+
Hot-Join. Only devices without a currently assigned dynamic address
190+
will respond to the ENTDAA broadcast and be assigned addresses.
191+
192+
Note that this mechanism is distinct from Hot-Join, since this is
193+
controller-initiated discovery, while Hot-Join is device-initiated
194+
method to provoke controller discovery procedure.

drivers/i3c/master.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,32 @@ static ssize_t dev_nack_retry_count_store(struct device *dev,
758758

759759
static DEVICE_ATTR_RW(dev_nack_retry_count);
760760

761+
static ssize_t do_daa_store(struct device *dev,
762+
struct device_attribute *attr,
763+
const char *buf, size_t count)
764+
{
765+
struct i3c_master_controller *master = dev_to_i3cmaster(dev);
766+
bool val;
767+
int ret;
768+
769+
if (kstrtobool(buf, &val))
770+
return -EINVAL;
771+
772+
if (!val)
773+
return -EINVAL;
774+
775+
if (!master->init_done)
776+
return -EAGAIN;
777+
778+
ret = i3c_master_do_daa(master);
779+
if (ret)
780+
return ret;
781+
782+
return count;
783+
}
784+
785+
static DEVICE_ATTR_WO(do_daa);
786+
761787
static struct attribute *i3c_masterdev_attrs[] = {
762788
&dev_attr_mode.attr,
763789
&dev_attr_current_master.attr,
@@ -769,6 +795,7 @@ static struct attribute *i3c_masterdev_attrs[] = {
769795
&dev_attr_dynamic_address.attr,
770796
&dev_attr_hdrcap.attr,
771797
&dev_attr_hotjoin.attr,
798+
&dev_attr_do_daa.attr,
772799
NULL,
773800
};
774801
ATTRIBUTE_GROUPS(i3c_masterdev);

0 commit comments

Comments
 (0)