Commit 02f85b25 authored by Michael Hope's avatar Michael Hope Committed by Benjamin Cabé
Browse files

drivers: clock_control: fix the CH32V00x clock definitions

Some time during the initial review, the CH32V003 clock definitions
were exended to include clocks from the CH32V20x and CH32V30x series.
As the CH32V20x series now has a separate clocks include, remove the
non-existent clocks.

While there, drop the 'A' prefix to match the register names in the
CH32V00X reference manual.

Also add the USART2 clock that's present in the CH32V00x series.

Signed-off-by: default avatarMichael Hope <michaelh@juju.nz>
parent 1d7a0957
Loading
Loading
Loading
Loading
+20 −26
Changes for include/zephyr/dt-bindings/clock/ch32v00x-clocks.h: 20 added lines, 26 removed lines.
Original line number Diff line number Diff line
@@ -7,36 +7,30 @@
#ifndef __CH32V00X_CLOCKS_H__
#define __CH32V00X_CLOCKS_H__

#define CH32V00X_AHB_PCENR_OFFSET  0
#define CH32V00X_APB2_PCENR_OFFSET 1
#define CH32V00X_APB1_PCENR_OFFSET 2
#define CH32V00X_HB_PCENR_OFFSET  0
#define CH32V00X_PB2_PCENR_OFFSET 1
#define CH32V00X_PB1_PCENR_OFFSET 2

#define CH32V00X_CLOCK_CONFIG(bus, bit) (((CH32V00X_##bus##_PCENR_OFFSET) << 5) | (bit))

#define CH32V00X_CLOCK_DMA1  CH32V00X_CLOCK_CONFIG(AHB, 0)
#define CH32V00X_CLOCK_SRAM  CH32V00X_CLOCK_CONFIG(AHB, 2)
#define CH32V00X_CLOCK_FLITF CH32V00X_CLOCK_CONFIG(AHB, 4)
#define CH32V00X_CLOCK_CRC   CH32V00X_CLOCK_CONFIG(AHB, 6)
#define CH32V00X_CLOCK_USB   CH32V00X_CLOCK_CONFIG(AHB, 12)
#define CH32V00X_CLOCK_DMA1 CH32V00X_CLOCK_CONFIG(HB, 0)
#define CH32V00X_CLOCK_SRAM CH32V00X_CLOCK_CONFIG(HB, 2)

#define CH32V00X_CLOCK_AFIO   CH32V00X_CLOCK_CONFIG(APB2, 0)
#define CH32V00X_CLOCK_IOPA   CH32V00X_CLOCK_CONFIG(APB2, 2)
#define CH32V00X_CLOCK_IOPB   CH32V00X_CLOCK_CONFIG(APB2, 3)
#define CH32V00X_CLOCK_IOPC   CH32V00X_CLOCK_CONFIG(APB2, 4)
#define CH32V00X_CLOCK_IOPD   CH32V00X_CLOCK_CONFIG(APB2, 5)
#define CH32V00X_CLOCK_ADC1   CH32V00X_CLOCK_CONFIG(APB2, 9)
#define CH32V00X_CLOCK_ADC2   CH32V00X_CLOCK_CONFIG(APB2, 10)
#define CH32V00X_CLOCK_TIM1   CH32V00X_CLOCK_CONFIG(APB2, 11)
#define CH32V00X_CLOCK_SPI1   CH32V00X_CLOCK_CONFIG(APB2, 12)
#define CH32V00X_CLOCK_USART1 CH32V00X_CLOCK_CONFIG(APB2, 14)
#define CH32V00X_CLOCK_AFIO   CH32V00X_CLOCK_CONFIG(PB2, 0)
#define CH32V00X_CLOCK_IOPA   CH32V00X_CLOCK_CONFIG(PB2, 2)
#define CH32V00X_CLOCK_IOPB   CH32V00X_CLOCK_CONFIG(PB2, 3)
#define CH32V00X_CLOCK_IOPC   CH32V00X_CLOCK_CONFIG(PB2, 4)
#define CH32V00X_CLOCK_IOPD   CH32V00X_CLOCK_CONFIG(PB2, 5)
#define CH32V00X_CLOCK_ADC1   CH32V00X_CLOCK_CONFIG(PB2, 9)
#define CH32V00X_CLOCK_TIM1   CH32V00X_CLOCK_CONFIG(PB2, 11)
#define CH32V00X_CLOCK_SPI1   CH32V00X_CLOCK_CONFIG(PB2, 12)
#define CH32V00X_CLOCK_USART2 CH32V00X_CLOCK_CONFIG(PB2, 13)
#define CH32V00X_CLOCK_USART1 CH32V00X_CLOCK_CONFIG(PB2, 14)

#define CH32V00X_CLOCK_TIM2   CH32V00X_CLOCK_CONFIG(APB1, 0)
#define CH32V00X_CLOCK_TIM3   CH32V00X_CLOCK_CONFIG(APB1, 1)
#define CH32V00X_CLOCK_WWDG   CH32V00X_CLOCK_CONFIG(APB1, 11)
#define CH32V00X_CLOCK_USART2 CH32V00X_CLOCK_CONFIG(APB1, 17)
#define CH32V00X_CLOCK_I2C1   CH32V00X_CLOCK_CONFIG(APB1, 21)
#define CH32V00X_CLOCK_BKP    CH32V00X_CLOCK_CONFIG(APB1, 27)
#define CH32V00X_CLOCK_PWR    CH32V00X_CLOCK_CONFIG(APB1, 28)
#define CH32V00X_CLOCK_USB    CH32V00X_CLOCK_CONFIG(APB1, 23)
#define CH32V00X_CLOCK_TIM2 CH32V00X_CLOCK_CONFIG(PB1, 0)
#define CH32V00X_CLOCK_TIM3 CH32V00X_CLOCK_CONFIG(PB1, 2)
#define CH32V00X_CLOCK_WWDG CH32V00X_CLOCK_CONFIG(PB1, 11)
#define CH32V00X_CLOCK_I2C1 CH32V00X_CLOCK_CONFIG(PB1, 21)
#define CH32V00X_CLOCK_PWR  CH32V00X_CLOCK_CONFIG(PB1, 28)

#endif