Skip to content

Commit 31406c1

Browse files
danieldegrassecarlescufi
authored andcommitted
drivers: sensor: Add pinctrl support for mcux acmp sensor
Add pinctrl support for mcux acmp sensor driver Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent de18fdf commit 31406c1

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

drivers/sensor/mcux_acmp/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
config MCUX_ACMP
77
bool "NXP MCUX Analog Comparator (ACMP)"
88
depends on HAS_MCUX_ACMP
9+
select PINCTRL
910
help
1011
Enable driver for the NXP MCUX Analog Comparator (ACMP).
1112

drivers/sensor/mcux_acmp/mcux_acmp.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <drivers/sensor/mcux_acmp.h>
1212
#include <logging/log.h>
1313
#include <fsl_acmp.h>
14+
#include <drivers/pinctrl.h>
1415

1516
LOG_MODULE_REGISTER(mcux_acmp, CONFIG_SENSOR_LOG_LEVEL);
1617

@@ -58,6 +59,7 @@ BUILD_ASSERT(kACMP_PortInputFromMux == 1);
5859
struct mcux_acmp_config {
5960
CMP_Type *base;
6061
acmp_filter_config_t filter;
62+
const struct pinctrl_dev_config *pincfg;
6163
#ifdef CONFIG_MCUX_ACMP_TRIGGER
6264
void (*irq_config_func)(const struct device *dev);
6365
#endif /* CONFIG_MCUX_ACMP_TRIGGER */
@@ -351,6 +353,12 @@ static int mcux_acmp_init(const struct device *dev)
351353
{
352354
const struct mcux_acmp_config *config = dev->config;
353355
struct mcux_acmp_data *data = dev->data;
356+
int err;
357+
358+
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
359+
if (err) {
360+
return err;
361+
}
354362

355363
ACMP_GetDefaultConfig(&data->config);
356364
data->config.enableHighSpeed = config->high_speed;
@@ -402,6 +410,7 @@ static const struct mcux_acmp_config mcux_acmp_config_##n = { \
402410
.unfiltered = DT_INST_PROP(n, nxp_use_unfiltered_output), \
403411
.output = DT_INST_PROP(n, nxp_enable_output_pin), \
404412
.window = DT_INST_PROP(n, nxp_window_mode), \
413+
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
405414
config_func_init \
406415
}
407416

@@ -431,6 +440,8 @@ static const struct mcux_acmp_config mcux_acmp_config_##n = { \
431440
\
432441
static const struct mcux_acmp_config mcux_acmp_config_##n; \
433442
\
443+
PINCTRL_DT_INST_DEFINE(n); \
444+
\
434445
DEVICE_DT_INST_DEFINE(n, &mcux_acmp_init, \
435446
NULL, \
436447
&mcux_acmp_data_##n, \

dts/bindings/sensor/nxp,kinetis-acmp.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: NXP Kinetis Analog Comparator (ACMP)
55

66
compatible: "nxp,kinetis-acmp"
77

8-
include: base.yaml
8+
include: [base.yaml, pinctrl-device.yaml]
99

1010
properties:
1111
interrupts:

0 commit comments

Comments
 (0)