Skip to content

Commit 7efa5c8

Browse files
ananglcfriedt
authored andcommitted
drivers: flash_mspi_nor: Make transfer timeout configurable
Although the value currently hard-coded in the driver (10 ms) is quite high, it may turn out to be insufficient when there is a need to use some very low SCK frequency, like 250 kHz. Make the timeout value configurable per-instance, via devicetree. Signed-off-by: Andrzej Głąbek <[email protected]>
1 parent 68c6b6c commit 7efa5c8

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

drivers/flash/flash_mspi_nor.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void flash_mspi_command_set(const struct device *dev, const struct flash_mspi_no
2727
dev_data->xfer.xfer_mode = MSPI_PIO;
2828
dev_data->xfer.packets = &dev_data->packet;
2929
dev_data->xfer.num_packet = 1;
30-
dev_data->xfer.timeout = 10;
30+
dev_data->xfer.timeout = dev_config->transfer_timeout;
3131

3232
dev_data->xfer.cmd_length = cmd->cmd_length;
3333
dev_data->xfer.addr_length = cmd->addr_length;
@@ -887,6 +887,7 @@ BUILD_ASSERT((FLASH_SIZE_INST(inst) % CONFIG_FLASH_MSPI_NOR_LAYOUT_PAGE_SIZE) ==
887887
/ 1000, \
888888
.reset_recovery_us = DT_INST_PROP_OR(inst, t_reset_recovery, 0) \
889889
/ 1000,)) \
890+
.transfer_timeout = DT_INST_PROP(inst, transfer_timeout), \
890891
FLASH_PAGE_LAYOUT_DEFINE(inst) \
891892
.jedec_id = DT_INST_PROP(inst, jedec_id), \
892893
.jedec_cmds = FLASH_CMDS(inst), \

drivers/flash/flash_mspi_nor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct flash_mspi_nor_config {
3535
uint32_t reset_pulse_us;
3636
uint32_t reset_recovery_us;
3737
#endif
38+
uint32_t transfer_timeout;
3839
#if defined(CONFIG_FLASH_PAGE_LAYOUT)
3940
struct flash_pages_layout layout;
4041
#endif

dts/bindings/mtd/jedec,mspi-nor.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ properties:
2222
type: int
2323
description: |
2424
Minimum time, in nanoseconds, the flash chip needs to recover after reset.
25+
26+
transfer-timeout:
27+
type: int
28+
default: 10
29+
description: |
30+
Maximum time, in milliseconds, allowed for a single transfer on the MSPI
31+
bus in communication with the flash chip. The default value is the one
32+
that was previously hard-coded in the flash_mspi_nor driver.

0 commit comments

Comments
 (0)