History log of /u-boot/drivers/thermal/imx_tmu.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# d678a59d 18-May-2024 Tom Rini <trini@konsulko.com>

Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""

When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay
Ethernet"' I failed to notice that b4 noticed it was based on next and
so took that as the base commit and merged that part of next to master.

This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing
changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35.

Reported-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 66fa3531 01-May-2024 Tom Rini <trini@konsulko.com>

thermal: Remove <common.h> and add needed includes

Remove <common.h> from this driver directory and when needed
add missing include files directly.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 6a9de676 28-Mar-2024 Ye Li <ye.li@nxp.com>

thermal: imx_tmu: Fix TMU error on iMX8MQ

imx_tmu_arch_init does not implement for iMX8MQ, error is returned

Signed-off-by: Ye Li <ye.li@nxp.com>

# 9ae369a0 03-Mar-2024 Benjamin Hahn <B.Hahn@phytec.de>

drivers: imx_tmu: Select polling-rate from cpu-thermal devicetree node

The polling rate is already specified in some devicetrees, like
imx8mp.dtsi for example, but was not selected so far. For the
trippoints, the cpu-thermal node is used. Also get the polling rate from
this node. Use the default of 5000ms if the polling rate should not be
specified in the devicetree.

NOTE: The polling rate from the devicetree will be used after this
patch. In imx8*.dtsi devicetrees the polling delay is set to 2000ms for
example.

Signed-off-by: Benjamin Hahn <B.Hahn@phytec.de>
Reviewed-by: Fabio Estevam <festevam@gmail.com>

# a79fca7b 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Increase the polling interval

Polling every second to check whether the CPU has cooled down is
too frequent.

Allow more time for the CPU to cool down by increasing the polling
interval to 5 seconds by defaut.

This value is used in the absence of the 'polling-delay' devicetree
property.

Signed-off-by: Fabio Estevam <festevam@denx.de>

# f4898e4b 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Fix the temperature unit

The temperature unit is millidegree Celsius, so divide by 1000 to correctly
print the temperature values in Celsius.

While at it, also change a typo: "has beyond" to "is beyond".

Signed-off-by: Fabio Estevam <festevam@denx.de>

# 966480fe 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Increase the log level for high temperatures

dev_info() message is not printed by default. Increase the log level
to dev_crit(). This allows the critical messages related to the temperature
getting beyong the alert threshold to be displayed.

Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 402b8106 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Fix the polling default

When the 'polling-delay' property is not passed via devicetree,
pdata->polling_delay keeps at 0. This causes the imx_tmu driver to get
stuck inside the busy while() loop when the CPU temperature is above
the alert point.

Fix this problem by passing a one second polling interval, which provides
a proper delay to let the system to cool down and exit the while() loop
when the temperature is below the alert point.

Signed-off-by: Fabio Estevam <festevam@denx.de>

# b08a0a4b 27-Apr-2023 Ye Li <ye.li@nxp.com>

thermal: imx_tmu: Update TMU driver to support iMX93

The TMU used on iMX93 is IP revision 2.1 which is different with previous
revision used on iMX8MQ. So add a new FLAG V4 for this revision to
distinguish the operations.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# eb1e370a 04-Apr-2023 Marek Vasut <marex@denx.de>

thermal: imx_tmu: Move architecture code into driver

Stop polluting the architecture directory with driver specific code,
move it into driver where it should be. Split the code slightly so
the MX8MM/MX8MN fuse readout and programming and MX8MP fuse readout
and programming are in their separate functions, and called in case
of matching SoC.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>

# 114eb250 04-Apr-2023 Marek Vasut <marex@denx.de>

thermal: imx_tmu: Clean up all prints

Use dev_(dev, ...) for all printing and debug logging, since this
already includes the device name. Drop device name where duplicate.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>

# 0cf207ec 27-Sep-2021 Wolfgang Denk <wd@denx.de>

WS cleanup: remove SPACE(s) followed by TAB

Signed-off-by: Wolfgang Denk <wd@denx.de>

# deb78ff3 05-Feb-2021 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: enable monitoring and default alert/critical

Set default critical/alert temperature and enabling monoitoring.

Without calling imx_tmu_enable_msite() monitoring will not be enabled
and read_temperature will return 0. Additionally without setting alert
temperature will cause imx_tmu_get_temp() to spin indefiniately thinking
the system needs to cool.

This resolves the board spinning endlessly when enabling IMX_TMU in the
SPL.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

Move this out of the common header and include it only where needed. In
a number of cases this requires adding "struct udevice;" to avoid adding
another large header or in other cases replacing / adding missing header
files that had been pulled in, very indirectly. Finally, we have a few
cases where we did not need to include <asm/global_data.h> at all, so
remove that include.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c69cda25 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename dev_get_platdata() to dev_get_plat()

Rename this to be consistent with the change from 'platdata'.

Signed-off-by: Simon Glass <sjg@chromium.org>

# caa4daa2 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename 'platdata' variables to just 'plat'

We use 'priv' for private data but often use 'platdata' for platform data.
We can't really use 'pdata' since that is ambiguous (it could mean private
or platform data).

Rename some of the latter variables to end with 'plat' for consistency.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 41575d8e 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename auto_alloc_size members to be shorter

This construct is quite long-winded. In earlier days it made some sense
since auto-allocation was a strange concept. But with driver model now
used pretty universally, we can shorten this to 'auto'. This reduces
verbosity and makes it easier to read.

Coincidentally it also ensures that every declaration is on one line,
thus making dtoc's job easier.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 85abf041 12-Oct-2020 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: fix missing include

commit c05ed00afb dropped linux/delay.h from common header

add linux/delay.h to avoid compile warning here

Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 634fe73e 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support i.MX8MP

