Skip to content

Commit 3932794

Browse files
XenuIsWatchingkartben
authored andcommitted
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>
1 parent c050359 commit 3932794

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

drivers/i3c/i3c_shell.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,36 @@ static int cmd_i3c_hdr_ddr_read(const struct shell *sh, size_t argc, char **argv
566566
return ret;
567567
}
568568

569+
/* i3c ccc rstdaa_dc <device> <target> */
570+
static int cmd_i3c_ccc_rstdaa_dc(const struct shell *sh, size_t argc, char **argv)
571+
{
572+
const struct device *dev, *tdev;
573+
struct i3c_device_desc *desc;
574+
int ret;
575+
576+
ret = i3c_parse_args(sh, argv, &dev, &tdev, &desc);
577+
if (ret != 0) {
578+
return ret;
579+
}
580+
581+
if (!(desc->flags & I3C_V1P0_SUPPORT)) {
582+
shell_error(sh, "I3C: %s does not support RSTDAA_DC.", tdev->name);
583+
return -ENOTSUP;
584+
}
585+
586+
ret = i3c_ccc_do_rstdaa(desc);
587+
if (ret < 0) {
588+
shell_error(sh, "I3C: unable to send CCC RSTDAA.");
589+
return ret;
590+
}
591+
592+
/* reset device DA */
593+
desc->dynamic_addr = 0;
594+
shell_print(sh, "Reset dynamic address for device %s", desc->dev->name);
595+
596+
return ret;
597+
}
598+
569599
/* i3c ccc rstdaa <device> */
570600
static int cmd_i3c_ccc_rstdaa(const struct shell *sh, size_t argc, char **argv)
571601
{
@@ -2246,6 +2276,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
22462276
/* L2 I3C CCC Shell Commands*/
22472277
SHELL_STATIC_SUBCMD_SET_CREATE(
22482278
sub_i3c_ccc_cmds,
2279+
SHELL_CMD_ARG(rstdaa_dc, &dsub_i3c_device_attached_name,
2280+
"Send CCC RSTDAA\n"
2281+
"Usage: ccc rstdaa_dc <device> <target>",
2282+
cmd_i3c_ccc_rstdaa_dc, 3, 0),
22492283
SHELL_CMD_ARG(rstdaa, &dsub_i3c_device_name,
22502284
"Send CCC RSTDAA\n"
22512285
"Usage: ccc rstdaa <device>",

0 commit comments

Comments
 (0)