Skip to content

Commit 6cbb3f5

Browse files
erwangocarlescufi
authored andcommitted
drivers: clock_control: stm32: Fixed domain clock configuration
In some case, we may need to describe a domain clock for a device while there is no way to configure it (ex: USB clock set on PLL_Q output on F405 devices > It is not selectable). Then, configuring a device clock domain in the clock_control driver will allow to retrieve its subsys rate. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent c4b53d5 commit 6cbb3f5

File tree

13 files changed

+31
-2
lines changed

13 files changed

+31
-2
lines changed

drivers/clock_control/clock_stm32_ll_common.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ static inline int stm32_clock_control_configure(const struct device *dev,
242242
return err;
243243
}
244244

245+
if (pclken->enr == NO_SEL) {
246+
/* Domain clock is fixed. Nothing to set. Exit */
247+
return 0;
248+
}
249+
245250
sys_set_bits(DT_REG_ADDR(DT_NODELABEL(rcc)) + STM32_CLOCK_REG_GET(pclken->enr),
246251
STM32_CLOCK_VAL_GET(pclken->enr) << STM32_CLOCK_SHIFT_GET(pclken->enr));
247252

include/zephyr/dt-bindings/clock/stm32f0_clock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,7 @@
7373
#define USART3_SEL(val) STM32_CLOCK(val, 3, 18, CFGR3_REG)
7474
/** BDCR devices */
7575
#define RTC_SEL(val) STM32_CLOCK(val, 3, 8, BDCR_REG)
76+
/** Dummy: Add a specificier when no selection is possible */
77+
#define NO_SEL 0xFF
7678

7779
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32F0_CLOCK_H_ */

include/zephyr/dt-bindings/clock/stm32f1_clock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,7 @@
5959
/** @brief Device domain clocks selection helpers */
6060
/** BDCR devices */
6161
#define RTC_SEL(val) STM32_CLOCK(val, 3, 8, BDCR_REG)
62+
/** Dummy: Add a specificier when no selection is possible */
63+
#define NO_SEL 0xFF
6264

6365
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32F1_CLOCK_H_ */

include/zephyr/dt-bindings/clock/stm32f3_clock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,7 @@
8383
#define TIM3_4_SEL(val) STM32_CLOCK(val, 1, 25, CFGR3_REG)
8484
/** BDCR devices */
8585
#define RTC_SEL(val) STM32_CLOCK(val, 3, 8, BDCR_REG)
86+
/** Dummy: Add a specificier when no selection is possible */
87+
#define NO_SEL 0xFF
8688

8789
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32F3_CLOCK_H_ */

include/zephyr/dt-bindings/clock/stm32f4_clock.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,7 @@
6868
/** BDCR devices */
6969
#define RTC_SEL(val) STM32_CLOCK(val, 3, 8, BDCR_REG)
7070

71+
/** Dummy: Add a specificier when no selection is possible */
72+
#define NO_SEL 0xFF
73+
7174
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32F4_CLOCK_H_ */

include/zephyr/dt-bindings/clock/stm32f7_clock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,7 @@
9292
#define CK48M_SEL(val) STM32_CLOCK(val, 1, 27, DKCFGR2_REG)
9393
#define SDMMC1_SEL(val) STM32_CLOCK(val, 1, 28, DKCFGR2_REG)
9494
#define SDMMC2_SEL(val) STM32_CLOCK(val, 1, 29, DKCFGR2_REG)
95+
/** Dummy: Add a specificier when no selection is possible */
96+
#define NO_SEL 0xFF
9597

9698
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32F7_CLOCK_H_ */

include/zephyr/dt-bindings/clock/stm32g0_clock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
#define USB_SEL(val) STM32_CLOCK(val, 3, 12, CCIPR2_REG)
9393
/** BDCR devices */
9494
#define RTC_SEL(val) STM32_CLOCK(val, 3, 8, BDCR_REG)
95-
96-
95+
/** Dummy: Add a specificier when no selection is possible */
96+
#define NO_SEL 0xFF
9797

9898
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32G0_CLOCK_H_ */

include/zephyr/dt-bindings/clock/stm32g4_clock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,7 @@
9595
#define QSPI_SEL(val) STM32_CLOCK(val, 3, 20, CCIPR2_REG)
9696
/** BDCR devices */
9797
#define RTC_SEL(val) STM32_CLOCK(val, 3, 8, BDCR_REG)
98+
/** Dummy: Add a specificier when no selection is possible */
99+
#define NO_SEL 0xFF
98100

99101
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32G4_CLOCK_H_ */

include/zephyr/dt-bindings/clock/stm32l0_clock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,7 @@
7474
#define HSI48_SEL(val) STM32_CLOCK(val, 1, 26, CCIPR_REG)
7575
/** CSR devices */
7676
#define RTC_SEL(val) STM32_CLOCK(val, 3, 16, CSR_REG)
77+
/** Dummy: Add a specificier when no selection is possible */
78+
#define NO_SEL 0xFF
7779

7880
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32L0_CLOCK_H_ */

include/zephyr/dt-bindings/clock/stm32l1_clock.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,7 @@
5757

5858
#define RTC_SEL(val) STM32_CLOCK(val, 3, 16, CSR_REG)
5959

60+
/** Dummy: Add a specificier when no selection is possible */
61+
#define NO_SEL 0xFF
62+
6063
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32L1_CLOCK_H_ */

0 commit comments

Comments
 (0)