Support i.MX8MP thermal which has two probes and supports
temperature range from -40 to 125. Still uses default 1p HW
calibration at 25C and loads calibration parameters from fuse.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 951bf19d 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Check the TEMP range for iMX8MM

On iMX8MM, the V flag in TRISTR register only reflect the state of SNSR
value, not the calibrated TEMP value. So checking this flag is not
reliable. Per IC suggestion, change to read the TEMP/AVG_TEMP directly
and check whether it in valid range 10-125C.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# b5447b98 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Fix for temperature out of range

When the temperature is out of sensor's range, the Valid bit won't be
set in TRITSR register. So the polling loop won't go out.

Change the codes to retry 10 times with 100ms interval for the Valid bit.
If the timeout, we give a warning for the invalid data.

Modifed from Ye's NXP patch

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 84897408 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support TMU arch level initialization

i.MX8MM TMU needs to load some registers from fuse, this is arch
dependent operation and may vary on different platforms. So add
a interface for arch level initialization.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# fc8657b7 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Add support for thermal sensor on iMX8MM

The analog sensors on iMX8MM are new, used for 14LPP process. So the
Temperature Sensor Monitoring Unit (TMU) has some change accordingly.
We use version 2 in TMU driver to represent the new TMU, so the one
driver can service for both i.MX8MQ/M.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 2cd7f479 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: Add thermal driver for i.MX8M

The driver is ported form Linux Kernel and support driver model.
Users need to provide the tmu node and sensors nodes in DTB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 66fa3531 01-May-2024 Tom Rini <trini@konsulko.com>

thermal: Remove <common.h> and add needed includes

Remove <common.h> from this driver directory and when needed
add missing include files directly.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 6a9de676 28-Mar-2024 Ye Li <ye.li@nxp.com>

thermal: imx_tmu: Fix TMU error on iMX8MQ

imx_tmu_arch_init does not implement for iMX8MQ, error is returned

Signed-off-by: Ye Li <ye.li@nxp.com>

# 9ae369a0 03-Mar-2024 Benjamin Hahn <B.Hahn@phytec.de>

drivers: imx_tmu: Select polling-rate from cpu-thermal devicetree node

The polling rate is already specified in some devicetrees, like
imx8mp.dtsi for example, but was not selected so far. For the
trippoints, the cpu-thermal node is used. Also get the polling rate from
this node. Use the default of 5000ms if the polling rate should not be
specified in the devicetree.

NOTE: The polling rate from the devicetree will be used after this
patch. In imx8*.dtsi devicetrees the polling delay is set to 2000ms for
example.

Signed-off-by: Benjamin Hahn <B.Hahn@phytec.de>
Reviewed-by: Fabio Estevam <festevam@gmail.com>

# a79fca7b 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Increase the polling interval

Polling every second to check whether the CPU has cooled down is
too frequent.

Allow more time for the CPU to cool down by increasing the polling
interval to 5 seconds by defaut.

This value is used in the absence of the 'polling-delay' devicetree
property.

Signed-off-by: Fabio Estevam <festevam@denx.de>

# f4898e4b 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Fix the temperature unit

The temperature unit is millidegree Celsius, so divide by 1000 to correctly
print the temperature values in Celsius.

While at it, also change a typo: "has beyond" to "is beyond".

Signed-off-by: Fabio Estevam <festevam@denx.de>

# 966480fe 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Increase the log level for high temperatures

dev_info() message is not printed by default. Increase the log level
to dev_crit(). This allows the critical messages related to the temperature
getting beyong the alert threshold to be displayed.

Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 402b8106 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Fix the polling default

When the 'polling-delay' property is not passed via devicetree,
pdata->polling_delay keeps at 0. This causes the imx_tmu driver to get
stuck inside the busy while() loop when the CPU temperature is above
the alert point.

Fix this problem by passing a one second polling interval, which provides
a proper delay to let the system to cool down and exit the while() loop
when the temperature is below the alert point.

Signed-off-by: Fabio Estevam <festevam@denx.de>

# b08a0a4b 27-Apr-2023 Ye Li <ye.li@nxp.com>

thermal: imx_tmu: Update TMU driver to support iMX93

The TMU used on iMX93 is IP revision 2.1 which is different with previous
revision used on iMX8MQ. So add a new FLAG V4 for this revision to
distinguish the operations.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# eb1e370a 04-Apr-2023 Marek Vasut <marex@denx.de>

thermal: imx_tmu: Move architecture code into driver

Stop polluting the architecture directory with driver specific code,
move it into driver where it should be. Split the code slightly so
the MX8MM/MX8MN fuse readout and programming and MX8MP fuse readout
and programming are in their separate functions, and called in case
of matching SoC.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>

# 114eb250 04-Apr-2023 Marek Vasut <marex@denx.de>

thermal: imx_tmu: Clean up all prints

Use dev_(dev, ...) for all printing and debug logging, since this
already includes the device name. Drop device name where duplicate.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>

# 0cf207ec 27-Sep-2021 Wolfgang Denk <wd@denx.de>

WS cleanup: remove SPACE(s) followed by TAB

Signed-off-by: Wolfgang Denk <wd@denx.de>

# deb78ff3 05-Feb-2021 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: enable monitoring and default alert/critical

Set default critical/alert temperature and enabling monoitoring.

Without calling imx_tmu_enable_msite() monitoring will not be enabled
and read_temperature will return 0. Additionally without setting alert
temperature will cause imx_tmu_get_temp() to spin indefiniately thinking
the system needs to cool.

This resolves the board spinning endlessly when enabling IMX_TMU in the
SPL.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

Move this out of the common header and include it only where needed. In
a number of cases this requires adding "struct udevice;" to avoid adding
another large header or in other cases replacing / adding missing header
files that had been pulled in, very indirectly. Finally, we have a few
cases where we did not need to include <asm/global_data.h> at all, so
remove that include.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c69cda25 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename dev_get_platdata() to dev_get_plat()

Rename this to be consistent with the change from 'platdata'.

Signed-off-by: Simon Glass <sjg@chromium.org>

# caa4daa2 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename 'platdata' variables to just 'plat'

We use 'priv' for private data but often use 'platdata' for platform data.
We can't really use 'pdata' since that is ambiguous (it could mean private
or platform data).

Rename some of the latter variables to end with 'plat' for consistency.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 41575d8e 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename auto_alloc_size members to be shorter

This construct is quite long-winded. In earlier days it made some sense
since auto-allocation was a strange concept. But with driver model now
used pretty universally, we can shorten this to 'auto'. This reduces
verbosity and makes it easier to read.

Coincidentally it also ensures that every declaration is on one line,
thus making dtoc's job easier.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 85abf041 12-Oct-2020 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: fix missing include

commit c05ed00afb dropped linux/delay.h from common header

add linux/delay.h to avoid compile warning here

Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 634fe73e 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support i.MX8MP

Support i.MX8MP thermal which has two probes and supports
temperature range from -40 to 125. Still uses default 1p HW
calibration at 25C and loads calibration parameters from fuse.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 951bf19d 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Check the TEMP range for iMX8MM

On iMX8MM, the V flag in TRISTR register only reflect the state of SNSR
value, not the calibrated TEMP value. So checking this flag is not
reliable. Per IC suggestion, change to read the TEMP/AVG_TEMP directly
and check whether it in valid range 10-125C.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# b5447b98 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Fix for temperature out of range

When the temperature is out of sensor's range, the Valid bit won't be
set in TRITSR register. So the polling loop won't go out.

Change the codes to retry 10 times with 100ms interval for the Valid bit.
If the timeout, we give a warning for the invalid data.

Modifed from Ye's NXP patch

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 84897408 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support TMU arch level initialization

i.MX8MM TMU needs to load some registers from fuse, this is arch
dependent operation and may vary on different platforms. So add
a interface for arch level initialization.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# fc8657b7 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Add support for thermal sensor on iMX8MM

The analog sensors on iMX8MM are new, used for 14LPP process. So the
Temperature Sensor Monitoring Unit (TMU) has some change accordingly.
We use version 2 in TMU driver to represent the new TMU, so the one
driver can service for both i.MX8MQ/M.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 2cd7f479 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: Add thermal driver for i.MX8M

The driver is ported form Linux Kernel and support driver model.
Users need to provide the tmu node and sensors nodes in DTB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 6a9de676 28-Mar-2024 Ye Li <ye.li@nxp.com>

thermal: imx_tmu: Fix TMU error on iMX8MQ

imx_tmu_arch_init does not implement for iMX8MQ, error is returned

Signed-off-by: Ye Li <ye.li@nxp.com>

# 9ae369a0 03-Mar-2024 Benjamin Hahn <B.Hahn@phytec.de>

drivers: imx_tmu: Select polling-rate from cpu-thermal devicetree node

The polling rate is already specified in some devicetrees, like
imx8mp.dtsi for example, but was not selected so far. For the
trippoints, the cpu-thermal node is used. Also get the polling rate from
this node. Use the default of 5000ms if the polling rate should not be
specified in the devicetree.

NOTE: The polling rate from the devicetree will be used after this
patch. In imx8*.dtsi devicetrees the polling delay is set to 2000ms for
example.

Signed-off-by: Benjamin Hahn <B.Hahn@phytec.de>
Reviewed-by: Fabio Estevam <festevam@gmail.com>

# a79fca7b 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Increase the polling interval

Polling every second to check whether the CPU has cooled down is
too frequent.

Allow more time for the CPU to cool down by increasing the polling
interval to 5 seconds by defaut.

This value is used in the absence of the 'polling-delay' devicetree
property.

Signed-off-by: Fabio Estevam <festevam@denx.de>

# f4898e4b 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Fix the temperature unit

The temperature unit is millidegree Celsius, so divide by 1000 to correctly
print the temperature values in Celsius.

While at it, also change a typo: "has beyond" to "is beyond".

Signed-off-by: Fabio Estevam <festevam@denx.de>

# 966480fe 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Increase the log level for high temperatures

dev_info() message is not printed by default. Increase the log level
to dev_crit(). This allows the critical messages related to the temperature
getting beyong the alert threshold to be displayed.

Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 402b8106 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Fix the polling default

When the 'polling-delay' property is not passed via devicetree,
pdata->polling_delay keeps at 0. This causes the imx_tmu driver to get
stuck inside the busy while() loop when the CPU temperature is above
the alert point.

Fix this problem by passing a one second polling interval, which provides
a proper delay to let the system to cool down and exit the while() loop
when the temperature is below the alert point.

Signed-off-by: Fabio Estevam <festevam@denx.de>

# b08a0a4b 27-Apr-2023 Ye Li <ye.li@nxp.com>

thermal: imx_tmu: Update TMU driver to support iMX93

The TMU used on iMX93 is IP revision 2.1 which is different with previous
revision used on iMX8MQ. So add a new FLAG V4 for this revision to
distinguish the operations.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# eb1e370a 04-Apr-2023 Marek Vasut <marex@denx.de>

thermal: imx_tmu: Move architecture code into driver

Stop polluting the architecture directory with driver specific code,
move it into driver where it should be. Split the code slightly so
the MX8MM/MX8MN fuse readout and programming and MX8MP fuse readout
and programming are in their separate functions, and called in case
of matching SoC.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>

# 114eb250 04-Apr-2023 Marek Vasut <marex@denx.de>

thermal: imx_tmu: Clean up all prints

Use dev_(dev, ...) for all printing and debug logging, since this
already includes the device name. Drop device name where duplicate.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>

# 0cf207ec 27-Sep-2021 Wolfgang Denk <wd@denx.de>

WS cleanup: remove SPACE(s) followed by TAB

Signed-off-by: Wolfgang Denk <wd@denx.de>

# deb78ff3 05-Feb-2021 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: enable monitoring and default alert/critical

Set default critical/alert temperature and enabling monoitoring.

Without calling imx_tmu_enable_msite() monitoring will not be enabled
and read_temperature will return 0. Additionally without setting alert
temperature will cause imx_tmu_get_temp() to spin indefiniately thinking
the system needs to cool.

This resolves the board spinning endlessly when enabling IMX_TMU in the
SPL.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

Move this out of the common header and include it only where needed. In
a number of cases this requires adding "struct udevice;" to avoid adding
another large header or in other cases replacing / adding missing header
files that had been pulled in, very indirectly. Finally, we have a few
cases where we did not need to include <asm/global_data.h> at all, so
remove that include.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c69cda25 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename dev_get_platdata() to dev_get_plat()

Rename this to be consistent with the change from 'platdata'.

Signed-off-by: Simon Glass <sjg@chromium.org>

# caa4daa2 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename 'platdata' variables to just 'plat'

We use 'priv' for private data but often use 'platdata' for platform data.
We can't really use 'pdata' since that is ambiguous (it could mean private
or platform data).

Rename some of the latter variables to end with 'plat' for consistency.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 41575d8e 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename auto_alloc_size members to be shorter

This construct is quite long-winded. In earlier days it made some sense
since auto-allocation was a strange concept. But with driver model now
used pretty universally, we can shorten this to 'auto'. This reduces
verbosity and makes it easier to read.

Coincidentally it also ensures that every declaration is on one line,
thus making dtoc's job easier.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 85abf041 12-Oct-2020 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: fix missing include

commit c05ed00afb dropped linux/delay.h from common header

add linux/delay.h to avoid compile warning here

Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 634fe73e 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support i.MX8MP

Support i.MX8MP thermal which has two probes and supports
temperature range from -40 to 125. Still uses default 1p HW
calibration at 25C and loads calibration parameters from fuse.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 951bf19d 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Check the TEMP range for iMX8MM

On iMX8MM, the V flag in TRISTR register only reflect the state of SNSR
value, not the calibrated TEMP value. So checking this flag is not
reliable. Per IC suggestion, change to read the TEMP/AVG_TEMP directly
and check whether it in valid range 10-125C.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# b5447b98 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Fix for temperature out of range

When the temperature is out of sensor's range, the Valid bit won't be
set in TRITSR register. So the polling loop won't go out.

Change the codes to retry 10 times with 100ms interval for the Valid bit.
If the timeout, we give a warning for the invalid data.

Modifed from Ye's NXP patch

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 84897408 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support TMU arch level initialization

i.MX8MM TMU needs to load some registers from fuse, this is arch
dependent operation and may vary on different platforms. So add
a interface for arch level initialization.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# fc8657b7 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Add support for thermal sensor on iMX8MM

The analog sensors on iMX8MM are new, used for 14LPP process. So the
Temperature Sensor Monitoring Unit (TMU) has some change accordingly.
We use version 2 in TMU driver to represent the new TMU, so the one
driver can service for both i.MX8MQ/M.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 2cd7f479 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: Add thermal driver for i.MX8M

The driver is ported form Linux Kernel and support driver model.
Users need to provide the tmu node and sensors nodes in DTB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# a79fca7b 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Increase the polling interval

Polling every second to check whether the CPU has cooled down is
too frequent.

Allow more time for the CPU to cool down by increasing the polling
interval to 5 seconds by defaut.

This value is used in the absence of the 'polling-delay' devicetree
property.

Signed-off-by: Fabio Estevam <festevam@denx.de>

# f4898e4b 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Fix the temperature unit

The temperature unit is millidegree Celsius, so divide by 1000 to correctly
print the temperature values in Celsius.

While at it, also change a typo: "has beyond" to "is beyond".

Signed-off-by: Fabio Estevam <festevam@denx.de>

# 966480fe 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Increase the log level for high temperatures

dev_info() message is not printed by default. Increase the log level
to dev_crit(). This allows the critical messages related to the temperature
getting beyong the alert threshold to be displayed.

Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 402b8106 23-Aug-2023 Fabio Estevam <festevam@denx.de>

thermal: imx_tmu: Fix the polling default

When the 'polling-delay' property is not passed via devicetree,
pdata->polling_delay keeps at 0. This causes the imx_tmu driver to get
stuck inside the busy while() loop when the CPU temperature is above
the alert point.

Fix this problem by passing a one second polling interval, which provides
a proper delay to let the system to cool down and exit the while() loop
when the temperature is below the alert point.

Signed-off-by: Fabio Estevam <festevam@denx.de>

# b08a0a4b 27-Apr-2023 Ye Li <ye.li@nxp.com>

thermal: imx_tmu: Update TMU driver to support iMX93

The TMU used on iMX93 is IP revision 2.1 which is different with previous
revision used on iMX8MQ. So add a new FLAG V4 for this revision to
distinguish the operations.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# eb1e370a 04-Apr-2023 Marek Vasut <marex@denx.de>

thermal: imx_tmu: Move architecture code into driver

Stop polluting the architecture directory with driver specific code,
move it into driver where it should be. Split the code slightly so
the MX8MM/MX8MN fuse readout and programming and MX8MP fuse readout
and programming are in their separate functions, and called in case
of matching SoC.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>

# 114eb250 04-Apr-2023 Marek Vasut <marex@denx.de>

thermal: imx_tmu: Clean up all prints

Use dev_(dev, ...) for all printing and debug logging, since this
already includes the device name. Drop device name where duplicate.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>

# 0cf207ec 27-Sep-2021 Wolfgang Denk <wd@denx.de>

WS cleanup: remove SPACE(s) followed by TAB

Signed-off-by: Wolfgang Denk <wd@denx.de>

# deb78ff3 05-Feb-2021 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: enable monitoring and default alert/critical

Set default critical/alert temperature and enabling monoitoring.

Without calling imx_tmu_enable_msite() monitoring will not be enabled
and read_temperature will return 0. Additionally without setting alert
temperature will cause imx_tmu_get_temp() to spin indefiniately thinking
the system needs to cool.

This resolves the board spinning endlessly when enabling IMX_TMU in the
SPL.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

Move this out of the common header and include it only where needed. In
a number of cases this requires adding "struct udevice;" to avoid adding
another large header or in other cases replacing / adding missing header
files that had been pulled in, very indirectly. Finally, we have a few
cases where we did not need to include <asm/global_data.h> at all, so
remove that include.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c69cda25 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename dev_get_platdata() to dev_get_plat()

Rename this to be consistent with the change from 'platdata'.

Signed-off-by: Simon Glass <sjg@chromium.org>

# caa4daa2 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename 'platdata' variables to just 'plat'

We use 'priv' for private data but often use 'platdata' for platform data.
We can't really use 'pdata' since that is ambiguous (it could mean private
or platform data).

Rename some of the latter variables to end with 'plat' for consistency.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 41575d8e 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename auto_alloc_size members to be shorter

This construct is quite long-winded. In earlier days it made some sense
since auto-allocation was a strange concept. But with driver model now
used pretty universally, we can shorten this to 'auto'. This reduces
verbosity and makes it easier to read.

Coincidentally it also ensures that every declaration is on one line,
thus making dtoc's job easier.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 85abf041 12-Oct-2020 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: fix missing include

commit c05ed00afb dropped linux/delay.h from common header

add linux/delay.h to avoid compile warning here

Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 634fe73e 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support i.MX8MP

Support i.MX8MP thermal which has two probes and supports
temperature range from -40 to 125. Still uses default 1p HW
calibration at 25C and loads calibration parameters from fuse.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 951bf19d 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Check the TEMP range for iMX8MM

On iMX8MM, the V flag in TRISTR register only reflect the state of SNSR
value, not the calibrated TEMP value. So checking this flag is not
reliable. Per IC suggestion, change to read the TEMP/AVG_TEMP directly
and check whether it in valid range 10-125C.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# b5447b98 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Fix for temperature out of range

When the temperature is out of sensor's range, the Valid bit won't be
set in TRITSR register. So the polling loop won't go out.

Change the codes to retry 10 times with 100ms interval for the Valid bit.
If the timeout, we give a warning for the invalid data.

Modifed from Ye's NXP patch

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 84897408 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support TMU arch level initialization

i.MX8MM TMU needs to load some registers from fuse, this is arch
dependent operation and may vary on different platforms. So add
a interface for arch level initialization.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# fc8657b7 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Add support for thermal sensor on iMX8MM

The analog sensors on iMX8MM are new, used for 14LPP process. So the
Temperature Sensor Monitoring Unit (TMU) has some change accordingly.
We use version 2 in TMU driver to represent the new TMU, so the one
driver can service for both i.MX8MQ/M.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 2cd7f479 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: Add thermal driver for i.MX8M

The driver is ported form Linux Kernel and support driver model.
Users need to provide the tmu node and sensors nodes in DTB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# b08a0a4b 27-Apr-2023 Ye Li <ye.li@nxp.com>

thermal: imx_tmu: Update TMU driver to support iMX93

The TMU used on iMX93 is IP revision 2.1 which is different with previous
revision used on iMX8MQ. So add a new FLAG V4 for this revision to
distinguish the operations.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# eb1e370a 04-Apr-2023 Marek Vasut <marex@denx.de>

thermal: imx_tmu: Move architecture code into driver

Stop polluting the architecture directory with driver specific code,
move it into driver where it should be. Split the code slightly so
the MX8MM/MX8MN fuse readout and programming and MX8MP fuse readout
and programming are in their separate functions, and called in case
of matching SoC.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>

# 114eb250 04-Apr-2023 Marek Vasut <marex@denx.de>

thermal: imx_tmu: Clean up all prints

Use dev_(dev, ...) for all printing and debug logging, since this
already includes the device name. Drop device name where duplicate.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>

# 0cf207ec 27-Sep-2021 Wolfgang Denk <wd@denx.de>

WS cleanup: remove SPACE(s) followed by TAB

Signed-off-by: Wolfgang Denk <wd@denx.de>

# deb78ff3 05-Feb-2021 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: enable monitoring and default alert/critical

Set default critical/alert temperature and enabling monoitoring.

Without calling imx_tmu_enable_msite() monitoring will not be enabled
and read_temperature will return 0. Additionally without setting alert
temperature will cause imx_tmu_get_temp() to spin indefiniately thinking
the system needs to cool.

This resolves the board spinning endlessly when enabling IMX_TMU in the
SPL.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

Move this out of the common header and include it only where needed. In
a number of cases this requires adding "struct udevice;" to avoid adding
another large header or in other cases replacing / adding missing header
files that had been pulled in, very indirectly. Finally, we have a few
cases where we did not need to include <asm/global_data.h> at all, so
remove that include.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c69cda25 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename dev_get_platdata() to dev_get_plat()

Rename this to be consistent with the change from 'platdata'.

Signed-off-by: Simon Glass <sjg@chromium.org>

# caa4daa2 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename 'platdata' variables to just 'plat'

We use 'priv' for private data but often use 'platdata' for platform data.
We can't really use 'pdata' since that is ambiguous (it could mean private
or platform data).

Rename some of the latter variables to end with 'plat' for consistency.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 41575d8e 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename auto_alloc_size members to be shorter

