All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] mfd: rk808: Prepare rk805 for poweroff
@ 2018-10-02  7:38 ` Stefan Mavrodiev
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Mavrodiev @ 2018-10-02  7:38 UTC (permalink / raw)
  To: Heiko Stuebner, linux-rockchip, Lee Jones, open list; +Cc: Stefan Mavrodiev

RK805 has SLEEP signal, which can put the device into SLEEP or OFF
mode. The default is SLEEP mode.

However, when the kernel performs power-off (actually the ATF) the
device will not go fully off and this will result in higher power
consumption and inability to wake the device with RTC alarm.

The solution is to enable pm_power_off_prepare function, which will
configure SLEEP pin for OFF function.

Signed-off-by: Stefan Mavrodiev <stefan@olimex.com>
---
 drivers/mfd/rk808.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 216fbf6..50f3f78 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -387,6 +387,25 @@ static void rk805_device_shutdown(void)
 		dev_err(&rk808_i2c_client->dev, "power off error!\n");
 }
 
+static void rk805_device_shutdown_prepare(void)
+{
+	int ret;
+	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
+
+	if (!rk808) {
+		dev_warn(&rk808_i2c_client->dev,
+			 "have no rk805, so do nothing here\n");
+
+		return;
+	}
+
+	ret = regmap_update_bits(rk808->regmap,
+				 RK805_GPIO_IO_POL_REG,
+				 SLP_SD_MSK, SHUTDOWN_FUN);
+	if (ret)
+		dev_err(&rk808_i2c_client->dev, "power off error!\n");
+}
+
 static void rk808_device_shutdown(void)
 {
 	int ret;
@@ -549,6 +568,10 @@ static int rk808_probe(struct i2c_client *client,
 	if (pm_off && !pm_power_off) {
 		rk808_i2c_client = client;
 		pm_power_off = pm_pwroff_fn;
+	} else if (pm_off && !pm_power_off_prepare &&
+		   rk808->variant == RK805_ID) {
+		rk808_i2c_client = client;
+		pm_power_off_prepare = rk805_device_shutdown_prepare;
 	}
 
 	return 0;
@@ -564,6 +587,7 @@ static int rk808_remove(struct i2c_client *client)
 
 	regmap_del_irq_chip(client->irq, rk808->irq_data);
 	pm_power_off = NULL;
+	pm_power_off_prepare = NULL;
 
 	return 0;
 }
-- 
2.7.4


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

* [PATCH 1/1] mfd: rk808: Prepare rk805 for poweroff
@ 2018-10-02  7:38 ` Stefan Mavrodiev
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Mavrodiev @ 2018-10-02  7:38 UTC (permalink / raw)
  To: Heiko Stuebner, linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	Lee Jones, open list
  Cc: Stefan Mavrodiev

RK805 has SLEEP signal, which can put the device into SLEEP or OFF
mode. The default is SLEEP mode.

However, when the kernel performs power-off (actually the ATF) the
device will not go fully off and this will result in higher power
consumption and inability to wake the device with RTC alarm.

The solution is to enable pm_power_off_prepare function, which will
configure SLEEP pin for OFF function.

Signed-off-by: Stefan Mavrodiev <stefan-kyXcfZUBQGPQT0dZR+AlfA@public.gmane.org>
---
 drivers/mfd/rk808.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 216fbf6..50f3f78 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -387,6 +387,25 @@ static void rk805_device_shutdown(void)
 		dev_err(&rk808_i2c_client->dev, "power off error!\n");
 }
 
