Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: i3c: add i3c_slave_hj_req support in i3c npcm4xx driver #122

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions drivers/i3c/i3c_npcm4xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2603,6 +2603,19 @@ int i3c_npcm4xx_slave_send_sir(const struct device *dev, struct i3c_ibi_payload
return -ENOSYS;
}

int i3c_npcm4xx_slave_hj_req(const struct device *dev)
{
struct i3c_npcm4xx_config *config = DEV_CFG(dev);
I3C_PORT_Enum port;

port = config->inst_id;
I3C_Slave_Insert_Task_HotJoin(port);

k_work_submit_to_queue(&npcm4xx_i3c_work_q[port], &work_send_ibi[port]);

return 0;
}

int i3c_npcm4xx_slave_get_dynamic_addr(const struct device *dev, uint8_t *dynamic_addr)
{
struct i3c_npcm4xx_config *config = DEV_CFG(dev);
Expand Down
14 changes: 14 additions & 0 deletions drivers/i3c/i3c_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ static uint32_t args_to_wdata(char *arg, uint8_t *buf)
return len;
}

static const char hj_req_helper[] = "i3c hj_req <dev>";
static int cmd_hj_req(const struct shell *shell, size_t argc, char **argv)
{
const struct device *dev;

dev = device_get_binding(argv[1]);
if (!dev) {
shell_error(shell, "I3C: Device %s not found.", argv[1]);
return -ENODEV;
}
return i3c_slave_hj_req(dev);
}

static const char priv_xfer_helper[] = "i3c xfer <dev> -a <addr> -w <wdata> -r <read length>";
static int cmd_priv_xfer(const struct shell *shell, size_t argc, char **argv)
{
Expand Down Expand Up @@ -586,6 +599,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_i3c_cmds,
SHELL_CMD(attach, &dsub_device_name, attach_helper, cmd_attach),
SHELL_CMD(ccc, &dsub_device_name, send_ccc_helper, cmd_send_ccc),
SHELL_CMD(xfer, &dsub_device_name, priv_xfer_helper, cmd_priv_xfer),
SHELL_CMD(hj_req, &dsub_device_name, hj_req_helper, cmd_hj_req),
#ifdef CONFIG_I3C_SLAVE_MQUEUE
SHELL_CMD(smq, &dsub_device_name, smq_xfer_helper, cmd_smq_xfer),
SHELL_CMD(stress, &dsub_device_name, do_stress_helper, cmd_do_stress),
Expand Down
9 changes: 9 additions & 0 deletions include/drivers/i3c/i3c.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ int i3c_npcm4xx_slave_get_event_enabling(const struct device *dev, uint32_t *eve
*/
int i3c_npcm4xx_slave_send_sir(const struct device *dev, struct i3c_ibi_payload *payload);

/**
* @brief slave device sends Hot-join request
*
* @param dev the I3C controller in slave mode
* @return int 0 = success
*/
int i3c_npcm4xx_slave_hj_req(const struct device *dev);

/**
* @brief set the static address of the i3c controller in slave mode
* @param dev the I3C controller in slave mode
Expand Down Expand Up @@ -249,6 +257,7 @@ int i3c_master_send_getbcr(const struct device *master, uint8_t addr, uint8_t *b
#define i3c_slave_register i3c_npcm4xx_slave_register
#define i3c_slave_set_static_addr i3c_npcm4xx_slave_set_static_addr
#define i3c_slave_send_sir i3c_npcm4xx_slave_send_sir
#define i3c_slave_hj_req i3c_npcm4xx_slave_hj_req
#define i3c_slave_put_read_data i3c_npcm4xx_slave_put_read_data
#define i3c_slave_get_dynamic_addr i3c_npcm4xx_slave_get_dynamic_addr
#define i3c_slave_get_event_enabling i3c_npcm4xx_slave_get_event_enabling
Expand Down
Loading