From 0ecef25d5e77d146937f3c549ecd41782029e9bf Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Fri, 6 Sep 2019 13:47:21 +0200 Subject: [PATCH] drivers: pwm: Add STM32G4X PWM Support Add PWM driver support for STM32G4X SoC series. Signed-off-by: Erwan Gouriou Signed-off-by: Richard Osterloh --- dts/arm/st/g4/stm32g4.dtsi | 160 +++++++++++++++++++++++++++ soc/arm/st_stm32/stm32g4/dts_fixup.h | 66 +++++++++++ 2 files changed, 226 insertions(+) diff --git a/dts/arm/st/g4/stm32g4.dtsi b/dts/arm/st/g4/stm32g4.dtsi index 81033bc9d70..0dc5935d176 100644 --- a/dts/arm/st/g4/stm32g4.dtsi +++ b/dts/arm/st/g4/stm32g4.dtsi @@ -239,6 +239,166 @@ label = "SPI_3"; }; + timers1: timers@40012c00 { + compatible = "st,stm32-timers"; + reg = <0x40012c00 0x400>; + clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00000800>; + status = "disabled"; + label = "TIMERS_1"; + + pwm { + compatible = "st,stm32-pwm"; + status = "disabled"; + st,prescaler = <10000>; + label = "PWM_1"; + #pwm-cells = <2>; + }; + }; + + timers2: timers@40000000 { + compatible = "st,stm32-timers"; + reg = <0x40000000 0x400>; + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00000001>; + status = "disabled"; + label = "TIMERS_2"; + + pwm { + compatible = "st,stm32-pwm"; + status = "disabled"; + st,prescaler = <0>; + label = "PWM_2"; + #pwm-cells = <2>; + }; + }; + + timers3: timers@40000400 { + compatible = "st,stm32-timers"; + reg = <0x40000400 0x400>; + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00000002>; + status = "disabled"; + label = "TIMERS_3"; + + pwm { + compatible = "st,stm32-pwm"; + status = "disabled"; + st,prescaler = <10000>; + label = "PWM_3"; + #pwm-cells = <2>; + }; + }; + + timers4: timers@40000800 { + compatible = "st,stm32-timers"; + reg = <0x40000800 0x400>; + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00000004>; + status = "disabled"; + label = "TIMERS_4"; + + pwm { + compatible = "st,stm32-pwm"; + status = "disabled"; + st,prescaler = <10000>; + label = "PWM_4"; + #pwm-cells = <2>; + }; + }; + + timers6: timers@40001000 { + compatible = "st,stm32-timers"; + reg = <0x40001000 0x400>; + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00000010>; + status = "disabled"; + label = "TIMERS_6"; + + pwm { + compatible = "st,stm32-pwm"; + status = "disabled"; + st,prescaler = <10000>; + label = "PWM_6"; + #pwm-cells = <2>; + }; + }; + + timers7: timers@40001400 { + compatible = "st,stm32-timers"; + reg = <0x40001400 0x400>; + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00000020>; + status = "disabled"; + label = "TIMERS_7"; + + pwm { + compatible = "st,stm32-pwm"; + status = "disabled"; + st,prescaler = <10000>; + label = "PWM_7"; + #pwm-cells = <2>; + }; + }; + + timers8: timers@40013400 { + compatible = "st,stm32-timers"; + reg = <0x40013400 0x400>; + clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00004000>; + status = "disabled"; + label = "TIMERS_8"; + + pwm { + compatible = "st,stm32-pwm"; + status = "disabled"; + st,prescaler = <10000>; + label = "PWM_8"; + #pwm-cells = <2>; + }; + }; + + timers15: timers@40014000 { + compatible = "st,stm32-timers"; + reg = <0x40014000 0x400>; + clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00010000>; + status = "disabled"; + label = "TIMERS_15"; + + pwm { + compatible = "st,stm32-pwm"; + status = "disabled"; + st,prescaler = <10000>; + label = "PWM_15"; + #pwm-cells = <2>; + }; + }; + + timers16: timers@40014400 { + compatible = "st,stm32-timers"; + reg = <0x40014400 0x400>; + clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00020000>; + status = "disabled"; + label = "TIMERS_16"; + + pwm { + compatible = "st,stm32-pwm"; + status = "disabled"; + st,prescaler = <10000>; + label = "PWM_16"; + #pwm-cells = <2>; + }; + }; + + timers17: timers@40014800 { + compatible = "st,stm32-timers"; + reg = <0x40014800 0x400>; + clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00040000>; + status = "disabled"; + label = "TIMERS_17"; + + pwm { + compatible = "st,stm32-pwm"; + status = "disabled"; + st,prescaler = <10000>; + label = "PWM_17"; + #pwm-cells = <2>; + }; + }; + }; }; diff --git a/soc/arm/st_stm32/stm32g4/dts_fixup.h b/soc/arm/st_stm32/stm32g4/dts_fixup.h index 60326acfc51..ec27d48aaf3 100644 --- a/soc/arm/st_stm32/stm32g4/dts_fixup.h +++ b/soc/arm/st_stm32/stm32g4/dts_fixup.h @@ -170,4 +170,70 @@ #define DT_SPI_3_CLOCK_BITS DT_ST_STM32_SPI_FIFO_40003C00_CLOCK_BITS #define DT_SPI_3_CLOCK_BUS DT_ST_STM32_SPI_FIFO_40003C00_CLOCK_BUS +#define DT_PWM_STM32_1_DEV_NAME DT_ST_STM32_PWM_40012C00_PWM_LABEL +#define DT_PWM_STM32_1_PRESCALER DT_ST_STM32_PWM_40012C00_PWM_ST_PRESCALER +#define DT_TIM_STM32_1_BASE_ADDRESS DT_ST_STM32_TIMERS_40012C00_BASE_ADDRESS +#define DT_TIM_STM32_1_CLOCK_BITS DT_ST_STM32_TIMERS_40012C00_CLOCK_BITS +#define DT_TIM_STM32_1_CLOCK_BUS DT_ST_STM32_TIMERS_40012C00_CLOCK_BUS + +#define DT_PWM_STM32_2_DEV_NAME DT_ST_STM32_PWM_40000000_PWM_LABEL +#define DT_PWM_STM32_2_PRESCALER DT_ST_STM32_PWM_40000000_PWM_ST_PRESCALER +#define DT_TIM_STM32_2_BASE_ADDRESS DT_ST_STM32_TIMERS_40000000_BASE_ADDRESS +#define DT_TIM_STM32_2_CLOCK_BITS DT_ST_STM32_TIMERS_40000000_CLOCK_BITS +#define DT_TIM_STM32_2_CLOCK_BUS DT_ST_STM32_TIMERS_40000000_CLOCK_BUS + +#define DT_PWM_STM32_3_DEV_NAME DT_ST_STM32_PWM_40000400_PWM_LABEL +#define DT_PWM_STM32_3_PRESCALER DT_ST_STM32_PWM_40000400_PWM_ST_PRESCALER +#define DT_TIM_STM32_3_BASE_ADDRESS DT_ST_STM32_TIMERS_40000400_BASE_ADDRESS +#define DT_TIM_STM32_3_CLOCK_BITS DT_ST_STM32_TIMERS_40000400_CLOCK_BITS +#define DT_TIM_STM32_3_CLOCK_BUS DT_ST_STM32_TIMERS_40000400_CLOCK_BUS + +#define DT_PWM_STM32_4_DEV_NAME DT_ST_STM32_PWM_40000800_PWM_LABEL +#define DT_PWM_STM32_4_PRESCALER DT_ST_STM32_PWM_40000800_PWM_ST_PRESCALER +#define DT_TIM_STM32_4_BASE_ADDRESS DT_ST_STM32_TIMERS_40000800_BASE_ADDRESS +#define DT_TIM_STM32_4_CLOCK_BITS DT_ST_STM32_TIMERS_40000800_CLOCK_BITS +#define DT_TIM_STM32_4_CLOCK_BUS DT_ST_STM32_TIMERS_40000800_CLOCK_BUS + +#define DT_PWM_STM32_5_DEV_NAME DT_ST_STM32_PWM_40000C00_PWM_LABEL +#define DT_PWM_STM32_5_PRESCALER DT_ST_STM32_PWM_40000C00_PWM_ST_PRESCALER +#define DT_TIM_STM32_5_BASE_ADDRESS DT_ST_STM32_TIMERS_40000C00_BASE_ADDRESS +#define DT_TIM_STM32_5_CLOCK_BITS DT_ST_STM32_TIMERS_40000C00_CLOCK_BITS +#define DT_TIM_STM32_5_CLOCK_BUS DT_ST_STM32_TIMERS_40000C00_CLOCK_BUS + +#define DT_PWM_STM32_6_DEV_NAME DT_ST_STM32_PWM_40001000_PWM_LABEL +#define DT_PWM_STM32_6_PRESCALER DT_ST_STM32_PWM_40001000_PWM_ST_PRESCALER +#define DT_TIM_STM32_6_BASE_ADDRESS DT_ST_STM32_TIMERS_40001000_BASE_ADDRESS +#define DT_TIM_STM32_6_CLOCK_BITS DT_ST_STM32_TIMERS_40001000_CLOCK_BITS +#define DT_TIM_STM32_6_CLOCK_BUS DT_ST_STM32_TIMERS_40001000_CLOCK_BUS + +#define DT_PWM_STM32_7_DEV_NAME DT_ST_STM32_PWM_40001400_PWM_LABEL +#define DT_PWM_STM32_7_PRESCALER DT_ST_STM32_PWM_40001400_PWM_ST_PRESCALER +#define DT_TIM_STM32_7_BASE_ADDRESS DT_ST_STM32_TIMERS_40001400_BASE_ADDRESS +#define DT_TIM_STM32_7_CLOCK_BITS DT_ST_STM32_TIMERS_40001400_CLOCK_BITS +#define DT_TIM_STM32_7_CLOCK_BUS DT_ST_STM32_TIMERS_40001400_CLOCK_BUS + +#define DT_PWM_STM32_8_DEV_NAME DT_ST_STM32_PWM_40013400_PWM_LABEL +#define DT_PWM_STM32_8_PRESCALER DT_ST_STM32_PWM_40013400_PWM_ST_PRESCALER +#define DT_TIM_STM32_8_BASE_ADDRESS DT_ST_STM32_TIMERS_40013400_BASE_ADDRESS +#define DT_TIM_STM32_8_CLOCK_BITS DT_ST_STM32_TIMERS_40013400_CLOCK_BITS +#define DT_TIM_STM32_8_CLOCK_BUS DT_ST_STM32_TIMERS_40013400_CLOCK_BUS + +#define DT_PWM_STM32_15_DEV_NAME DT_ST_STM32_PWM_40014000_PWM_LABEL +#define DT_PWM_STM32_15_PRESCALER DT_ST_STM32_PWM_40014000_PWM_ST_PRESCALER +#define DT_TIM_STM32_15_BASE_ADDRESS DT_ST_STM32_TIMERS_40014000_BASE_ADDRESS +#define DT_TIM_STM32_15_CLOCK_BITS DT_ST_STM32_TIMERS_40014000_CLOCK_BITS +#define DT_TIM_STM32_15_CLOCK_BUS DT_ST_STM32_TIMERS_40014000_CLOCK_BUS + +#define DT_PWM_STM32_16_DEV_NAME DT_ST_STM32_PWM_40014400_PWM_LABEL +#define DT_PWM_STM32_16_PRESCALER DT_ST_STM32_PWM_40014400_PWM_ST_PRESCALER +#define DT_TIM_STM32_16_BASE_ADDRESS DT_ST_STM32_TIMERS_40014400_BASE_ADDRESS +#define DT_TIM_STM32_16_CLOCK_BITS DT_ST_STM32_TIMERS_40014400_CLOCK_BITS +#define DT_TIM_STM32_16_CLOCK_BUS DT_ST_STM32_TIMERS_40014400_CLOCK_BUS + +#define DT_PWM_STM32_17_DEV_NAME DT_ST_STM32_PWM_40014800_PWM_LABEL +#define DT_PWM_STM32_17_PRESCALER DT_ST_STM32_PWM_40014800_PWM_ST_PRESCALER +#define DT_TIM_STM32_17_BASE_ADDRESS DT_ST_STM32_TIMERS_40014800_BASE_ADDRESS +#define DT_TIM_STM32_17_CLOCK_BITS DT_ST_STM32_TIMERS_40014800_CLOCK_BITS +#define DT_TIM_STM32_17_CLOCK_BUS DT_ST_STM32_TIMERS_40014800_CLOCK_BUS + /* End of SoC Level DTS fixup file */