+static void rk805_device_shutdown_prepare(void)
+{
+	int ret;
+	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
+
+	if (!rk808) {
+		dev_warn(&rk808_i2c_client->dev,
+			 "have no rk805, so do nothing here\n");
+
+		return;
+	}
+
+	ret = regmap_update_bits(rk808->regmap,
+				 RK805_GPIO_IO_POL_REG,
+				 SLP_SD_MSK, SHUTDOWN_FUN);
+	if (ret)
+		dev_err(&rk808_i2c_client->dev, "power off error!\n");
+}
+
 static void rk808_device_shutdown(void)
 {
 	int ret;
@@ -549,6 +568,10 @@ static int rk808_probe(struct i2c_client *client,
 	if (pm_off && !pm_power_off) {
 		rk808_i2c_client = client;
 		pm_power_off = pm_pwroff_fn;
+	} else if (pm_off && !pm_power_off_prepare &&
+		   rk808->variant == RK805_ID) {
+		rk808_i2c_client = client;
+		pm_power_off_prepare = rk805_device_shutdown_prepare;
 	}
 
 	return 0;
@@ -564,6 +587,7 @@ static int rk808_remove(struct i2c_client *client)
 
 	regmap_del_irq_chip(client->irq, rk808->irq_data);
 	pm_power_off = NULL;
+	pm_power_off_prepare = NULL;
 
 	return 0;
 }
-- 
2.7.4

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

* Re: [PATCH 1/1] mfd: rk808: Prepare rk805 for poweroff
  2018-10-02  7:38 ` Stefan Mavrodiev
  (?)
@ 2019-01-09 13:07 ` Heiko Stübner
  2019-01-09 13:10   ` Stefan Mavrodiev
  -1 siblings, 1 reply; 8+ messages in thread
From: Heiko Stübner @ 2019-01-09 13:07 UTC (permalink / raw)
  To: Stefan Mavrodiev; +Cc: linux-rockchip, Lee Jones, open list

Hi Stefan, Lee,

Am Dienstag, 2. Oktober 2018, 09:38:29 CET schrieb Stefan Mavrodiev:
> RK805 has SLEEP signal, which can put the device into SLEEP or OFF
> mode. The default is SLEEP mode.
> 
> However, when the kernel performs power-off (actually the ATF) the
> device will not go fully off and this will result in higher power
> consumption and inability to wake the device with RTC alarm.
> 
> The solution is to enable pm_power_off_prepare function, which will
> configure SLEEP pin for OFF function.
> 
> Signed-off-by: Stefan Mavrodiev <stefan@olimex.com>

just found this while cleaning my inbox and this change looks
significant and it seems hasn't been applied yet.

I guess this is still relevant, right?


Heiko

> ---
>  drivers/mfd/rk808.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
> index 216fbf6..50f3f78 100644
> --- a/drivers/mfd/rk808.c
> +++ b/drivers/mfd/rk808.c
> @@ -387,6 +387,25 @@ static void rk805_device_shutdown(void)
>  		dev_err(&rk808_i2c_client->dev, "power off error!\n");
>  }
> 
> +static void rk805_device_shutdown_prepare(void)
> +{
> +	int ret;
> +	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
> +
> +	if (!rk808) {
> +		dev_warn(&rk808_i2c_client->dev,
> +			 "have no rk805, so do nothing here\n");
> +
> +		return;
> +	}
> +
> +	ret = regmap_update_bits(rk808->regmap,
> +				 RK805_GPIO_IO_POL_REG,
> +				 SLP_SD_MSK, SHUTDOWN_FUN);
> +	if (ret)
> +		dev_err(&rk808_i2c_client->dev, "power off error!\n");
> +}
> +
>  static void rk808_device_shutdown(void)
>  {
>  	int ret;
> @@ -549,6 +568,10 @@ static int rk808_probe(struct i2c_client *client,
>  	if (pm_off && !pm_power_off) {
>  		rk808_i2c_client = client;
>  		pm_power_off = pm_pwroff_fn;
> +	} else if (pm_off && !pm_power_off_prepare &&
> +		   rk808->variant == RK805_ID) {
> +		rk808_i2c_client = client;
> +		pm_power_off_prepare = rk805_device_shutdown_prepare;
>  	}
> 
>  	return 0;
> @@ -564,6 +587,7 @@ static int rk808_remove(struct i2c_client *client)
> 
>  	regmap_del_irq_chip(client->irq, rk808->irq_data);
>  	pm_power_off = NULL;
> +	pm_power_off_prepare = NULL;
> 
>  	return 0;
>  }





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

* Re: [PATCH 1/1] mfd: rk808: Prepare rk805 for poweroff
  2019-01-09 13:07 ` Heiko Stübner
@ 2019-01-09 13:10   ` Stefan Mavrodiev
  2019-01-09 13:11       ` Heiko Stübner
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Mavrodiev @ 2019-01-09 13:10 UTC (permalink / raw)
  To: Heiko Stübner, Stefan Mavrodiev; +Cc: linux-rockchip, Lee Jones, open list


On 1/9/19 3:07 PM, Heiko Stübner wrote:
> Hi Stefan, Lee,
>
> Am Dienstag, 2. Oktober 2018, 09:38:29 CET schrieb Stefan Mavrodiev:
>> RK805 has SLEEP signal, which can put the device into SLEEP or OFF
>> mode. The default is SLEEP mode.
>>
>> However, when the kernel performs power-off (actually the ATF) the
>> device will not go fully off and this will result in higher power
>> consumption and inability to wake the device with RTC alarm.
>>
>> The solution is to enable pm_power_off_prepare function, which will
>> configure SLEEP pin for OFF function.
>>
>> Signed-off-by: Stefan Mavrodiev <stefan@olimex.com>
> just found this while cleaning my inbox and this change looks
> significant and it seems hasn't been applied yet.
>
> I guess this is still relevant, right?

Yes, but I guess it's out-of-sync with the latest kernel.

>
>
> Heiko
>
>> ---
>>   drivers/mfd/rk808.c | 24 ++++++++++++++++++++++++
>>   1 file changed, 24 insertions(+)
>>
>> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
>> index 216fbf6..50f3f78 100644
>> --- a/drivers/mfd/rk808.c
>> +++ b/drivers/mfd/rk808.c
>> @@ -387,6 +387,25 @@ static void rk805_device_shutdown(void)
>>   		dev_err(&rk808_i2c_client->dev, "power off error!\n");
>>   }
>>
>> +static void rk805_device_shutdown_prepare(void)
>> +{
>> +	int ret;
>> +	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
>> +
>> +	if (!rk808) {
>> +		dev_warn(&rk808_i2c_client->dev,
>> +			 "have no rk805, so do nothing here\n");
>> +
>> +		return;
>> +	}
>> +
>> +	ret = regmap_update_bits(rk808->regmap,
>> +				 RK805_GPIO_IO_POL_REG,
>> +				 SLP_SD_MSK, SHUTDOWN_FUN);
>> +	if (ret)
>> +		dev_err(&rk808_i2c_client->dev, "power off error!\n");
>> +}
>> +
>>   static void rk808_device_shutdown(void)
>>   {
>>   	int ret;
>> @@ -549,6 +568,10 @@ static int rk808_probe(struct i2c_client *client,
>>   	if (pm_off && !pm_power_off) {
>>   		rk808_i2c_client = client;
>>   		pm_power_off = pm_pwroff_fn;
>> +	} else if (pm_off && !pm_power_off_prepare &&
>> +		   rk808->variant == RK805_ID) {
>> +		rk808_i2c_client = client;
>> +		pm_power_off_prepare = rk805_device_shutdown_prepare;
>>   	}
>>
>>   	return 0;
>> @@ -564,6 +587,7 @@ static int rk808_remove(struct i2c_client *client)
>>
>>   	regmap_del_irq_chip(client->irq, rk808->irq_data);
>>   	pm_power_off = NULL;
>> +	pm_power_off_prepare = NULL;
>>
>>   	return 0;
>>   }
>
>
>

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

* Re: [PATCH 1/1] mfd: rk808: Prepare rk805 for poweroff
@ 2019-01-09 13:11       ` Heiko Stübner
  0 siblings, 0 replies; 8+ messages in thread
From: Heiko Stübner @ 2019-01-09 13:11 UTC (permalink / raw)
  To: Stefan Mavrodiev; +Cc: Stefan Mavrodiev, linux-rockchip, Lee Jones, open list

Am Mittwoch, 9. Januar 2019, 14:10:34 CET schrieb Stefan Mavrodiev:
> On 1/9/19 3:07 PM, Heiko Stübner wrote:
> > Hi Stefan, Lee,
> > 
> > Am Dienstag, 2. Oktober 2018, 09:38:29 CET schrieb Stefan Mavrodiev:
> >> RK805 has SLEEP signal, which can put the device into SLEEP or OFF
> >> mode. The default is SLEEP mode.
> >> 
> >> However, when the kernel performs power-off (actually the ATF) the
> >> device will not go fully off and this will result in higher power
> >> consumption and inability to wake the device with RTC alarm.
> >> 
> >> The solution is to enable pm_power_off_prepare function, which will
> >> configure SLEEP pin for OFF function.
> >> 
> >> Signed-off-by: Stefan Mavrodiev <stefan@olimex.com>
> > 
> > just found this while cleaning my inbox and this change looks
> > significant and it seems hasn't been applied yet.
> > 
> > I guess this is still relevant, right?
> 
> Yes, but I guess it's out-of-sync with the latest kernel.

you could rebase and resend it :-)


> >> ---
> >> 
> >>   drivers/mfd/rk808.c | 24 ++++++++++++++++++++++++
> >>   1 file changed, 24 insertions(+)
> >> 
> >> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
> >> index 216fbf6..50f3f78 100644
> >> --- a/drivers/mfd/rk808.c
> >> +++ b/drivers/mfd/rk808.c
> >> @@ -387,6 +387,25 @@ static void rk805_device_shutdown(void)
> >> 
> >>   		dev_err(&rk808_i2c_client->dev, "power off error!\n");
> >>   
> >>   }
> >> 
> >> +static void rk805_device_shutdown_prepare(void)
> >> +{
> >> +	int ret;
> >> +	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
> >> +
> >> +	if (!rk808) {
> >> +		dev_warn(&rk808_i2c_client->dev,
> >> +			 "have no rk805, so do nothing here\n");
> >> +
> >> +		return;
> >> +	}
> >> +
> >> +	ret = regmap_update_bits(rk808->regmap,
> >> +				 RK805_GPIO_IO_POL_REG,
> >> +				 SLP_SD_MSK, SHUTDOWN_FUN);
> >> +	if (ret)
> >> +		dev_err(&rk808_i2c_client->dev, "power off error!\n");
> >> +}
> >> +
> >> 
> >>   static void rk808_device_shutdown(void)
> >>   {
> >>   
> >>   	int ret;
> >> 
> >> @@ -549,6 +568,10 @@ static int rk808_probe(struct i2c_client *client,
> >> 
> >>   	if (pm_off && !pm_power_off) {
> >>   	
> >>   		rk808_i2c_client = client;
> >>   		pm_power_off = pm_pwroff_fn;
> >> 
> >> +	} else if (pm_off && !pm_power_off_prepare &&
> >> +		   rk808->variant == RK805_ID) {
> >> +		rk808_i2c_client = client;
> >> +		pm_power_off_prepare = rk805_device_shutdown_prepare;
> >> 
> >>   	}
> >>   	
> >>   	return 0;
> >> 
> >> @@ -564,6 +587,7 @@ static int rk808_remove(struct i2c_client *client)
> >> 
> >>   	regmap_del_irq_chip(client->irq, rk808->irq_data);
> >>   	pm_power_off = NULL;
> >> 
> >> +	pm_power_off_prepare = NULL;
> >> 
> >>   	return 0;
> >>   
> >>   }





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

* Re: [PATCH 1/1] mfd: rk808: Prepare rk805 for poweroff
@ 2019-01-09 13:11       ` Heiko Stübner
  0 siblings, 0 replies; 8+ messages in thread
From: Heiko Stübner @ 2019-01-09 13:11 UTC (permalink / raw)
  To: Stefan Mavrodiev
  Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Lee Jones,
	open list, Stefan Mavrodiev

Am Mittwoch, 9. Januar 2019, 14:10:34 CET schrieb Stefan Mavrodiev:
> On 1/9/19 3:07 PM, Heiko Stübner wrote:
> > Hi Stefan, Lee,
> > 
> > Am Dienstag, 2. Oktober 2018, 09:38:29 CET schrieb Stefan Mavrodiev:
> >> RK805 has SLEEP signal, which can put the device into SLEEP or OFF
> >> mode. The default is SLEEP mode.
> >> 
> >> However, when the kernel performs power-off (actually the ATF) the
> >> device will not go fully off and this will result in higher power
> >> consumption and inability to wake the device with RTC alarm.
> >> 
> >> The solution is to enable pm_power_off_prepare function, which will
> >> configure SLEEP pin for OFF function.
> >> 
> >> Signed-off-by: Stefan Mavrodiev <stefan-kyXcfZUBQGPQT0dZR+AlfA@public.gmane.org>
> > 
> > just found this while cleaning my inbox and this change looks
> > significant and it seems hasn't been applied yet.
> > 
> > I guess this is still relevant, right?
> 
> Yes, but I guess it's out-of-sync with the latest kernel.

you could rebase and resend it :-)


