Skip to content

Commit dd23583

Browse files
committed
Merge tag 'thermal-v6.4-rc1-3' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/thermal/linux
Pull more thermal control changes for 6.4-rc1 from Daniel Lezcano: "- Add compatible strings DT bindings for imx6sll and imx6ul to fix dtbs check warning (Stefan Wahren) - Update the example in the DT bindings to reflect changes with the ADC node name for QCom TM and TM5 (Marijn Suijten) - Fix the comments for the cpuidle_cooling_register() function to match the function prototype (Chenggang Wang) - Fix inconsistent temperature read and some Mediatek variant board reboot by reverting a change and handling the temperature differently (AngeloGioacchino Del Regno) - Fix a memory leak in the initialization error path for the Mediatek driver (Kang Chen) - Use of_address_to_resource() in the Mediatek driver (Rob Herring) - Fix unit address in the QCom tsens driver DT bindings (Krzysztof Kozlowski)" * tag 'thermal-v6.4-rc1-3' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/thermal/linux: dt-bindings: thermal: qcom-tsens: Correct unit address thermal/drivers/mediatek: Use of_address_to_resource() thermal/drivers/mediatek: Change clk_prepare_enable to devm_clk_get_enabled in mtk_thermal_probe thermal/drivers/mediatek: Use devm_of_iomap to avoid resource leak in mtk_thermal_probe thermal/drivers/mediatek: Add temperature constraints to validate read Revert "thermal/drivers/mediatek: Add delay after thermal banks initialization" thermal/drivers/cpuidle_cooling: Delete unmatched comments dt-bindings: thermal: Use generic ADC node name in examples dt-bindings: imx-thermal: Add imx6sll and imx6ul compatible
2 parents 5e0ca0b + 2afa82d commit dd23583

6 files changed

Lines changed: 64 additions & 59 deletions

File tree

Documentation/devicetree/bindings/thermal/imx-thermal.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ maintainers:
1212

1313
properties:
1414
compatible:
15-
enum:
16-
- fsl,imx6q-tempmon
17-
- fsl,imx6sx-tempmon
18-
- fsl,imx7d-tempmon
15+
oneOf:
16+
- enum:
17+
- fsl,imx6q-tempmon
18+
- fsl,imx6sx-tempmon
19+
- fsl,imx7d-tempmon
20+
- items:
21+
- enum:
22+
- fsl,imx6sll-tempmon
23+
- fsl,imx6ul-tempmon
24+
- const: fsl,imx6sx-tempmon
1925

