Skip to content

Commit 2cffa44

Browse files
[nrf fromlist] drivers: spi: spi_nrfx_spis: add conditional PM ISR safety
Requesting/releasing SPIM device may be ISR safe, but it cannot be reliably known whether managing its power domain is. Is is then assumed that if power domains are used, device is no longer ISR safe. This macro let's us check if we will be requesting/releasing power domains and determines PM device ISR safety value. Upstream PR #: 96402 Signed-off-by: Michał Stasiak <[email protected]>
1 parent e7637d5 commit 2cffa44

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

drivers/spi/spi_nrfx_spis.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,32 @@ static int spi_nrfx_init(const struct device *dev)
551551
return pm_device_driver_init(dev, spi_nrfx_pm_action);
552552
}
553553

554+
/* Macro determines PM actions interrupt safety level.
555+
*
556+
* Requesting/releasing SPIS device may be ISR safe, but it cannot be reliably known whether
557+
* managing its power domain is. It is then assumed that if power domains are used, device is
558+
* no longer ISR safe. This macro let's us check if we will be requesting/releasing
559+
* power domains and determines PM device ISR safety value.
560+
*
561+
* Additionally, fast SPIS devices are not ISR safe.
562+
*/
563+
#define SPIS_PM_ISR_SAFE(idx) \
564+
COND_CODE_1( \
565+
UTIL_AND( \
566+
IS_ENABLED(CONFIG_PM_DEVICE_POWER_DOMAIN), \
567+
UTIL_AND( \
568+
DT_NODE_HAS_PROP(SPIS(idx), power_domains), \
569+
DT_NODE_HAS_STATUS_OKAY(DT_PHANDLE(SPIS(idx), power_domains)) \
570+
) \
571+
), \
572+
(0), \
573+
(COND_CODE_1( \
574+
SPIS_IS_FAST(idx), \
575+
(0), \
576+
(PM_DEVICE_ISR_SAFE) \
577+
)) \
578+
)
579+
554580
#define SPI_NRFX_SPIS_DEFINE(idx) \
555581
NRF_DT_CHECK_NODE_HAS_REQUIRED_MEMORY_REGIONS(SPIS(idx)); \
556582
static void irq_connect##idx(void) \
@@ -597,8 +623,7 @@ static int spi_nrfx_init(const struct device *dev)
597623
!(DT_GPIO_FLAGS(SPIS(idx), wake_gpios) & GPIO_ACTIVE_LOW),\
598624
"WAKE line must be configured as active high"); \
599625
PM_DEVICE_DT_DEFINE(SPIS(idx), spi_nrfx_pm_action, \
600-
COND_CODE_1(SPIS_IS_FAST(idx), (0), \
601-
(PM_DEVICE_ISR_SAFE))); \
626+
SPIS_PM_ISR_SAFE(idx)); \
602627
SPI_DEVICE_DT_DEFINE(SPIS(idx), \
603628
spi_nrfx_init, \
604629
PM_DEVICE_DT_GET(SPIS(idx)), \

0 commit comments

Comments
 (0)