Skip to content

Commit ca8355f

Browse files
utsavm9anangl
authored andcommitted
[nrf fromtree] drivers: flash_mspi_nor: Track last applied MSPI config
Instead of just tracking in a bool whether the MSPI device is in Standard MSPI vs. QPI/OPI config, track the entire MSPI config which was last applied. This makes it easier later to track more than two configs to apply based on the next command to transceive. Signed-off-by: Utsav Munendra <[email protected]> (cherry picked from commit 8bc4a92)
1 parent 8e6999a commit ca8355f

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

drivers/flash/flash_mspi_nor.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ static int perform_xfer(const struct device *dev, uint8_t cmd)
124124
}
125125
}
126126

127-
if (cfg) {
127+
if (cfg && cfg != dev_data->last_applied_cfg) {
128128
rc = mspi_dev_config(dev_config->bus, &dev_config->mspi_id,
129129
MSPI_DEVICE_CONFIG_IO_MODE, cfg);
130130
if (rc < 0) {
131131
LOG_ERR("%s: dev_config() failed: %d", __func__, rc);
132132
return rc;
133133
}
134-
134+
dev_data->last_applied_cfg = cfg;
135135
dev_data->in_target_io_mode = mem_access;
136136
}
137137

@@ -262,6 +262,7 @@ static int acquire(const struct device *dev)
262262
LOG_ERR("mspi_dev_config() failed: %d", rc);
263263
} else {
264264
if (dev_config->multiperipheral_bus) {
265+
dev_data->last_applied_cfg = &dev_config->mspi_nor_cfg;
265266
dev_data->in_target_io_mode = true;
266267
}
267268

@@ -867,9 +868,14 @@ static int switch_to_target_io_mode(const struct device *dev)
867868
}
868869
}
869870

870-
return mspi_dev_config(dev_config->bus, &dev_config->mspi_id,
871+
rc = mspi_dev_config(dev_config->bus, &dev_config->mspi_id,
871872
NON_XIP_DEV_CFG_MASK,
872873
&dev_config->mspi_nor_cfg);
874+
if (rc < 0) {
875+
return rc;
876+
}
877+
dev_data->last_applied_cfg = &dev_config->mspi_nor_cfg;
878+
return 0;
873879
}
874880

875881
#if defined(WITH_SUPPLY_GPIO)
@@ -965,7 +971,7 @@ static int soft_reset(const struct device *dev)
965971
LOG_ERR("%s: dev_config() failed: %d", __func__, rc);
966972
return rc;
967973
}
968-
974+
dev_data->last_applied_cfg = &dev_config->mspi_nor_cfg;
969975
dev_data->in_target_io_mode = true;
970976

971977
rc = soft_reset_66_99(dev);
@@ -980,7 +986,7 @@ static int soft_reset(const struct device *dev)
980986
LOG_ERR("%s: dev_config() failed: %d", __func__, rc);
981987
return rc;
982988
}
983-
989+
dev_data->last_applied_cfg = &dev_config->mspi_nor_init_cfg;
984990
dev_data->in_target_io_mode = false;
985991
}
986992

@@ -1010,7 +1016,7 @@ static int flash_chip_init(const struct device *dev)
10101016
LOG_ERR("%s: dev_config() failed: %d", __func__, rc);
10111017
return rc;
10121018
}
1013-
1019+
dev_data->last_applied_cfg = &dev_config->mspi_nor_init_cfg;
10141020
dev_data->in_target_io_mode = false;
10151021

10161022
#if defined(WITH_SUPPLY_GPIO)

drivers/flash/flash_mspi_nor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ struct flash_mspi_nor_data {
114114
struct flash_mspi_nor_cmd_info cmd_info;
115115
struct flash_mspi_nor_switch_info switch_info;
116116
bool in_target_io_mode;
117+
const struct mspi_dev_cfg *last_applied_cfg;
117118
};
118119

119120
#ifdef __cplusplus

0 commit comments

Comments
 (0)