Skip to content

Commit 34b9a92

Browse files
Priyansh Jaindlezcano
authored andcommitted
thermal/drivers/tsens: Add suspend to RAM support for tsens
As part of suspend to RAM, tsens hardware will be turned off. While resume callback, re-initialize tsens hardware. Signed-off-by: Priyansh Jain <[email protected]> Acked-by: Amit Kucheria <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ff96922 commit 34b9a92

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

drivers/thermal/qcom/tsens-v2.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ static const struct reg_field tsens_v2_regfields[MAX_REGFIELDS] = {
107107
static const struct tsens_ops ops_generic_v2 = {
108108
.init = init_common,
109109
.get_temp = get_temp_tsens_valid,
110+
.resume = tsens_resume_common,
110111
};
111112

112113
struct tsens_plat_data data_tsens_v2 = {

drivers/thermal/qcom/tsens.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/pm.h>
1818
#include <linux/regmap.h>
1919
#include <linux/slab.h>
20+
#include <linux/suspend.h>
2021
#include <linux/thermal.h>
2122
#include "../thermal_hwmon.h"
2223
#include "tsens.h"
@@ -1193,6 +1194,36 @@ static int tsens_register_irq(struct tsens_priv *priv, char *irqname,
11931194
return ret;
11941195
}
11951196

1197+
#ifdef CONFIG_SUSPEND
1198+
static int tsens_reinit(struct tsens_priv *priv)
1199+
{
1200+
if (tsens_version(priv) >= VER_2_X) {
1201+
/*
1202+
* Re-enable the watchdog, unmask the bark.
1203+
* Disable cycle completion monitoring
1204+
*/
1205+
if (priv->feat->has_watchdog) {
1206+
regmap_field_write(priv->rf[WDOG_BARK_MASK], 0);
1207+
regmap_field_write(priv->rf[CC_MON_MASK], 1);
1208+
}
1209+
1210+
/* Re-enable interrupts */
1211+
tsens_enable_irq(priv);
1212+
}
1213+
1214+
return 0;
1215+
}
1216+
1217+
int tsens_resume_common(struct tsens_priv *priv)
1218+
{
1219+
if (pm_suspend_target_state == PM_SUSPEND_MEM)
1220+
tsens_reinit(priv);
1221+
1222+
return 0;
1223+
}
1224+
1225+
#endif /* !CONFIG_SUSPEND */
1226+
11961227
static int tsens_register(struct tsens_priv *priv)
11971228
{
11981229
int i, ret;

drivers/thermal/qcom/tsens.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,11 @@ void compute_intercept_slope(struct tsens_priv *priv, u32 *pt1, u32 *pt2, u32 mo
634634
int init_common(struct tsens_priv *priv);
635635
int get_temp_tsens_valid(const struct tsens_sensor *s, int *temp);
636636
int get_temp_common(const struct tsens_sensor *s, int *temp);
637+
#ifdef CONFIG_SUSPEND
638+
int tsens_resume_common(struct tsens_priv *priv);
639+
#else
640+
#define tsens_resume_common NULL
641+
#endif
637642

638643
/* TSENS target */
639644
extern struct tsens_plat_data data_8960;

0 commit comments

Comments
 (0)