> >> ---
> >> 
> >>   drivers/mfd/rk808.c | 24 ++++++++++++++++++++++++
> >>   1 file changed, 24 insertions(+)
> >> 
> >> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
> >> index 216fbf6..50f3f78 100644
> >> --- a/drivers/mfd/rk808.c
> >> +++ b/drivers/mfd/rk808.c
> >> @@ -387,6 +387,25 @@ static void rk805_device_shutdown(void)
> >> 
> >>   		dev_err(&rk808_i2c_client->dev, "power off error!\n");
> >>   
> >>   }
> >> 
> >> +static void rk805_device_shutdown_prepare(void)
> >> +{
> >> +	int ret;
> >> +	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
> >> +
> >> +	if (!rk808) {
> >> +		dev_warn(&rk808_i2c_client->dev,
> >> +			 "have no rk805, so do nothing here\n");
> >> +
> >> +		return;
> >> +	}
> >> +
> >> +	ret = regmap_update_bits(rk808->regmap,
> >> +				 RK805_GPIO_IO_POL_REG,
> >> +				 SLP_SD_MSK, SHUTDOWN_FUN);
> >> +	if (ret)
> >> +		dev_err(&rk808_i2c_client->dev, "power off error!\n");
> >> +}
> >> +
> >> 
> >>   static void rk808_device_shutdown(void)
> >>   {
> >>   
> >>   	int ret;
> >> 
> >> @@ -549,6 +568,10 @@ static int rk808_probe(struct i2c_client *client,
> >> 
> >>   	if (pm_off && !pm_power_off) {
> >>   	
> >>   		rk808_i2c_client = client;
> >>   		pm_power_off = pm_pwroff_fn;
> >> 
> >> +	} else if (pm_off && !pm_power_off_prepare &&
> >> +		   rk808->variant == RK805_ID) {
> >> +		rk808_i2c_client = client;
> >> +		pm_power_off_prepare = rk805_device_shutdown_prepare;
> >> 
> >>   	}
> >>   	
> >>   	return 0;
> >> 
> >> @@ -564,6 +587,7 @@ static int rk808_remove(struct i2c_client *client)
> >> 
> >>   	regmap_del_irq_chip(client->irq, rk808->irq_data);
> >>   	pm_power_off = NULL;
> >> 
> >> +	pm_power_off_prepare = NULL;
> >> 
> >>   	return 0;
> >>   
> >>   }

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

* Re: [PATCH 1/1] mfd: rk808: Prepare rk805 for poweroff
  2019-01-09 13:11       ` Heiko Stübner
@ 2019-01-09 13:15         ` Stefan Mavrodiev
  -1 siblings, 0 replies; 8+ messages in thread
From: Stefan Mavrodiev @ 2019-01-09 13:15 UTC (permalink / raw)
  To: Heiko Stübner; +Cc: Stefan Mavrodiev, linux-rockchip, Lee Jones, open list


On 1/9/19 3:11 PM, Heiko Stübner wrote:
> Am Mittwoch, 9. Januar 2019, 14:10:34 CET schrieb Stefan Mavrodiev:
>> On 1/9/19 3:07 PM, Heiko Stübner wrote:
>>> Hi Stefan, Lee,
>>>
>>> Am Dienstag, 2. Oktober 2018, 09:38:29 CET schrieb Stefan Mavrodiev:
>>>> RK805 has SLEEP signal, which can put the device into SLEEP or OFF
>>>> mode. The default is SLEEP mode.
>>>>
>>>> However, when the kernel performs power-off (actually the ATF) the
>>>> device will not go fully off and this will result in higher power
>>>> consumption and inability to wake the device with RTC alarm.
>>>>
>>>> The solution is to enable pm_power_off_prepare function, which will
>>>> configure SLEEP pin for OFF function.
>>>>
>>>> Signed-off-by: Stefan Mavrodiev <stefan@olimex.com>
>>> just found this while cleaning my inbox and this change looks
>>> significant and it seems hasn't been applied yet.
>>>
>>> I guess this is still relevant, right?
>> Yes, but I guess it's out-of-sync with the latest kernel.
> you could rebase and resend it :-)