2026
interrupts:
2127
description: |

Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm-hc.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ examples:
124124
#size-cells = <0>;
125125
#io-channel-cells = <1>;
126126
127-
/* Other propreties are omitted */
128-
adc-chan@4c {
127+
/* Other properties are omitted */
128+
channel@4c {
129129
reg = <ADC5_XO_THERM_100K_PU>;
130130
};
131131
};

Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,11 @@ examples:
178178
#io-channel-cells = <1>;
179179
180180
/* Other properties are omitted */
181-
conn-therm@4f {
181+
channel@4f {
182182
reg = <ADC5_AMUX_THM3_100K_PU>;
183183
qcom,ratiometric;
184184
qcom,hw-settle-time = <200>;
185+
label = "conn_therm";
185186
};
186187
};
187188
@@ -217,16 +218,18 @@ examples:
217218
#io-channel-cells = <1>;
218219
219220
/* Other properties are omitted */
220-
xo-therm@44 {
221+
channel@44 {
221222
reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
222223
qcom,ratiometric;
223224
qcom,hw-settle-time = <200>;
225+
label = "xo_therm";
224226
};
225227
226-
conn-therm@147 {
228+
channel@147 {
227229
reg = <PM8350_ADC7_AMUX_THM4_100K_PU(1)>;
228230
qcom,ratiometric;
229231
qcom,hw-settle-time = <200>;
232+
label = "conn_therm";
230233
};
231234
};
232235

Documentation/devicetree/bindings/thermal/qcom-tsens.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ examples:
326326
- |
327327
#include <dt-bindings/interrupt-controller/arm-gic.h>
328328
// Example 1 (new calbiration data: for pre v1 IP):
329-
thermal-sensor@900000 {
329+
thermal-sensor@4a9000 {
330330
compatible = "qcom,msm8916-tsens", "qcom,tsens-v0_1";
331331
reg = <0x4a9000 0x1000>, /* TM */
332332
<0x4a8000 0x1000>; /* SROT */
@@ -356,7 +356,7 @@ examples:
356356
- |
357357
#include <dt-bindings/interrupt-controller/arm-gic.h>
358358
// Example 1 (legacy: for pre v1 IP):
359-
tsens1: thermal-sensor@900000 {
359+
tsens1: thermal-sensor@4a9000 {
360360
compatible = "qcom,msm8916-tsens", "qcom,tsens-v0_1";
361361
reg = <0x4a9000 0x1000>, /* TM */
362362
<0x4a8000 0x1000>; /* SROT */

drivers/thermal/cpuidle_cooling.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,6 @@ static int __cpuidle_cooling_register(struct device_node *np,
236236
*
237237
* This function is in charge of creating a cooling device per cpuidle
238238
* driver and register it to the thermal framework.
239-
*
240-
* Return: zero on success, or negative value corresponding to the
241-
* error detected in the underlying subsystems.
242239
*/
243240
void cpuidle_cooling_register(struct cpuidle_driver *drv)
244241
{

drivers/thermal/mediatek/auxadc_thermal.c

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@
116116
/* The calibration coefficient of sensor */
117117
#define MT8173_CALIBRATION 165
118118

119+
/* Valid temperatures range */
120+
#define MT8173_TEMP_MIN -20000
121+
#define MT8173_TEMP_MAX 150000
122+
119123
/*
120124
* Layout of the fuses providing the calibration data
121125
* These macros could be used for MT8183, MT8173, MT2701, and MT2712.
@@ -689,6 +693,11 @@ static const struct mtk_thermal_data mt7986_thermal_data = {
689693
.version = MTK_THERMAL_V3,
690694
};
691695

696+
static bool mtk_thermal_temp_is_valid(int temp)
697+
{
698+
return (temp >= MT8173_TEMP_MIN) && (temp <= MT8173_TEMP_MAX);
699+
}
700+
692701
/**
693702
* raw_to_mcelsius_v1 - convert a raw ADC value to mcelsius
694703
* @mt: The thermal controller
@@ -815,6 +824,17 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank)
815824
temp = mt->raw_to_mcelsius(
816825
mt, conf->bank_data[bank->id].sensors[i], raw);
817826

827+
/*
828+
* Depending on the filt/sen intervals and ADC polling time,
829+
* we may need up to 60 milliseconds after initialization: this
830+
* will result in the first reading containing an out of range
831+
* temperature value.
832+
* Validate the reading to both address the aforementioned issue
833+
* and to eventually avoid bogus readings during runtime in the
834+
* event that the AUXADC gets unstable due to high EMI, etc.
835+
*/
836+
if (!mtk_thermal_temp_is_valid(temp))
837+
temp = THERMAL_TEMP_INVALID;
818838

819839
if (temp > max)
820840
max = temp;
@@ -959,14 +979,12 @@ static void mtk_thermal_init_bank(struct mtk_thermal *mt, int num,
959979

960980
static u64 of_get_phys_base(struct device_node *np)
961981
{
962-
u64 size64;
963-
const __be32 *regaddr_p;
982+
struct resource res;
964983

965-
regaddr_p = of_get_address(np, 0, &size64, NULL);
966-
if (!regaddr_p)
984+
if (of_address_to_resource(np, 0, &res))
967985
return OF_BAD_ADDR;
968986

969-
return of_translate_address(np, regaddr_p);
987+
return res.start;
970988
}
971989

972990
static int mtk_thermal_extract_efuse_v1(struct mtk_thermal *mt, u32 *buf)
@@ -1186,14 +1204,6 @@ static int mtk_thermal_probe(struct platform_device *pdev)
11861204

11871205
mt->conf = of_device_get_match_data(&pdev->dev);
11881206

1189-
mt->clk_peri_therm = devm_clk_get(&pdev->dev, "therm");
1190-
if (IS_ERR(mt->clk_peri_therm))
1191-
return PTR_ERR(mt->clk_peri_therm);
1192-
1193-
mt->clk_auxadc = devm_clk_get(&pdev->dev, "auxadc");
1194-
if (IS_ERR(mt->clk_auxadc))
1195-
return PTR_ERR(mt->clk_auxadc);
1196-
11971207
mt->thermal_base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
11981208
if (IS_ERR(mt->thermal_base))
11991209
return PTR_ERR(mt->thermal_base);
@@ -1212,7 +1222,12 @@ static int mtk_thermal_probe(struct platform_device *pdev)
12121222
return -ENODEV;
12131223
}
12141224

1215-
auxadc_base = of_iomap(auxadc, 0);
1225+
auxadc_base = devm_of_iomap(&pdev->dev, auxadc, 0, NULL);
1226+
if (IS_ERR(auxadc_base)) {
1227+
of_node_put(auxadc);
1228+
return PTR_ERR(auxadc_base);
1229+
}
1230+
12161231
auxadc_phys_base = of_get_phys_base(auxadc);
12171232

12181233
of_node_put(auxadc);
@@ -1228,7 +1243,12 @@ static int mtk_thermal_probe(struct platform_device *pdev)
12281243
return -ENODEV;
12291244
}
12301245

1231-
apmixed_base = of_iomap(apmixedsys, 0);
1246+
apmixed_base = devm_of_iomap(&pdev->dev, apmixedsys, 0, NULL);
1247+
if (IS_ERR(apmixed_base)) {
1248+
of_node_put(apmixedsys);
1249+
return PTR_ERR(apmixed_base);
1250+
}
1251+
12321252
apmixed_phys_base = of_get_phys_base(apmixedsys);
12331253

12341254
of_node_put(apmixedsys);
@@ -1242,16 +1262,18 @@ static int mtk_thermal_probe(struct platform_device *pdev)
12421262
if (ret)
12431263
return ret;
12441264

1245-
ret = clk_prepare_enable(mt->clk_auxadc);
1246-
if (ret) {
1265+
mt->clk_auxadc = devm_clk_get_enabled(&pdev->dev, "auxadc");
1266+
if (IS_ERR(mt->clk_auxadc)) {
1267+
ret = PTR_ERR(mt->clk_auxadc);
12471268
dev_err(&pdev->dev, "Can't enable auxadc clk: %d\n", ret);
12481269
return ret;
12491270
}
12501271

1251-
ret = clk_prepare_enable(mt->clk_peri_therm);
1252-
if (ret) {
1272+
mt->clk_peri_therm = devm_clk_get_enabled(&pdev->dev, "therm");
1273+
if (IS_ERR(mt->clk_peri_therm)) {
1274+
ret = PTR_ERR(mt->clk_peri_therm);
12531275
dev_err(&pdev->dev, "Can't enable peri clk: %d\n", ret);
1254-
goto err_disable_clk_auxadc;
1276+
return ret;
12551277
}
12561278

12571279
mtk_thermal_turn_on_buffer(mt, apmixed_base);
@@ -1273,43 +1295,20 @@ static int mtk_thermal_probe(struct platform_device *pdev)
12731295

12741296
platform_set_drvdata(pdev, mt);
12751297

1276-
/* Delay for thermal banks to be ready */
1277-
msleep(30);
1278-
12791298
tzdev = devm_thermal_of_zone_register(&pdev->dev, 0, mt,
12801299
&mtk_thermal_ops);
1281-
if (IS_ERR(tzdev)) {
1282-
ret = PTR_ERR(tzdev);
1283-
goto err_disable_clk_peri_therm;
1284-
}
1300+
if (IS_ERR(tzdev))
1301+
return PTR_ERR(tzdev);
12851302

12861303
ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);
12871304
if (ret)
12881305
dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs");
12891306

12901307
return 0;
1291-
1292-
err_disable_clk_peri_therm:
1293-
clk_disable_unprepare(mt->clk_peri_therm);
1294-
err_disable_clk_auxadc:
1295-
clk_disable_unprepare(mt->clk_auxadc);
1296-
1297-
return ret;
1298-
}
1299-
1300-
static int mtk_thermal_remove(struct platform_device *pdev)
1301-
{
1302-
struct mtk_thermal *mt = platform_get_drvdata(pdev);
1303-
1304-
clk_disable_unprepare(mt->clk_peri_therm);
1305-
clk_disable_unprepare(mt->clk_auxadc);
1306-
1307-
return 0;
13081308
}
13091309

13101310
static struct platform_driver mtk_thermal_driver = {
13111311
.probe = mtk_thermal_probe,
1312-
.remove = mtk_thermal_remove,
13131312
.driver = {
13141313
.name = "mtk-thermal",
13151314
.of_match_table = mtk_thermal_of_match,

0 commit comments

Comments
 (0)