From c9906dd3cf20bd2bf27dccd0445436bbf4b7f6a0 Mon Sep 17 00:00:00 2001 From: Mieszko Mierunski Date: Fri, 16 Nov 2018 13:46:59 +0100 Subject: [PATCH] dts: nrf: Remove qdec dts.fixup defines and use aliases instead. Changed driver to use defines from aliases instead of fixup. Signed-off-by: Mieszko Mierunski --- drivers/sensor/qdec_nrfx/qdec_nrfx.c | 34 ++++++++++++++++------------ dts/arm/nordic/nrf51822.dtsi | 1 + dts/arm/nordic/nrf52810.dtsi | 1 + dts/arm/nordic/nrf52832.dtsi | 1 + dts/arm/nordic/nrf52840.dtsi | 1 + soc/arm/nordic_nrf/nrf51/dts_fixup.h | 15 ------------ soc/arm/nordic_nrf/nrf52/dts_fixup.h | 15 ------------ 7 files changed, 23 insertions(+), 45 deletions(-) diff --git a/drivers/sensor/qdec_nrfx/qdec_nrfx.c b/drivers/sensor/qdec_nrfx/qdec_nrfx.c index 59ae526387d..fd6cd93a429 100644 --- a/drivers/sensor/qdec_nrfx/qdec_nrfx.c +++ b/drivers/sensor/qdec_nrfx/qdec_nrfx.c @@ -91,14 +91,17 @@ static int qdec_nrfx_channel_get(struct device *dev, data->acc = 0; irq_unlock(key); - static_assert(DT_QDEC_STEPS > 0, "only positive number valid"); - static_assert(DT_QDEC_STEPS <= 2148, "overflow possible"); + static_assert(DT_NORDIC_NRF_QDEC_QDEC_0_STEPS > 0, + "only positive number valid"); + static_assert(DT_NORDIC_NRF_QDEC_QDEC_0_STEPS <= 2148, + "overflow possible"); - val->val1 = (acc * FULL_ANGLE) / DT_QDEC_STEPS; - val->val2 = (acc * FULL_ANGLE) - (val->val1 * DT_QDEC_STEPS); + val->val1 = (acc * FULL_ANGLE) / DT_NORDIC_NRF_QDEC_QDEC_0_STEPS; + val->val2 = (acc * FULL_ANGLE) + - (val->val1 * DT_NORDIC_NRF_QDEC_QDEC_0_STEPS); if (val->val2 != 0) { val->val2 *= 1000000; - val->val2 /= DT_QDEC_STEPS; + val->val2 /= DT_NORDIC_NRF_QDEC_QDEC_0_STEPS; } return 0; @@ -161,11 +164,11 @@ static void qdec_nrfx_event_handler(nrfx_qdec_event_t event) static void qdec_nrfx_gpio_ctrl(bool enable) { -#if defined(DT_QDEC_ENABLE_PIN) +#if defined(DT_NORDIC_NRF_QDEC_QDEC_0_ENABLE_PIN) uint32_t val = (enable)?(0):(1); - nrf_gpio_pin_write(DT_QDEC_ENABLE_PIN, val); - nrf_gpio_cfg_output(DT_QDEC_ENABLE_PIN); + nrf_gpio_pin_write(DT_NORDIC_NRF_QDEC_QDEC_0_ENABLE_PIN, val); + nrf_gpio_cfg_output(DT_NORDIC_NRF_QDEC_QDEC_0_ENABLE_PIN); #endif } @@ -174,14 +177,14 @@ static int qdec_nrfx_init(struct device *dev) static const nrfx_qdec_config_t config = { .reportper = NRF_QDEC_REPORTPER_40, .sampleper = NRF_QDEC_SAMPLEPER_2048us, - .psela = DT_QDEC_A_PIN, - .pselb = DT_QDEC_B_PIN, -#if defined(DT_QDEC_LED_PIN) - .pselled = DT_QDEC_LED_PIN, + .psela = DT_NORDIC_NRF_QDEC_QDEC_0_A_PIN, + .pselb = DT_NORDIC_NRF_QDEC_QDEC_0_B_PIN, +#if defined(DT_NORDIC_NRF_QDEC_QDEC_0_LED_PIN) + .pselled = DT_NORDIC_NRF_QDEC_QDEC_0_LED_PIN, #else .pselled = 0xFFFFFFFF, /* disabled */ #endif - .ledpre = DT_QDEC_LED_PRE, + .ledpre = DT_NORDIC_NRF_QDEC_QDEC_0_LED_PRE, .ledpol = NRF_QDEC_LEPOL_ACTIVE_HIGH, .interrupt_priority = NRFX_QDEC_CONFIG_IRQ_PRIORITY, .dbfen = 0, /* disabled */ @@ -192,7 +195,8 @@ static int qdec_nrfx_init(struct device *dev) LOG_DBG(""); - IRQ_CONNECT(DT_QDEC_IRQ, DT_QDEC_IRQ_PRI, + IRQ_CONNECT(DT_NORDIC_NRF_QDEC_QDEC_0_IRQ, + DT_NORDIC_NRF_QDEC_QDEC_0_IRQ_PRIORITY, nrfx_isr, nrfx_qdec_irq_handler, 0); nerr = nrfx_qdec_init(&config, qdec_nrfx_event_handler); @@ -302,6 +306,6 @@ static const struct sensor_driver_api qdec_nrfx_driver_api = { .trigger_set = qdec_nrfx_trigger_set, }; -DEVICE_DEFINE(qdec_nrfx, DT_QDEC_NAME, qdec_nrfx_init, +DEVICE_DEFINE(qdec_nrfx, DT_NORDIC_NRF_QDEC_QDEC_0_LABEL, qdec_nrfx_init, qdec_nrfx_pm_control, NULL, NULL, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, &qdec_nrfx_driver_api); diff --git a/dts/arm/nordic/nrf51822.dtsi b/dts/arm/nordic/nrf51822.dtsi index ea1ca632b0e..a29b632a26f 100644 --- a/dts/arm/nordic/nrf51822.dtsi +++ b/dts/arm/nordic/nrf51822.dtsi @@ -46,6 +46,7 @@ gpio-0 = &gpio0; gpiote-0 = &gpiote; wdt-0 = &wdt; + qdec-0 = &qdec; }; soc { diff --git a/dts/arm/nordic/nrf52810.dtsi b/dts/arm/nordic/nrf52810.dtsi index 727db474f7b..0a43153feb6 100644 --- a/dts/arm/nordic/nrf52810.dtsi +++ b/dts/arm/nordic/nrf52810.dtsi @@ -43,6 +43,7 @@ gpio-0 = &gpio0; gpiote-0 = &gpiote; wdt-0 = &wdt; + qdec-0 = &qdec; }; soc { diff --git a/dts/arm/nordic/nrf52832.dtsi b/dts/arm/nordic/nrf52832.dtsi index 5ddbbc71882..e0ab5e7c852 100644 --- a/dts/arm/nordic/nrf52832.dtsi +++ b/dts/arm/nordic/nrf52832.dtsi @@ -47,6 +47,7 @@ gpio-0 = &gpio0; gpiote-0 = &gpiote; wdt-0 = &wdt; + qdec-0 = &qdec; }; soc { diff --git a/dts/arm/nordic/nrf52840.dtsi b/dts/arm/nordic/nrf52840.dtsi index cc01df37e6a..333480f1b6a 100644 --- a/dts/arm/nordic/nrf52840.dtsi +++ b/dts/arm/nordic/nrf52840.dtsi @@ -53,6 +53,7 @@ usbd-0 = &usbd; cc310 = &cryptocell; arm-cryptocell-310 = &cryptocell310; + qdec-0 = &qdec; }; soc { diff --git a/soc/arm/nordic_nrf/nrf51/dts_fixup.h b/soc/arm/nordic_nrf/nrf51/dts_fixup.h index f5189acaea0..1fad98d4bc3 100644 --- a/soc/arm/nordic_nrf/nrf51/dts_fixup.h +++ b/soc/arm/nordic_nrf/nrf51/dts_fixup.h @@ -13,21 +13,6 @@ #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 -#define DT_QDEC_IRQ_PRI DT_NORDIC_NRF_QDEC_40012000_IRQ_0_PRIORITY -#define DT_QDEC_IRQ DT_NORDIC_NRF_QDEC_40012000_IRQ_0 -#define DT_QDEC_A_PIN DT_NORDIC_NRF_QDEC_40012000_A_PIN -#define DT_QDEC_B_PIN DT_NORDIC_NRF_QDEC_40012000_B_PIN -#if defined(DT_NORDIC_NRF_QDEC_40012000_LED_PIN) -#define DT_QDEC_LED_PIN DT_NORDIC_NRF_QDEC_40012000_LED_PIN -#endif -#if defined(DT_NORDIC_NRF_QDEC_40012000_ENABLE_PIN) -#define DT_QDEC_ENABLE_PIN DT_NORDIC_NRF_QDEC_40012000_ENABLE_PIN -#endif -#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_NAME DT_NORDIC_NRF_SPI_SPI_0_LABEL #define DT_SPI_1_NAME DT_NORDIC_NRF_SPI_SPI_1_LABEL diff --git a/soc/arm/nordic_nrf/nrf52/dts_fixup.h b/soc/arm/nordic_nrf/nrf52/dts_fixup.h index 40a35dde78b..d29341b977d 100644 --- a/soc/arm/nordic_nrf/nrf52/dts_fixup.h +++ b/soc/arm/nordic_nrf/nrf52/dts_fixup.h @@ -15,21 +15,6 @@ #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 -#define DT_QDEC_IRQ_PRI DT_NORDIC_NRF_QDEC_40012000_IRQ_0_PRIORITY -#define DT_QDEC_IRQ DT_NORDIC_NRF_QDEC_40012000_IRQ_0 -#define DT_QDEC_A_PIN DT_NORDIC_NRF_QDEC_40012000_A_PIN -#define DT_QDEC_B_PIN DT_NORDIC_NRF_QDEC_40012000_B_PIN -#if defined(DT_NORDIC_NRF_QDEC_40012000_LED_PIN) -#define DT_QDEC_LED_PIN DT_NORDIC_NRF_QDEC_40012000_LED_PIN -#endif -#if defined(DT_NORDIC_NRF_QDEC_40012000_ENABLE_PIN) -#define DT_QDEC_ENABLE_PIN DT_NORDIC_NRF_QDEC_40012000_ENABLE_PIN -#endif -#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_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