From 27f1397d9b525298a4c4f740beccca8c84a170b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Bj=C3=B8rn=20Nedergaard?= Date: Mon, 13 Jan 2025 08:40:33 +0100 Subject: [PATCH 1/4] west: point nxp_hal module to PR reference for soc driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit points nxp_hal to the PR which enables mcux driver for die temperature for i.MX RT117X and i.MX RT118X devices. Signed-off-by: Anders Bjørn Nedergaard --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index 2c0a8d9fd1ec07..1ee84ab9152909 100644 --- a/west.yml +++ b/west.yml @@ -203,7 +203,7 @@ manifest: groups: - hal - name: hal_nxp - revision: b4e6f883719387cbbf6e73346a553bf1b79e77b0 + revision: pull/494/head path: modules/hal/nxp groups: - hal From 14b52e0c897fb64f4fcb251b3ad05a808bb65fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Bj=C3=B8rn=20Nedergaard?= Date: Mon, 13 Jan 2025 08:22:25 +0100 Subject: [PATCH 2/4] dts: bindings: Add nxp i.MX RT die termerature binding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added die temperature binding for i.MX RT 117X and i.MX RT 118X Signed-off-by: Anders Bjørn Nedergaard --- dts/bindings/sensor/nxp,tmpsns.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 dts/bindings/sensor/nxp,tmpsns.yaml diff --git a/dts/bindings/sensor/nxp,tmpsns.yaml b/dts/bindings/sensor/nxp,tmpsns.yaml new file mode 100644 index 00000000000000..b778337b2697f1 --- /dev/null +++ b/dts/bindings/sensor/nxp,tmpsns.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2024 Polytech A/S +# SPDX-License-Identifier: Apache-2.0 + +description: NXP TMPSNS + +compatible: "nxp,tmpsns" + +include: base.yaml From 753dd743dbfb45a30b8ae761d365b24233fa7c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Bj=C3=B8rn=20Nedergaard?= Date: Mon, 13 Jan 2025 08:25:17 +0100 Subject: [PATCH 3/4] drivers: sensor: temperature: Add i.MX RT die temperature sensor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added driver for i.MX RT117X and i.MX RT118X die temperature sensor Signed-off-by: Anders Bjørn Nedergaard --- drivers/sensor/nxp/CMakeLists.txt | 1 + drivers/sensor/nxp/Kconfig | 1 + drivers/sensor/nxp/nxp_tmpsns/CMakeLists.txt | 3 + drivers/sensor/nxp/nxp_tmpsns/Kconfig | 13 ++++ drivers/sensor/nxp/nxp_tmpsns/nxp_tmpsns.c | 68 ++++++++++++++++++++ dts/arm/nxp/nxp_rt118x.dtsi | 7 ++ dts/arm/nxp/nxp_rt11xx.dtsi | 5 ++ 7 files changed, 98 insertions(+) create mode 100644 drivers/sensor/nxp/nxp_tmpsns/CMakeLists.txt create mode 100644 drivers/sensor/nxp/nxp_tmpsns/Kconfig create mode 100644 drivers/sensor/nxp/nxp_tmpsns/nxp_tmpsns.c diff --git a/drivers/sensor/nxp/CMakeLists.txt b/drivers/sensor/nxp/CMakeLists.txt index bca607d819fc4e..9970c0ca8144b6 100644 --- a/drivers/sensor/nxp/CMakeLists.txt +++ b/drivers/sensor/nxp/CMakeLists.txt @@ -7,6 +7,7 @@ add_subdirectory_ifdef(CONFIG_FXLS8974 fxls8974) add_subdirectory_ifdef(CONFIG_FXOS8700 fxos8700) add_subdirectory_ifdef(CONFIG_MCUX_LPCMP mcux_lpcmp) add_subdirectory_ifdef(CONFIG_NXP_TEMPMON nxp_tempmon) +add_subdirectory_ifdef(CONFIG_NXP_TMPSNS nxp_tmpsns) add_subdirectory_ifdef(CONFIG_P3T1755 p3t1755) add_subdirectory_ifdef(CONFIG_QDEC_MCUX qdec_mcux) add_subdirectory_ifdef(CONFIG_QDEC_NXP_S32 qdec_nxp_s32) diff --git a/drivers/sensor/nxp/Kconfig b/drivers/sensor/nxp/Kconfig index e1289d7fdeb612..4e3ca269a51755 100644 --- a/drivers/sensor/nxp/Kconfig +++ b/drivers/sensor/nxp/Kconfig @@ -9,6 +9,7 @@ source "drivers/sensor/nxp/mcux_acmp/Kconfig" source "drivers/sensor/nxp/mcux_lpcmp/Kconfig" source "drivers/sensor/nxp/nxp_kinetis_temp/Kconfig" source "drivers/sensor/nxp/nxp_tempmon/Kconfig" +source "drivers/sensor/nxp/nxp_tmpsns/Kconfig" source "drivers/sensor/nxp/p3t1755/Kconfig" source "drivers/sensor/nxp/qdec_mcux/Kconfig" source "drivers/sensor/nxp/qdec_nxp_s32/Kconfig" diff --git a/drivers/sensor/nxp/nxp_tmpsns/CMakeLists.txt b/drivers/sensor/nxp/nxp_tmpsns/CMakeLists.txt new file mode 100644 index 00000000000000..1bc2a79b92dcf3 --- /dev/null +++ b/drivers/sensor/nxp/nxp_tmpsns/CMakeLists.txt @@ -0,0 +1,3 @@ +zephyr_library() + +zephyr_library_sources(nxp_tmpsns.c) diff --git a/drivers/sensor/nxp/nxp_tmpsns/Kconfig b/drivers/sensor/nxp/nxp_tmpsns/Kconfig new file mode 100644 index 00000000000000..2175b2bf5179fa --- /dev/null +++ b/drivers/sensor/nxp/nxp_tmpsns/Kconfig @@ -0,0 +1,13 @@ +# NXP i.MX RT temperature sensor configuration options + +# Copyright (c) 2025 Polytech A/S +# SPDX-License-Identifier: Apache-2.0 + +config NXP_TMPSNS + bool "NXP TMPSNS sensor" + depends on SENSOR + depends on DT_HAS_NXP_TMPSNS_ENABLED + depends on SOC_SERIES_IMXRT11XX || SOC_SERIES_IMXRT118X + default y + help + Enable temperature measurement for NXP TMPSNS sensor diff --git a/drivers/sensor/nxp/nxp_tmpsns/nxp_tmpsns.c b/drivers/sensor/nxp/nxp_tmpsns/nxp_tmpsns.c new file mode 100644 index 00000000000000..2e3cd2e474a986 --- /dev/null +++ b/drivers/sensor/nxp/nxp_tmpsns/nxp_tmpsns.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2025 Polytech A/S + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#define DT_DRV_COMPAT nxp_tmpsns + +#include +#include + +struct nxp_tmpsns_data { + float die_temp; +}; + +static int nxp_tmpsns_channel_get(const struct device *dev, enum sensor_channel chan, + struct sensor_value *val) +{ + const struct nxp_tmpsns_data *data = dev->data; + + switch (chan) { + case SENSOR_CHAN_ALL: + case SENSOR_CHAN_DIE_TEMP: + return sensor_value_from_float(val, data->die_temp); + default: + return -ENOTSUP; + } +} + +static int nxp_tmpsns_channel_fetch(const struct device *dev, enum sensor_channel chan) +{ + struct nxp_tmpsns_data *data = dev->data; + + switch (chan) { + case SENSOR_CHAN_ALL: + case SENSOR_CHAN_DIE_TEMP: + data->die_temp = TMPSNS_GetCurrentTemperature(TMPSNS); + return 0; + default: + return -ENOTSUP; + } +} + +static const struct sensor_driver_api tmpsns_driver_api = { + .channel_get = nxp_tmpsns_channel_get, + .sample_fetch = nxp_tmpsns_channel_fetch, +}; + +static int nxp_tmpsns_init(const struct device *dev) +{ + tmpsns_config_t config; + + TMPSNS_GetDefaultConfig(&config); + config.measureMode = kTEMPSENSOR_ContinuousMode; + config.frequency = 0x03U; + TMPSNS_Init(TMPSNS, &config); + TMPSNS_StartMeasure(TMPSNS); + + return 0; +} + +#define NXP_TMPSNS_DEFINE(inst) \ + struct nxp_tmpsns_data nxp_tmpsns_data_##inst; \ + SENSOR_DEVICE_DT_INST_DEFINE(inst, nxp_tmpsns_init, NULL, &nxp_tmpsns_data_##inst, NULL, \ + POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, \ + &tmpsns_driver_api); + +DT_INST_FOREACH_STATUS_OKAY(NXP_TMPSNS_DEFINE) diff --git a/dts/arm/nxp/nxp_rt118x.dtsi b/dts/arm/nxp/nxp_rt118x.dtsi index 6b5101391e3807..23e9417c70c0d0 100644 --- a/dts/arm/nxp/nxp_rt118x.dtsi +++ b/dts/arm/nxp/nxp_rt118x.dtsi @@ -44,6 +44,13 @@ }; }; }; + + soc { + temp: temp { + compatible = "nxp,tmpsns"; + status = "disabled"; + }; + }; }; &peripheral { diff --git a/dts/arm/nxp/nxp_rt11xx.dtsi b/dts/arm/nxp/nxp_rt11xx.dtsi index d83c2c833f2bab..7c16faf318f321 100644 --- a/dts/arm/nxp/nxp_rt11xx.dtsi +++ b/dts/arm/nxp/nxp_rt11xx.dtsi @@ -1307,6 +1307,11 @@ status = "disabled"; }; }; + + temp: temp { + compatible = "nxp,tmpsns"; + status = "disabled"; + }; }; }; From b891f14cc80fabcc8ca63dafe5d5ac38429a301f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Bj=C3=B8rn=20Nedergaard?= Date: Mon, 13 Jan 2025 08:30:28 +0100 Subject: [PATCH 4/4] tests: drivers: temp_sensor: Add overlay for i.MX RT1170-EVK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added temp_sensor overlay for i.MX RT1170-EVK Signed-off-by: Anders Bjørn Nedergaard --- .../temp_sensor/boards/mimxrt1170_evk_mimxrt1176_cm7.overlay | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/drivers/sensor/temp_sensor/boards/mimxrt1170_evk_mimxrt1176_cm7.overlay diff --git a/tests/drivers/sensor/temp_sensor/boards/mimxrt1170_evk_mimxrt1176_cm7.overlay b/tests/drivers/sensor/temp_sensor/boards/mimxrt1170_evk_mimxrt1176_cm7.overlay new file mode 100644 index 00000000000000..435e4f4a6ccf81 --- /dev/null +++ b/tests/drivers/sensor/temp_sensor/boards/mimxrt1170_evk_mimxrt1176_cm7.overlay @@ -0,0 +1,3 @@ +temp_sensor: &temp { + status = "okay"; +};