This construct is quite long-winded. In earlier days it made some sense
since auto-allocation was a strange concept. But with driver model now
used pretty universally, we can shorten this to 'auto'. This reduces
verbosity and makes it easier to read.

Coincidentally it also ensures that every declaration is on one line,
thus making dtoc's job easier.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 85abf041 12-Oct-2020 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: fix missing include

commit c05ed00afb dropped linux/delay.h from common header

add linux/delay.h to avoid compile warning here

Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 634fe73e 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support i.MX8MP

Support i.MX8MP thermal which has two probes and supports
temperature range from -40 to 125. Still uses default 1p HW
calibration at 25C and loads calibration parameters from fuse.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 951bf19d 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Check the TEMP range for iMX8MM

On iMX8MM, the V flag in TRISTR register only reflect the state of SNSR
value, not the calibrated TEMP value. So checking this flag is not
reliable. Per IC suggestion, change to read the TEMP/AVG_TEMP directly
and check whether it in valid range 10-125C.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# b5447b98 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Fix for temperature out of range

When the temperature is out of sensor's range, the Valid bit won't be
set in TRITSR register. So the polling loop won't go out.

Change the codes to retry 10 times with 100ms interval for the Valid bit.
If the timeout, we give a warning for the invalid data.

Modifed from Ye's NXP patch

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 84897408 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support TMU arch level initialization

i.MX8MM TMU needs to load some registers from fuse, this is arch
dependent operation and may vary on different platforms. So add
a interface for arch level initialization.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# fc8657b7 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Add support for thermal sensor on iMX8MM

The analog sensors on iMX8MM are new, used for 14LPP process. So the
Temperature Sensor Monitoring Unit (TMU) has some change accordingly.
We use version 2 in TMU driver to represent the new TMU, so the one
driver can service for both i.MX8MQ/M.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 2cd7f479 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: Add thermal driver for i.MX8M

The driver is ported form Linux Kernel and support driver model.
Users need to provide the tmu node and sensors nodes in DTB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 0cf207ec 27-Sep-2021 Wolfgang Denk <wd@denx.de>

WS cleanup: remove SPACE(s) followed by TAB

Signed-off-by: Wolfgang Denk <wd@denx.de>

# deb78ff3 05-Feb-2021 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: enable monitoring and default alert/critical

Set default critical/alert temperature and enabling monoitoring.

Without calling imx_tmu_enable_msite() monitoring will not be enabled
and read_temperature will return 0. Additionally without setting alert
temperature will cause imx_tmu_get_temp() to spin indefiniately thinking
the system needs to cool.

This resolves the board spinning endlessly when enabling IMX_TMU in the
SPL.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

Move this out of the common header and include it only where needed. In
a number of cases this requires adding "struct udevice;" to avoid adding
another large header or in other cases replacing / adding missing header
files that had been pulled in, very indirectly. Finally, we have a few
cases where we did not need to include <asm/global_data.h> at all, so
remove that include.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c69cda25 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename dev_get_platdata() to dev_get_plat()

Rename this to be consistent with the change from 'platdata'.

Signed-off-by: Simon Glass <sjg@chromium.org>

# caa4daa2 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename 'platdata' variables to just 'plat'

We use 'priv' for private data but often use 'platdata' for platform data.
We can't really use 'pdata' since that is ambiguous (it could mean private
or platform data).

Rename some of the latter variables to end with 'plat' for consistency.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 41575d8e 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename auto_alloc_size members to be shorter

This construct is quite long-winded. In earlier days it made some sense
since auto-allocation was a strange concept. But with driver model now
used pretty universally, we can shorten this to 'auto'. This reduces
verbosity and makes it easier to read.

Coincidentally it also ensures that every declaration is on one line,
thus making dtoc's job easier.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 85abf041 12-Oct-2020 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: fix missing include

commit c05ed00afb dropped linux/delay.h from common header

add linux/delay.h to avoid compile warning here

Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 634fe73e 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support i.MX8MP

Support i.MX8MP thermal which has two probes and supports
temperature range from -40 to 125. Still uses default 1p HW
calibration at 25C and loads calibration parameters from fuse.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 951bf19d 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Check the TEMP range for iMX8MM

On iMX8MM, the V flag in TRISTR register only reflect the state of SNSR
value, not the calibrated TEMP value. So checking this flag is not
reliable. Per IC suggestion, change to read the TEMP/AVG_TEMP directly
and check whether it in valid range 10-125C.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# b5447b98 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Fix for temperature out of range

When the temperature is out of sensor's range, the Valid bit won't be
set in TRITSR register. So the polling loop won't go out.

Change the codes to retry 10 times with 100ms interval for the Valid bit.
If the timeout, we give a warning for the invalid data.

Modifed from Ye's NXP patch

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 84897408 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support TMU arch level initialization

i.MX8MM TMU needs to load some registers from fuse, this is arch
dependent operation and may vary on different platforms. So add
a interface for arch level initialization.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# fc8657b7 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Add support for thermal sensor on iMX8MM

The analog sensors on iMX8MM are new, used for 14LPP process. So the
Temperature Sensor Monitoring Unit (TMU) has some change accordingly.
We use version 2 in TMU driver to represent the new TMU, so the one
driver can service for both i.MX8MQ/M.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 2cd7f479 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: Add thermal driver for i.MX8M

The driver is ported form Linux Kernel and support driver model.
Users need to provide the tmu node and sensors nodes in DTB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# deb78ff3 05-Feb-2021 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: enable monitoring and default alert/critical

Set default critical/alert temperature and enabling monoitoring.

Without calling imx_tmu_enable_msite() monitoring will not be enabled
and read_temperature will return 0. Additionally without setting alert
temperature will cause imx_tmu_get_temp() to spin indefiniately thinking
the system needs to cool.

