All of lore.kernel.org
 help / color / mirror / Atom feed
* [v2 PATCH] thermal: rcar_gen3_thermal: Add Standby/Reset Mode support
@ 2018-11-06  6:08 Nguyen An Hoan
  2019-04-11 19:45 ` Niklas Söderlund
  0 siblings, 1 reply; 3+ messages in thread
From: Nguyen An Hoan @ 2018-11-06  6:08 UTC (permalink / raw)
  To: linux-renesas-soc, geert+renesas, wsa
  Cc: niklas.soderlund, kuninori.morimoto.gx, yoshihiro.shimoda.uh,
	h-inayoshi, nv-dung, na-hoan, cv-dong

From: Hoan Nguyen An <na-hoan@jinso.co.jp>

According to the hardware manual, Gen3 supports Standby/Reset mode.
Add this function, and we should use this function while suspend
to reduce the energy consumption.

Signed-off-by: Hoan Nguyen An <na-hoan@jinso.co.jp>
---
 drivers/thermal/rcar_gen3_thermal.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c
index 7aed533..e654519 100644
--- a/drivers/thermal/rcar_gen3_thermal.c
+++ b/drivers/thermal/rcar_gen3_thermal.c
@@ -447,11 +447,32 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
 	return ret;
 }
 
+static int rcar_gen3_thermal_reset(struct rcar_gen3_thermal_priv* priv)
+{
+	unsigned int i;
+	u32 reg_val;
+
+	for (i = 0; i < priv->num_tscs; i++) {
+		struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i];
+
+		rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN, 0);
+		rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0);
+
+		reg_val = rcar_gen3_thermal_read(tsc, REG_GEN3_THCTR);
+		rcar_gen3_thermal_write(tsc, REG_GEN3_THCTR, reg_val & ~THCTR_THSST);
+	}
+
+	usleep_range(1000, 2000);
+
+	return 0;
+}
+
 static int __maybe_unused rcar_gen3_thermal_suspend(struct device *dev)
 {
 	struct rcar_gen3_thermal_priv *priv = dev_get_drvdata(dev);
 
-	rcar_thermal_irq_set(priv, false);
+	/* Reset to enter standby mode */
+	rcar_gen3_thermal_reset(priv);
 
 	return 0;
 }
-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [v2 PATCH] thermal: rcar_gen3_thermal: Add Standby/Reset Mode support
  2018-11-06  6:08 [v2 PATCH] thermal: rcar_gen3_thermal: Add Standby/Reset Mode support Nguyen An Hoan
@ 2019-04-11 19:45 ` Niklas Söderlund
  2019-04-16  3:16   ` Hoan
  0 siblings, 1 reply; 3+ messages in thread
From: Niklas Söderlund @ 2019-04-11 19:45 UTC (permalink / raw)
  To: Nguyen An Hoan
  Cc: linux-renesas-soc, geert+renesas, wsa, kuninori.morimoto.gx,
	yoshihiro.shimoda.uh, h-inayoshi, nv-dung, cv-dong

Hi Hoan,

Thanks for your work.

Sorry for very late review, somehow this got lost in my inbox.

On 2018-11-06 15:08:26 +0900, Nguyen An Hoan wrote:
> From: Hoan Nguyen An <na-hoan@jinso.co.jp>
> 
> According to the hardware manual, Gen3 supports Standby/Reset mode.
> Add this function, and we should use this function while suspend
> to reduce the energy consumption.
> 
> Signed-off-by: Hoan Nguyen An <na-hoan@jinso.co.jp>

Nice clean commit and matches the datasheet,

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Interrupts fire both before and after suspending as expected,

Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
>  drivers/thermal/rcar_gen3_thermal.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c
> index 7aed533..e654519 100644
> --- a/drivers/thermal/rcar_gen3_thermal.c
> +++ b/drivers/thermal/rcar_gen3_thermal.c
> @@ -447,11 +447,32 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
>  	return ret;
>  }
>  
> +static int rcar_gen3_thermal_reset(struct rcar_gen3_thermal_priv* priv)
> +{
> +	unsigned int i;
> +	u32 reg_val;
> +
> +	for (i = 0; i < priv->num_tscs; i++) {
> +		struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i];
> +
> +		rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN, 0);
> +		rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0);
> +
> +		reg_val = rcar_gen3_thermal_read(tsc, REG_GEN3_THCTR);
> +		rcar_gen3_thermal_write(tsc, REG_GEN3_THCTR, reg_val & ~THCTR_THSST);
> +	}
> +
> +	usleep_range(1000, 2000);
> +
> +	return 0;
> +}
> +
>  static int __maybe_unused rcar_gen3_thermal_suspend(struct device *dev)
>  {
>  	struct rcar_gen3_thermal_priv *priv = dev_get_drvdata(dev);
>  
> -	rcar_thermal_irq_set(priv, false);
> +	/* Reset to enter standby mode */
> +	rcar_gen3_thermal_reset(priv);
>  
>  	return 0;
>  }
> -- 
> 2.7.4
> 

-- 
Regards,
Niklas Söderlund

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [v2 PATCH] thermal: rcar_gen3_thermal: Add Standby/Reset Mode support
  2019-04-11 19:45 ` Niklas Söderlund