I would like to test it first. I'll resend the patch in couple of days
(I hope so).

PS: The previous email was from different mail address. Sorry about that.

Stefan Mavrodiev

>
>
>>>> ---
>>>>
>>>>    drivers/mfd/rk808.c | 24 ++++++++++++++++++++++++
>>>>    1 file changed, 24 insertions(+)
>>>>
>>>> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
>>>> index 216fbf6..50f3f78 100644
>>>> --- a/drivers/mfd/rk808.c
>>>> +++ b/drivers/mfd/rk808.c
>>>> @@ -387,6 +387,25 @@ static void rk805_device_shutdown(void)
>>>>
>>>>    		dev_err(&rk808_i2c_client->dev, "power off error!\n");
>>>>    
>>>>    }
>>>>
>>>> +static void rk805_device_shutdown_prepare(void)
>>>> +{
>>>> +	int ret;
>>>> +	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
>>>> +
>>>> +	if (!rk808) {
>>>> +		dev_warn(&rk808_i2c_client->dev,
>>>> +			 "have no rk805, so do nothing here\n");
>>>> +
>>>> +		return;
>>>> +	}
>>>> +
>>>> +	ret = regmap_update_bits(rk808->regmap,
>>>> +				 RK805_GPIO_IO_POL_REG,
>>>> +				 SLP_SD_MSK, SHUTDOWN_FUN);
>>>> +	if (ret)
>>>> +		dev_err(&rk808_i2c_client->dev, "power off error!\n");
>>>> +}
>>>> +
>>>>
>>>>    static void rk808_device_shutdown(void)
>>>>    {
>>>>    
>>>>    	int ret;
>>>>
>>>> @@ -549,6 +568,10 @@ static int rk808_probe(struct i2c_client *client,
>>>>
>>>>    	if (pm_off && !pm_power_off) {
>>>>    	
>>>>    		rk808_i2c_client = client;
>>>>    		pm_power_off = pm_pwroff_fn;
>>>>
>>>> +	} else if (pm_off && !pm_power_off_prepare &&
>>>> +		   rk808->variant == RK805_ID) {
>>>> +		rk808_i2c_client = client;
>>>> +		pm_power_off_prepare = rk805_device_shutdown_prepare;
>>>>
>>>>    	}
>>>>    	
>>>>    	return 0;
>>>>
>>>> @@ -564,6 +587,7 @@ static int rk808_remove(struct i2c_client *client)
>>>>
>>>>    	regmap_del_irq_chip(client->irq, rk808->irq_data);
>>>>    	pm_power_off = NULL;
>>>>
>>>> +	pm_power_off_prepare = NULL;
>>>>
>>>>    	return 0;
>>>>    
>>>>    }
>
>
>

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

* Re: [PATCH 1/1] mfd: rk808: Prepare rk805 for poweroff
@ 2019-01-09 13:15         ` Stefan Mavrodiev
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Mavrodiev @ 2019-01-09 13:15 UTC (permalink / raw)
  To: Heiko Stübner
  Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Lee Jones,
	open list, Stefan Mavrodiev


On 1/9/19 3:11 PM, Heiko Stübner wrote:
> Am Mittwoch, 9. Januar 2019, 14:10:34 CET schrieb Stefan Mavrodiev:
>> On 1/9/19 3:07 PM, Heiko Stübner wrote:
>>> Hi Stefan, Lee,
>>>
>>> Am Dienstag, 2. Oktober 2018, 09:38:29 CET schrieb Stefan Mavrodiev:
>>>> RK805 has SLEEP signal, which can put the device into SLEEP or OFF
>>>> mode. The default is SLEEP mode.
>>>>
>>>> However, when the kernel performs power-off (actually the ATF) the
>>>> device will not go fully off and this will result in higher power
>>>> consumption and inability to wake the device with RTC alarm.
>>>>
>>>> The solution is to enable pm_power_off_prepare function, which will
>>>> configure SLEEP pin for OFF function.
>>>>
>>>> Signed-off-by: Stefan Mavrodiev <stefan@olimex.com>
>>> just found this while cleaning my inbox and this change looks
>>> significant and it seems hasn't been applied yet.
>>>
>>> I guess this is still relevant, right?
>> Yes, but I guess it's out-of-sync with the latest kernel.
> you could rebase and resend it :-)

I would like to test it first. I'll resend the patch in couple of days
(I hope so).

PS: The previous email was from different mail address. Sorry about that.

Stefan Mavrodiev

>
>
>>>> ---
>>>>
>>>>    drivers/mfd/rk808.c | 24 ++++++++++++++++++++++++
>>>>    1 file changed, 24 insertions(+)
>>>>
>>>> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
>>>> index 216fbf6..50f3f78 100644
>>>> --- a/drivers/mfd/rk808.c
>>>> +++ b/drivers/mfd/rk808.c
>>>> @@ -387,6 +387,25 @@ static void rk805_device_shutdown(void)
>>>>
>>>>    		dev_err(&rk808_i2c_client->dev, "power off error!\n");
>>>>    
>>>>    }
>>>>
>>>> +static void rk805_device_shutdown_prepare(void)
>>>> +{
>>>> +	int ret;
>>>> +	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
>>>> +
>>>> +	if (!rk808) {
>>>> +		dev_warn(&rk808_i2c_client->dev,
>>>> +			 "have no rk805, so do nothing here\n");
>>>> +
>>>> +		return;
>>>> +	}
>>>> +
>>>> +	ret = regmap_update_bits(rk808->regmap,
>>>> +				 RK805_GPIO_IO_POL_REG,
>>>> +				 SLP_SD_MSK, SHUTDOWN_FUN);
>>>> +	if (ret)
>>>> +		dev_err(&rk808_i2c_client->dev, "power off error!\n");
>>>> +}
>>>> +
>>>>
>>>>    static void rk808_device_shutdown(void)
>>>>    {
>>>>    
>>>>    	int ret;
>>>>
>>>> @@ -549,6 +568,10 @@ static int rk808_probe(struct i2c_client *client,
>>>>
>>>>    	if (pm_off && !pm_power_off) {
>>>>    	
>>>>    		rk808_i2c_client = client;
>>>>    		pm_power_off = pm_pwroff_fn;
>>>>
>>>> +	} else if (pm_off && !pm_power_off_prepare &&
>>>> +		   rk808->variant == RK805_ID) {
>>>> +		rk808_i2c_client = client;
>>>> +		pm_power_off_prepare = rk805_device_shutdown_prepare;
>>>>
>>>>    	}
>>>>    	
>>>>    	return 0;
>>>>
>>>> @@ -564,6 +587,7 @@ static int rk808_remove(struct i2c_client *client)
>>>>
>>>>    	regmap_del_irq_chip(client->irq, rk808->irq_data);
>>>>    	pm_power_off = NULL;
>>>>
>>>> +	pm_power_off_prepare = NULL;
>>>>
>>>>    	return 0;
>>>>    
>>>>    }
>
>
>

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

end of thread, other threads:[~2019-01-09 13:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-02  7:38 [PATCH 1/1] mfd: rk808: Prepare rk805 for poweroff Stefan Mavrodiev
2018-10-02  7:38 ` Stefan Mavrodiev
2019-01-09 13:07 ` Heiko Stübner
2019-01-09 13:10   ` Stefan Mavrodiev
2019-01-09 13:11     ` Heiko Stübner
2019-01-09 13:11       ` Heiko Stübner
2019-01-09 13:15       ` Stefan Mavrodiev
2019-01-09 13:15         ` Stefan Mavrodiev

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.