Skip to content

Commit 75f78d6

Browse files
Niklas SöderlundEduardo Valentin
authored andcommitted
thermal: rcar_gen3_thermal: add suspend and resume support
To restore operation it's easiest to reinitialise all TSCs. In order to do this the current trip window needs to be stored in the TSC structure so that it can be restored upon resume. Signed-off-by: Niklas Söderlund <[email protected]> Reviewed-by: Wolfram Sang <[email protected]> Signed-off-by: Eduardo Valentin <[email protected]>
1 parent cc4d072 commit 75f78d6

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

drivers/thermal/rcar_gen3_thermal.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ struct rcar_gen3_thermal_tsc {
8282
void __iomem *base;
8383
struct thermal_zone_device *zone;
8484
struct equation_coefs coef;
85+
int low;
86+
int high;
8587
};
8688

8789
struct rcar_gen3_thermal_priv {
@@ -217,6 +219,9 @@ static int rcar_gen3_thermal_set_trips(void *devdata, int low, int high)
217219
rcar_gen3_thermal_write(tsc, REG_GEN3_IRQTEMP2,
218220
rcar_gen3_thermal_mcelsius_to_temp(tsc, high));
219221

222+
tsc->low = low;
223+
tsc->high = high;
224+
220225
return 0;
221226
}
222227

@@ -454,9 +459,39 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
454459
return ret;
455460
}
456461

462+
static int __maybe_unused rcar_gen3_thermal_suspend(struct device *dev)
463+
{
464+
struct rcar_gen3_thermal_priv *priv = dev_get_drvdata(dev);
465+
466+
rcar_thermal_irq_set(priv, false);
467+
468+
return 0;
469+
}
470+
471+
static int __maybe_unused rcar_gen3_thermal_resume(struct device *dev)
472+
{
473+
struct rcar_gen3_thermal_priv *priv = dev_get_drvdata(dev);
474+
unsigned int i;
475+
476+
for (i = 0; i < priv->num_tscs; i++) {
477+
struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i];
478+
479+
priv->data->thermal_init(tsc);
480+
rcar_gen3_thermal_set_trips(tsc, tsc->low, tsc->high);
481+
}
482+
483+
rcar_thermal_irq_set(priv, true);
484+
485+
return 0;
486+
}
487+
488+
static SIMPLE_DEV_PM_OPS(rcar_gen3_thermal_pm_ops, rcar_gen3_thermal_suspend,
489+
rcar_gen3_thermal_resume);
490+
457491
static struct platform_driver rcar_gen3_thermal_driver = {
458492
.driver = {
459493
.name = "rcar_gen3_thermal",
494+
.pm = &rcar_gen3_thermal_pm_ops,
460495
.of_match_table = rcar_gen3_thermal_dt_ids,
461496
},
462497
.probe = rcar_gen3_thermal_probe,

0 commit comments

Comments
 (0)