Skip to content

drivers: sensor: temperature: Add i.MX RT die temperature sensor #83880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

anedergaard
Copy link
Contributor

  • Added dts binding for die temperature sensor for i.MX RT117X and i.MX RT118X
  • Added driver for die temperature readings on i.MX RT117X and i.MX RT118X
  • Added overlay file for RT1170-EVK in temp_sensor test for validation

@zephyrbot
Copy link
Collaborator

zephyrbot commented Jan 13, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@zephyrbot zephyrbot added manifest manifest-hal_nxp DNM This PR should not be merged (Do Not Merge) labels Jan 13, 2025
@anedergaard anedergaard force-pushed the driver-tmpsns-imxrt11xx branch from 353c9e1 to ab9fb98 Compare January 13, 2025 08:24
Copy link
Collaborator

@jeppenodgaard jeppenodgaard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality LGTM.
I think some naming alignment is needed. There's tmpsns, temp, temperature.

@anedergaard
Copy link
Contributor Author

Functionality LGTM. I think some naming alignment is needed. There's tmpsns, temp, temperature.

Yes, you are right, I'll align the naming once @DerekSnell has suggested a compatible string.

@DerekSnell
Copy link
Collaborator

Hi @anedergaard ,
Thank you for this contribution, and for getting guidance on the naming. As @decsny stated, NXP does not like to use SOC or SOC family names in the bindings and drivers, because the hardware IP is frequently re-used across the portfolio on other familes.

The IP name for this HW peripheral is TMPSNS, which is also the name used in the SOC reference manual, and in the HAL driver fsl_tempsensor.c. So I think the best name for this binding is nxp,tmpsns.

Thank you

@anedergaard anedergaard force-pushed the driver-tmpsns-imxrt11xx branch 2 times, most recently from 42f9cdc to 9b87ba0 Compare January 14, 2025 20:55
@anedergaard
Copy link
Contributor Author

Hi @DerekSnell,
Thank you for the feedback on naming and the reasoning behind it - I appreciate it!

Updated 1

  • Addressed driver naming, renamed binding to nxp,tmpsns
  • Rebased to address conflicts

@anedergaard anedergaard force-pushed the driver-tmpsns-imxrt11xx branch from 9b87ba0 to b891f14 Compare January 14, 2025 21:07
@anedergaard
Copy link
Contributor Author

Update 2:

  • Addressed compliance issue on Kconfig source order.

depends on SOC_SERIES_IMXRT11XX || SOC_SERIES_IMXRT118X
default y
help
Enable temperature measurement for NXP TMPSNS sensor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Enable temperature measurement for NXP TMPSNS sensor
Enable temperature measurement for NXP TMPSNS sensor

}
}

static const struct sensor_driver_api tmpsns_driver_api = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static const struct sensor_driver_api tmpsns_driver_api = {
static DEVICE_API(sensor, tmpsns_driver_api) = {

Copy link
Collaborator

@jeppenodgaard jeppenodgaard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming looks good :)

const struct nxp_tmpsns_data *data = dev->data;

switch (chan) {
case SENSOR_CHAN_ALL:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this line.
get cannot support SENSOR_CHAN_ALL since there is only one val reference.

Copy link
Collaborator

@DerekSnell DerekSnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @anedergaard ,

Thank you for contributing this. I am blocking to address this build warning when I build the test for the MIMXRT1170-EVK. The test does build and runs well on my board. But can you improve the DTS to avoid this warning?

CMake Warning at 
/zephyrproject/zephyr/cmake/modules/dts.cmake:425 (message):
  dtc raised one or more warnings:
 
  /build/zephyr/zephyr.dts:4051.27-4054.5:
  Warning (simple_bus_reg): /soc/temp: missing or empty reg/ranges property

Otherwise, the naming changes you made look good to me.

I see your PR got caught in a known CI issue with the RT1180, which should be resolved when #83827 merges.

A very minor nit, but since you will be updating - there is a typo in commit message "termerature"

Thank you

@anedergaard anedergaard force-pushed the driver-tmpsns-imxrt11xx branch from b891f14 to 783ed44 Compare January 20, 2025 21:11
@@ -0,0 +1,3 @@
zephyr_library()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File needs a license/copyright header

bool "NXP TMPSNS sensor"
depends on SENSOR
depends on DT_HAS_NXP_TMPSNS_ENABLED
depends on SOC_SERIES_IMXRT11XX || SOC_SERIES_IMXRT118X
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this depends. Is'nt is sufficient to base it on if the temperature sensor is enabled in device tree.

switch (chan) {
case SENSOR_CHAN_ALL:
case SENSOR_CHAN_DIE_TEMP:
data->die_temp = TMPSNS_GetCurrentTemperature(TMPSNS);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be getting the base address from device tree.


soc {
temp: temp {
compatible = "nxp,tmpsns";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add base address and interrupt properties. Also this should be part of the peripheral block

@@ -1307,6 +1307,11 @@
status = "disabled";
};
};

temp: temp {
compatible = "nxp,tmpsns";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing base and interrupt properties

#include <zephyr/drivers/sensor.h>

struct nxp_tmpsns_data {
float die_temp;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're going to use a float instead of the q31 format you should depend on FPU

config.measureMode = kTEMPSENSOR_ContinuousMode;
config.frequency = 0x03U;
TMPSNS_Init(TMPSNS, &config);
TMPSNS_StartMeasure(TMPSNS);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to start measuring on init? Why not enable the attribute for sample frequency to start sampling?

@anedergaard
Copy link
Contributor Author

Thanks for the review feedback, I appreciate it.
I'll look into the requested changes.

@fabiobaltieri fabiobaltieri added DNM (manifest) This PR should not be merged (controlled by action-manifest) and removed DNM This PR should not be merged (Do Not Merge) labels Feb 4, 2025
Copy link

github-actions bot commented Apr 6, 2025

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Apr 6, 2025
@decsny
Copy link
Member

decsny commented Apr 14, 2025

@anedergaard any update for this PR?

@decsny decsny removed the Stale label Apr 14, 2025
@anedergaard
Copy link
Contributor Author

@anedergaard any update for this PR?

Hi @decsny, sorry for stalling this PR.

I will address the hal_nxp SDK-NG changes first, then address the changes requested for this PR

Added die temperature binding for i.MX RT 117X and i.MX RT 118X

Signed-off-by: Anders Bjørn Nedergaard <[email protected]>
Added driver for i.MX RT117X and i.MX RT118X die temperature sensor

Signed-off-by: Anders Bjørn Nedergaard <[email protected]>
…-EVK

Added temp_sensor overlay for i.MX RT1170-EVK & RT1180-EVK

Signed-off-by: Anders Bjørn Nedergaard <[email protected]>
@anedergaard anedergaard force-pushed the driver-tmpsns-imxrt11xx branch from 783ed44 to 693aee3 Compare April 20, 2025 12:21
@github-actions github-actions bot removed manifest manifest-hal_nxp DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Apr 20, 2025
@anedergaard
Copy link
Contributor Author

Update: Moved to use hal_nxp SDK-NG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Sensors Sensors platform: NXP Drivers NXP Semiconductors, drivers platform: NXP NXP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants