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 <mieszko.mierunski@nordicsemi.no>
This commit is contained in:
Mieszko Mierunski 2018-11-16 13:46:59 +01:00 committed by Carles Cufí
commit c9906dd3cf
7 changed files with 23 additions and 45 deletions

View file

@ -91,14 +91,17 @@ static int qdec_nrfx_channel_get(struct device *dev,
data->acc = 0; data->acc = 0;
irq_unlock(key); irq_unlock(key);
static_assert(DT_QDEC_STEPS > 0, "only positive number valid"); static_assert(DT_NORDIC_NRF_QDEC_QDEC_0_STEPS > 0,
static_assert(DT_QDEC_STEPS <= 2148, "overflow possible"); "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->val1 = (acc * FULL_ANGLE) / DT_NORDIC_NRF_QDEC_QDEC_0_STEPS;
val->val2 = (acc * FULL_ANGLE) - (val->val1 * DT_QDEC_STEPS); val->val2 = (acc * FULL_ANGLE)
- (val->val1 * DT_NORDIC_NRF_QDEC_QDEC_0_STEPS);
if (val->val2 != 0) { if (val->val2 != 0) {
val->val2 *= 1000000; val->val2 *= 1000000;
val->val2 /= DT_QDEC_STEPS; val->val2 /= DT_NORDIC_NRF_QDEC_QDEC_0_STEPS;
} }
return 0; 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) 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); uint32_t val = (enable)?(0):(1);
nrf_gpio_pin_write(DT_QDEC_ENABLE_PIN, val); nrf_gpio_pin_write(DT_NORDIC_NRF_QDEC_QDEC_0_ENABLE_PIN, val);
nrf_gpio_cfg_output(DT_QDEC_ENABLE_PIN); nrf_gpio_cfg_output(DT_NORDIC_NRF_QDEC_QDEC_0_ENABLE_PIN);
#endif #endif
} }
@ -174,14 +177,14 @@ static int qdec_nrfx_init(struct device *dev)
static const nrfx_qdec_config_t config = { static const nrfx_qdec_config_t config = {
.reportper = NRF_QDEC_REPORTPER_40, .reportper = NRF_QDEC_REPORTPER_40,
.sampleper = NRF_QDEC_SAMPLEPER_2048us, .sampleper = NRF_QDEC_SAMPLEPER_2048us,
.psela = DT_QDEC_A_PIN, .psela = DT_NORDIC_NRF_QDEC_QDEC_0_A_PIN,
.pselb = DT_QDEC_B_PIN, .pselb = DT_NORDIC_NRF_QDEC_QDEC_0_B_PIN,
#if defined(DT_QDEC_LED_PIN) #if defined(DT_NORDIC_NRF_QDEC_QDEC_0_LED_PIN)
.pselled = DT_QDEC_LED_PIN, .pselled = DT_NORDIC_NRF_QDEC_QDEC_0_LED_PIN,
#else #else
.pselled = 0xFFFFFFFF, /* disabled */ .pselled = 0xFFFFFFFF, /* disabled */
#endif #endif
.ledpre = DT_QDEC_LED_PRE, .ledpre = DT_NORDIC_NRF_QDEC_QDEC_0_LED_PRE,
.ledpol = NRF_QDEC_LEPOL_ACTIVE_HIGH, .ledpol = NRF_QDEC_LEPOL_ACTIVE_HIGH,
.interrupt_priority = NRFX_QDEC_CONFIG_IRQ_PRIORITY, .interrupt_priority = NRFX_QDEC_CONFIG_IRQ_PRIORITY,
.dbfen = 0, /* disabled */ .dbfen = 0, /* disabled */
@ -192,7 +195,8 @@ static int qdec_nrfx_init(struct device *dev)
LOG_DBG(""); 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); nrfx_isr, nrfx_qdec_irq_handler, 0);
nerr = nrfx_qdec_init(&config, qdec_nrfx_event_handler); 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, .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, qdec_nrfx_pm_control, NULL, NULL, POST_KERNEL,
CONFIG_SENSOR_INIT_PRIORITY, &qdec_nrfx_driver_api); CONFIG_SENSOR_INIT_PRIORITY, &qdec_nrfx_driver_api);

View file

@ -46,6 +46,7 @@
gpio-0 = &gpio0; gpio-0 = &gpio0;
gpiote-0 = &gpiote; gpiote-0 = &gpiote;
wdt-0 = &wdt; wdt-0 = &wdt;
qdec-0 = &qdec;
}; };
soc { soc {

View file

@ -43,6 +43,7 @@
gpio-0 = &gpio0; gpio-0 = &gpio0;
gpiote-0 = &gpiote; gpiote-0 = &gpiote;
wdt-0 = &wdt; wdt-0 = &wdt;
qdec-0 = &qdec;
}; };
soc { soc {

View file

@ -47,6 +47,7 @@
gpio-0 = &gpio0; gpio-0 = &gpio0;
gpiote-0 = &gpiote; gpiote-0 = &gpiote;
wdt-0 = &wdt; wdt-0 = &wdt;
qdec-0 = &qdec;
}; };
soc { soc {

View file

@ -53,6 +53,7 @@
usbd-0 = &usbd; usbd-0 = &usbd;
cc310 = &cryptocell; cc310 = &cryptocell;
arm-cryptocell-310 = &cryptocell310; arm-cryptocell-310 = &cryptocell310;
qdec-0 = &qdec;
}; };
soc { soc {

View file

@ -13,21 +13,6 @@
#define DT_I2C_0_NAME DT_NORDIC_NRF_I2C_I2C_0_LABEL #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_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_0_NAME DT_NORDIC_NRF_SPI_SPI_0_LABEL
#define DT_SPI_1_NAME DT_NORDIC_NRF_SPI_SPI_1_LABEL #define DT_SPI_1_NAME DT_NORDIC_NRF_SPI_SPI_1_LABEL

View file

@ -15,21 +15,6 @@
#define DT_I2C_0_NAME DT_NORDIC_NRF_I2C_I2C_0_LABEL #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_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_0_NAME DT_NORDIC_NRF_SPI_SPI_0_LABEL
#define DT_SPI_1_NAME DT_NORDIC_NRF_SPI_SPI_1_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_2_NAME DT_NORDIC_NRF_SPI_SPI_2_LABEL