Skip to content

Commit 4e55597

Browse files
bjarki-andreasennashif
authored andcommitted
drivers: sensor: mcux_acmp: update dts binding and adapt driver
Update the devicetree binding for the nxp,kinetis-acmp comparator and move the binding to dts/bindings/comparator. The update to the binding includes: - Remove unused io-channel-cells property - Remove unused sensor-device include - Adding missing properties dac config, discrete mode config, and input configs. - Rename properties to exclude redundant vendor prefix since props in this binding are not inhereted, and as such, don't need to be namespaced. - Deprecate the old names of the renamed properties The sensor based device driver has been updated to support both the deprecated and new property names. This allows it to use both nxp,enable-sample and filter-enable-sample for example. Additionally, remove the unused io-channel-cells properties from in-tree nodes of compatible = "nxp,kinetis-acmp" Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent e0363f2 commit 4e55597

File tree

7 files changed

+246
-78
lines changed

7 files changed

+246
-78
lines changed

drivers/sensor/nxp/mcux_acmp/mcux_acmp.c

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,49 @@ BUILD_ASSERT(kACMP_PortInputFromDAC == 0);
4141
BUILD_ASSERT(kACMP_PortInputFromMux == 1);
4242
#endif /* MCUX_ACMP_HAS_INPSEL || MCUX_ACMP_HAS_INNSEL */
4343

44+
/*
45+
* prop New property name
46+
* depr Deprecated property name
47+
*/
48+
#define MCUX_ACMP_DT_INST_PROP(inst, prop, depr) \
49+
COND_CODE_1( \
50+
DT_INST_NODE_HAS_PROP(inst, prop), \
51+
(DT_INST_PROP(inst, prop)), \
52+
(DT_INST_PROP(inst, depr)) \
53+
)
54+
55+
/*
56+
* prop New property name
57+
* depr Deprecated property name
58+
*/
59+
#define MCUX_ACMP_DT_INST_PROP_OR(inst, prop, depr, default_value) \
60+
COND_CODE_1( \
61+
DT_INST_NODE_HAS_PROP(inst, prop) || DT_INST_NODE_HAS_PROP(inst, depr), \
62+
(MCUX_ACMP_DT_INST_PROP(inst, prop, depr)), \
63+
(default_value) \
64+
)
65+
66+
#define MCUX_ACMP_DT_INST_ENABLE_SAMPLE(inst) \
67+
MCUX_ACMP_DT_INST_PROP(inst, filter_enable_sample, nxp_enable_sample)
68+
69+
#define MCUX_ACMP_DT_INST_FILTER_COUNT(inst) \
70+
MCUX_ACMP_DT_INST_PROP_OR(inst, filter_count, nxp_filter_count, 0)
71+
72+
#define MCUX_ACMP_DT_INST_FILTER_PERIOD(inst) \
73+
MCUX_ACMP_DT_INST_PROP_OR(inst, filter_period, nxp_filter_period, 0)
74+
75+
#define MCUX_ACMP_DT_INST_HIGH_SPEED(inst) \
76+
MCUX_ACMP_DT_INST_PROP(inst, enable_high_speed_mode, nxp_high_speed_mode)
77+
78+
#define MCUX_ACMP_DT_INST_USE_UNFILTERED_MODE(inst) \
79+
MCUX_ACMP_DT_INST_PROP(inst, use_unfiltered_output, nxp_use_unfiltered_output)
80+
81+
#define MCUX_ACMP_DT_INST_USE_ENABLE_PIN_OUT(inst) \
82+
MCUX_ACMP_DT_INST_PROP(inst, enable_pin_out, nxp_enable_output_pin)
83+
84+
#define MCUX_ACMP_DT_INST_ENABLE_WINDOW_MODE(inst) \
85+
MCUX_ACMP_DT_INST_PROP(inst, enable_window_mode, nxp_window_mode)
86+
4487
struct mcux_acmp_config {
4588
CMP_Type *base;
4689
acmp_filter_config_t filter;
@@ -487,18 +530,18 @@ static const struct sensor_driver_api mcux_acmp_driver_api = {
487530
.channel_get = mcux_acmp_channel_get,
488531
};
489532

490-
#define MCUX_ACMP_DECLARE_CONFIG(n, config_func_init) \
533+
#define MCUX_ACMP_DECLARE_CONFIG(n, config_func_init) \
491534
static const struct mcux_acmp_config mcux_acmp_config_##n = { \
492535
.base = (CMP_Type *)DT_INST_REG_ADDR(n), \
493536
.filter = { \
494-
.enableSample = DT_INST_PROP(n, nxp_enable_sample), \
495-
.filterCount = DT_INST_PROP_OR(n, nxp_filter_count, 0), \
496-
.filterPeriod = DT_INST_PROP_OR(n, nxp_filter_period, 0), \
537+
.enableSample = MCUX_ACMP_DT_INST_ENABLE_SAMPLE(n), \
538+
.filterCount = MCUX_ACMP_DT_INST_FILTER_COUNT(n), \
539+
.filterPeriod = MCUX_ACMP_DT_INST_FILTER_PERIOD(n), \
497540
}, \
498-
.high_speed = DT_INST_PROP(n, nxp_high_speed_mode), \
499-
.unfiltered = DT_INST_PROP(n, nxp_use_unfiltered_output), \
500-
.output = DT_INST_PROP(n, nxp_enable_output_pin), \
501-
.window = DT_INST_PROP(n, nxp_window_mode), \
541+
.high_speed = MCUX_ACMP_DT_INST_HIGH_SPEED(n), \
542+
.unfiltered = MCUX_ACMP_DT_INST_USE_UNFILTERED_MODE(n), \
543+
.output = MCUX_ACMP_DT_INST_USE_ENABLE_PIN_OUT(n), \
544+
.window = MCUX_ACMP_DT_INST_ENABLE_WINDOW_MODE(n), \
502545
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
503546
config_func_init \
504547
}

