<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>i.MX ProcessorsのトピックRe: Linux-fslc temperature calibration in kernel driver imx_thermal.c</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Linux-fslc-temperature-calibration-in-kernel-driver-imx-thermal/m-p/2195167#M241760</link>
    <description>&lt;P&gt;Hi Jorge,&lt;/P&gt;&lt;P&gt;as I reported in my initial post, I confirm you that&amp;nbsp;&lt;SPAN&gt;trip temperature points are incorrect:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;actual Alarm/Passive temperature is 102,8°C instead of 95°C&lt;/LI&gt;&lt;LI&gt;actual Panic temperature is 108.7°C instead of 100°C&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;This is a potentially critical issue, the panic temperature is above the maximum operating temperature of 105°C.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Oct 2025 14:19:35 GMT</pubDate>
    <dc:creator>ennebi</dc:creator>
    <dc:date>2025-10-29T14:19:35Z</dc:date>
    <item>
      <title>Linux-fslc temperature calibration in kernel driver imx_thermal.c</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Linux-fslc-temperature-calibration-in-kernel-driver-imx-thermal/m-p/2189166#M241508</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm using Linux-fslc with imx6ull.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I observed that the "i.MX 6ULL Applications Processor Reference Manual", at "Chapter 52 Temperature Monitor" specifies that temperature calibration is defined with 2 points:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-&amp;nbsp;(N1, T1) = (ROOM_COUNT, 25.0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-&amp;nbsp;(N2, T2) = (HOT_COUNT, HOT_TEMP)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;While the kernel driver imx_thermal.c (5.15 and 6.12 are the same), in&amp;nbsp;&lt;SPAN&gt;imx_init_calib() considers only one calibration point: the&amp;nbsp;OCOTP_ANA1[ROOM_COUNT] at 25°C as in the following code extract:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;static int imx_init_calib(struct platform_device *pdev, u32 ocotp_ana1)
{
	struct imx_thermal_data *data = platform_get_drvdata(pdev);
	int n1;
	u64 temp64;

	if (ocotp_ana1 == 0 || ocotp_ana1 == ~0) {
		dev_err(&amp;amp;pdev-&amp;gt;dev, "invalid sensor calibration data\n");
		return -EINVAL;
	}

	/*
	 * On i.MX7D, we only use the calibration data at 25C to get the temp,
	 * Tmeas = ( Nmeas - n1) + 25; n1 is the fuse value for 25C.
	 */
	if (data-&amp;gt;socdata-&amp;gt;version == TEMPMON_IMX7D) {
		data-&amp;gt;c1 = (ocotp_ana1 &amp;gt;&amp;gt; 9) &amp;amp; 0x1ff;
		return 0;
	}

	/*
	 * The sensor is calibrated at 25 °C (aka T1) and the value measured
	 * (aka N1) at this temperature is provided in bits [31:20] in the
	 * i.MX's OCOTP value ANA1.
	 * To find the actual temperature T, the following formula has to be used
	 * when reading value n from the sensor:
	 *
	 * T = T1 + (N - N1) / (0.4148468 - 0.0015423 * N1) °C + 3.580661 °C
	 *   = [T1' - N1 / (0.4148468 - 0.0015423 * N1) °C] + N / (0.4148468 - 0.0015423 * N1) °C
	 *   = [T1' + N1 / (0.0015423 * N1 - 0.4148468) °C] - N / (0.0015423 * N1 - 0.4148468) °C
	 *   = c2 - c1 * N
	 *
	 * with
	 *
	 *  T1' = 28.580661 °C
	 *   c1 = 1 / (0.0015423 * N1 - 0.4297157) °C
	 *   c2 = T1' + N1 / (0.0015423 * N1 - 0.4148468) °C
	 *      = T1' + N1 * c1
	 */
	n1 = ocotp_ana1 &amp;gt;&amp;gt; 20;

	temp64 = 10000000; /* use 10^7 as fixed point constant for values in formula */
	temp64 *= 1000; /* to get result in °mC */
	do_div(temp64, 15423 * n1 - 4148468);
	data-&amp;gt;c1 = temp64;
	data-&amp;gt;c2 = n1 * data-&amp;gt;c1 + 28581;

	return 0;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This line '&lt;/SPAN&gt;&lt;SPAN&gt;n1 &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; ocotp_ana1 &lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN&gt;20',&amp;nbsp;drops&amp;nbsp;OCOTP_ANA1[HOT_COUNT] and&amp;nbsp;OCOTP_ANA1[HOT_TEMP] and this leads to temperature&amp;nbsp;inconsistencies.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To confirm this, I did some verifications on a board, by reading registers and calculating trip temperatures:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Calibration register&amp;nbsp;OCOTP_ANA1=0x50F4A269&lt;BR /&gt;&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;ROOM_COUNT=0x50F = 1295&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;HOT_COUNT=0x4A2 = 1186&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;HOT_TEMP(°C)=0x69=105&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;TEMPMON_TEMPSENSE0=0x4A551206&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;ALARM_VALUE=0x4A5=1189&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;TEMPMON_TEMPSENSE2=&amp;nbsp;0x049D0FFF&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;PANIC_ALARM_VALUE=49D=1181&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;than I converted [ALARM_VALUE] and&amp;nbsp; [PANIC_ALARM_VALUE] to celsius temperature according to reference manual indication:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Tmeas = HOT_TEMP - (Nmeas - HOT_COUNT) * ((HOT_TEMP - 25.0) /&lt;BR /&gt;(ROOM_COUNT – HOT_COUNT))&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;so I got:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Alarm/Passive temperature = 102,8°C&lt;/LI&gt;&lt;LI&gt;Panic temperature = 108.7°C&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;those temperatures are greater than default trip temperature:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Alarm/passive temperature = 95°C (10°c less than max temperature of 105°C)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Panic temperature = 100°C (5°C less than max temperature of 105°C)&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;This looks like a potentially critical issue in the driver where the panic temperature is already above the maximum operating temperature from datasheet.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can you confirm the issue?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Oct 2025 11:10:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Linux-fslc-temperature-calibration-in-kernel-driver-imx-thermal/m-p/2189166#M241508</guid>
      <dc:creator>ennebi</dc:creator>
      <dc:date>2025-10-20T11:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Linux-fslc temperature calibration in kernel driver imx_thermal.c</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Linux-fslc-temperature-calibration-in-kernel-driver-imx-thermal/m-p/2193655#M241688</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Have you encountered any temperature measurement inaccuracies or trip temperature points are incorrect?&lt;/P&gt;
&lt;P&gt;I have discussed the code with owner. It's an very old code and he though the algorithm should be okay.&lt;/P&gt;
&lt;P&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2025 17:23:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Linux-fslc-temperature-calibration-in-kernel-driver-imx-thermal/m-p/2193655#M241688</guid>
      <dc:creator>JorgeCas</dc:creator>
      <dc:date>2025-10-27T17:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Linux-fslc temperature calibration in kernel driver imx_thermal.c</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Linux-fslc-temperature-calibration-in-kernel-driver-imx-thermal/m-p/2195167#M241760</link>
      <description>&lt;P&gt;Hi Jorge,&lt;/P&gt;&lt;P&gt;as I reported in my initial post, I confirm you that&amp;nbsp;&lt;SPAN&gt;trip temperature points are incorrect:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;actual Alarm/Passive temperature is 102,8°C instead of 95°C&lt;/LI&gt;&lt;LI&gt;actual Panic temperature is 108.7°C instead of 100°C&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;This is a potentially critical issue, the panic temperature is above the maximum operating temperature of 105°C.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Oct 2025 14:19:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Linux-fslc-temperature-calibration-in-kernel-driver-imx-thermal/m-p/2195167#M241760</guid>
      <dc:creator>ennebi</dc:creator>
      <dc:date>2025-10-29T14:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Linux-fslc temperature calibration in kernel driver imx_thermal.c</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Linux-fslc-temperature-calibration-in-kernel-driver-imx-thermal/m-p/2207009#M242245</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;The coefficients used for single-point calibration and two-point calibration differ significantly. Regarding your question—have you compared the temperature derived from single-point calibration against actual ambient conditions to assess error margins?&lt;/P&gt;
&lt;P&gt;On iMX6, single-point calibration is applied with calculations referenced in imx_init_calib, incorporating additional coefficients c1 and c2. Notably, even imx_set_alarm_temp utilizes single-point calibration coefficients when configuring alarm thresholds.&lt;/P&gt;
&lt;P&gt;Crucially, attempting to inversely convert single-point calibration results using two-point calibration methodology is fundamentally incorrect—the calibration frameworks are not interchangeable or reversible in this manner.&lt;/P&gt;
&lt;P&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Nov 2025 18:15:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Linux-fslc-temperature-calibration-in-kernel-driver-imx-thermal/m-p/2207009#M242245</guid>
      <dc:creator>JorgeCas</dc:creator>
      <dc:date>2025-11-18T18:15:01Z</dc:date>
    </item>
  </channel>
</rss>

