@@ -19,6 +19,10 @@ static const struct device *const reg1 = DEVICE_DT_GET(DT_NODELABEL(reg1));
19
19
static const struct device * const reg2 = DEVICE_DT_GET (DT_NODELABEL (reg2 ));
20
20
/* REG3: regulator-max/min-microvolt/microamp, regulator-allowed-modes */
21
21
static const struct device * const reg3 = DEVICE_DT_GET (DT_NODELABEL (reg3 ));
22
+ /* REG4: regulator-boot-off */
23
+ static const struct device * const reg4 = DEVICE_DT_GET (DT_NODELABEL (reg4 ));
24
+ /* REG5: regulator-boot-off and is_enabled */
25
+ static const struct device * const reg5 = DEVICE_DT_GET (DT_NODELABEL (reg5 ));
22
26
23
27
ZTEST (regulator_api , test_parent_dvs_state_set_not_implemented )
24
28
{
@@ -129,6 +133,10 @@ ZTEST(regulator_api, test_common_config)
129
133
zassert_equal (config -> allowed_modes [1 ], 10U );
130
134
zassert_equal (config -> allowed_modes_cnt , 2U );
131
135
zassert_equal (REGULATOR_ACTIVE_DISCHARGE_GET_BITS (config -> flags ), 1U );
136
+
137
+ /* reg4: regulator-boot-off */
138
+ config = reg4 -> config ;
139
+ zassert_equal (config -> flags & REGULATOR_BOOT_OFF , REGULATOR_BOOT_OFF );
132
140
}
133
141
134
142
ZTEST (regulator_api , test_common_is_init_enabled )
@@ -137,6 +145,8 @@ ZTEST(regulator_api, test_common_is_init_enabled)
137
145
zassert_true (regulator_common_is_init_enabled (reg1 ));
138
146
zassert_true (regulator_common_is_init_enabled (reg2 ));
139
147
zassert_false (regulator_common_is_init_enabled (reg3 ));
148
+ zassert_false (regulator_common_is_init_enabled (reg4 ));
149
+ zassert_false (regulator_common_is_init_enabled (reg5 ));
140
150
}
141
151
142
152
ZTEST (regulator_api , test_enable_disable )
@@ -171,6 +181,16 @@ ZTEST(regulator_api, test_enable_disable)
171
181
zassert_equal (regulator_disable (reg0 ), 0 );
172
182
zassert_equal (regulator_fake_disable_fake .arg0_val , reg0 );
173
183
zassert_equal (regulator_fake_disable_fake .call_count , 2U );
184
+
185
+ /* REG5: disabled at boot, can be enabled again */
186
+ zassert_equal (regulator_enable (reg5 ), 0 );
187
+ zassert_equal (regulator_fake_enable_fake .call_count , 3U );
188
+
189
+ /* REG5: disable */
190
+ zassert_equal (regulator_disable (reg5 ), 0 );
191
+ zassert_equal (regulator_fake_disable_fake .call_count , 3U );
192
+
193
+
174
194
}
175
195
176
196
ZTEST (regulator_api , test_count_voltages_not_implemented )
@@ -776,6 +796,8 @@ void *setup(void)
776
796
zassert_true (device_is_ready (reg1 ));
777
797
zassert_true (device_is_ready (reg2 ));
778
798
zassert_true (device_is_ready (reg3 ));
799
+ zassert_true (device_is_ready (reg4 ));
800
+ zassert_true (device_is_ready (reg5 ));
779
801
780
802
/* REG1, REG2 initialized at init time (always-on/boot-on) */
781
803
zassert_equal (regulator_fake_enable_fake .call_count , 2U );
@@ -785,6 +807,13 @@ void *setup(void)
785
807
/* REG3 mode set at init time (initial-mode) */
786
808
zassert_equal (regulator_fake_set_mode_fake .call_count , 1U );
787
809
810
+ /* REG4 already disabled at init time (boot-off) */
811
+ zassert_false (regulator_is_enabled (reg4 ));
812
+
813
+ /* REG5 explicitly disabled at init time (boot-off) */
814
+ zassert_equal (regulator_fake_disable_fake .call_count , 1U );
815
+ zassert_false (regulator_is_enabled (reg5 ));
816
+
788
817
return NULL ;
789
818
}
790
819
0 commit comments