Skip to content

Commit abd5eb2

Browse files
dts: bindings: comparator: add STM32 COMP device driver
Add STM32 COMP devices comparator DTS description Signed-off-by: Alexander Kozhinov <[email protected]>
1 parent ca85e76 commit abd5eb2

File tree

3 files changed

+277
-0
lines changed

3 files changed

+277
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Copyright (c) 2025 Alexander Kozhinov <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: |
5+
STM32 Comparator
6+
7+
The following example displays the minimum node layout:
8+
9+
comp1: comparator@40010200 {
10+
reg = <0x40010200 0x4>;
11+
interrupts = <64 0>;
12+
clocks = <&rcc STM32_CLOCK(APB2, 0)>;
13+
st,exti-line = <21>;
14+
positive-input = "IN0";
15+
negative-input = "VREFINT";
16+
status = "okay";
17+
};
18+
19+
NOTE: The shown example is for stm32g474re
20+
21+
Enabling the comparator node requires setting the minimum default
22+
configuration of the comparator. This includes selecting the
23+
positive and negative inputs, and routing them using pinctrl:
24+
25+
&comp1 {
26+
pinctrl-0 = <&comp1_inp_pa1 &comp1_out_pa6>;
27+
pinctrl-names = "default";
28+
29+
positive-input = "IN0";
30+
negative-input = "VREFINT";
31+
status = "okay";
32+
};
33+
34+
NOTE: Pins used above are an example for stm32g474re
35+
36+
compatible: "st,stm32-comp"
37+
38+
include:
39+
- base.yaml
40+
- pinctrl-device.yaml
41+
42+
properties:
43+
reg:
44+
required: true
45+
interrupts:
46+
required: true
47+
clocks:
48+
required: true
49+
50+
invert-output:
51+
type: string
52+
description: |
53+
Output polarity selection.
54+
enum:
55+
- NONINVERTED
56+
- INVERTED
57+
default: NONINVERTED
58+
59+
st,exti-line:
60+
required: true
61+
type: int
62+
description: |
63+
EXTI interrupt line number connected to the comparator (COMPx) event.
64+
65+
st,lock-enable:
66+
type: boolean
67+
description: |
68+
The comparator configuration can be locked to prevent any
69+
modification until the next system reset.
70+
Once the lock bit is set, it can be cleared only by a system reset.
71+
This feature allows to protect the comparator configuration against
72+
unintentional modification.
73+
74+
positive-input:
75+
required: true
76+
type: string
77+
description: |
78+
Selects positive input pin provided by the pinmux controller.
79+
IN0 corresponds to the first pinmux option, IN1 to the second one.
80+
enum:
81+
- IN0
82+
- IN1
83+
84+
negative-input:
85+
required: true
86+
type: string
87+
description: |
88+
Selects negative input. May be a package pin (IN0 / IN1) via pinctrl
89+
or an internal signal (e.g. VREFINT, DAC).
90+
In case of package pin assignment IN0 will correspond to first pinmux pin
91+
option and IN1 to the second one.
92+
enum:
93+
- 1_4VREFINT
94+
- 1_2VREFINT
95+
- 3_4VREFINT
96+
- VREFINT
97+
- IN0
98+
- IN1
99+
100+
hysteresis:
101+
type: string
102+
description: |
103+
Selects the hysteresis voltage level.
104+
Hysteresis adds a voltage offset to the comparator threshold to prevent
105+
unwanted output toggling when the input voltage is noisy or slowly
106+
varying around the comparator threshold.
107+
enum:
108+
- NONE
109+
- LOW
110+
- MEDIUM
111+
- HIGH
112+
default: NONE
113+
114+
st,blank-sel:
115+
type: string
116+
description: |
117+
Blanking source to mask short spikes at PWM period start.
118+
Ref (example): STM32G4 RM0440 Rev 8, 24.3.6.
119+
enum:
120+
- NONE
121+
default: NONE
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Copyright (c) 2025 Alexander Kozhinov <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: |
5+
STM32G4 series Comparator
6+
7+
include:
8+
- name: st,stm32-comp.yaml
9+
property-blocklist:
10+
- hysteresis
11+
- st,blank-sel
12+
- positive-input
13+
- negative-input
14+
15+
compatible: "st,stm32g4-comp"
16+
17+
properties:
18+
negative-input:
19+
required: true
20+
type: string
21+
enum:
22+
- 1_4VREFINT
23+
- 1_2VREFINT
24+
- 3_4VREFINT
25+
- VREFINT
26+
- DAC1_CH1
27+
- DAC1_CH2
28+
- DAC2_CH1
29+
- DAC3_CH1
30+
- DAC3_CH2
31+
- DAC4_CH1
32+
- DAC4_CH2
33+
- IN0
34+
- IN1
35+
36+
positive-input:
37+
required: true
38+
type: string
39+
enum:
40+
- IN0
41+
- IN1
42+
- DAC2_CH1
43+
44+
hysteresis:
45+
type: string
46+
enum:
47+
- NONE
48+
- LOW
49+
- MEDIUM
50+
- HIGH
51+
- 10MV
52+
- 20MV
53+
- 30MV
54+
- 40MV
55+
- 50MV
56+
- 60MV
57+
- 70MV
58+
default: NONE
59+
60+
st,blank-sel:
61+
type: string
62+
enum:
63+
- NONE
64+
- TIM1_OC5_COMP1
65+
- TIM1_OC5_COMP2
66+
- TIM1_OC5_COMP3
67+
- TIM1_OC5_COMP4
68+
- TIM1_OC5_COMP5
69+
- TIM1_OC5_COMP6
70+
- TIM1_OC5_COMP7
71+
- TIM2_OC3_COMP1
72+
- TIM2_OC3_COMP2
73+
- TIM2_OC3_COMP5
74+
- TIM2_OC4_COMP3
75+
- TIM2_OC4_COMP6
76+
- TIM3_OC3_COMP1
77+
- TIM3_OC3_COMP2
78+
- TIM3_OC3_COMP3
79+
- TIM3_OC3_COMP5
80+
- TIM3_OC3_COMP7
81+
- TIM3_OC4_COMP4
82+
- TIM8_OC5_COMP1
83+
- TIM8_OC5_COMP2
84+
- TIM8_OC5_COMP3
85+
- TIM8_OC5_COMP4
86+
- TIM8_OC5_COMP5
87+
- TIM8_OC5_COMP6
88+
- TIM8_OC5_COMP7
89+
- TIM15_OC1_COMP4
90+
- TIM15_OC2_COMP6
91+
- TIM15_OC2_COMP7
92+
- TIM20_OC5
93+
- TIM15_OC1
94+
- TIM4_OC3
95+
default: NONE
96+
97+
st,miller-effect-hold-disable:
98+
type: boolean
99+
description: |
100+
Disable undocumented hold feature (COMP_CxCSR bit 1).
101+
NOTE: This setting is supported only by stm32g4x series.
102+
NOTE: It is recommended to enable the feature unless very fast events are tracked.
103+
Please refer to following url for details:
104+
https://community.st.com/t5/stm32-mcus-products/stm32g431-comparator-bug/m-p/679540#M250779
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright (c) 2025 Alexander Kozhinov <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: |
5+
STM32H7 series Comparator
6+
7+
include:
8+
- name: st,stm32-comp.yaml
9+
property-blocklist:
10+
- st,blank-sel
11+
- negative-input
12+
13+
compatible: "st,stm32h7-comp"
14+
15+
properties:
16+
negative-input:
17+
required: true
18+
type: string
19+
enum:
20+
- 1_4VREFINT
21+
- 1_2VREFINT
22+
- 3_4VREFINT
23+
- VREFINT
24+
- DAC1_CH1
25+
- DAC1_CH2
26+
- IN0
27+
- IN1
28+
- TPSENS_DAC2CH1
29+
- VBAT_VDDAP
30+
31+
st,power-mode:
32+
type: string
33+
description: |
34+
Select comparator speed vs power mode.
35+
Typical modes: fast (higher current), medium, low power, ultra-low power.
36+
Availability varies by series.
37+
enum:
38+
- HIGHSPEED
39+
- MEDIUMSPEED
40+
- ULTRALOWPOWER
41+
42+
st,blank-sel:
43+
type: string
44+
enum:
45+
- NONE
46+
- TIM1_OC5
47+
- TIM2_OC3
48+
- TIM3_OC3
49+
- TIM3_OC4
50+
- TIM8_OC5
51+
- TIM15_OC1
52+
default: NONE

0 commit comments

Comments
 (0)