From f4d0951e3a10a6dac6a44cb15bf9673c87bbb60e Mon Sep 17 00:00:00 2001 From: Jari Tenhunen Date: Fri, 29 Jun 2018 21:20:25 +0300 Subject: [PATCH] thermal: imx_thermal: Fix reading of thermal grade OTP value on i.MX7D According to fusemap in reference manual, speed/thermal grading is configured at fuse address 0x440[9:8]. By reading the correct bits, this change fixes the detection of thermal grade at least on extended consumer grade models (P/N char 5E, 8E), possibly industrial and automative models, too. Tested on a board with P/N MCIMX7D5EVM10SC. Signed-off-by: Jari Tenhunen --- drivers/thermal/imx_thermal.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index de4fc8791c6c3a..8db3f664ffe614 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -625,10 +625,13 @@ static int imx_get_sensor_data(struct platform_device *pdev) imx6_calibrate_data(data, val); /* use OTP for thermal grade */ - if (data->socdata->version == TEMPMON_IMX7) + if (data->socdata->version == TEMPMON_IMX7) { ret = regmap_read(map, IMX7_OCOTP_TESTER3, &val); - else + val = (val >> 8) & 0x03; + } else { ret = regmap_read(map, OCOTP_MEM0, &val); + val = (val >> 6) & 0x03; + } if (ret) { dev_err(&pdev->dev, "failed to read temp grade: %d\n", ret); @@ -636,7 +639,7 @@ static int imx_get_sensor_data(struct platform_device *pdev) } /* The maximum die temp is specified by the Temperature Grade */ - switch ((val >> 6) & 0x3) { + switch (val) { case 0: /* Commercial (0 to 95C) */ data->temp_grade = "Commercial"; data->temp_max = 95000;