Skip to content

Commit 366444e

Browse files
bryanbrattlofDaniel Lezcano
authored andcommitted
thermal/drivers/k3_j72xx_bandgap: Map fuse_base only for erratum workaround
Some of TI's J721E SoCs require a software trimming procedure for the temperature monitors to function properly. To determine if a particular J721E is not affected by this erratum, both bits in the WKUP_SPARE_FUSE0 region must be set. Other SoCs, not affected by this erratum, will not need this region. Map the 'fuse_base' region only when the erratum fix is needed. Signed-off-by: Bryan Brattlof <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent 156f0e2 commit 366444e

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

drivers/thermal/k3_j72xx_bandgap.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,32 @@ static int k3_j72xx_bandgap_probe(struct platform_device *pdev)
386386
if (IS_ERR(bgp->cfg2_base))
387387
return PTR_ERR(bgp->cfg2_base);
388388

389-
res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
390-
fuse_base = devm_ioremap_resource(dev, res);
391-
if (IS_ERR(fuse_base))
392-
return PTR_ERR(fuse_base);
393-
394389
driver_data = of_device_get_match_data(dev);
395390
if (driver_data)
396391
workaround_needed = driver_data->has_errata_i2128;
397392

393+
/*
394+
* Some of TI's J721E SoCs require a software trimming procedure
395+
* for the temperature monitors to function properly. To determine
396+
* if this particular SoC is NOT affected, both bits in the
397+
* WKUP_SPARE_FUSE0[31:30] will be set (0xC0000000) indicating
398+
* when software trimming should NOT be applied.
399+
*
400+
* https://www.ti.com/lit/er/sprz455c/sprz455c.pdf
401+
*/
402+
if (workaround_needed) {
403+
res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
404+
fuse_base = devm_ioremap_resource(dev, res);
405+
if (IS_ERR(fuse_base))
406+
return PTR_ERR(fuse_base);
407+
408+
if ((readl(fuse_base) & 0xc0000000) == 0xc0000000)
409+
workaround_needed = false;
410+
}
411+
412+
dev_dbg(bgp->dev, "Work around %sneeded\n",
413+
workaround_needed ? "" : "not ");
414+
398415
pm_runtime_enable(dev);
399416
ret = pm_runtime_get_sync(dev);
400417
if (ret < 0) {
@@ -427,13 +444,6 @@ static int k3_j72xx_bandgap_probe(struct platform_device *pdev)
427444
goto err_free_ref_table;
428445
}
429446

430-
/* Workaround not needed if bit30/bit31 is set even for J721e */
431-
if (workaround_needed && (readl(fuse_base + 0x0) & 0xc0000000) == 0xc0000000)
432-
workaround_needed = false;
433-
434-
dev_dbg(bgp->dev, "Work around %sneeded\n",
435-
workaround_needed ? "" : "not ");
436-
437447
if (!workaround_needed)
438448
init_table(5, ref_table, golden_factors);
439449
else

0 commit comments

Comments
 (0)