@ 2019-04-16  3:16   ` Hoan
  0 siblings, 0 replies; 3+ messages in thread
From: Hoan @ 2019-04-16  3:16 UTC (permalink / raw)
  To: Niklas Söderlund, Zhang Rui, edubezval, Daniel Lezcano
  Cc: linux-renesas-soc, geert+renesas, wsa, kuninori.morimoto.gx,
	yoshihiro.shimoda.uh, h-inayoshi, nv-dung, cv-dong

Dear Niklas-san

Always thanks for your helps!


Sorry for forgetting CC maintainer. CC Maintainers!

On 2019/04/12 4:45, Niklas Söderlund wrote:
> Hi Hoan,
>
> Thanks for your work.
>
> Sorry for very late review, somehow this got lost in my inbox.
>
> On 2018-11-06 15:08:26 +0900, Nguyen An Hoan wrote:
>> From: Hoan Nguyen An <na-hoan@jinso.co.jp>
>>
>> According to the hardware manual, Gen3 supports Standby/Reset mode.
>> Add this function, and we should use this function while suspend
>> to reduce the energy consumption.
>>
>> Signed-off-by: Hoan Nguyen An <na-hoan@jinso.co.jp>
> Nice clean commit and matches the datasheet,
>
> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>
> Interrupts fire both before and after suspending as expected,
>
> Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>
>> ---
>>   drivers/thermal/rcar_gen3_thermal.c | 23 ++++++++++++++++++++++-
>>   1 file changed, 22 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c
>> index 7aed533..e654519 100644
>> --- a/drivers/thermal/rcar_gen3_thermal.c
>> +++ b/drivers/thermal/rcar_gen3_thermal.c
>> @@ -447,11 +447,32 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
>>   	return ret;
>>   }
>>   
>> +static int rcar_gen3_thermal_reset(struct rcar_gen3_thermal_priv* priv)
>> +{
>> +	unsigned int i;
>> +	u32 reg_val;
>> +
>> +	for (i = 0; i < priv->num_tscs; i++) {
>> +		struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i];
>> +
>> +		rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN, 0);
>> +		rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0);
>> +
>> +		reg_val = rcar_gen3_thermal_read(tsc, REG_GEN3_THCTR);
>> +		rcar_gen3_thermal_write(tsc, REG_GEN3_THCTR, reg_val & ~THCTR_THSST);
>> +	}
>> +
>> +	usleep_range(1000, 2000);
>> +
>> +	return 0;
>> +}
>> +
>>   static int __maybe_unused rcar_gen3_thermal_suspend(struct device *dev)
>>   {
>>   	struct rcar_gen3_thermal_priv *priv = dev_get_drvdata(dev);
>>   
>> -	rcar_thermal_irq_set(priv, false);
>> +	/* Reset to enter standby mode */
>> +	rcar_gen3_thermal_reset(priv);
>>   
>>   	return 0;
>>   }
>> -- 
>> 2.7.4
>>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-16  3:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-06  6:08 [v2 PATCH] thermal: rcar_gen3_thermal: Add Standby/Reset Mode support Nguyen An Hoan
2019-04-11 19:45 ` Niklas Söderlund
2019-04-16  3:16   ` Hoan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.