Skip to content

Commit

Permalink
drivers: i3c: shell: add ccc getacccr command
Browse files Browse the repository at this point in the history
Add the CCC GETACCCR command to the i3c shell.

Signed-off-by: Ryan McClelland <[email protected]>
  • Loading branch information
XenuIsWatching committed Sep 12, 2024
1 parent 51d9a71 commit d014e7d
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions drivers/i3c/i3c_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,54 @@ static int cmd_i3c_ccc_enttm(const struct shell *shell_ctx, size_t argc, char **
return ret;
}

/* i3c ccc getacccr <device> <target> */
static int cmd_i3c_ccc_getacccr(const struct shell *shell_ctx, size_t argc, char **argv)
{
const struct device *dev, *tdev;
struct i3c_device_desc *desc;
struct i3c_ccc_address handoff_address;
int ret;

dev = device_get_binding(argv[ARGV_DEV]);
if (!dev) {
shell_error(shell_ctx, "I3C: Device driver %s not found.", argv[ARGV_DEV]);
return -ENODEV;
}
tdev = device_get_binding(argv[ARGV_TDEV]);
if (!tdev) {
shell_error(shell_ctx, "I3C: Device driver %s not found.", argv[ARGV_TDEV]);
return -ENODEV;
}
desc = get_i3c_attached_desc_from_dev_name(dev, tdev->name);
if (!desc) {
shell_error(shell_ctx, "I3C: Device %s not attached to bus.", tdev->name);
return -ENODEV;
}

if (!i3c_device_is_controller_capable(desc)) {
shell_error(shell_ctx, "I3C: Not a Controller Capable Device");
return -EINVAL;
}

ret = i3c_ccc_do_getacccr(desc, &handoff_address);
if (ret < 0) {
shell_error(shell_ctx, "I3C: unable to send CCC GETACCCR.");
return ret;
}

/* Verify Odd Parity and Correct Dynamic Address Reply */
if ((i3c_odd_parity(handoff_address.addr >> 1) != (handoff_address.addr & BIT(0))) ||
(handoff_address.addr >> 1 != target->dynamic_addr)) {
shell_error(shell_ctx, "I3C: invalid returned address 0x%02x; expected 0x%02x",
handoff_address.addr, target->dynamic_addr);
return -EIO;

Check notice on line 1094 in drivers/i3c/i3c_shell.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_shell.c:1094 - handoff_address.addr, target->dynamic_addr); + handoff_address.addr, target->dynamic_addr);
}

shell_print("I3C: Controller Handoff successful");

return ret;
}

/* i3c ccc rstact_bc <device> <defining byte> */
static int cmd_i3c_ccc_rstact_bc(const struct shell *shell_ctx, size_t argc, char **argv)
{
Expand Down Expand Up @@ -2090,6 +2138,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
"Send CCC ENTTM\n"
"Usage: ccc enttm <device> <defining byte>",
cmd_i3c_ccc_enttm, 3, 0),
SHELL_CMD_ARG(enttm, &dsub_i3c_device_name,
"Send CCC GETACCCR\n"
"Usage: ccc getacccr <device> <target>",
cmd_i3c_ccc_getacccr, 3, 0),
SHELL_CMD_ARG(rstact_bc, &dsub_i3c_device_name,
"Send CCC RSTACT BC\n"
"Usage: ccc rstact_bc <device> <defining byte>",
Expand Down

0 comments on commit d014e7d

Please sign in to comment.