Skip to content

Commit a19429e

Browse files
xodus7kartben
authored andcommitted
drivers: i3c: i3c_dw: make transfer timeout a Kconfig option
The current value of 1s is much too long, default to 100ms instead which is enough for even a large 4kB FM I2C transfer to finish in time let alone a typical I3C transfer. Make this configurable in case projects want to tune this. Signed-off-by: Corey Wharton <[email protected]>
1 parent b818a76 commit a19429e

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

drivers/i3c/Kconfig.dw

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@ module = I3C_DW
66
module-str = i3c-dw
77
source "subsys/logging/Kconfig.template.log_config"
88

9-
config I3C_DW
9+
menuconfig I3C_DW
1010
bool "DW I3C support"
1111
select I3C_IBI_WORKQUEUE if I3C_USE_IBI
1212
depends on DT_HAS_SNPS_DESIGNWARE_I3C_ENABLED
1313
depends on CLOCK_CONTROL
1414
default y
1515
help
1616
Enable the Synopsys Designware I3C driver
17+
18+
if I3C_DW
19+
20+
config I3C_DW_RW_TIMEOUT_MS
21+
int "Set the Read/Write timeout in milliseconds"
22+
default 100
23+
24+
endif # I3C_DW

drivers/i3c/i3c_dw.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ static int dw_i3c_xfers(const struct device *dev, struct i3c_device_desc *target
841841

842842
start_xfer(dev);
843843

844-
ret = k_sem_take(&data->sem_xfer, K_MSEC(1000));
844+
ret = k_sem_take(&data->sem_xfer, K_MSEC(CONFIG_I3C_DW_RW_TIMEOUT_MS));
845845
if (ret) {
846846
LOG_ERR("%s: Semaphore err (%d)", dev->name, ret);
847847
goto error;
@@ -1000,7 +1000,7 @@ static int dw_i3c_i2c_transfer(const struct device *dev, struct i3c_i2c_device_d
10001000

10011001
start_xfer(dev);
10021002

1003-
ret = k_sem_take(&data->sem_xfer, K_MSEC(1000));
1003+
ret = k_sem_take(&data->sem_xfer, K_MSEC(CONFIG_I3C_DW_RW_TIMEOUT_MS));
10041004
if (ret) {
10051005
LOG_ERR("%s: Semaphore err (%d)", dev->name, ret);
10061006
goto error;
@@ -1239,7 +1239,7 @@ static int dw_i3c_target_ibi_raise_hj(const struct device *dev)
12391239
sys_write32(sys_read32(config->regs + SLV_EVENT_STATUS) | SLV_EVENT_STATUS_HJ_EN,
12401240
config->regs + SLV_EVENT_STATUS);
12411241

1242-
ret = k_sem_take(&data->sem_hj, K_MSEC(1000));
1242+
ret = k_sem_take(&data->sem_hj, K_MSEC(CONFIG_I3C_DW_RW_TIMEOUT_MS));
12431243
if (ret) {
12441244
return ret;
12451245
}
@@ -1741,7 +1741,7 @@ static int dw_i3c_do_ccc(const struct device *dev, struct i3c_ccc_payload *paylo
17411741

17421742
start_xfer(dev);
17431743

1744-
ret = k_sem_take(&data->sem_xfer, K_MSEC(1000));
1744+
ret = k_sem_take(&data->sem_xfer, K_MSEC(CONFIG_I3C_DW_RW_TIMEOUT_MS));
17451745
if (ret) {
17461746
LOG_ERR("%s: Semaphore err (%d)", dev->name, ret);
17471747
goto error;
@@ -1895,7 +1895,7 @@ static int dw_i3c_do_daa(const struct device *dev)
18951895
COMMAND_PORT_CMD(I3C_CCC_ENTDAA) | COMMAND_PORT_ADDR_ASSGN_CMD;
18961896

18971897
start_xfer(dev);
1898-
ret = k_sem_take(&data->sem_xfer, K_MSEC(1000));
1898+
ret = k_sem_take(&data->sem_xfer, K_MSEC(CONFIG_I3C_DW_RW_TIMEOUT_MS));
18991899

19001900
pm_device_busy_clear(dev);
19011901
k_mutex_unlock(&data->mt);

0 commit comments

Comments
 (0)