This resolves the board spinning endlessly when enabling IMX_TMU in the
SPL.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

Move this out of the common header and include it only where needed. In
a number of cases this requires adding "struct udevice;" to avoid adding
another large header or in other cases replacing / adding missing header
files that had been pulled in, very indirectly. Finally, we have a few
cases where we did not need to include <asm/global_data.h> at all, so
remove that include.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c69cda25 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename dev_get_platdata() to dev_get_plat()

Rename this to be consistent with the change from 'platdata'.

Signed-off-by: Simon Glass <sjg@chromium.org>

# caa4daa2 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename 'platdata' variables to just 'plat'

We use 'priv' for private data but often use 'platdata' for platform data.
We can't really use 'pdata' since that is ambiguous (it could mean private
or platform data).

Rename some of the latter variables to end with 'plat' for consistency.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 41575d8e 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename auto_alloc_size members to be shorter

This construct is quite long-winded. In earlier days it made some sense
since auto-allocation was a strange concept. But with driver model now
used pretty universally, we can shorten this to 'auto'. This reduces
verbosity and makes it easier to read.

Coincidentally it also ensures that every declaration is on one line,
thus making dtoc's job easier.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 85abf041 12-Oct-2020 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: fix missing include

commit c05ed00afb dropped linux/delay.h from common header

add linux/delay.h to avoid compile warning here

Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 634fe73e 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support i.MX8MP

Support i.MX8MP thermal which has two probes and supports
temperature range from -40 to 125. Still uses default 1p HW
calibration at 25C and loads calibration parameters from fuse.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 951bf19d 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Check the TEMP range for iMX8MM

On iMX8MM, the V flag in TRISTR register only reflect the state of SNSR
value, not the calibrated TEMP value. So checking this flag is not
reliable. Per IC suggestion, change to read the TEMP/AVG_TEMP directly
and check whether it in valid range 10-125C.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# b5447b98 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Fix for temperature out of range

When the temperature is out of sensor's range, the Valid bit won't be
set in TRITSR register. So the polling loop won't go out.

Change the codes to retry 10 times with 100ms interval for the Valid bit.
If the timeout, we give a warning for the invalid data.

Modifed from Ye's NXP patch

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 84897408 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support TMU arch level initialization

i.MX8MM TMU needs to load some registers from fuse, this is arch
dependent operation and may vary on different platforms. So add
a interface for arch level initialization.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# fc8657b7 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Add support for thermal sensor on iMX8MM

The analog sensors on iMX8MM are new, used for 14LPP process. So the
Temperature Sensor Monitoring Unit (TMU) has some change accordingly.
We use version 2 in TMU driver to represent the new TMU, so the one
driver can service for both i.MX8MQ/M.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 2cd7f479 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: Add thermal driver for i.MX8M

The driver is ported form Linux Kernel and support driver model.
Users need to provide the tmu node and sensors nodes in DTB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

Move this out of the common header and include it only where needed. In
a number of cases this requires adding "struct udevice;" to avoid adding
another large header or in other cases replacing / adding missing header
files that had been pulled in, very indirectly. Finally, we have a few
cases where we did not need to include <asm/global_data.h> at all, so
remove that include.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c69cda25 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename dev_get_platdata() to dev_get_plat()

Rename this to be consistent with the change from 'platdata'.

Signed-off-by: Simon Glass <sjg@chromium.org>

# caa4daa2 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename 'platdata' variables to just 'plat'

We use 'priv' for private data but often use 'platdata' for platform data.
We can't really use 'pdata' since that is ambiguous (it could mean private
or platform data).

Rename some of the latter variables to end with 'plat' for consistency.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 41575d8e 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename auto_alloc_size members to be shorter

This construct is quite long-winded. In earlier days it made some sense
since auto-allocation was a strange concept. But with driver model now
used pretty universally, we can shorten this to 'auto'. This reduces
verbosity and makes it easier to read.

Coincidentally it also ensures that every declaration is on one line,
thus making dtoc's job easier.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 85abf041 12-Oct-2020 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: fix missing include

commit c05ed00afb dropped linux/delay.h from common header

add linux/delay.h to avoid compile warning here

Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 634fe73e 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support i.MX8MP

Support i.MX8MP thermal which has two probes and supports
temperature range from -40 to 125. Still uses default 1p HW
calibration at 25C and loads calibration parameters from fuse.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 951bf19d 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Check the TEMP range for iMX8MM

On iMX8MM, the V flag in TRISTR register only reflect the state of SNSR
value, not the calibrated TEMP value. So checking this flag is not
reliable. Per IC suggestion, change to read the TEMP/AVG_TEMP directly
and check whether it in valid range 10-125C.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# b5447b98 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Fix for temperature out of range

When the temperature is out of sensor's range, the Valid bit won't be
set in TRITSR register. So the polling loop won't go out.

Change the codes to retry 10 times with 100ms interval for the Valid bit.
If the timeout, we give a warning for the invalid data.

Modifed from Ye's NXP patch

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 84897408 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support TMU arch level initialization

i.MX8MM TMU needs to load some registers from fuse, this is arch
dependent operation and may vary on different platforms. So add
a interface for arch level initialization.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# fc8657b7 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Add support for thermal sensor on iMX8MM

The analog sensors on iMX8MM are new, used for 14LPP process. So the
Temperature Sensor Monitoring Unit (TMU) has some change accordingly.
We use version 2 in TMU driver to represent the new TMU, so the one
driver can service for both i.MX8MQ/M.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 2cd7f479 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: Add thermal driver for i.MX8M

The driver is ported form Linux Kernel and support driver model.
Users need to provide the tmu node and sensors nodes in DTB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# c69cda25 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename dev_get_platdata() to dev_get_plat()

Rename this to be consistent with the change from 'platdata'.

Signed-off-by: Simon Glass <sjg@chromium.org>

