1
1
/*
2
2
* Copyright (c) 2019-2020 Peter Bigot Consulting, LLC
3
3
* Copyright (c) 2021 Laird Connectivity
4
+ * Copyright (c) 2025 Marcin Lyda <[email protected] >
4
5
*
5
6
* SPDX-License-Identifier: Apache-2.0
6
7
*/
@@ -50,6 +51,7 @@ struct mcp7940n_config {
50
51
struct counter_config_info generic ;
51
52
struct i2c_dt_spec i2c ;
52
53
const struct gpio_dt_spec int_gpios ;
54
+ bool vbat_enable ;
53
55
};
54
56
55
57
struct mcp7940n_data {
@@ -678,6 +680,10 @@ static int mcp7940n_init(const struct device *dev)
678
680
goto out ;
679
681
}
680
682
683
+ /* Configure VBat enable */
684
+ data -> registers .rtc_weekday .vbaten = cfg -> vbat_enable ;
685
+
686
+ /* Set day of week and update VBat enable config */
681
687
rc = set_day_of_week (dev , & unix_time );
682
688
if (rc < 0 ) {
683
689
goto out ;
@@ -693,7 +699,6 @@ static int mcp7940n_init(const struct device *dev)
693
699
694
700
/* Configure alarm interrupt gpio */
695
701
if (cfg -> int_gpios .port != NULL ) {
696
-
697
702
if (!gpio_is_ready_dt (& cfg -> int_gpios )) {
698
703
LOG_ERR ("Port device %s is not ready" ,
699
704
cfg -> int_gpios .port -> name );
@@ -757,6 +762,7 @@ static DEVICE_API(counter, mcp7940n_api) = {
757
762
}, \
758
763
.i2c = I2C_DT_SPEC_INST_GET(index), \
759
764
.int_gpios = GPIO_DT_SPEC_INST_GET_OR(index, int_gpios, {0}), \
765
+ .vbat_enable = DT_INST_PROP(index, vbat_enable) \
760
766
}; \
761
767
\
762
768
DEVICE_DT_INST_DEFINE(index, mcp7940n_init, NULL, \
0 commit comments