Skip to content

Commit 4d06420

Browse files
MrVandlezcano
authored andcommitted
thermal/drivers/qoriq: Fix getting tmu range
TMU Version 1 has 4 TTRCRs, while TMU Version >=2 has 16 TTRCRs. So limit the len to 4 will report "invalid range data" for i.MX93. This patch drop the local array with allocated ttrcr array and able to support larger tmu ranges. Fixes: f12d60c ("thermal/drivers/qoriq: Support version 2.1") Tested-by: Sascha Hauer <[email protected]> Signed-off-by: Peng Fan <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 79d9984 commit 4d06420

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/thermal/qoriq_thermal.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
#define REGS_TTRnCR(n) (0xf10 + 4 * (n)) /* Temperature Range n
5858
* Control Register
5959
*/
60+
#define NUM_TTRCR_V1 4
61+
#define NUM_TTRCR_MAX 16
62+
6063
#define REGS_IPBRR(n) (0xbf8 + 4 * (n)) /* IP Block Revision
6164
* Register n
6265
*/
@@ -71,6 +74,7 @@ struct qoriq_sensor {
7174

7275
struct qoriq_tmu_data {
7376
int ver;
77+
u32 ttrcr[NUM_TTRCR_MAX];
7478
struct regmap *regmap;
7579
struct clk *clk;
7680
struct qoriq_sensor sensor[SITES_MAX];
@@ -182,25 +186,25 @@ static int qoriq_tmu_calibration(struct device *dev,
182186
struct qoriq_tmu_data *data)
183187
{
184188
int i, val, len;
185-
u32 range[4];
186189
const u32 *calibration;
187190
struct device_node *np = dev->of_node;
188191

189192
len = of_property_count_u32_elems(np, "fsl,tmu-range");
190-
if (len < 0 || len > 4) {
193+
if (len < 0 || (data->ver == TMU_VER1 && len > NUM_TTRCR_V1) ||
194+
(data->ver > TMU_VER1 && len > NUM_TTRCR_MAX)) {
191195
dev_err(dev, "invalid range data.\n");
192196
return len;
193197
}
194198

195-
val = of_property_read_u32_array(np, "fsl,tmu-range", range, len);
199+
val = of_property_read_u32_array(np, "fsl,tmu-range", data->ttrcr, len);
196200
if (val != 0) {
197201
dev_err(dev, "failed to read range data.\n");
198202
return val;
199203
}
200204

201205
/* Init temperature range registers */
202206
for (i = 0; i < len; i++)
203-
regmap_write(data->regmap, REGS_TTRnCR(i), range[i]);
207+
regmap_write(data->regmap, REGS_TTRnCR(i), data->ttrcr[i]);
204208

205209
calibration = of_get_property(np, "fsl,tmu-calibration", &len);
206210
if (calibration == NULL || len % 8) {

0 commit comments

Comments
 (0)