Skip to content

Commit 6b7a852

Browse files
committed
flash: spi_nor: handle SPI bus power
Automatically request and release the SPI bus before talking to the flash chip. Signed-off-by: Jordan Yates <[email protected]>
1 parent 9dc23ee commit 6b7a852

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/flash/spi_nor.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,16 +557,24 @@ static int exit_dpd(const struct device *const dev)
557557
/* Everything necessary to acquire owning access to the device. */
558558
static void acquire_device(const struct device *dev)
559559
{
560+
const struct spi_nor_config *cfg = dev->config;
561+
560562
if (IS_ENABLED(CONFIG_MULTITHREADING)) {
561563
struct spi_nor_data *const driver_data = dev->data;
562564

563565
k_sem_take(&driver_data->sem, K_FOREVER);
564566
}
567+
568+
(void)pm_device_runtime_get(cfg->spi.bus);
565569
}
566570

567571
/* Everything necessary to release access to the device. */
568572
static void release_device(const struct device *dev)
569573
{
574+
const struct spi_nor_config *cfg = dev->config;
575+
576+
(void)pm_device_runtime_put(cfg->spi.bus);
577+
570578
if (IS_ENABLED(CONFIG_MULTITHREADING)) {
571579
struct spi_nor_data *const driver_data = dev->data;
572580

0 commit comments

Comments
 (0)