Skip to content

Commit 184ee44

Browse files
nzmichaelhcfriedt
authored andcommitted
drivers: clock_control: fix the ch32v003/006 build
A recent commit added support for the CH32V30x/20x PLL multiplier. The code is protected by a `IS_ENABLED(...)` but uses a constant that doesn't exist for the CH32V00x, breaking the build. Tested by building samples/basic/blinky for the ch32v003evt and linkw. Signed-off-by: Michael Hope <[email protected]>
1 parent 6edfdb9 commit 184ee44

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/clock_control/clock_control_wch_rcc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define WCH_RCC_SRC_IS_HSI 1
3636
#endif
3737

38+
#if defined(CONFIG_DT_HAS_WCH_CH32V20X_30X_PLL_CLOCK_ENABLED)
3839
#if defined(CONFIG_SOC_CH32V307)
3940
/* TODO: Entry 13 is 6.5x (fractional multiple currently unsupported without
4041
* changes to RCC config datatype)
@@ -43,6 +44,7 @@ static const uint8_t pllmul_lut[] = {18, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
4344
#else
4445
static const uint8_t pllmul_lut[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18};
4546
#endif
47+
#endif
4648

4749
struct clock_control_wch_rcc_config {
4850
RCC_TypeDef *regs;
@@ -165,7 +167,7 @@ static int clock_control_wch_rcc_init(const struct device *dev)
165167
} else if (IS_ENABLED(WCH_RCC_PLL_SRC_IS_HSI)) {
166168
RCC->CFGR0 &= ~RCC_PLLSRC;
167169
}
168-
170+
#if defined(RCC_PLLMULL)
169171
uint8_t pllmul = 0x0; /* Default Reset Value */
170172

171173
for (size_t i = 0; i < ARRAY_SIZE(pllmul_lut); i++) {
@@ -175,6 +177,7 @@ static int clock_control_wch_rcc_init(const struct device *dev)
175177
}
176178
RCC->CFGR0 &= ~RCC_PLLMULL;
177179
RCC->CFGR0 |= WCH_RCC_PLLMUL_VAL(pllmul);
180+
#endif
178181
RCC->CTLR |= RCC_PLLON;
179182
while ((RCC->CTLR & RCC_PLLRDY) == 0) {
180183
}

0 commit comments

Comments
 (0)