Skip to content

Commit 32f0a15

Browse files
XenuIsWatchingnashif
authored andcommitted
drivers: i3c: shell: add ccc rstact shell command
Add a shell command for rstact format 2 and 3. Signed-off-by: Ryan McClelland <[email protected]>
1 parent e20b556 commit 32f0a15

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

drivers/i3c/i3c_shell.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,56 @@ static int cmd_i3c_ccc_rstact_bc(const struct shell *sh, size_t argc, char **arg
12031203
return ret;
12041204
}
12051205

1206+
/* i3c ccc rstact <device> <target> <defining byte> */
1207+
static int cmd_i3c_ccc_rstact(const struct shell *sh, size_t argc, char **argv)
1208+
{
1209+
const struct device *dev, *tdev;
1210+
struct i3c_device_desc *desc;
1211+
enum i3c_ccc_rstact_defining_byte action;
1212+
int ret;
1213+
uint8_t data;
1214+
1215+
dev = device_get_binding(argv[ARGV_DEV]);
1216+
if (!dev) {
1217+
shell_error(sh, "I3C: Device driver %s not found.", argv[ARGV_DEV]);
1218+
return -ENODEV;
1219+
}
1220+
1221+
tdev = device_get_binding(argv[ARGV_TDEV]);
1222+
if (!tdev) {
1223+
shell_error(sh, "I3C: Device driver %s not found.", argv[ARGV_TDEV]);
1224+
return -ENODEV;
1225+
}
1226+
desc = get_i3c_attached_desc_from_dev_name(dev, tdev->name);
1227+
if (!desc) {
1228+
shell_error(sh, "I3C: Device %s not attached to bus.", tdev->name);
1229+
return -ENODEV;
1230+
}
1231+
1232+
action = strtol(argv[5], NULL, 16);
1233+
1234+
if (strcmp(argv[4], "get") == 0) {
1235+
ret = i3c_ccc_do_rstact_fmt3(tdev, action, &data);
1236+
} else if (strcmp(argv[4], "set") == 0) {
1237+
ret = i3c_ccc_do_rstact_fmt2(tdev, action);
1238+
} else {
1239+
shell_error(sh, "I3C: invalid parameter");
1240+
return -EINVAL;
1241+
}
1242+
1243+
if (ret < 0) {
1244+
shell_error(sh, "I3C: unable to send CCC RSTACT BC.");
1245+
return ret;
1246+
}
1247+
1248+
if (action >= 0x80) {
1249+
shell_print("RSTACT Returned Data: 0x%02x", data);
1250+
}
1251+
1252+
return ret;
1253+
}
1254+
1255+
12061256
/* i3c ccc enec_bc <device> <defining byte> */
12071257
static int cmd_i3c_ccc_enec_bc(const struct shell *sh, size_t argc, char **argv)
12081258
{
@@ -2369,6 +2419,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
23692419
"Send CCC ENTTM\n"
23702420
"Usage: ccc enttm <device> <defining byte>",
23712421
cmd_i3c_ccc_enttm, 3, 0),
2422+
SHELL_CMD_ARG(rstact, &dsub_i3c_device_attached_name,
2423+
"Send CCC RSTACT\n"
2424+
"Usage: ccc rstact <device> <target> <\"set\"/\"get\"> <defining byte>",
2425+
cmd_i3c_ccc_rstact, 5, 0),
23722426
SHELL_CMD_ARG(rstact_bc, &dsub_i3c_device_name,
23732427
"Send CCC RSTACT BC\n"
23742428
"Usage: ccc rstact_bc <device> <defining byte>",

0 commit comments

Comments
 (0)