From 170c9026cb4c87eb4ae08a02f8f9e661d499aa6c Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Mon, 14 Feb 2022 14:19:09 -0800 Subject: [PATCH] counter: cmos: use device tree to instantiate driver This changes the CMOS RTC driver to use device tree to instantiate the driver instance. Signed-off-by: Daniel Leung --- drivers/counter/counter_cmos.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/counter/counter_cmos.c b/drivers/counter/counter_cmos.c index 7fc01d259f6..0833ed0a5b9 100644 --- a/drivers/counter/counter_cmos.c +++ b/drivers/counter/counter_cmos.c @@ -11,14 +11,16 @@ * crossing clock domains (no pun intended). Use accordingly. */ +#define DT_DRV_COMPAT motorola_mc146818 + #include #include #include /* The "CMOS" device is accessed via an address latch and data port. */ -#define X86_CMOS_ADDR 0x70 -#define X86_CMOS_DATA 0x71 +#define X86_CMOS_ADDR (DT_INST_REG_ADDR_BY_IDX(0, 0)) +#define X86_CMOS_DATA (DT_INST_REG_ADDR_BY_IDX(0, 1)) /* * A snapshot of the RTC state, or at least the state we're @@ -208,5 +210,5 @@ static const struct counter_driver_api api = { .get_value = get_value }; -DEVICE_DEFINE(counter_cmos, "CMOS", init, NULL, NULL, &info, - POST_KERNEL, CONFIG_COUNTER_INIT_PRIORITY, &api); +DEVICE_DT_INST_DEFINE(0, &init, NULL, NULL, &info, + POST_KERNEL, CONFIG_COUNTER_INIT_PRIORITY, &api);