Skip to content

Commit

Permalink
thermal: rcar_gen3_thermal: Correct the order of checking THSCP
Browse files Browse the repository at this point in the history
Currently, Software Correction Parameter (THSCP) Register cannot be read
before pm_runtime_get_sync(), so even if FUSE values are available, they
cannot be fetched from this registers and pseudo values are used instead

This patch corrects the order of checking THSCP register:
- These register values are read in case of Thermal sensor is A type
- Read function has to be placed after turning on power domains
  Otherwise, values of this register are not guaranteed
- If FUSE values are available, they can be retrieved correctly now

Signed-off-by: Tien Dao <[email protected]>
  • Loading branch information
tienminhdao authored and linhphungjy committed May 6, 2020
1 parent e0a66c0 commit 2a2e9d9
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions drivers/thermal/rcar_gen3_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,33 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
priv->thermal_init = rcar_gen3_thermal_init_r8a77990;
}

platform_set_drvdata(pdev, priv);

/*
* Request 2 (of the 3 possible) IRQs, the driver only needs to
* to trigger on the low and high trip points of the current
* temp window at this point.
*/
for (i = 0; i < 2; i++) {
irq = platform_get_irq(pdev, i);
if (irq < 0)
return irq;

irqname = devm_kasprintf(dev, GFP_KERNEL, "%s:ch%d",
dev_name(dev), i);
if (!irqname)
return -ENOMEM;

ret = devm_request_threaded_irq(dev, irq, NULL,
rcar_gen3_thermal_irq,
IRQF_ONESHOT, irqname, priv);
if (ret)
return ret;
}

pm_runtime_enable(dev);
pm_runtime_get_sync(dev);

if (is_ths_typeA) {
/* Use FUSE default values if they are missing.
* If not, fetch them from registers.
Expand Down Expand Up @@ -573,34 +600,6 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
iounmap(ptat_base);
}


platform_set_drvdata(pdev, priv);

/*
* Request 2 (of the 3 possible) IRQs, the driver only needs to
* to trigger on the low and high trip points of the current
* temp window at this point.
*/
for (i = 0; i < 2; i++) {
irq = platform_get_irq(pdev, i);
if (irq < 0)
return irq;

irqname = devm_kasprintf(dev, GFP_KERNEL, "%s:ch%d",
dev_name(dev), i);
if (!irqname)
return -ENOMEM;

ret = devm_request_threaded_irq(dev, irq, NULL,
rcar_gen3_thermal_irq,
IRQF_ONESHOT, irqname, priv);
if (ret)
return ret;
}

pm_runtime_enable(dev);
pm_runtime_get_sync(dev);

for (i = 0; i < TSC_MAX_NUM; i++) {
struct rcar_gen3_thermal_tsc *tsc;

Expand Down

0 comments on commit 2a2e9d9

Please sign in to comment.