drivers: i3c: add reattach_i3c_device api

Some I3C controllers have retaining registers which are used to contain
the DA of the i3c device. This needs to be updated every time the DA is
updated with SETNEWDA or SETDASA

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
This commit is contained in:
Ryan McClelland 2023-03-16 15:26:12 -07:00 committed by Christopher Friedt
commit 71c5ccb1ef
3 changed files with 53 additions and 14 deletions

View file

@ -130,7 +130,8 @@ int i3c_ccc_do_setdasa(const struct i3c_device_desc *target)
* Note that the 7-bit address needs to start at bit 1
* (aka left-justified). So shift left by 1;
*/
dyn_addr = target->static_addr << 1;
dyn_addr = (target->init_dynamic_addr ?
target->init_dynamic_addr : target->static_addr) << 1;
ccc_tgt_payload.addr = target->static_addr;
ccc_tgt_payload.rnw = 0;

View file

@ -402,23 +402,13 @@ static int i3c_bus_setdasa(const struct device *dev,
continue;
}
/*
* If there is a desired dynamic address and it is
* not the same as the static address, wait till
* ENTDAA to do address assignment as this is
* no longer SETDASA.
*/
if ((desc->init_dynamic_addr != 0U) &&
(desc->init_dynamic_addr != desc->static_addr)) {
*need_daa = true;
continue;
}
LOG_DBG("SETDASA for 0x%x", desc->static_addr);
ret = i3c_ccc_do_setdasa(desc);
if (ret == 0) {
desc->dynamic_addr = desc->static_addr;
desc->dynamic_addr = (desc->init_dynamic_addr ? desc->init_dynamic_addr
: desc->static_addr);
i3c_reattach_i3c_device(desc, desc->static_addr);
} else {
LOG_ERR("SETDASA error on address 0x%x (%d)",
desc->static_addr, ret);