-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
base: main
Are you sure you want to change the base?
drivers: sensor: temperature: Add i.MX RT die temperature sensor #83880
Conversation
anedergaard
commented
Jan 13, 2025
- 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
The following west manifest projects have changed revision in this Pull Request:
✅ All manifest checks OK Note: This message is automatically posted and updated by the Manifest GitHub Action. |
353c9e1
to
ab9fb98
Compare
There was a problem hiding this 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.
Yes, you are right, I'll align the naming once @DerekSnell has suggested a compatible string. |
Hi @anedergaard , 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 Thank you |
42f9cdc
to
9b87ba0
Compare
Hi @DerekSnell, Updated 1
|
9b87ba0
to
b891f14
Compare
Update 2:
|
depends on SOC_SERIES_IMXRT11XX || SOC_SERIES_IMXRT118X | ||
default y | ||
help | ||
Enable temperature measurement for NXP TMPSNS sensor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enable temperature measurement for NXP TMPSNS sensor | |
Enable temperature measurement for NXP TMPSNS sensor |
} | ||
} | ||
|
||
static const struct sensor_driver_api tmpsns_driver_api = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static const struct sensor_driver_api tmpsns_driver_api = { | |
static DEVICE_API(sensor, tmpsns_driver_api) = { |
tests/drivers/sensor/temp_sensor/boards/mimxrt1170_evk_mimxrt1176_cm7.overlay
Show resolved
Hide resolved
There was a problem hiding this 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: |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
b891f14
to
783ed44
Compare
@@ -0,0 +1,3 @@ | |||
zephyr_library() |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
dts/arm/nxp/nxp_rt118x.dtsi
Outdated
|
||
soc { | ||
temp: temp { | ||
compatible = "nxp,tmpsns"; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
Thanks for the review feedback, I appreciate it. |
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. |
@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]>
783ed44
to
693aee3
Compare
Update: Moved to use hal_nxp SDK-NG |