Skip to content

Commit 9d61657

Browse files
utsavm9anangl
authored andcommitted
[nrf fromtree] drivers: flash_mspi_nor: Remove bool tracking of target IO mode
Remove the Boolean tracking of MSPI IO mode as we can now rely on tracking the entire dev config applied to the MSPI device, multiple of which will exist in later commits. Signed-off-by: Utsav Munendra <[email protected]> (cherry picked from commit eae1276)
1 parent 744270a commit 9d61657

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

drivers/flash/flash_mspi_nor.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ static int cmd_wrsr(const struct device *dev, uint8_t op_code,
3535

3636
#include "flash_mspi_nor_quirks.h"
3737

38+
static bool in_octal_io(const struct device *dev)
39+
{
40+
struct flash_mspi_nor_data *dev_data = dev->data;
41+
42+
return dev_data->last_applied_cfg &&
43+
dev_data->last_applied_cfg->io_mode == MSPI_IO_MODE_OCTAL;
44+
}
45+
3846
static void set_up_xfer(const struct device *dev, enum mspi_xfer_direction dir)
3947
{
4048
const struct flash_mspi_nor_config *dev_config = dev->config;
@@ -86,7 +94,7 @@ static int perform_xfer(const struct device *dev, uint8_t cmd)
8694
int rc;
8795

8896
if (dev_data->cmd_info.cmd_extension != CMD_EXTENSION_NONE &&
89-
dev_data->in_target_io_mode) {
97+
in_octal_io(dev)) {
9098
dev_data->xfer.cmd_length = 2;
9199
dev_data->packet.cmd = get_extended_command(dev, cmd);
92100
} else {
@@ -107,7 +115,7 @@ static int perform_xfer(const struct device *dev, uint8_t cmd)
107115
/* For commands accessing the flash memory (read and program),
108116
* ensure that the target IO mode is active.
109117
*/
110-
if (!dev_data->in_target_io_mode) {
118+
if (!in_octal_io(dev)) {
111119
cfg = &dev_config->mspi_nor_cfg;
112120
}
113121
} else {
@@ -123,7 +131,6 @@ static int perform_xfer(const struct device *dev, uint8_t cmd)
123131
return rc;
124132
}
125133
dev_data->last_applied_cfg = cfg;
126-
dev_data->in_target_io_mode = mem_access;
127134
}
128135

129136
rc = mspi_transceive(dev_config->bus, &dev_config->mspi_id,
@@ -142,7 +149,7 @@ static int cmd_rdsr(const struct device *dev, uint8_t op_code, uint8_t *sr)
142149
int rc;
143150

144151
set_up_xfer(dev, MSPI_RX);
145-
if (dev_data->in_target_io_mode) {
152+
if (in_octal_io(dev)) {
146153
dev_data->xfer.rx_dummy = dev_data->cmd_info.rdsr_dummy;
147154
dev_data->xfer.addr_length = dev_data->cmd_info.rdsr_addr_4
148155
? 4 : 0;
@@ -254,7 +261,6 @@ static int acquire(const struct device *dev)
254261
} else {
255262
if (dev_config->multiperipheral_bus) {
256263
dev_data->last_applied_cfg = &dev_config->mspi_nor_cfg;
257-
dev_data->in_target_io_mode = true;
258264
}
259265

260266
return 0;
@@ -546,7 +552,7 @@ static int sfdp_read(const struct device *dev, off_t addr, void *dest,
546552
int rc;
547553

548554
set_up_xfer(dev, MSPI_RX);
549-
if (dev_data->in_target_io_mode) {
555+
if (in_octal_io(dev)) {
550556
dev_data->xfer.rx_dummy = dev_data->cmd_info.sfdp_dummy_20
551557
? 20 : 8;
552558
dev_data->xfer.addr_length = dev_data->cmd_info.sfdp_addr_4
@@ -572,7 +578,7 @@ static int read_jedec_id(const struct device *dev, uint8_t *id)
572578
int rc;
573579

574580
set_up_xfer(dev, MSPI_RX);
575-
if (dev_data->in_target_io_mode) {
581+
if (in_octal_io(dev)) {
576582
dev_data->xfer.rx_dummy = dev_data->cmd_info.rdid_dummy;
577583
dev_data->xfer.addr_length = dev_data->cmd_info.rdid_addr_4
578584
? 4 : 0;
@@ -963,7 +969,6 @@ static int soft_reset(const struct device *dev)
963969
return rc;
964970
}
965971
dev_data->last_applied_cfg = &dev_config->mspi_nor_cfg;
966-
dev_data->in_target_io_mode = true;
967972

968973
rc = soft_reset_66_99(dev);
969974
if (rc < 0) {
@@ -978,7 +983,6 @@ static int soft_reset(const struct device *dev)
978983
return rc;
979984
}
980985
dev_data->last_applied_cfg = &dev_config->mspi_control_cfg;
981-
dev_data->in_target_io_mode = false;
982986
}
983987

984988
rc = soft_reset_66_99(dev);
@@ -1011,7 +1015,6 @@ static int flash_chip_init(const struct device *dev)
10111015
LOG_ERR("%s: dev_config() failed: %d", __func__, rc);
10121016
return rc;
10131017
}
1014-
dev_data->in_target_io_mode = false;
10151018

10161019
#if defined(WITH_SUPPLY_GPIO)
10171020
if (dev_config->supply.port) {
@@ -1111,8 +1114,6 @@ static int flash_chip_init(const struct device *dev)
11111114
}
11121115
dev_data->chip_initialized = true;
11131116

1114-
dev_data->in_target_io_mode = true;
1115-
11161117
if (IS_ENABLED(CONFIG_FLASH_MSPI_NOR_USE_SFDP)) {
11171118
/* Read the SFDP signature to test if communication with
11181119
* the flash chip can be successfully performed after switching

drivers/flash/flash_mspi_nor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ struct flash_mspi_nor_data {
113113
struct jesd216_erase_type erase_types[JESD216_NUM_ERASE_TYPES];
114114
struct flash_mspi_nor_cmd_info cmd_info;
115115
struct flash_mspi_nor_switch_info switch_info;
116-
bool in_target_io_mode;
117116
const struct mspi_dev_cfg *last_applied_cfg;
118117
bool chip_initialized;
119118
};

0 commit comments

Comments
 (0)