Re: [PATCH] thermal/drivers/tsens: Add suspend to RAM support for tsens

From: Priyansh Jain
Date: Wed Jan 24 2024 - 05:43:25 EST




On 1/22/2024 8:02 PM, Konrad Dybcio wrote:
On 22.01.2024 11:07, Priyansh Jain wrote:
Add suspend callback support for tsens which disables tsens interrupts
in suspend to RAM callback.

Would it not be preferrable to have the "critical overheat", wakeup-
capable interrupts be enabled, even if the system is suspended?



As part of suspend to RAM, tsens hardware will be turned off and it cannot generate any interrupt.Also system doesn't want to abort suspend to RAM due to tsens interrupts since system is already going into lowest
power state. Hence disabling tsens interrupt during suspend to RAM callback.

Regards,
Priyansh

Add resume callback support for tsens which reinitializes tsens hardware
and enables back tsens interrupts in resume callback.

Signed-off-by: Priyansh Jain <quic_priyjain@xxxxxxxxxxx>
---

[...]


+
+int tsens_suspend_common(struct tsens_priv *priv)
+{
+ switch (pm_suspend_target_state) {
+ case PM_SUSPEND_MEM:
+ if (priv->combo_irq > 0) {
+ disable_irq_nosync(priv->combo_irq);
+ disable_irq_wake(priv->combo_irq);
+ }
+
+ if (priv->uplow_irq > 0) {
+ disable_irq_nosync(priv->uplow_irq);
+ disable_irq_wake(priv->uplow_irq);
+ }
+
+ if (priv->crit_irq > 0) {
+ disable_irq_nosync(priv->crit_irq);
+ disable_irq_wake(priv->crit_irq);
+ }
+ break;
+ default:
+ break;
+ }

if (pm_suspend_target_state != PM_SUSPEND_MEM)
return 0;

<rest of the code>

[...]

+ /* For saving irq number to re-use later */

This is rather self-explanatory

Konrad