sensor: mcux_acmp: namespace driver and kconfigs
The mcux_acmp will get support by the comparator subsystem. To avoid
namespace clashes, namespace the driver, kconfigs and use the
MCUX_ACMP config solely to select the MCUX SDK driver.
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
diff --git a/drivers/sensor/nxp/CMakeLists.txt b/drivers/sensor/nxp/CMakeLists.txt
index 73dc2cb..36e39e0 100644
--- a/drivers/sensor/nxp/CMakeLists.txt
+++ b/drivers/sensor/nxp/CMakeLists.txt
@@ -5,10 +5,10 @@
add_subdirectory_ifdef(CONFIG_FXAS21002 fxas21002)
add_subdirectory_ifdef(CONFIG_FXLS8974 fxls8974)
add_subdirectory_ifdef(CONFIG_FXOS8700 fxos8700)
-add_subdirectory_ifdef(CONFIG_MCUX_ACMP mcux_acmp)
add_subdirectory_ifdef(CONFIG_MCUX_LPCMP mcux_lpcmp)
add_subdirectory_ifdef(CONFIG_NXP_TEMPMON nxp_tempmon)
add_subdirectory_ifdef(CONFIG_QDEC_MCUX qdec_mcux)
add_subdirectory_ifdef(CONFIG_QDEC_NXP_S32 qdec_nxp_s32)
+add_subdirectory_ifdef(CONFIG_SENSOR_MCUX_ACMP mcux_acmp)
add_subdirectory_ifdef(CONFIG_TEMP_KINETIS nxp_kinetis_temp)
# zephyr-keep-sorted-stop
diff --git a/drivers/sensor/nxp/mcux_acmp/Kconfig b/drivers/sensor/nxp/mcux_acmp/Kconfig
index 0f976c6..1934e4d 100644
--- a/drivers/sensor/nxp/mcux_acmp/Kconfig
+++ b/drivers/sensor/nxp/mcux_acmp/Kconfig
@@ -4,17 +4,18 @@
# Copyright 2024 NXP
# SPDX-License-Identifier: Apache-2.0
-config MCUX_ACMP
+config SENSOR_MCUX_ACMP
bool "NXP MCUX Analog Comparator (ACMP)"
default y
depends on DT_HAS_NXP_KINETIS_ACMP_ENABLED
select PINCTRL
+ select MCUX_ACMP
help
Enable driver for the NXP MCUX Analog Comparator (ACMP).
-config MCUX_ACMP_TRIGGER
+config SENSOR_MCUX_ACMP_TRIGGER
bool "Trigger support"
- depends on MCUX_ACMP
+ depends on SENSOR_MCUX_ACMP
help
Enable trigger support for the NXP MCUX Analog Comparator
(ACMP).
diff --git a/drivers/sensor/nxp/mcux_acmp/mcux_acmp.c b/drivers/sensor/nxp/mcux_acmp/mcux_acmp.c
index 30339f3..69c01c3 100644
--- a/drivers/sensor/nxp/mcux_acmp/mcux_acmp.c
+++ b/drivers/sensor/nxp/mcux_acmp/mcux_acmp.c
@@ -45,9 +45,9 @@
CMP_Type *base;
acmp_filter_config_t filter;
const struct pinctrl_dev_config *pincfg;
-#ifdef CONFIG_MCUX_ACMP_TRIGGER
+#ifdef CONFIG_SENSOR_MCUX_ACMP_TRIGGER
void (*irq_config_func)(const struct device *dev);
-#endif /* CONFIG_MCUX_ACMP_TRIGGER */
+#endif /* CONFIG_SENSOR_MCUX_ACMP_TRIGGER */
bool high_speed : 1;
bool unfiltered : 1;
bool output : 1;
@@ -61,7 +61,7 @@
#if MCUX_ACMP_HAS_DISCRETE_MODE
acmp_discrete_mode_config_t discrete_config;
#endif
-#ifdef CONFIG_MCUX_ACMP_TRIGGER
+#ifdef CONFIG_SENSOR_MCUX_ACMP_TRIGGER
const struct device *dev;
sensor_trigger_handler_t rising_handler;
const struct sensor_trigger *rising_trigger;
@@ -69,7 +69,7 @@
const struct sensor_trigger *falling_trigger;
struct k_work work;
volatile uint32_t status;
-#endif /* CONFIG_MCUX_ACMP_TRIGGER */
+#endif /* CONFIG_SENSOR_MCUX_ACMP_TRIGGER */
bool cout;
};
@@ -370,7 +370,7 @@
return 0;
}
-#ifdef CONFIG_MCUX_ACMP_TRIGGER
+#ifdef CONFIG_SENSOR_MCUX_ACMP_TRIGGER
static int mcux_acmp_trigger_set(const struct device *dev,
const struct sensor_trigger *trig,
sensor_trigger_handler_t handler)
@@ -431,7 +431,7 @@
k_work_submit(&data->work);
}
-#endif /* CONFIG_MCUX_ACMP_TRIGGER */
+#endif /* CONFIG_SENSOR_MCUX_ACMP_TRIGGER */
static int mcux_acmp_init(const struct device *dev)
{
@@ -462,7 +462,7 @@
/* Disable DAC */
ACMP_SetDACConfig(config->base, NULL);
-#ifdef CONFIG_MCUX_ACMP_TRIGGER
+#ifdef CONFIG_SENSOR_MCUX_ACMP_TRIGGER
data->dev = dev;
k_work_init(&data->work, mcux_acmp_trigger_work_handler);
@@ -470,7 +470,7 @@
ACMP_EnableInterrupts(config->base,
kACMP_OutputRisingInterruptEnable |
kACMP_OutputFallingInterruptEnable);
-#endif /* CONFIG_MCUX_ACMP_TRIGGER */
+#endif /* CONFIG_SENSOR_MCUX_ACMP_TRIGGER */
ACMP_Enable(config->base, true);
@@ -480,9 +480,9 @@
static const struct sensor_driver_api mcux_acmp_driver_api = {
.attr_set = mcux_acmp_attr_set,
.attr_get = mcux_acmp_attr_get,
-#ifdef CONFIG_MCUX_ACMP_TRIGGER
+#ifdef CONFIG_SENSOR_MCUX_ACMP_TRIGGER
.trigger_set = mcux_acmp_trigger_set,
-#endif /* CONFIG_MCUX_ACMP_TRIGGER */
+#endif /* CONFIG_SENSOR_MCUX_ACMP_TRIGGER */
.sample_fetch = mcux_acmp_sample_fetch,
.channel_get = mcux_acmp_channel_get,
};
@@ -503,7 +503,7 @@
config_func_init \
}
-#ifdef CONFIG_MCUX_ACMP_TRIGGER
+#ifdef CONFIG_SENSOR_MCUX_ACMP_TRIGGER
#define MCUX_ACMP_CONFIG_FUNC(n) \
static void mcux_acmp_config_func_##n(const struct device *dev) \
{ \
@@ -517,12 +517,12 @@
.irq_config_func = mcux_acmp_config_func_##n
#define MCUX_ACMP_INIT_CONFIG(n) \
MCUX_ACMP_DECLARE_CONFIG(n, MCUX_ACMP_CONFIG_FUNC_INIT(n))
-#else /* !CONFIG_MCUX_ACMP_TRIGGER */
+#else /* !CONFIG_SENSOR_MCUX_ACMP_TRIGGER */
#define MCUX_ACMP_CONFIG_FUNC(n)
#define MCUX_ACMP_CONFIG_FUNC_INIT
#define MCUX_ACMP_INIT_CONFIG(n) \
MCUX_ACMP_DECLARE_CONFIG(n, MCUX_ACMP_CONFIG_FUNC_INIT)
-#endif /* !CONFIG_MCUX_ACMP_TRIGGER */
+#endif /* !CONFIG_SENSOR_MCUX_ACMP_TRIGGER */
#define MCUX_ACMP_INIT(n) \
static struct mcux_acmp_data mcux_acmp_data_##n; \
diff --git a/modules/hal_nxp/Kconfig b/modules/hal_nxp/Kconfig
index aaec4e8..4f055fa 100644
--- a/modules/hal_nxp/Kconfig
+++ b/modules/hal_nxp/Kconfig
@@ -4,4 +4,5 @@
# SPDX-License-Identifier: Apache-2.0
#
-# file is empty and kept as a place holder if/when Kconfig is needed
+config MCUX_ACMP
+ bool "Include ACMP driver from MCUX SDK"
diff --git a/samples/sensor/mcux_acmp/prj.conf b/samples/sensor/mcux_acmp/prj.conf
index 8b70c7a..202fe6b 100644
--- a/samples/sensor/mcux_acmp/prj.conf
+++ b/samples/sensor/mcux_acmp/prj.conf
@@ -1,2 +1,2 @@
CONFIG_SENSOR=y
-CONFIG_MCUX_ACMP_TRIGGER=y
+CONFIG_SENSOR_MCUX_ACMP_TRIGGER=y
diff --git a/samples/sensor/mcux_acmp/sample.yaml b/samples/sensor/mcux_acmp/sample.yaml
index fa7782d..a00773f 100644
--- a/samples/sensor/mcux_acmp/sample.yaml
+++ b/samples/sensor/mcux_acmp/sample.yaml
@@ -27,4 +27,4 @@
sample.sensor.mcux_acmp.no_trigger:
build_only: true
extra_configs:
- - CONFIG_MCUX_ACMP_TRIGGER=n
+ - CONFIG_SENSOR_MCUX_ACMP_TRIGGER=n