Skip to content

Commit

Permalink
drivers: i3c: add i3c_slave_hj_req support in i3c npcm4xx driver
Browse files Browse the repository at this point in the history
Support i3c_slave_hj_req.

Signed-off-by: James Chiang <[email protected]>
Signed-off-by: Tyrone Ting <[email protected]>
  • Loading branch information
warp5tw authored and jc849 committed Aug 2, 2024
1 parent 23c5de3 commit d4877e0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
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 @@ -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),
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 @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d4877e0

Please sign in to comment.