dts/arm/nxp/nxp_ke1xf.dtsi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,6 @@
575575
interrupts = <40 0>;
576576
clocks = <&scg KINETIS_SCG_BUS_CLK>;
577577
status = "disabled";
578-
#io-channel-cells = <2>;
579578
};
580579

581580
cmp1: cmp@40074000 {
@@ -584,7 +583,6 @@
584583
interrupts = <41 0>;
585584
clocks = <&scg KINETIS_SCG_BUS_CLK>;
586585
status = "disabled";
587-
#io-channel-cells = <2>;
588586
};
589587

590588
cmp2: cmp@40075000 {
@@ -593,7 +591,6 @@
593591
interrupts = <70 0>;
594592
clocks = <&scg KINETIS_SCG_BUS_CLK>;
595593
status = "disabled";
596-
#io-channel-cells = <2>;
597594
};
598595

599596
flexio1: flexio@4005a000 {

dts/arm/nxp/nxp_ke1xz.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@
419419
interrupts = <16 0>;
420420
clocks = <&scg KINETIS_SCG_BUS_CLK>;
421421
status = "disabled";
422-
#io-channel-cells = <2>;
423422
};
424423

425424
lpspi0: spi@4002c000 {

dts/arm/nxp/nxp_rt118x.dtsi

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,31 +300,27 @@
300300
reg = <0x2dc0000 0x4000>;
301301
interrupts = <200 0>;
302302
status = "disabled";
303-
#io-channel-cells = <2>;
304303
};
305304

306305
acmp2: cmp@2dd0000 {
307306
compatible = "nxp,kinetis-acmp";
308307
reg = <0x2dd0000 0x4000>;
309308
interrupts = <201 0>;
310309
status = "disabled";
311-
#io-channel-cells = <2>;
312310
};
313311

314312
acmp3: cmp@2de0000 {
315313
compatible = "nxp,kinetis-acmp";
316314
reg = <0x2de0000 0x4000>;
317315
interrupts = <202 0>;
318316
status = "disabled";
319-
#io-channel-cells = <2>;
320317
};
321318

322319
acmp4: cmp@2df0000 {
323320
compatible = "nxp,kinetis-acmp";
324321
reg = <0x2df0000 0x4000>;
325322
interrupts = <203 0>;
326323
status = "disabled";
327-
#io-channel-cells = <2>;
328324
};
329325

330326
lpadc1: lpadc@2600000 {

dts/arm/nxp/nxp_rt11xx.dtsi

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,31 +1011,27 @@
10111011
reg = <0x401a4000 0x4000>;
10121012
interrupts = <157 0>;
10131013
status = "disabled";
1014-
#io-channel-cells = <2>;
10151014
};
10161015

10171016
acmp2: cmp@401a8000 {
10181017
compatible = "nxp,kinetis-acmp";
10191018
reg = <0x401a8000 0x4000>;
10201019
interrupts = <158 0>;
10211020
status = "disabled";
1022-
#io-channel-cells = <2>;
10231021
};
10241022

10251023
acmp3: cmp@401ac000 {
10261024
compatible = "nxp,kinetis-acmp";
10271025
reg = <0x401ac000 0x4000>;
10281026
interrupts = <159 0>;
10291027
status = "disabled";
1030-
#io-channel-cells = <2>;
10311028
};
10321029

10331030
acmp4: cmp@401b0000 {
10341031
compatible = "nxp,kinetis-acmp";
10351032
reg = <0x401b0000 0x4000>;
10361033
interrupts = <160 0>;
10371034
status = "disabled";
1038-
#io-channel-cells = <2>;
10391035
};
10401036

