Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions drivers/spi/spi_nrfx_spis.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ LOG_MODULE_REGISTER(spi_nrfx_spis, CONFIG_SPI_LOG_LEVEL);
#include <nrf/gpd.h>
#endif

#define SPIS_IS_FAST(idx) IS_EQ(idx, 120)

#define NRFX_SPIS_IS_FAST(unused, prefix, id, _) SPIS_IS_FAST(prefix##id)

#if NRFX_FOREACH_ENABLED(SPIS, NRFX_SPIS_IS_FAST, (+), (0), _)
/* If fast instances are used then system managed device PM cannot be used because
* it may call PM actions from locked context and fast SPIM PM actions can only be
* called from a thread context.
*/
BUILD_ASSERT(!IS_ENABLED(CONFIG_PM_DEVICE_SYSTEM_MANAGED));
#endif

struct spi_nrfx_data {
struct spi_context ctx;
const struct device *dev;
Expand Down Expand Up @@ -335,7 +347,7 @@ static void event_handler(const nrfx_spis_evt_t *p_event, void *p_context)
spi_context_complete(&dev_data->ctx, dev_data->dev,
p_event->rx_amount);

pm_device_runtime_put(dev_data->dev);
pm_device_runtime_put_async(dev_data->dev, K_NO_WAIT);
}
}

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

#define SPIS_NODE(idx) COND_CODE_1(IS_EQ(idx, 120), (spis##idx), (spi##idx))
#define SPIS_NODE(idx) COND_CODE_1(SPIS_IS_FAST(idx), (spis##idx), (spi##idx))

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

Expand Down Expand Up @@ -502,7 +514,8 @@ static int spi_nrfx_init(const struct device *dev)
BUILD_ASSERT(!DT_NODE_HAS_PROP(SPIS(idx), wake_gpios) || \
!(DT_GPIO_FLAGS(SPIS(idx), wake_gpios) & GPIO_ACTIVE_LOW),\
"WAKE line must be configured as active high"); \
PM_DEVICE_DT_DEFINE(SPIS(idx), spi_nrfx_pm_action, 1); \
PM_DEVICE_DT_DEFINE(SPIS(idx), spi_nrfx_pm_action, \
COND_CODE_1(SPIS_IS_FAST(idx), (0), (PM_DEVICE_ISR_SAFE))); \
SPI_DEVICE_DT_DEFINE(SPIS(idx), \
spi_nrfx_init, \
PM_DEVICE_DT_GET(SPIS(idx)), \
Expand Down
Loading