Skip to content

Commit c00f8c6

Browse files
asmellbycfriedt
authored andcommitted
drivers: counter: gecko_stimer: Use chosen node
Use the `silabs,sleeptimer` chosen node instead of a devicetree compatible to select the devicetree node for the counter. Signed-off-by: Aksel Skauge Mellbye <[email protected]>
1 parent a13c810 commit c00f8c6

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

drivers/counter/Kconfig.gecko

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Copyright (c) 2019, Piotr Mienkowski
44
# SPDX-License-Identifier: Apache-2.0
55

6+
DT_CHOSEN_SILABS_SLEEPTIMER := silabs,sleeptimer
7+
68
config COUNTER_GECKO_RTCC
79
bool "Silicon Labs Gecko Counter (RTCC) driver"
810
default y
@@ -16,7 +18,7 @@ config COUNTER_GECKO_RTCC
1618
config COUNTER_GECKO_STIMER
1719
bool "Silicon Labs Gecko Counter Sleep Timer driver"
1820
default y
19-
depends on DT_HAS_SILABS_GECKO_STIMER_ENABLED
21+
depends on $(dt_chosen_enabled,$(DT_CHOSEN_SILABS_SLEEPTIMER))
2022
select SILABS_SISDK_SLEEPTIMER
2123
help
2224
Enable the counter driver for Sleep Timer module for Silicon Labs

drivers/counter/counter_gecko_stimer.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#define DT_DRV_COMPAT silabs_gecko_stimer
8-
97
#include <errno.h>
108
#include <stddef.h>
119
#include <string.h>
@@ -21,7 +19,7 @@
2119

2220
LOG_MODULE_REGISTER(counter_gecko, CONFIG_COUNTER_LOG_LEVEL);
2321

24-
#define DT_RTC DT_COMPAT_GET_ANY_STATUS_OKAY(silabs_gecko_stimer)
22+
#define DT_RTC DT_CHOSEN(silabs_sleeptimer)
2523

2624
#define STIMER_ALARM_NUM 2
2725
#define STIMER_MAX_VALUE 0xFFFFFFFFUL
@@ -273,30 +271,30 @@ static DEVICE_API(counter, counter_gecko_driver_api) = {
273271
.get_top_value = counter_gecko_get_top_value,
274272
};
275273

276-
BUILD_ASSERT((DT_INST_PROP(0, prescaler) > 0U) && (DT_INST_PROP(0, prescaler) <= 32768U));
274+
BUILD_ASSERT((DT_PROP(DT_RTC, prescaler) > 0U) && (DT_PROP(DT_RTC, prescaler) <= 32768U));
277275

278276
static void counter_gecko_0_irq_config(void)
279277
{
280278
#ifndef CONFIG_SILABS_SLEEPTIMER_TIMER
281279
IRQ_DIRECT_CONNECT(DT_IRQ(DT_RTC, irq), DT_IRQ(DT_RTC, priority),
282280
CONCAT(DT_STRING_UPPER_TOKEN_BY_IDX(DT_RTC, interrupt_names, 0),
283281
_IRQHandler), 0);
284-
irq_enable(DT_INST_IRQN(0));
282+
irq_enable(DT_IRQN(DT_RTC));
285283
#endif
286284
}
287285

288286
static const struct counter_gecko_config counter_gecko_0_config = {
289287
.info = {
290288
.max_top_value = STIMER_MAX_VALUE,
291-
.freq = DT_INST_PROP(0, clock_frequency) / DT_INST_PROP(0, prescaler),
289+
.freq = DT_PROP(DT_RTC, clock_frequency) / DT_PROP(DT_RTC, prescaler),
292290
.flags = COUNTER_CONFIG_INFO_COUNT_UP,
293291
.channels = STIMER_ALARM_NUM,
294292
},
295293
.irq_config = counter_gecko_0_irq_config,
296-
.prescaler = DT_INST_PROP(0, prescaler),
294+
.prescaler = DT_PROP(DT_RTC, prescaler),
297295
};
298296

299297
static struct counter_gecko_data counter_gecko_0_data;
300298

301-
DEVICE_DT_INST_DEFINE(0, counter_gecko_init, NULL, &counter_gecko_0_data, &counter_gecko_0_config,
302-
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &counter_gecko_driver_api);
299+
DEVICE_DT_DEFINE(DT_RTC, counter_gecko_init, NULL, &counter_gecko_0_data, &counter_gecko_0_config,
300+
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &counter_gecko_driver_api);

tests/drivers/counter/counter_basic_api/src/test_counter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static const struct device *const devices[] = {
9494
DEVS_FOR_DT_COMPAT(st_stm32_rtc)
9595
#endif
9696
#ifdef CONFIG_COUNTER_GECKO_STIMER
97-
DEVS_FOR_DT_COMPAT(silabs_gecko_stimer)
97+
DEVICE_DT_GET(DT_CHOSEN(silabs_sleeptimer)),
9898
#endif
9999
#ifdef CONFIG_COUNTER_NXP_PIT
100100
DEVS_FOR_DT_COMPAT(nxp_pit_channel)

0 commit comments

Comments
 (0)