10411037
anatop: anatop@40c84000 {
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
# Copyright (c) 2020 Vestas Wind Systems A/S
2+
# Copyright (c) 2024 Nordic Semiconductor ASA
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
description: NXP Kinetis ACMP (Analog CoMParator)
6+
7+
compatible: "nxp,kinetis-acmp"
8+
9+
include:
10+
- base.yaml
11+
- pinctrl-device.yaml
12+
13+
properties:
14+
interrupts:
15+
required: true
16+
17+
reg:
18+
required: true
19+
20+
nxp,enable-output-pin:
21+
type: boolean
22+
deprecated: true
23+
description: Deprecated. Please use enable-pin-out instead
24+
25+
nxp,use-unfiltered-output:
26+
type: boolean
27+
deprecated: true
28+
description: Deprecated. Please use use-unfiltered-output instead
29+
30+
nxp,high-speed-mode:
31+
type: boolean
32+
deprecated: true
33+
description: Deprecated. Please use enable-high-speed-mode instead
34+
35+
nxp,enable-sample:
36+
type: boolean
37+
deprecated: true
38+
description: Deprecated. Please use filter-enable-sample instead
39+
40+
nxp,filter-count:
41+
type: int
42+
deprecated: true
43+
description: Deprecated. Please use filter-count instead
44+
45+
nxp,filter-period:
46+
type: int
47+
deprecated: true
48+
description: Deprecated. Please use filter-period instead
49+
50+
nxp,window-mode:
51+
type: boolean
52+
deprecated: true
53+
description: Deprecated. Please use enable-window-mode instead
54+
55+
offset-mode:
56+
type: string
57+
enum:
58+
- "LEVEL0"
59+
- "LEVEL1"
60+
61+
hysteresis-mode:
62+
type: string
63+
enum:
64+
- "LEVEL0"
65+
- "LEVEL1"
66+
- "LEVEL2"
67+
- "LEVEL3"
68+
69+
enable-high-speed-mode:
70+
type: boolean
71+
72+
invert-output:
73+
type: boolean
74+
75+
use-unfiltered-output:
76+
type: boolean
77+
78+
enable-pin-out:
79+
type: boolean
80+
81+
enable-window-mode:
82+
type: boolean
83+
84+
positive-mux-input:
85+
type: string
86+
enum:
87+
- IN0
88+
- IN1
89+
- IN2
90+
- IN3
91+
- IN4
92+
- IN5
93+
- IN6
94+
- IN7
95+
96+
negative-mux-input:
97+
type: string
98+
enum:
99+
- IN0
100+
- IN1
101+
- IN2
102+
- IN3
103+
- IN4
104+
- IN5
105+
- IN6
106+
- IN7
107+
108+
positive-port-input:
109+
type: string
110+
enum:
111+
- DAC
112+
- MUX
113+
114+
negative-port-input:
115+
type: string
116+
enum:
117+
- DAC
118+
- MUX
119+
120+
filter-enable-sample:
121+
type: boolean
122+
123+
filter-count:
124+
type: int
125+
description: Filter sample count (0 to 7).
126+
127+
filter-period:
128+
type: int
129+
description: Filter sample period in bus clock cycles (0 to 255).
130+
131+
dac-vref-source:
132+
type: string
133+
enum:
134+
- "VIN1"
135+
- "VIN2"
136+
137+
dac-value:
138+
type: int
139+
140+
dac-enable:
141+
type: boolean
142+
143+
dac-enable-high-speed:
144+
type: boolean
145+
146+
discrete-mode-enable-positive-channel:
147+
type: boolean
148+
149+
discrete-mode-enable-negative-channel:
150+
type: boolean
151+
152+
discrete-mode-enable-resistor-divider:
153+
type: boolean
154+
155+
discrete-mode-clock-source:
156+
type: string
157+
enum:
158+
- "SLOW"
159+
- "FAST"
160+
161+
discrete-mode-sample-time:
162+
type: string
163+
enum:
164+
- "T1"
165+
- "T2"
166+
- "T4"
167+
- "T8"
168+
- "T16"
169+
- "T32"
170+
- "T64"
171+
- "T256"
172+
173+
discrete-mode-phase1-time:
174+
type: string
175+
enum:
176+
- "ALT0"
177+
- "ALT1"
178+
- "ALT2"
179+
- "ALT3"
180+
- "ALT4"
181+
- "ALT5"
182+
- "ALT6"
183+
- "ALT7"
184+
185+
discrete-mode-phase2-time:
186+
type: string
187+
enum:
188+
- "ALT0"
189+
- "ALT1"
190+
- "ALT2"
191+
- "ALT3"
192+
- "ALT4"
193+
- "ALT5"
194+
- "ALT6"
195+
- "ALT7"

0 commit comments

Comments
 (0)