Skip to content

Commit ae5d6f2

Browse files
committed
drivers: pwm: add the CH32V20x/30x GPTM devices and pinctrl definitions
The CH32V20x/30x family has three General-purpose Timers (GPTM) named TIM2 to TIM4. Add to Devicetree and define the alternate function mappings. Signed-off-by: Michael Hope <[email protected]>
1 parent afa83a3 commit ae5d6f2

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

dts/riscv/wch/ch32v203/ch32v203.dtsi

+27
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,33 @@
130130
reg = <0x40021000 16>;
131131
#clock-cells = <1>;
132132
};
133+
134+
tim2: counter@40000000 {
135+
compatible = "wch,gptm";
136+
reg = <0x40000000 16>;
137+
pwm-controller;
138+
#pwm-cells = <3>;
139+
prescaler = <1>;
140+
clocks = <&rcc CH32V20X_V30X_CLOCK_TIM2>;
141+
};
142+
143+
tim3: counter@40000400 {
144+
compatible = "wch,gptm";
145+
reg = <0x40000400 16>;
146+
pwm-controller;
147+
#pwm-cells = <3>;
148+
prescaler = <1>;
149+
clocks = <&rcc CH32V20X_V30X_CLOCK_TIM3>;
150+
};
151+
152+
tim4: counter@40000800 {
153+
compatible = "wch,gptm";
154+
reg = <0x40000800 16>;
155+
pwm-controller;
156+
#pwm-cells = <3>;
157+
prescaler = <1>;
158+
clocks = <&rcc CH32V20X_V30X_CLOCK_TIM4>;
159+
};
133160
};
134161
};
135162

include/zephyr/dt-bindings/pinctrl/ch32v20x_30x-pinctrl.h

+46
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,50 @@
177177
#define I2C1_SDA_PB7_0 CH32V20X_V30X_PINMUX_DEFINE(PB, 7, I2C1, 0)
178178
#define I2C1_SDA_PB9_1 CH32V20X_V30X_PINMUX_DEFINE(PB, 9, I2C1, 1)
179179

