dts: nrf: Remove SPI dts.fixup defines and use aliases instead.

Changed driver to use defines from aliases instead of fixup.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
This commit is contained in:
Mieszko Mierunski 2018-10-03 14:08:07 +02:00 committed by Carles Cufí
commit c1f7e0c955
9 changed files with 116 additions and 149 deletions

View file

@ -271,37 +271,37 @@ static int init_spi(struct device *dev, const nrfx_spi_config_t *config)
return 0;
}
#define SPI_NRFX_SPI_DEVICE(idx) \
static int spi_##idx##_init(struct device *dev) \
{ \
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_SPI##idx), \
CONFIG_SPI_##idx##_IRQ_PRI, \
nrfx_isr, nrfx_spi_##idx##_irq_handler, 0); \
const nrfx_spi_config_t config = { \
.sck_pin = DT_SPI_##idx##_NRF_SCK_PIN, \
.mosi_pin = DT_SPI_##idx##_NRF_MOSI_PIN, \
.miso_pin = DT_SPI_##idx##_NRF_MISO_PIN, \
.ss_pin = NRFX_SPI_PIN_NOT_USED, \
.orc = CONFIG_SPI_##idx##_NRF_ORC, \
.frequency = NRF_SPI_FREQ_4M, \
.mode = NRF_SPI_MODE_0, \
.bit_order = NRF_SPI_BIT_ORDER_MSB_FIRST, \
}; \
return init_spi(dev, &config); \
} \
static struct spi_nrfx_data spi_##idx##_data = { \
SPI_CONTEXT_INIT_LOCK(spi_##idx##_data, ctx), \
SPI_CONTEXT_INIT_SYNC(spi_##idx##_data, ctx), \
.busy = false, \
}; \
static const struct spi_nrfx_config spi_##idx##_config = { \
.spi = NRFX_SPI_INSTANCE(idx), \
}; \
DEVICE_AND_API_INIT(spi_##idx, CONFIG_SPI_##idx##_NAME, \
spi_##idx##_init, \
&spi_##idx##_data, \
&spi_##idx##_config, \
POST_KERNEL, CONFIG_SPI_INIT_PRIORITY, \
#define SPI_NRFX_SPI_DEVICE(idx) \
static int spi_##idx##_init(struct device *dev) \
{ \
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_SPI##idx), \
DT_NORDIC_NRF_SPI_SPI_##idx##_IRQ_PRIORITY, \
nrfx_isr, nrfx_spi_##idx##_irq_handler, 0); \
const nrfx_spi_config_t config = { \
.sck_pin = DT_NORDIC_NRF_SPI_SPI_##idx##_SCK_PIN, \
.mosi_pin = DT_NORDIC_NRF_SPI_SPI_##idx##_MOSI_PIN, \
.miso_pin = DT_NORDIC_NRF_SPI_SPI_##idx##_MISO_PIN, \
.ss_pin = NRFX_SPI_PIN_NOT_USED, \
.orc = CONFIG_SPI_##idx##_NRF_ORC, \
.frequency = NRF_SPI_FREQ_4M, \
.mode = NRF_SPI_MODE_0, \
.bit_order = NRF_SPI_BIT_ORDER_MSB_FIRST, \
}; \
return init_spi(dev, &config); \
} \
static struct spi_nrfx_data spi_##idx##_data = { \
SPI_CONTEXT_INIT_LOCK(spi_##idx##_data, ctx), \
SPI_CONTEXT_INIT_SYNC(spi_##idx##_data, ctx), \
.busy = false, \
}; \
static const struct spi_nrfx_config spi_##idx##_config = { \
.spi = NRFX_SPI_INSTANCE(idx), \
}; \
DEVICE_AND_API_INIT(spi_##idx, DT_NORDIC_NRF_SPI_SPI_##idx##_LABEL, \
spi_##idx##_init, \
&spi_##idx##_data, \
&spi_##idx##_config, \
POST_KERNEL, CONFIG_SPI_INIT_PRIORITY, \
&spi_nrfx_driver_api)
#ifdef CONFIG_SPI_0_NRF_SPI

View file

@ -307,39 +307,40 @@ static int init_spim(struct device *dev, const nrfx_spim_config_t *config)
#define SPI_NRFX_SPIM_EXTENDED_CONFIG(idx)
#endif
#define SPI_NRFX_SPIM_DEVICE(idx) \
static int spi_##idx##_init(struct device *dev) \
{ \
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_SPIM##idx), \
CONFIG_SPI_##idx##_IRQ_PRI, \
nrfx_isr, nrfx_spim_##idx##_irq_handler, 0); \
const nrfx_spim_config_t config = { \
.sck_pin = DT_SPI_##idx##_NRF_SCK_PIN, \
.mosi_pin = DT_SPI_##idx##_NRF_MOSI_PIN, \
.miso_pin = DT_SPI_##idx##_NRF_MISO_PIN, \
.ss_pin = NRFX_SPIM_PIN_NOT_USED, \
.orc = CONFIG_SPI_##idx##_NRF_ORC, \
.frequency = NRF_SPIM_FREQ_4M, \
.mode = NRF_SPIM_MODE_0, \
.bit_order = NRF_SPIM_BIT_ORDER_MSB_FIRST, \
SPI_NRFX_SPIM_EXTENDED_CONFIG(idx) \
}; \
return init_spim(dev, &config); \
} \
static struct spi_nrfx_data spi_##idx##_data = { \
SPI_CONTEXT_INIT_LOCK(spi_##idx##_data, ctx), \
SPI_CONTEXT_INIT_SYNC(spi_##idx##_data, ctx), \
.busy = false, \
}; \
static const struct spi_nrfx_config spi_##idx##_config = { \
.spim = NRFX_SPIM_INSTANCE(idx), \
.max_chunk_len = (1 << SPIM##idx##_EASYDMA_MAXCNT_SIZE) - 1, \
}; \
DEVICE_AND_API_INIT(spi_##idx, DT_SPI_##idx##_NAME, \
spi_##idx##_init, \
&spi_##idx##_data, \
&spi_##idx##_config, \
POST_KERNEL, CONFIG_SPI_INIT_PRIORITY, \
#define SPI_NRFX_SPIM_DEVICE(idx) \
static int spi_##idx##_init(struct device *dev) \
{ \
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_SPIM##idx), \
DT_NORDIC_NRF_SPI_SPI_##idx##_IRQ_PRIORITY, \
nrfx_isr, nrfx_spim_##idx##_irq_handler, 0); \
const nrfx_spim_config_t config = { \
.sck_pin = DT_NORDIC_NRF_SPI_SPI_##idx##_SCK_PIN, \
.mosi_pin = DT_NORDIC_NRF_SPI_SPI_##idx##_MOSI_PIN, \
.miso_pin = DT_NORDIC_NRF_SPI_SPI_##idx##_MISO_PIN, \
.ss_pin = NRFX_SPIM_PIN_NOT_USED, \
.orc = CONFIG_SPI_##idx##_NRF_ORC, \
.frequency = NRF_SPIM_FREQ_4M, \
.mode = NRF_SPIM_MODE_0, \
.bit_order = NRF_SPIM_BIT_ORDER_MSB_FIRST, \
SPI_NRFX_SPIM_EXTENDED_CONFIG(idx) \
}; \
return init_spim(dev, &config); \
} \
static struct spi_nrfx_data spi_##idx##_data = { \
SPI_CONTEXT_INIT_LOCK(spi_##idx##_data, ctx), \
SPI_CONTEXT_INIT_SYNC(spi_##idx##_data, ctx), \
.busy = false, \
}; \
static const struct spi_nrfx_config spi_##idx##_config = { \
.spim = NRFX_SPIM_INSTANCE(idx), \
.max_chunk_len = (1 << SPIM##idx##_EASYDMA_MAXCNT_SIZE) - 1, \
}; \
DEVICE_AND_API_INIT(spi_##idx, \
DT_NORDIC_NRF_SPI_SPI_##idx##_LABEL, \
spi_##idx##_init, \
&spi_##idx##_data, \
&spi_##idx##_config, \
POST_KERNEL, CONFIG_SPI_INIT_PRIORITY, \
&spi_nrfx_driver_api)
#ifdef CONFIG_SPI_0_NRF_SPIM

View file

@ -247,39 +247,41 @@ static int init_spis(struct device *dev, const nrfx_spis_config_t *config)
return 0;
}
#define SPI_NRFX_SPIS_DEVICE(idx) \
static int spi_##idx##_init(struct device *dev) \
{ \
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_SPIS##idx), \
CONFIG_SPI_##idx##_IRQ_PRI, \
nrfx_isr, nrfx_spis_##idx##_irq_handler, 0); \
const nrfx_spis_config_t config = { \
.sck_pin = DT_SPI_##idx##_NRF_SCK_PIN, \
.mosi_pin = DT_SPI_##idx##_NRF_MOSI_PIN, \
.miso_pin = DT_SPI_##idx##_NRF_MISO_PIN, \
.csn_pin = DT_SPI_##idx##_NRF_CSN_PIN, \
.mode = NRF_SPIS_MODE_0, \
.bit_order = NRF_SPIS_BIT_ORDER_MSB_FIRST, \
.csn_pullup = NRFX_SPIS_DEFAULT_CSN_PULLUP, \
.miso_drive = NRFX_SPIS_DEFAULT_MISO_DRIVE, \
.orc = CONFIG_SPI_##idx##_NRF_ORC, \
.def = CONFIG_SPI_##idx##_NRF_DEF, \
}; \
return init_spis(dev, &config); \
} \
static struct spi_nrfx_data spi_##idx##_data = { \
SPI_CONTEXT_INIT_LOCK(spi_##idx##_data, ctx), \
SPI_CONTEXT_INIT_SYNC(spi_##idx##_data, ctx), \
}; \
static const struct spi_nrfx_config spi_##idx##_config = { \
.spis = NRFX_SPIS_INSTANCE(idx), \
.max_buf_len = (1 << SPIS##idx##_EASYDMA_MAXCNT_SIZE) - 1, \
}; \
DEVICE_AND_API_INIT(spi_##idx, DT_SPI_##idx##_NAME, \
spi_##idx##_init, \
&spi_##idx##_data, \
&spi_##idx##_config, \
POST_KERNEL, CONFIG_SPI_INIT_PRIORITY, \
#define SPI_NRFX_SPIS_DEVICE(idx) \
static int spi_##idx##_init(struct device *dev) \
{ \
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_SPIS##idx), \
DT_NORDIC_NRF_SPI_SPI_##idx##_IRQ_PRIORITY, \
nrfx_isr, nrfx_spis_##idx##_irq_handler, 0); \
const nrfx_spis_config_t config = { \
.sck_pin = DT_NORDIC_NRF_SPI_SPI_##idx##_SCK_PIN, \
.mosi_pin = DT_NORDIC_NRF_SPI_SPI_##idx##_MOSI_PIN, \
.miso_pin = DT_NORDIC_NRF_SPI_SPI_##idx##_MISO_PIN, \
.csn_pin = DT_NORDIC_NRF_SPI_SPI_##idx##_CSN_PIN, \
.mode = NRF_SPIS_MODE_0, \
.bit_order = NRF_SPIS_BIT_ORDER_MSB_FIRST, \
.csn_pullup = NRFX_SPIS_DEFAULT_CSN_PULLUP, \
.miso_drive = NRFX_SPIS_DEFAULT_MISO_DRIVE, \
.orc = CONFIG_SPI_##idx##_NRF_ORC, \
.def = CONFIG_SPI_##idx##_NRF_DEF, \
}; \
return init_spis(dev, &config); \
} \
static struct spi_nrfx_data spi_##idx##_data = { \
SPI_CONTEXT_INIT_LOCK(spi_##idx##_data, ctx), \
SPI_CONTEXT_INIT_SYNC(spi_##idx##_data, ctx), \
}; \
static const struct spi_nrfx_config spi_##idx##_config = { \
.spis = NRFX_SPIS_INSTANCE(idx), \
.max_buf_len = (1 << SPIS##idx##_EASYDMA_MAXCNT_SIZE) - 1, \
}; \
DEVICE_AND_API_INIT(spi_##idx, \
DT_NORDIC_NRF_SPI_SPI_##idx##_LABEL, \
spi_##idx##_init, \
&spi_##idx##_data, \
&spi_##idx##_config, \
POST_KERNEL, \
CONFIG_SPI_INIT_PRIORITY, \
&spi_nrfx_driver_api)
#ifdef CONFIG_SPI_0_NRF_SPIS

View file

@ -39,6 +39,8 @@
aliases {
i2c-0 = &i2c0;
i2c-1 = &i2c1;
spi-0 = &spi0;
spi-1 = &spi1;
};
soc {

View file

@ -37,6 +37,7 @@
aliases {
i2c-0 = &i2c0;
spi-0 = &spi0;
};
soc {

View file

@ -39,6 +39,9 @@
aliases {
i2c-0 = &i2c0;
i2c-1 = &i2c1;
spi-0 = &spi0;
spi-1 = &spi1;
spi-2 = &spi2;
};
soc {

View file

@ -39,6 +39,10 @@
aliases {
i2c-0 = &i2c0;
i2c-1 = &i2c1;
spi-0 = &spi0;
spi-1 = &spi1;
spi-2 = &spi2;
spi-3 = &spi3;
};
soc {

View file

@ -44,23 +44,8 @@
#define DT_QDEC_LED_PRE DT_NORDIC_NRF_QDEC_40012000_LED_PRE
#define DT_QDEC_STEPS DT_NORDIC_NRF_QDEC_40012000_STEPS
#define DT_SPI_0_BASE_ADDRESS DT_NORDIC_NRF_SPI_40003000_BASE_ADDRESS
#define DT_SPI_0_NAME DT_NORDIC_NRF_SPI_40003000_LABEL
#define CONFIG_SPI_0_IRQ_PRI DT_NORDIC_NRF_SPI_40003000_IRQ_0_PRIORITY
#define DT_SPI_0_IRQ DT_NORDIC_NRF_SPI_40003000_IRQ_0
#define DT_SPI_0_NRF_SCK_PIN DT_NORDIC_NRF_SPI_40003000_SCK_PIN
#define DT_SPI_0_NRF_MOSI_PIN DT_NORDIC_NRF_SPI_40003000_MOSI_PIN
#define DT_SPI_0_NRF_MISO_PIN DT_NORDIC_NRF_SPI_40003000_MISO_PIN
#define DT_SPI_0_NRF_CSN_PIN DT_NORDIC_NRF_SPI_40003000_CSN_PIN
#define DT_SPI_1_BASE_ADDRESS DT_NORDIC_NRF_SPI_40004000_BASE_ADDRESS
#define DT_SPI_1_NAME DT_NORDIC_NRF_SPI_40004000_LABEL
#define CONFIG_SPI_1_IRQ_PRI DT_NORDIC_NRF_SPI_40004000_IRQ_0_PRIORITY
#define DT_SPI_1_IRQ DT_NORDIC_NRF_SPI_40004000_IRQ_0
#define DT_SPI_1_NRF_SCK_PIN DT_NORDIC_NRF_SPI_40004000_SCK_PIN
#define DT_SPI_1_NRF_MOSI_PIN DT_NORDIC_NRF_SPI_40004000_MOSI_PIN
#define DT_SPI_1_NRF_MISO_PIN DT_NORDIC_NRF_SPI_40004000_MISO_PIN
#define DT_SPI_1_NRF_CSN_PIN DT_NORDIC_NRF_SPI_40004000_CSN_PIN
#define DT_SPI_0_NAME DT_NORDIC_NRF_SPI_SPI_0_LABEL
#define DT_SPI_1_NAME DT_NORDIC_NRF_SPI_SPI_1_LABEL
#define CONFIG_WDT_0_NAME DT_NORDIC_NRF_WATCHDOG_40010000_LABEL
#define DT_WDT_NRF_IRQ DT_NORDIC_NRF_WATCHDOG_40010000_IRQ_WDT

View file

@ -77,41 +77,10 @@
#define DT_QDEC_LED_PRE DT_NORDIC_NRF_QDEC_40012000_LED_PRE
#define DT_QDEC_STEPS DT_NORDIC_NRF_QDEC_40012000_STEPS
#define DT_SPI_0_BASE_ADDRESS DT_NORDIC_NRF_SPI_40003000_BASE_ADDRESS
#define DT_SPI_0_NAME DT_NORDIC_NRF_SPI_40003000_LABEL
#define CONFIG_SPI_0_IRQ_PRI DT_NORDIC_NRF_SPI_40003000_IRQ_0_PRIORITY
#define DT_SPI_0_IRQ DT_NORDIC_NRF_SPI_40003000_IRQ_0
#define DT_SPI_0_NRF_SCK_PIN DT_NORDIC_NRF_SPI_40003000_SCK_PIN
#define DT_SPI_0_NRF_MOSI_PIN DT_NORDIC_NRF_SPI_40003000_MOSI_PIN
#define DT_SPI_0_NRF_MISO_PIN DT_NORDIC_NRF_SPI_40003000_MISO_PIN
#define DT_SPI_0_NRF_CSN_PIN DT_NORDIC_NRF_SPI_40003000_CSN_PIN
#define DT_SPI_1_BASE_ADDRESS DT_NORDIC_NRF_SPI_40004000_BASE_ADDRESS
#define DT_SPI_1_NAME DT_NORDIC_NRF_SPI_40004000_LABEL
#define CONFIG_SPI_1_IRQ_PRI DT_NORDIC_NRF_SPI_40004000_IRQ_0_PRIORITY
#define DT_SPI_1_IRQ DT_NORDIC_NRF_SPI_40004000_IRQ_0
#define DT_SPI_1_NRF_SCK_PIN DT_NORDIC_NRF_SPI_40004000_SCK_PIN
#define DT_SPI_1_NRF_MOSI_PIN DT_NORDIC_NRF_SPI_40004000_MOSI_PIN
#define DT_SPI_1_NRF_MISO_PIN DT_NORDIC_NRF_SPI_40004000_MISO_PIN
#define DT_SPI_1_NRF_CSN_PIN DT_NORDIC_NRF_SPI_40004000_CSN_PIN
#define DT_SPI_2_BASE_ADDRESS DT_NORDIC_NRF_SPI_40023000_BASE_ADDRESS
#define DT_SPI_2_NAME DT_NORDIC_NRF_SPI_40023000_LABEL
#define CONFIG_SPI_2_IRQ_PRI DT_NORDIC_NRF_SPI_40023000_IRQ_0_PRIORITY
#define DT_SPI_2_IRQ DT_NORDIC_NRF_SPI_40023000_IRQ_0
#define DT_SPI_2_NRF_SCK_PIN DT_NORDIC_NRF_SPI_40023000_SCK_PIN
#define DT_SPI_2_NRF_MOSI_PIN DT_NORDIC_NRF_SPI_40023000_MOSI_PIN
#define DT_SPI_2_NRF_MISO_PIN DT_NORDIC_NRF_SPI_40023000_MISO_PIN
#define DT_SPI_2_NRF_CSN_PIN DT_NORDIC_NRF_SPI_40023000_CSN_PIN
#define DT_SPI_3_BASE_ADDRESS DT_NORDIC_NRF_SPI_4002B000_BASE_ADDRESS
#define DT_SPI_3_NAME DT_NORDIC_NRF_SPI_4002B000_LABEL
#define CONFIG_SPI_3_IRQ_PRI DT_NORDIC_NRF_SPI_4002B000_IRQ_0_PRIORITY
#define DT_SPI_3_IRQ DT_NORDIC_NRF_SPI_4002B000_IRQ_0
#define DT_SPI_3_NRF_SCK_PIN DT_NORDIC_NRF_SPI_4002B000_SCK_PIN
#define DT_SPI_3_NRF_MOSI_PIN DT_NORDIC_NRF_SPI_4002B000_MOSI_PIN
#define DT_SPI_3_NRF_MISO_PIN DT_NORDIC_NRF_SPI_4002B000_MISO_PIN
#define DT_SPI_3_NRF_CSN_PIN DT_NORDIC_NRF_SPI_4002B000_CSN_PIN
#define DT_SPI_0_NAME DT_NORDIC_NRF_SPI_SPI_0_LABEL
#define DT_SPI_1_NAME DT_NORDIC_NRF_SPI_SPI_1_LABEL
#define DT_SPI_2_NAME DT_NORDIC_NRF_SPI_SPI_2_LABEL
#define DT_SPI_3_NAME DT_NORDIC_NRF_SPI_SPI_3_LABEL
#define DT_USBD_NRF_IRQ DT_NORDIC_NRF_USBD_40027000_IRQ_USBD
#define DT_USBD_NRF_IRQ_PRI DT_NORDIC_NRF_USBD_40027000_IRQ_USBD_PRIORITY