diff --git a/drivers/i3c/i3c_npcm4xx.c b/drivers/i3c/i3c_npcm4xx.c index 8f9ddb29dbfcef..c2ead24951912f 100644 --- a/drivers/i3c/i3c_npcm4xx.c +++ b/drivers/i3c/i3c_npcm4xx.c @@ -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); diff --git a/drivers/i3c/i3c_shell.c b/drivers/i3c/i3c_shell.c index af6620a29b8fb2..32277c61f76e29 100644 --- a/drivers/i3c/i3c_shell.c +++ b/drivers/i3c/i3c_shell.c @@ -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 "; +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 -a -w -r "; static int cmd_priv_xfer(const struct shell *shell, size_t argc, char **argv) { @@ -660,6 +673,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_i3c_cmds, SHELL_CMD(ccc, &dsub_device_name, send_ccc_helper, cmd_send_ccc), SHELL_CMD(entdaa, &dsub_device_name, entdaa_helper, cmd_entdaa), 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), diff --git a/include/drivers/i3c/i3c.h b/include/drivers/i3c/i3c.h index 490dbb926cd7f8..a998424b5ea2c4 100644 --- a/include/drivers/i3c/i3c.h +++ b/include/drivers/i3c/i3c.h @@ -210,6 +210,14 @@ int i3c_npcm4xx_slave_get_event_enabling(const struct device *dev, uint32_t *eve int i3c_aspeed_slave_send_sir(const struct device *dev, struct i3c_ibi_payload *payload); 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 @@ -284,6 +292,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