# caa4daa2 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename 'platdata' variables to just 'plat'

We use 'priv' for private data but often use 'platdata' for platform data.
We can't really use 'pdata' since that is ambiguous (it could mean private
or platform data).

Rename some of the latter variables to end with 'plat' for consistency.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 41575d8e 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename auto_alloc_size members to be shorter

This construct is quite long-winded. In earlier days it made some sense
since auto-allocation was a strange concept. But with driver model now
used pretty universally, we can shorten this to 'auto'. This reduces
verbosity and makes it easier to read.

Coincidentally it also ensures that every declaration is on one line,
thus making dtoc's job easier.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 85abf041 12-Oct-2020 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: fix missing include

commit c05ed00afb dropped linux/delay.h from common header

add linux/delay.h to avoid compile warning here

Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 634fe73e 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support i.MX8MP

Support i.MX8MP thermal which has two probes and supports
temperature range from -40 to 125. Still uses default 1p HW
calibration at 25C and loads calibration parameters from fuse.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 951bf19d 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Check the TEMP range for iMX8MM

On iMX8MM, the V flag in TRISTR register only reflect the state of SNSR
value, not the calibrated TEMP value. So checking this flag is not
reliable. Per IC suggestion, change to read the TEMP/AVG_TEMP directly
and check whether it in valid range 10-125C.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# b5447b98 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Fix for temperature out of range

When the temperature is out of sensor's range, the Valid bit won't be
set in TRITSR register. So the polling loop won't go out.

Change the codes to retry 10 times with 100ms interval for the Valid bit.
If the timeout, we give a warning for the invalid data.

Modifed from Ye's NXP patch

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 84897408 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support TMU arch level initialization

i.MX8MM TMU needs to load some registers from fuse, this is arch
dependent operation and may vary on different platforms. So add
a interface for arch level initialization.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# fc8657b7 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Add support for thermal sensor on iMX8MM

The analog sensors on iMX8MM are new, used for 14LPP process. So the
Temperature Sensor Monitoring Unit (TMU) has some change accordingly.
We use version 2 in TMU driver to represent the new TMU, so the one
driver can service for both i.MX8MQ/M.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 2cd7f479 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: Add thermal driver for i.MX8M

The driver is ported form Linux Kernel and support driver model.
Users need to provide the tmu node and sensors nodes in DTB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 85abf041 12-Oct-2020 Tim Harvey <tharvey@gateworks.com>

thermal: imx_tmu: fix missing include

commit c05ed00afb dropped linux/delay.h from common header

add linux/delay.h to avoid compile warning here

Signed-off-by: Tim Harvey <tharvey@gateworks.com>

# 634fe73e 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support i.MX8MP

Support i.MX8MP thermal which has two probes and supports
temperature range from -40 to 125. Still uses default 1p HW
calibration at 25C and loads calibration parameters from fuse.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 951bf19d 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Check the TEMP range for iMX8MM

On iMX8MM, the V flag in TRISTR register only reflect the state of SNSR
value, not the calibrated TEMP value. So checking this flag is not
reliable. Per IC suggestion, change to read the TEMP/AVG_TEMP directly
and check whether it in valid range 10-125C.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# b5447b98 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Fix for temperature out of range

When the temperature is out of sensor's range, the Valid bit won't be
set in TRITSR register. So the polling loop won't go out.

Change the codes to retry 10 times with 100ms interval for the Valid bit.
If the timeout, we give a warning for the invalid data.

Modifed from Ye's NXP patch

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 84897408 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support TMU arch level initialization

i.MX8MM TMU needs to load some registers from fuse, this is arch
dependent operation and may vary on different platforms. So add
a interface for arch level initialization.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# fc8657b7 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Add support for thermal sensor on iMX8MM

The analog sensors on iMX8MM are new, used for 14LPP process. So the
Temperature Sensor Monitoring Unit (TMU) has some change accordingly.
We use version 2 in TMU driver to represent the new TMU, so the one
driver can service for both i.MX8MQ/M.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 2cd7f479 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: Add thermal driver for i.MX8M

The driver is ported form Linux Kernel and support driver model.
Users need to provide the tmu node and sensors nodes in DTB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 634fe73e 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support i.MX8MP

Support i.MX8MP thermal which has two probes and supports
temperature range from -40 to 125. Still uses default 1p HW
calibration at 25C and loads calibration parameters from fuse.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 951bf19d 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Check the TEMP range for iMX8MM

On iMX8MM, the V flag in TRISTR register only reflect the state of SNSR
value, not the calibrated TEMP value. So checking this flag is not
reliable. Per IC suggestion, change to read the TEMP/AVG_TEMP directly
and check whether it in valid range 10-125C.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# b5447b98 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Fix for temperature out of range

When the temperature is out of sensor's range, the Valid bit won't be
set in TRITSR register. So the polling loop won't go out.

Change the codes to retry 10 times with 100ms interval for the Valid bit.
If the timeout, we give a warning for the invalid data.

Modifed from Ye's NXP patch

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 84897408 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: support TMU arch level initialization

i.MX8MM TMU needs to load some registers from fuse, this is arch
dependent operation and may vary on different platforms. So add
a interface for arch level initialization.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# fc8657b7 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: imx_tmu: Add support for thermal sensor on iMX8MM

The analog sensors on iMX8MM are new, used for 14LPP process. So the
Temperature Sensor Monitoring Unit (TMU) has some change accordingly.
We use version 2 in TMU driver to represent the new TMU, so the one
driver can service for both i.MX8MQ/M.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 2cd7f479 03-May-2020 Peng Fan <peng.fan@nxp.com>

thermal: Add thermal driver for i.MX8M

The driver is ported form Linux Kernel and support driver model.
Users need to provide the tmu node and sensors nodes in DTB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>