drivers: counter_nrfx_timer: Port driver to DTS

This commit updates the counter_nrfx_timer driver in order to
use device tree infrastructure.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
This commit is contained in:
Piotr Zięcik 2019-02-26 15:18:17 +01:00 committed by Carles Cufí
parent 298b841873
commit 05fa9c8318
8 changed files with 156 additions and 64 deletions

View file

@ -19,16 +19,6 @@ config COUNTER_TIMER0
if COUNTER_TIMER0
config COUNTER_TIMER0_NAME
string "Counter device name"
default "Counter 0"
help
Specify the device name for Counter driver instance.
config COUNTER_TIMER0_IRQ_PRI
int "Counter interrupt priority"
default 0
config COUNTER_TIMER0_PRESCALER
int "Timer prescaler"
default 0
@ -46,16 +36,6 @@ config COUNTER_TIMER1
if COUNTER_TIMER1
config COUNTER_TIMER1_NAME
string "Counter device name"
default "Counter 1"
help
Specify the device name for Counter driver instance.
config COUNTER_TIMER1_IRQ_PRI
int "Counter interrupt priority"
default 0
config COUNTER_TIMER1_PRESCALER
int "Timer prescaler"
default 0
@ -73,17 +53,6 @@ config COUNTER_TIMER2
if COUNTER_TIMER2
config COUNTER_TIMER2_NAME
string "Counter device name"
default "Counter 2"
help
Specify the device name for Counter driver instance.
config COUNTER_TIMER2_IRQ_PRI
int "Counter interrupt priority"
default 0
config COUNTER_TIMER2_PRESCALER
int "Timer prescaler"
default 0
@ -101,17 +70,6 @@ config COUNTER_TIMER3
if COUNTER_TIMER3
config COUNTER_TIMER3_NAME
string "Counter device name"
default "Counter 3"
help
Specify the device name for Counter driver instance.
config COUNTER_TIMER3_IRQ_PRI
int "Counter interrupt priority"
default 0
config COUNTER_TIMER3_PRESCALER
int "Timer prescaler"
default 0
@ -129,17 +87,6 @@ config COUNTER_TIMER4
if COUNTER_TIMER4
config COUNTER_TIMER4_NAME
string "Counter device name"
default "Counter 4"
help
Specify the device name for Counter driver instance.
config COUNTER_TIMER4_IRQ_PRI
int "Counter interrupt priority"
default 0
config COUNTER_TIMER4_PRESCALER
int "Timer prescaler"
default 0

View file

