Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: i3c: Reset device list addresses when RST command is issued #78784

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion drivers/i3c/i3c_ccc.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,43 @@
return i3c_do_ccc(target->bus, &ccc_payload);
}

int i3c_reset_addresses(const struct device *controller)
{
struct i3c_driver_data *data;
sys_snode_t *node;

if (controller == NULL) {
LOG_ERR("%s controller null", __func__);
return 0;
}

data = (struct i3c_driver_data *)controller->data;
if (data == NULL) {
LOG_ERR("%s data null", __func__);
return 0;
}

if (!sys_slist_is_empty(&data->attached_dev.devices.i3c)) {
SYS_SLIST_FOR_EACH_NODE(&data->attached_dev.devices.i3c, node) {
struct i3c_device_desc *desc =
CONTAINER_OF(node, struct i3c_device_desc, node);
if (desc != NULL) {
desc->dynamic_addr = 0;
LOG_WRN("Reset dynamic address for device %s",
desc->dev->name);
}

Check notice on line 111 in drivers/i3c/i3c_ccc.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/i3c/i3c_ccc.c:111 - LOG_WRN("Reset dynamic address for device %s", - desc->dev->name); + LOG_WRN("Reset dynamic address for device %s", desc->dev->name);

Check notice on line 111 in drivers/i3c/i3c_ccc.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/i3c/i3c_ccc.c:111 - LOG_WRN("Reset dynamic address for device %s", - desc->dev->name); + LOG_WRN("Reset dynamic address for device %s", desc->dev->name);
}
}

return 0;
}

int i3c_ccc_do_rstact_all(const struct device *controller,
enum i3c_ccc_rstact_defining_byte action)
{
struct i3c_ccc_payload ccc_payload;
uint8_t def_byte;
int ret;

__ASSERT_NO_MSG(controller != NULL);

Expand All @@ -99,7 +131,10 @@
ccc_payload.ccc.data = &def_byte;
ccc_payload.ccc.data_len = 1U;

return i3c_do_ccc(controller, &ccc_payload);
ret = i3c_do_ccc(controller, &ccc_payload);
if (ret == 0) {

Check notice on line 135 in drivers/i3c/i3c_ccc.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/i3c/i3c_ccc.c:135 - ret = i3c_do_ccc(controller, &ccc_payload); + ret = i3c_do_ccc(controller, &ccc_payload);

Check notice on line 135 in drivers/i3c/i3c_ccc.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/i3c/i3c_ccc.c:135 - ret = i3c_do_ccc(controller, &ccc_payload); + ret = i3c_do_ccc(controller, &ccc_payload);
i3c_reset_addresses(controller);
}
}

int i3c_ccc_do_rstdaa_all(const struct device *controller)
Expand Down
Loading