Skip to content

Commit cd5475d

Browse files
committed
[nrf fromlist] drivers: spi: nrfx_spis: Fix spis120
ISR safe runtime PM can only be used for all instances except for spis120 which requires standard runtime PM. Added compilation guard against using CONFIG_PM_DEVICE_SYSTEM_MANAGED with spis120. Upstream PR #: 88428 Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 36d6c19 commit cd5475d

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

drivers/spi/spi_nrfx_spis.c

+16-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ LOG_MODULE_REGISTER(spi_nrfx_spis, CONFIG_SPI_LOG_LEVEL);
2424
#include <nrf/gpd.h>
2525
#endif
2626

27+
#define SPIS_IS_FAST(idx) IS_EQ(idx, 120)
28+
29+
#define NRFX_SPIS_IS_FAST(unused, prefix, id, _) SPIS_IS_FAST(prefix##id)
30+
31+
#if NRFX_FOREACH_ENABLED(SPIS, NRFX_SPIS_IS_FAST, (+), (0), _)
32+
/* If fast instances are used then system managed device PM cannot be used because
33+
* it may call PM actions from locked context and fast SPIM PM actions can only be
34+
* called from a thread context.
35+
*/
36+
BUILD_ASSERT(!IS_ENABLED(CONFIG_PM_DEVICE_SYSTEM_MANAGED));
37+
#endif
38+
2739
struct spi_nrfx_data {
2840
struct spi_context ctx;
2941
const struct device *dev;
@@ -335,7 +347,7 @@ static void event_handler(const nrfx_spis_evt_t *p_event, void *p_context)
335347
spi_context_complete(&dev_data->ctx, dev_data->dev,
336348
p_event->rx_amount);
337349

338-
pm_device_runtime_put(dev_data->dev);
350+
pm_device_runtime_put_async(dev_data->dev, K_NO_WAIT);
339351
}
340352
}
341353

@@ -457,7 +469,7 @@ static int spi_nrfx_init(const struct device *dev)
457469
* - Name-based HAL IRQ handlers, e.g. nrfx_spis_0_irq_handler
458470
*/
459471

460-
#define SPIS_NODE(idx) COND_CODE_1(IS_EQ(idx, 120), (spis##idx), (spi##idx))
472+
#define SPIS_NODE(idx) COND_CODE_1(SPIS_IS_FAST(idx), (spis##idx), (spi##idx))
461473

462474
#define SPIS(idx) DT_NODELABEL(SPIS_NODE(idx))
463475

@@ -502,7 +514,8 @@ static int spi_nrfx_init(const struct device *dev)
502514
BUILD_ASSERT(!DT_NODE_HAS_PROP(SPIS(idx), wake_gpios) || \
503515
!(DT_GPIO_FLAGS(SPIS(idx), wake_gpios) & GPIO_ACTIVE_LOW),\
504516
"WAKE line must be configured as active high"); \
505-
PM_DEVICE_DT_DEFINE(SPIS(idx), spi_nrfx_pm_action, 1); \
517+
PM_DEVICE_DT_DEFINE(SPIS(idx), spi_nrfx_pm_action, \
518+
COND_CODE_1(SPIS_IS_FAST(idx), (0), (PM_DEVICE_ISR_SAFE))); \
506519
SPI_DEVICE_DT_DEFINE(SPIS(idx), \
507520
spi_nrfx_init, \
508521
PM_DEVICE_DT_GET(SPIS(idx)), \

0 commit comments

Comments
 (0)