From 5a10087a2555f5639396fde3166b37c45b1d6668 Mon Sep 17 00:00:00 2001 From: Mieszko Mierunski Date: Wed, 3 Oct 2018 11:54:11 +0200 Subject: [PATCH] dts: nrf: Remove TWI dts.fixup defines and use aliases instead. Changed driver to use alias defines instead of fixup. Signed-off-by: Mieszko Mierunski --- drivers/i2c/i2c_nrfx_twi.c | 49 +++++++++++++++------------- drivers/i2c/i2c_nrfx_twim.c | 49 +++++++++++++++------------- dts/arm/nordic/nrf51822.dtsi | 5 +++ dts/arm/nordic/nrf52810.dtsi | 4 +++ dts/arm/nordic/nrf52832.dtsi | 5 +++ dts/arm/nordic/nrf52840.dtsi | 5 +++ soc/arm/nordic_nrf/nrf51/dts_fixup.h | 17 ++-------- soc/arm/nordic_nrf/nrf52/dts_fixup.h | 17 ++-------- 8 files changed, 75 insertions(+), 76 deletions(-) diff --git a/drivers/i2c/i2c_nrfx_twi.c b/drivers/i2c/i2c_nrfx_twi.c index bb468158c6a..e1051ecc662 100644 --- a/drivers/i2c/i2c_nrfx_twi.c +++ b/drivers/i2c/i2c_nrfx_twi.c @@ -136,29 +136,32 @@ static int init_twi(struct device *dev, const nrfx_twi_config_t *config) return 0; } -#define I2C_NRFX_TWI_DEVICE(idx) \ - static int twi_##idx##_init(struct device *dev) \ - { \ - IRQ_CONNECT(DT_I2C_##idx##_IRQ, \ - DT_I2C_##idx##_IRQ_PRI, \ - nrfx_isr, nrfx_twi_##idx##_irq_handler, 0); \ - const nrfx_twi_config_t config = { \ - .scl = DT_I2C_##idx##_SCL_PIN, \ - .sda = DT_I2C_##idx##_SDA_PIN, \ - .frequency = NRF_TWI_FREQ_100K, \ - }; \ - return init_twi(dev, &config); \ - } \ - static struct i2c_nrfx_twi_data twi_##idx##_data = { \ - .sync = _K_SEM_INITIALIZER(twi_##idx##_data.sync, 0, 1) \ - }; \ - static const struct i2c_nrfx_twi_config twi_##idx##_config = { \ - .twi = NRFX_TWI_INSTANCE(idx) \ - }; \ - DEVICE_AND_API_INIT(twi_##idx, CONFIG_I2C_##idx##_NAME, \ - twi_##idx##_init, &twi_##idx##_data, \ - &twi_##idx##_config, POST_KERNEL, \ - CONFIG_I2C_INIT_PRIORITY, \ +#define I2C_NRFX_TWI_DEVICE(idx) \ + static int twi_##idx##_init(struct device *dev) \ + { \ + IRQ_CONNECT(DT_NORDIC_NRF_I2C_I2C_##idx##_IRQ, \ + DT_NORDIC_NRF_I2C_I2C_##idx##_IRQ_PRIORITY, \ + nrfx_isr, nrfx_twi_##idx##_irq_handler, 0); \ + const nrfx_twi_config_t config = { \ + .scl = DT_NORDIC_NRF_I2C_I2C_##idx##_SCL_PIN, \ + .sda = DT_NORDIC_NRF_I2C_I2C_##idx##_SDA_PIN, \ + .frequency = NRF_TWI_FREQ_100K, \ + }; \ + return init_twi(dev, &config); \ + } \ + static struct i2c_nrfx_twi_data twi_##idx##_data = { \ + .sync = _K_SEM_INITIALIZER(twi_##idx##_data.sync, 0, 1) \ + }; \ + static const struct i2c_nrfx_twi_config twi_##idx##_config = { \ + .twi = NRFX_TWI_INSTANCE(idx) \ + }; \ + DEVICE_AND_API_INIT(twi_##idx, \ + DT_NORDIC_NRF_I2C_I2C_##idx##_LABEL, \ + twi_##idx##_init, \ + &twi_##idx##_data, \ + &twi_##idx##_config, \ + POST_KERNEL, \ + CONFIG_I2C_INIT_PRIORITY, \ &i2c_nrfx_twi_driver_api) #ifdef CONFIG_I2C_0_NRF_TWI diff --git a/drivers/i2c/i2c_nrfx_twim.c b/drivers/i2c/i2c_nrfx_twim.c index 2da1b4a27af..b6f6baa312c 100644 --- a/drivers/i2c/i2c_nrfx_twim.c +++ b/drivers/i2c/i2c_nrfx_twim.c @@ -137,29 +137,32 @@ static int init_twim(struct device *dev, const nrfx_twim_config_t *config) return 0; } -#define I2C_NRFX_TWIM_DEVICE(idx) \ - static int twim_##idx##_init(struct device *dev) \ - { \ - IRQ_CONNECT(DT_I2C_##idx##_IRQ, \ - DT_I2C_##idx##_IRQ_PRI, \ - nrfx_isr, nrfx_twim_##idx##_irq_handler, 0);\ - const nrfx_twim_config_t config = { \ - .scl = DT_I2C_##idx##_SCL_PIN, \ - .sda = DT_I2C_##idx##_SDA_PIN, \ - .frequency = NRF_TWIM_FREQ_100K, \ - }; \ - return init_twim(dev, &config); \ - } \ - static struct i2c_nrfx_twim_data twim_##idx##_data = { \ - .sync = _K_SEM_INITIALIZER(twim_##idx##_data.sync, 0, 1)\ - }; \ - static const struct i2c_nrfx_twim_config twim_##idx##_config = {\ - .twim = NRFX_TWIM_INSTANCE(idx) \ - }; \ - DEVICE_AND_API_INIT(twim_##idx, CONFIG_I2C_##idx##_NAME, \ - twim_##idx##_init, &twim_##idx##_data, \ - &twim_##idx##_config, POST_KERNEL, \ - CONFIG_I2C_INIT_PRIORITY, \ +#define I2C_NRFX_TWIM_DEVICE(idx) \ + static int twim_##idx##_init(struct device *dev) \ + { \ + IRQ_CONNECT(DT_NORDIC_NRF_I2C_I2C_##idx##_IRQ, \ + DT_NORDIC_NRF_I2C_I2C_##idx##_IRQ_PRIORITY, \ + nrfx_isr, nrfx_twim_##idx##_irq_handler, 0); \ + const nrfx_twim_config_t config = { \ + .scl = DT_NORDIC_NRF_I2C_I2C_##idx##_SCL_PIN, \ + .sda = DT_NORDIC_NRF_I2C_I2C_##idx##_SDA_PIN, \ + .frequency = NRF_TWIM_FREQ_100K, \ + }; \ + return init_twim(dev, &config); \ + } \ + static struct i2c_nrfx_twim_data twim_##idx##_data = { \ + .sync = _K_SEM_INITIALIZER(twim_##idx##_data.sync, 0, 1) \ + }; \ + static const struct i2c_nrfx_twim_config twim_##idx##_config = { \ + .twim = NRFX_TWIM_INSTANCE(idx) \ + }; \ + DEVICE_AND_API_INIT(twim_##idx, \ + DT_NORDIC_NRF_I2C_I2C_##idx##_LABEL, \ + twim_##idx##_init, \ + &twim_##idx##_data, \ + &twim_##idx##_config, \ + POST_KERNEL, \ + CONFIG_I2C_INIT_PRIORITY, \ &i2c_nrfx_twim_driver_api) #ifdef CONFIG_I2C_0_NRF_TWIM diff --git a/dts/arm/nordic/nrf51822.dtsi b/dts/arm/nordic/nrf51822.dtsi index 992ba123506..a895a3cbb60 100644 --- a/dts/arm/nordic/nrf51822.dtsi +++ b/dts/arm/nordic/nrf51822.dtsi @@ -36,6 +36,11 @@ compatible = "mmio-sram"; }; + aliases { + i2c-0 = &i2c0; + i2c-1 = &i2c1; + }; + soc { adc: adc@40007000 { compatible = "nordic,nrf-adc"; diff --git a/dts/arm/nordic/nrf52810.dtsi b/dts/arm/nordic/nrf52810.dtsi index 011261eb073..160cd994eb3 100644 --- a/dts/arm/nordic/nrf52810.dtsi +++ b/dts/arm/nordic/nrf52810.dtsi @@ -35,6 +35,10 @@ compatible = "mmio-sram"; }; + aliases { + i2c-0 = &i2c0; + }; + soc { adc: adc@40007000 { compatible = "nordic,nrf-saadc"; diff --git a/dts/arm/nordic/nrf52832.dtsi b/dts/arm/nordic/nrf52832.dtsi index e2d36b15488..3313a38c1e0 100644 --- a/dts/arm/nordic/nrf52832.dtsi +++ b/dts/arm/nordic/nrf52832.dtsi @@ -36,6 +36,11 @@ compatible = "mmio-sram"; }; + aliases { + i2c-0 = &i2c0; + i2c-1 = &i2c1; + }; + soc { adc: adc@40007000 { compatible = "nordic,nrf-saadc"; diff --git a/dts/arm/nordic/nrf52840.dtsi b/dts/arm/nordic/nrf52840.dtsi index 24eac620729..6adc2df4ec4 100644 --- a/dts/arm/nordic/nrf52840.dtsi +++ b/dts/arm/nordic/nrf52840.dtsi @@ -36,6 +36,11 @@ compatible = "mmio-sram"; }; + aliases { + i2c-0 = &i2c0; + i2c-1 = &i2c1; + }; + soc { adc: adc@40007000 { compatible = "nordic,nrf-saadc"; diff --git a/soc/arm/nordic_nrf/nrf51/dts_fixup.h b/soc/arm/nordic_nrf/nrf51/dts_fixup.h index 2df6c0ca348..570ce809fb3 100644 --- a/soc/arm/nordic_nrf/nrf51/dts_fixup.h +++ b/soc/arm/nordic_nrf/nrf51/dts_fixup.h @@ -26,21 +26,8 @@ #define DT_GPIOTE_IRQ_PRI DT_NORDIC_NRF_GPIOTE_40006000_IRQ_0_PRIORITY #define DT_GPIOTE_IRQ DT_NORDIC_NRF_GPIOTE_40006000_IRQ_0 -#define DT_I2C_0_BASE_ADDR DT_NORDIC_NRF_I2C_40003000_BASE_ADDRESS -#define CONFIG_I2C_0_NAME DT_NORDIC_NRF_I2C_40003000_LABEL -#define DT_I2C_0_BITRATE DT_NORDIC_NRF_I2C_40003000_CLOCK_FREQUENCY -#define DT_I2C_0_IRQ_PRI DT_NORDIC_NRF_I2C_40003000_IRQ_0_PRIORITY -#define DT_I2C_0_IRQ DT_NORDIC_NRF_I2C_40003000_IRQ_0 -#define DT_I2C_0_SDA_PIN DT_NORDIC_NRF_I2C_40003000_SDA_PIN -#define DT_I2C_0_SCL_PIN DT_NORDIC_NRF_I2C_40003000_SCL_PIN - -#define DT_I2C_1_BASE_ADDR DT_NORDIC_NRF_I2C_40004000_BASE_ADDRESS -#define CONFIG_I2C_1_NAME DT_NORDIC_NRF_I2C_40004000_LABEL -#define DT_I2C_1_BITRATE DT_NORDIC_NRF_I2C_40004000_CLOCK_FREQUENCY -#define DT_I2C_1_IRQ_PRI DT_NORDIC_NRF_I2C_40004000_IRQ_0_PRIORITY -#define DT_I2C_1_IRQ DT_NORDIC_NRF_I2C_40004000_IRQ_0 -#define DT_I2C_1_SDA_PIN DT_NORDIC_NRF_I2C_40004000_SDA_PIN -#define DT_I2C_1_SCL_PIN DT_NORDIC_NRF_I2C_40004000_SCL_PIN +#define DT_I2C_0_NAME DT_NORDIC_NRF_I2C_I2C_0_LABEL +#define DT_I2C_1_NAME DT_NORDIC_NRF_I2C_I2C_1_LABEL #define DT_QDEC_BASE_ADDR DT_NORDIC_NRF_QDEC_40012000_BASE_ADDRESS #define DT_QDEC_NAME DT_NORDIC_NRF_QDEC_40012000_LABEL diff --git a/soc/arm/nordic_nrf/nrf52/dts_fixup.h b/soc/arm/nordic_nrf/nrf52/dts_fixup.h index c360101f339..cb61c5a31df 100644 --- a/soc/arm/nordic_nrf/nrf52/dts_fixup.h +++ b/soc/arm/nordic_nrf/nrf52/dts_fixup.h @@ -59,21 +59,8 @@ #define DT_GPIOTE_IRQ_PRI DT_NORDIC_NRF_GPIOTE_40006000_IRQ_0_PRIORITY #define DT_GPIOTE_IRQ DT_NORDIC_NRF_GPIOTE_40006000_IRQ_0 -#define DT_I2C_0_BASE_ADDR DT_NORDIC_NRF_I2C_40003000_BASE_ADDRESS -#define CONFIG_I2C_0_NAME DT_NORDIC_NRF_I2C_40003000_LABEL -#define DT_I2C_0_BITRATE DT_NORDIC_NRF_I2C_40003000_CLOCK_FREQUENCY -#define DT_I2C_0_IRQ_PRI DT_NORDIC_NRF_I2C_40003000_IRQ_0_PRIORITY -#define DT_I2C_0_IRQ DT_NORDIC_NRF_I2C_40003000_IRQ_0 -#define DT_I2C_0_SDA_PIN DT_NORDIC_NRF_I2C_40003000_SDA_PIN -#define DT_I2C_0_SCL_PIN DT_NORDIC_NRF_I2C_40003000_SCL_PIN - -#define DT_I2C_1_BASE_ADDR DT_NORDIC_NRF_I2C_40004000_BASE_ADDRESS -#define CONFIG_I2C_1_NAME DT_NORDIC_NRF_I2C_40004000_LABEL -#define DT_I2C_1_BITRATE DT_NORDIC_NRF_I2C_40004000_CLOCK_FREQUENCY -#define DT_I2C_1_IRQ_PRI DT_NORDIC_NRF_I2C_40004000_IRQ_0_PRIORITY -#define DT_I2C_1_IRQ DT_NORDIC_NRF_I2C_40004000_IRQ_0 -#define DT_I2C_1_SDA_PIN DT_NORDIC_NRF_I2C_40004000_SDA_PIN -#define DT_I2C_1_SCL_PIN DT_NORDIC_NRF_I2C_40004000_SCL_PIN +#define DT_I2C_0_NAME DT_NORDIC_NRF_I2C_I2C_0_LABEL +#define DT_I2C_1_NAME DT_NORDIC_NRF_I2C_I2C_1_LABEL #define DT_QDEC_BASE_ADDR DT_NORDIC_NRF_QDEC_40012000_BASE_ADDRESS #define DT_QDEC_NAME DT_NORDIC_NRF_QDEC_40012000_LABEL