Skip to content

Commit d4ae43e

Browse files
SuperHeroAbnerjhedberg
authored andcommitted
drivers: xspi: fix device config failure in XIP mode
Add bus idle wait after clock rate query to ensure AHB transactions complete before device configuration. This prevents XSPI_SetDeviceConfig from failing due to ongoing AHB access detection in XIP environments. The issue occurs because clock_control_get_rate() triggers AHB transactions that complete asynchronously, causings subsequent device configuration to fail due to its bus status checking. Signed-off-by: Ruijia Wang <ruijia.wang@nxp.com>
1 parent 4bc8b31 commit d4ae43e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/flash/flash_mcux_xspi.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -439,11 +439,6 @@ static int flash_mcux_xspi_probe(const struct device *dev)
439439
uint32_t key = 0;
440440
int ret;
441441

442-
if (memc_xspi_is_running_xip(xspi_dev)) {
443-
key = irq_lock();
444-
memc_xspi_wait_bus_idle(xspi_dev);
445-
}
446-
447442
/* Setup the specific flash parameters. */
448443
for (uint32_t i = 0; i < ARRAY_SIZE(device_configs); i++) {
449444
if (strncmp(device_configs[i].name_prefix, data->dev_name,
@@ -470,13 +465,19 @@ static int flash_mcux_xspi_probe(const struct device *dev)
470465
break;
471466
}
472467

468+
/* Block potential AHB access when setup XSPI. */
469+
if (memc_xspi_is_running_xip(xspi_dev)) {
470+
key = irq_lock();
471+
memc_xspi_wait_bus_idle(xspi_dev);
472+
}
473+
473474
ret = memc_xspi_set_device_config(xspi_dev, dev_config, flash_dev_config->lut_array,
474475
flash_dev_config->lut_count);
475-
} while (0);
476476

477-
if (memc_xspi_is_running_xip(xspi_dev)) {
478-
irq_unlock(key);
479-
}
477+
if (memc_xspi_is_running_xip(xspi_dev)) {
478+
irq_unlock(key);
479+
}
480+
} while (0);
480481

481482
return ret;
482483
}

0 commit comments

Comments
 (0)