drivers: spi: convert spi_nrfx_spim.c to new DT API

This allows us to start using DT_NODELABEL() to access SPIMs that way,
instead of via an alias.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2020-03-06 15:56:30 -08:00 committed by Kumar Gala
commit ffcf7cad6a

View file

@ -366,11 +366,17 @@ static int spim_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
}
#endif /* CONFIG_DEVICE_POWER_MANAGEMENT */
#define SPIM_NRFX_MISO_PULL_DOWN(idx) \
IS_ENABLED(DT_NORDIC_NRF_SPIM_SPI_##idx##_MISO_PULL_DOWN)
/*
* We use NODELABEL here because the nrfx API requires us to call
* functions which are named according to SoC peripheral instance
* being operated on. Since DT_INST() makes no guarantees about that,
* it won't work.
*/
#define SPIM(idx) DT_NODELABEL(spi##idx)
#define SPIM_PROP(idx, prop) DT_PROP(SPIM(idx), prop)
#define SPIM_NRFX_MISO_PULL_UP(idx) \
IS_ENABLED(DT_NORDIC_NRF_SPIM_SPI_##idx##_MISO_PULL_UP)
#define SPIM_NRFX_MISO_PULL_DOWN(idx) DT_PROP(SPIM(idx), miso_pull_down)
#define SPIM_NRFX_MISO_PULL_UP(idx) DT_PROP(SPIM(idx), miso_pull_up)
#define SPIM_NRFX_MISO_PULL(idx) \
(SPIM_NRFX_MISO_PULL_UP(idx) \
@ -396,7 +402,7 @@ static int spim_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
static int spi_##idx##_init(struct device *dev) \
{ \
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_SPIM##idx), \
DT_NORDIC_NRF_SPIM_SPI_##idx##_IRQ_0_PRIORITY, \
DT_IRQ(SPIM(idx), priority), \
nrfx_isr, nrfx_spim_##idx##_irq_handler, 0); \
return init_spim(dev); \
} \
@ -409,9 +415,9 @@ static int spim_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
.spim = NRFX_SPIM_INSTANCE(idx), \
.max_chunk_len = (1 << SPIM##idx##_EASYDMA_MAXCNT_SIZE) - 1, \
.config = { \
.sck_pin = DT_NORDIC_NRF_SPIM_SPI_##idx##_SCK_PIN, \
.mosi_pin = DT_NORDIC_NRF_SPIM_SPI_##idx##_MOSI_PIN, \
.miso_pin = DT_NORDIC_NRF_SPIM_SPI_##idx##_MISO_PIN, \
.sck_pin = SPIM_PROP(idx, sck_pin), \
.mosi_pin = SPIM_PROP(idx, mosi_pin), \
.miso_pin = SPIM_PROP(idx, miso_pin), \
.ss_pin = NRFX_SPIM_PIN_NOT_USED, \
.orc = CONFIG_SPI_##idx##_NRF_ORC, \
.frequency = NRF_SPIM_FREQ_4M, \
@ -422,7 +428,7 @@ static int spim_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
} \
}; \
DEVICE_DEFINE(spi_##idx, \
DT_NORDIC_NRF_SPIM_SPI_##idx##_LABEL, \
SPIM_PROP(idx, label), \
spi_##idx##_init, \
spim_nrfx_pm_control, \
&spi_##idx##_data, \