Skip to content

Commit d6c4d25

Browse files
committed
drivers: clock control for stm32h5 driver implements control_get_status
Add the control_get_status API function to the stm32h5 clock_control driver Signed-off-by: Francois Ramu <[email protected]>
1 parent 0f98bf2 commit d6c4d25

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/clock_control/clock_stm32_ll_h5.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,36 @@ static int stm32_clock_control_get_subsys_rate(const struct device *dev,
349349
return 0;
350350
}
351351

352+
static enum clock_control_status stm32_clock_control_get_status(const struct device *dev,
353+
clock_control_subsys_t sub_system)
354+
{
355+
struct stm32_pclken *pclken = (struct stm32_pclken *)sub_system;
356+
357+
ARG_UNUSED(dev);
358+
359+
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == true) {
360+
/* Gated clocks */
361+
if ((sys_read32(DT_REG_ADDR(DT_NODELABEL(rcc)) + pclken->bus) & pclken->enr)
362+
== pclken->enr) {
363+
return CLOCK_CONTROL_STATUS_ON;
364+
} else {
365+
return CLOCK_CONTROL_STATUS_OFF;
366+
}
367+
} else {
368+
/* Domain clock sources */
369+
if (enabled_clock(pclken->bus) == 0) {
370+
return CLOCK_CONTROL_STATUS_ON;
371+
} else {
372+
return CLOCK_CONTROL_STATUS_OFF;
373+
}
374+
}
375+
}
376+
352377
static DEVICE_API(clock_control, stm32_clock_control_api) = {
353378
.on = stm32_clock_control_on,
354379
.off = stm32_clock_control_off,
355380
.get_rate = stm32_clock_control_get_subsys_rate,
381+
.get_status = stm32_clock_control_get_status,
356382
.configure = stm32_clock_control_configure,
357383
};
358384

0 commit comments

Comments
 (0)