Skip to content

Commit d9181ae

Browse files
XenuIsWatchingDevansh0210
authored andcommitted
drivers: i3c: shell: add shell cmd for ibi hj response
Add a shell command the i3c ibi hj response api. Signed-off-by: Ryan McClelland <[email protected]>
1 parent e0f2688 commit d9181ae

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

drivers/i3c/i3c_shell.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,39 @@ static int cmd_i3c_i2c_scan(const struct shell *sh, size_t argc, char **argv)
19291929
}
19301930

19311931
#ifdef CONFIG_I3C_USE_IBI
1932+
/* i3c ibi hj_response <device> <"ack"/"nack"> */
1933+
static int cmd_i3c_ibi_hj_response(const struct shell *sh, size_t argc, char **argv)
1934+
{
1935+
const struct device *dev;
1936+
bool ack;
1937+
int ret;
1938+
1939+
dev = device_get_binding(argv[ARGV_DEV]);
1940+
if (!dev) {
1941+
shell_error(sh, "I3C: Device driver %s not found.", argv[ARGV_DEV]);
1942+
return -ENODEV;
1943+
}
1944+
1945+
if (strcmp(argv[2], "ack") == 0) {
1946+
ack = true;
1947+
} else if (strcmp(argv[2], "nack") == 0) {
1948+
ack = false;
1949+
} else {
1950+
shell_error(sh, "I3C: invalid parameter");
1951+
return -EINVAL;
1952+
}
1953+
1954+
ret = i3c_ibi_hj_response(dev, ack);
1955+
if (ret != 0) {
1956+
shell_error(sh, "I3C: Unable to set IBI HJ Response");
1957+
return ret;
1958+
}
1959+
1960+
shell_print(sh, "I3C: Set IBI HJ Response");
1961+
1962+
return 0;
1963+
}
1964+
19321965
/* i3c ibi hj <device> */
19331966
static int cmd_i3c_ibi_hj(const struct shell *sh, size_t argc, char **argv)
19341967
{
@@ -2108,6 +2141,10 @@ SHELL_DYNAMIC_CMD_CREATE(dsub_i3c_device_name, i3c_device_name_get);
21082141
/* L2 I3C IBI Shell Commands*/
21092142
SHELL_STATIC_SUBCMD_SET_CREATE(
21102143
sub_i3c_ibi_cmds,
2144+
SHELL_CMD_ARG(hj_response, &dsub_i3c_device_name,
2145+
"Set IBI HJ Response\n"
2146+
"Usage: ibi hj_response <device> <\"ack\"/\"nack\">",
2147+
cmd_i3c_ibi_hj_response, 3, 0),
21112148
SHELL_CMD_ARG(hj, &dsub_i3c_device_name,
21122149
"Send IBI HJ\n"
21132150
"Usage: ibi hj <device>",

0 commit comments

Comments
 (0)