drivers: flash: npcx: add k_usleep when polling busy status

Adding k_usleep while polling the flash's busy status yields the CPU
resource, giving lower-priority threads the opportunity to run.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
This commit is contained in:
Jun Lin 2025-02-24 09:58:07 +08:00 committed by Benjamin Cabé
commit dee7927a21

View file

@ -26,6 +26,8 @@ LOG_MODULE_REGISTER(flash_npcx_fiu_nor, CONFIG_FLASH_LOG_LEVEL);
#define BLOCK_64K_SIZE KB(64) #define BLOCK_64K_SIZE KB(64)
#define BLOCK_4K_SIZE KB(4) #define BLOCK_4K_SIZE KB(4)
#define POLLING_BUSY_SLEEP_TIME_US 100
/* Device config */ /* Device config */
struct flash_npcx_nor_config { struct flash_npcx_nor_config {
/* QSPI bus device for mutex control and bus configuration */ /* QSPI bus device for mutex control and bus configuration */
@ -153,6 +155,7 @@ static int flash_npcx_nor_wait_until_ready(const struct device *dev)
return 0; return 0;
} }
k_usleep(POLLING_BUSY_SLEEP_TIME_US);
} while ((k_uptime_get() - st) < config->max_timeout); } while ((k_uptime_get() - st) < config->max_timeout);
return -EBUSY; return -EBUSY;