drivers: i3c: shell: add direct rstdaa shell command

This adds a shell helper for a direct rstdaa for I3C v1.0 devices

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
This commit is contained in:
Ryan McClelland 2025-03-20 23:12:28 -07:00 committed by Benjamin Cabé
commit 3932794aee

View file

@ -566,6 +566,36 @@ static int cmd_i3c_hdr_ddr_read(const struct shell *sh, size_t argc, char **argv
return ret;
}
/* i3c ccc rstdaa_dc <device> <target> */
static int cmd_i3c_ccc_rstdaa_dc(const struct shell *sh, size_t argc, char **argv)
{
const struct device *dev, *tdev;
struct i3c_device_desc *desc;
int ret;
ret = i3c_parse_args(sh, argv, &dev, &tdev, &desc);
if (ret != 0) {
return ret;
}
if (!(desc->flags & I3C_V1P0_SUPPORT)) {
shell_error(sh, "I3C: %s does not support RSTDAA_DC.", tdev->name);
return -ENOTSUP;
}
ret = i3c_ccc_do_rstdaa(desc);
if (ret < 0) {
shell_error(sh, "I3C: unable to send CCC RSTDAA.");
return ret;
}
/* reset device DA */
desc->dynamic_addr = 0;
shell_print(sh, "Reset dynamic address for device %s", desc->dev->name);
return ret;
}
/* i3c ccc rstdaa <device> */
static int cmd_i3c_ccc_rstdaa(const struct shell *sh, size_t argc, char **argv)
{
@ -2246,6 +2276,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
/* L2 I3C CCC Shell Commands*/
SHELL_STATIC_SUBCMD_SET_CREATE(
sub_i3c_ccc_cmds,
SHELL_CMD_ARG(rstdaa_dc, &dsub_i3c_device_attached_name,
"Send CCC RSTDAA\n"
"Usage: ccc rstdaa_dc <device> <target>",
cmd_i3c_ccc_rstdaa_dc, 3, 0),
SHELL_CMD_ARG(rstdaa, &dsub_i3c_device_name,
"Send CCC RSTDAA\n"
"Usage: ccc rstdaa <device>",