|
12 | 12 | #include <zephyr/kernel.h>
|
13 | 13 | #include <zephyr/drivers/clock_control.h>
|
14 | 14 | #include <zephyr/logging/log.h>
|
| 15 | +#include <zephyr/pm/device.h> |
15 | 16 |
|
16 | 17 | #include <inc/hw_rtc.h>
|
17 | 18 | #include <inc/hw_types.h>
|
@@ -153,6 +154,23 @@ static uint32_t counter_cc23x0_get_pending_int(const struct device *dev)
|
153 | 154 | return -ESRCH;
|
154 | 155 | }
|
155 | 156 |
|
| 157 | +#ifdef CONFIG_PM_DEVICE |
| 158 | + |
| 159 | +static int rtc_cc23x0_pm_action(const struct device *dev, enum pm_device_action action) |
| 160 | +{ |
| 161 | + switch (action) { |
| 162 | + case PM_DEVICE_ACTION_SUSPEND: |
| 163 | + return 0; |
| 164 | + case PM_DEVICE_ACTION_RESUME: |
| 165 | + counter_cc23x0_get_pending_int(dev); |
| 166 | + return 0; |
| 167 | + default: |
| 168 | + return -ENOTSUP; |
| 169 | + } |
| 170 | +} |
| 171 | + |
| 172 | +#endif /* CONFIG_PM_DEVICE */ |
| 173 | + |
156 | 174 | static uint32_t counter_cc23x0_get_top_value(const struct device *dev)
|
157 | 175 | {
|
158 | 176 | ARG_UNUSED(dev);
|
@@ -221,21 +239,22 @@ static const struct counter_driver_api rtc_cc23x0_api = {
|
221 | 239 | .get_freq = counter_cc23x0_get_freq,
|
222 | 240 | };
|
223 | 241 |
|
224 |
| -#define CC23X0_INIT(inst) \ |
225 |
| - static const struct counter_cc23x0_config cc23x0_config_##inst = { \ |
226 |
| - .counter_info = \ |
227 |
| - { \ |
228 |
| - .max_top_value = UINT32_MAX, \ |
229 |
| - .flags = COUNTER_CONFIG_INFO_COUNT_UP, \ |
230 |
| - .channels = 1, \ |
231 |
| - }, \ |
232 |
| - .base = DT_INST_REG_ADDR(inst), \ |
233 |
| - }; \ |
234 |
| - \ |
235 |
| - static struct counter_cc23x0_data cc23x0_data_##inst; \ |
236 |
| - \ |
237 |
| - DEVICE_DT_INST_DEFINE(0, &counter_cc23x0_init, NULL, &cc23x0_data_##inst, \ |
238 |
| - &cc23x0_config_##inst, POST_KERNEL, CONFIG_COUNTER_INIT_PRIORITY, \ |
239 |
| - &rtc_cc23x0_api); |
| 242 | +#define CC23X0_INIT(inst) \ |
| 243 | + PM_DEVICE_DT_INST_DEFINE(inst, rtc_cc23x0_pm_action); \ |
| 244 | + \ |
| 245 | + static const struct counter_cc23x0_config cc23x0_config_##inst = { \ |
| 246 | + .counter_info = { \ |
| 247 | + .max_top_value = UINT32_MAX, \ |
| 248 | + .flags = COUNTER_CONFIG_INFO_COUNT_UP, \ |
| 249 | + .channels = 1, \ |
| 250 | + }, \ |
| 251 | + .base = DT_INST_REG_ADDR(inst), \ |
| 252 | + }; \ |
| 253 | + \ |
| 254 | + static struct counter_cc23x0_data cc23x0_data_##inst; \ |
| 255 | + \ |
| 256 | + DEVICE_DT_INST_DEFINE(0, &counter_cc23x0_init, PM_DEVICE_DT_INST_GET(inst), \ |
| 257 | + &cc23x0_data_##inst, &cc23x0_config_##inst, POST_KERNEL, \ |
| 258 | + CONFIG_COUNTER_INIT_PRIORITY, &rtc_cc23x0_api); |
240 | 259 |
|
241 | 260 | DT_INST_FOREACH_STATUS_OKAY(CC23X0_INIT)
|
0 commit comments