@ -224,8 +224,8 @@ static const struct counter_driver_api counter_nrfx_driver_api = {
#define COUNTER_NRFX_TIMER_DEVICE(idx) \
static int counter_##idx##_init(struct device *dev) \
{ \
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_TIMER##idx), \
CONFIG_COUNTER_TIMER##idx##_IRQ_PRI, \
IRQ_CONNECT(DT_NORDIC_NRF_TIMER_TIMER_##idx##_IRQ, \
DT_NORDIC_NRF_TIMER_TIMER_##idx##_IRQ_PRIORITY, \
nrfx_isr, nrfx_timer_##idx##_irq_handler, 0); \
const nrfx_timer_config_t config = { \
.frequency = CONFIG_COUNTER_TIMER##idx##_PRESCALER, \
@ -254,7 +254,8 @@ static const struct counter_driver_api counter_nrfx_driver_api = {
.timer = NRFX_TIMER_INSTANCE(idx), \
LOG_INSTANCE_PTR_INIT(log, LOG_MODULE_NAME, idx) \
}; \
DEVICE_AND_API_INIT(timer_##idx, CONFIG_COUNTER_TIMER##idx##_NAME, \
DEVICE_AND_API_INIT(timer_##idx, \
DT_NORDIC_NRF_TIMER_TIMER_##idx##_LABEL, \
counter_##idx##_init, \
&counter_##idx##_data, \
&nrfx_counter_##idx##_config.info, \

View file

@ -49,6 +49,9 @@
qdec-0 = &qdec;
rtc-0 = &rtc0;
rtc-1 = &rtc1;
timer-0 = &timer0;
timer-1 = &timer1;
timer-2 = &timer2;
};
soc {
@ -159,6 +162,30 @@
label = "RTC_1";
};
timer0: timer@40008000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x40008000 0x1000>;
interrupts = <8 1>;
label = "TIMER_0";
};
timer1: timer@40009000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x40009000 0x1000>;
interrupts = <9 1>;
label = "TIMER_1";
};
timer2: timer@4000a000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x4000a000 0x1000>;
interrupts = <10 1>;
label = "TIMER_2";
};
wdt: watchdog@40010000 {
compatible = "nordic,nrf-watchdog";
reg = <0x40010000 0x1000>;

View file

@ -47,6 +47,9 @@
qdec-0 = &qdec;
rtc-0 = &rtc0;
rtc-1 = &rtc1;
timer-0 = &timer0;
timer-1 = &timer1;
timer-2 = &timer2;
};
soc {
@ -146,6 +149,30 @@
label = "RTC_1";
};
timer0: timer@40008000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x40008000 0x1000>;
interrupts = <8 1>;
label = "TIMER_0";
};
timer1: timer@40009000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x40009000 0x1000>;
interrupts = <9 1>;
label = "TIMER_1";
};
timer2: timer@4000a000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x4000a000 0x1000>;
interrupts = <10 1>;
label = "TIMER_2";
};
wdt: watchdog@40010000 {
compatible = "nordic,nrf-watchdog";
reg = <0x40010000 0x1000>;

View file

@ -54,6 +54,11 @@
rtc-0 = &rtc0;
rtc-1 = &rtc1;
rtc-2 = &rtc2;
timer-0 = &timer0;
timer-1 = &timer1;
timer-2 = &timer2;
timer-3 = &timer3;
timer-4 = &timer4;
};
soc {
@ -208,6 +213,46 @@
label = "RTC_2";
};
timer0: timer@40008000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x40008000 0x1000>;
interrupts = <8 1>;
label = "TIMER_0";
};
timer1: timer@40009000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x40009000 0x1000>;
interrupts = <9 1>;
label = "TIMER_1";
};
timer2: timer@4000a000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x4000a000 0x1000>;
interrupts = <10 1>;
label = "TIMER_2";
};
timer3: timer@4001a000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x4001a000 0x1000>;
interrupts = <26 1>;
label = "TIMER_3";
};
timer4: timer@4001b000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x4001b000 0x1000>;
interrupts = <27 1>;
label = "TIMER_4";
};
wdt: watchdog@40010000 {
compatible = "nordic,nrf-watchdog";
reg = <0x40010000 0x1000>;

View file

@ -61,6 +61,11 @@
rtc-0 = &rtc0;
rtc-1 = &rtc1;
rtc-2 = &rtc2;
timer-0 = &timer0;
timer-1 = &timer1;
timer-2 = &timer2;
timer-3 = &timer3;
timer-4 = &timer4;
};
soc {
@ -251,6 +256,46 @@
label = "RTC_2";
};
timer0: timer@40008000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x40008000 0x1000>;
interrupts = <8 1>;
label = "TIMER_0";
};
timer1: timer@40009000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x40009000 0x1000>;
interrupts = <9 1>;
label = "TIMER_1";
};
timer2: timer@4000a000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x4000a000 0x1000>;
interrupts = <10 1>;
label = "TIMER_2";
};
timer3: timer@4001a000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x4001a000 0x1000>;
interrupts = <26 1>;
label = "TIMER_3";
};
timer4: timer@4001b000 {
compatible = "nordic,nrf-timer";
status = "ok";
reg = <0x4001b000 0x1000>;
interrupts = <27 1>;
label = "TIMER_4";
};
usbd: usbd@40027000 {
compatible = "nordic,nrf-usbd";
reg = <0x40027000 0x1000>;

View file

@ -230,7 +230,7 @@ timer0: timer@f000 {
status = "disabled";
reg = <0xf000 0x1000>;
interrupts = <15 1>;
label = "TIMER0";
label = "TIMER_0";
};
timer1: timer@10000 {
@ -238,7 +238,7 @@ timer1: timer@10000 {
status = "disabled";
reg = <0x10000 0x1000>;
interrupts = <16 1>;
label = "TIMER1";
label = "TIMER_1";
};
timer2: timer@11000 {
@ -246,5 +246,5 @@ timer2: timer@11000 {
status = "disabled";
reg = <0x11000 0x1000>;
interrupts = <17 1>;
label = "TIMER2";
label = "TIMER_2";
};

View file

@ -28,19 +28,19 @@ const char *devices[] = {
#ifdef CONFIG_COUNTER_TIMER0
/* Nordic TIMER0 may be reserved for Bluetooth */
CONFIG_COUNTER_TIMER0_NAME,
DT_NORDIC_NRF_TIMER_TIMER_0_LABEL,
#endif
#ifdef CONFIG_COUNTER_TIMER1
CONFIG_COUNTER_TIMER1_NAME,
DT_NORDIC_NRF_TIMER_TIMER_1_LABEL,
#endif
#ifdef CONFIG_COUNTER_TIMER2
CONFIG_COUNTER_TIMER2_NAME,
DT_NORDIC_NRF_TIMER_TIMER_2_LABEL,
#endif
#ifdef CONFIG_COUNTER_TIMER3
CONFIG_COUNTER_TIMER3_NAME,
DT_NORDIC_NRF_TIMER_TIMER_3_LABEL,
#endif
#ifdef CONFIG_COUNTER_TIMER4
CONFIG_COUNTER_TIMER4_NAME,
DT_NORDIC_NRF_TIMER_TIMER_4_LABEL,
#endif
#ifdef CONFIG_COUNTER_RTC0
/* Nordic RTC0 may be reserved for Bluetooth */