180+
#define TIM2_ETR_PA0_0 CH32V20X_V30X_PINMUX_DEFINE(PA, 0, TIM2, 0)
181+
#define TIM2_ETR_PA15_1 CH32V20X_V30X_PINMUX_DEFINE(PA, 15, TIM2, 1)
182+
#define TIM2_ETR_PA0_2 CH32V20X_V30X_PINMUX_DEFINE(PA, 0, TIM2, 2)
183+
#define TIM2_ETR_PA15_3 CH32V20X_V30X_PINMUX_DEFINE(PA, 15, TIM2, 3)
184+
#define TIM2_CH1_PA0_0 CH32V20X_V30X_PINMUX_DEFINE(PA, 0, TIM2, 0)
185+
#define TIM2_CH1_PA15_1 CH32V20X_V30X_PINMUX_DEFINE(PA, 15, TIM2, 1)
186+
#define TIM2_CH1_PA0_1 CH32V20X_V30X_PINMUX_DEFINE(PA, 0, TIM2, 1)
187+
#define TIM2_CH1_PA15_1 CH32V20X_V30X_PINMUX_DEFINE(PA, 15, TIM2, 1)
188+
#define TIM2_CH2_PA1_0 CH32V20X_V30X_PINMUX_DEFINE(PA, 1, TIM2, 0)
189+
#define TIM2_CH2_PB3_1 CH32V20X_V30X_PINMUX_DEFINE(PB, 3, TIM2, 1)
190+
#define TIM2_CH2_PA1_2 CH32V20X_V30X_PINMUX_DEFINE(PA, 1, TIM2, 2)
191+
#define TIM2_CH2_PB3_3 CH32V20X_V30X_PINMUX_DEFINE(PB, 3, TIM2, 3)
192+
#define TIM2_CH3_PA2_0 CH32V20X_V30X_PINMUX_DEFINE(PA, 2, TIM2, 0)
193+
#define TIM2_CH3_PA2_1 CH32V20X_V30X_PINMUX_DEFINE(PA, 2, TIM2, 1)
194+
#define TIM2_CH3_PB10_2 CH32V20X_V30X_PINMUX_DEFINE(PB, 10, TIM2, 2)
195+
#define TIM2_CH3_PB10_2 CH32V20X_V30X_PINMUX_DEFINE(PB, 10, TIM2, 2)
196+
#define TIM2_CH4_PA3_0 CH32V20X_V30X_PINMUX_DEFINE(PA, 3, TIM2, 0)
197+
#define TIM2_CH4_PA3_1 CH32V20X_V30X_PINMUX_DEFINE(PA, 3, TIM2, 1)
198+
#define TIM2_CH4_PB11_2 CH32V20X_V30X_PINMUX_DEFINE(PB, 11, TIM2, 2)
199+
#define TIM2_CH4_PB11_3 CH32V20X_V30X_PINMUX_DEFINE(PB, 11, TIM2, 3)
200+
201+
#define TIM3_ETR_PD2_0 CH32V20X_V30X_PINMUX_DEFINE(PD, 2, TIM3, 0)
202+
#define TIM3_ETR_PD2_2 CH32V20X_V30X_PINMUX_DEFINE(PD, 2, TIM3, 2)
203+
#define TIM3_ETR_PD2_3 CH32V20X_V30X_PINMUX_DEFINE(PD, 2, TIM3, 3)
204+
#define TIM3_CH1_PA6_0 CH32V20X_V30X_PINMUX_DEFINE(PA, 6, TIM3, 0)
205+
#define TIM3_CH1_PB4_2 CH32V20X_V30X_PINMUX_DEFINE(PB, 4, TIM3, 2)
206+
#define TIM3_CH1_PC6_3 CH32V20X_V30X_PINMUX_DEFINE(PC, 6, TIM3, 3)
207+
#define TIM3_CH2_PA7_0 CH32V20X_V30X_PINMUX_DEFINE(PA, 7, TIM3, 0)
208+
#define TIM3_CH2_PB5_2 CH32V20X_V30X_PINMUX_DEFINE(PB, 5, TIM3, 2)
209+
#define TIM3_CH2_PC7_3 CH32V20X_V30X_PINMUX_DEFINE(PC, 7, TIM3, 3)
210+
#define TIM3_CH3_PB0_0 CH32V20X_V30X_PINMUX_DEFINE(PB, 0, TIM3, 0)
211+
#define TIM3_CH3_PB0_2 CH32V20X_V30X_PINMUX_DEFINE(PB, 0, TIM3, 2)
212+
#define TIM3_CH3_PC8_3 CH32V20X_V30X_PINMUX_DEFINE(PC, 8, TIM3, 3)
213+
#define TIM3_CH4_PB1_0 CH32V20X_V30X_PINMUX_DEFINE(PB, 1, TIM3, 0)
214+
#define TIM3_CH4_PB1_2 CH32V20X_V30X_PINMUX_DEFINE(PB, 1, TIM3, 2)
215+
#define TIM3_CH4_PC9_3 CH32V20X_V30X_PINMUX_DEFINE(PC, 9, TIM3, 3)
216+
217+
#define TIM4_CH1_PB6_0 CH32V20X_V30X_PINMUX_DEFINE(PB, 6, TIM4, 0)
218+
#define TIM4_CH1_PD12_1 CH32V20X_V30X_PINMUX_DEFINE(PD, 12, TIM4, 1)
219+
#define TIM4_CH2_PB7_0 CH32V20X_V30X_PINMUX_DEFINE(PB, 7, TIM4, 0)
220+
#define TIM4_CH2_PD13_1 CH32V20X_V30X_PINMUX_DEFINE(PD, 13, TIM4, 1)
221+
#define TIM4_CH3_PB8_0 CH32V20X_V30X_PINMUX_DEFINE(PB, 8, TIM4, 0)
222+
#define TIM4_CH3_PD14_1 CH32V20X_V30X_PINMUX_DEFINE(PD, 14, TIM4, 1)
223+
#define TIM4_CH4_PB9_0 CH32V20X_V30X_PINMUX_DEFINE(PB, 9, TIM4, 0)
224+
#define TIM4_CH4_PD15_1 CH32V20X_V30X_PINMUX_DEFINE(PD, 15, TIM4, 1)
225+
180226
#endif /* __CH32V20X_V30X_PINCTRL_H__ */

0 commit comments

Comments
 (0)