diff mbox series

[V2,3/6] soc: amlogic: init power domain state

Message ID 20230824055930.2576849-4-xianwei.zhao@amlogic.com (mailing list archive)
State New, archived
Headers show
Series Power: T7: add power domain driver | expand

Commit Message

Xianwei Zhao Aug. 24, 2023, 5:59 a.m. UTC
From: "xianwei.zhao" <xianwei.zhao@amlogic.com>

If initial power domain with 'AWAY_ON' property state is off,
turn on the power.

Signed-off-by: xianwei.zhao <xianwei.zhao@amlogic.com>
---
V1 -> V2: None
---
 drivers/genpd/amlogic/meson-secure-pwrc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Neil Armstrong Aug. 24, 2023, 8:30 a.m. UTC | #1
Hi,

On 24/08/2023 07:59, Xianwei Zhao wrote:
> From: "xianwei.zhao" <xianwei.zhao@amlogic.com>
> 
> If initial power domain with 'AWAY_ON' property state is off,
> turn on the power.
> 
> Signed-off-by: xianwei.zhao <xianwei.zhao@amlogic.com>
> ---
> V1 -> V2: None
> ---
>   drivers/genpd/amlogic/meson-secure-pwrc.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/genpd/amlogic/meson-secure-pwrc.c b/drivers/genpd/amlogic/meson-secure-pwrc.c
> index 76527f4946b4..3e7e3bd25d1f 100644
> --- a/drivers/genpd/amlogic/meson-secure-pwrc.c
> +++ b/drivers/genpd/amlogic/meson-secure-pwrc.c
> @@ -55,7 +55,7 @@ static bool pwrc_secure_is_off(struct meson_secure_pwrc_domain *pwrc_domain)
>   			  pwrc_domain->index, 0, 0, 0, 0) < 0)
>   		pr_err("failed to get power domain status\n");
>   
> -	return is_off;
> +	return !!is_off;

Can you explain this ? the function returns bool, so if if_off is > 0, it would return true,
so I don't see why you would need to transform is_off into 1 or 0 using !!.

>   }
>   
>   static int meson_secure_pwrc_off(struct generic_pm_domain *domain)
> @@ -222,6 +222,9 @@ static int meson_secure_pwrc_probe(struct platform_device *pdev)
>   		dom->base.power_on = meson_secure_pwrc_on;
>   		dom->base.power_off = meson_secure_pwrc_off;
>   
> +		if (match->domains[i].is_off(dom) && (dom->base.flags & GENPD_FLAG_ALWAYS_ON))
> +			meson_secure_pwrc_on(&dom->base);
> +
>   		pm_genpd_init(&dom->base, NULL, match->domains[i].is_off(dom));
>   
>   		pwrc->xlate.domains[i] = &dom->base;
Xianwei Zhao Aug. 24, 2023, 8:46 a.m. UTC | #2
Hi Neil,
    Thanks for your reply.

On 2023/8/24 16:30, Neil Armstrong wrote:
> [ EXTERNAL EMAIL ]
> 
> Hi,
> 
> On 24/08/2023 07:59, Xianwei Zhao wrote:
>> From: "xianwei.zhao" <xianwei.zhao@amlogic.com>
>>
>> If initial power domain with 'AWAY_ON' property state is off,
>> turn on the power.
>>
>> Signed-off-by: xianwei.zhao <xianwei.zhao@amlogic.com>
>> ---
>> V1 -> V2: None
>> ---
>>   drivers/genpd/amlogic/meson-secure-pwrc.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/genpd/amlogic/meson-secure-pwrc.c 
>> b/drivers/genpd/amlogic/meson-secure-pwrc.c
>> index 76527f4946b4..3e7e3bd25d1f 100644
>> --- a/drivers/genpd/amlogic/meson-secure-pwrc.c
>> +++ b/drivers/genpd/amlogic/meson-secure-pwrc.c
>> @@ -55,7 +55,7 @@ static bool pwrc_secure_is_off(struct 
>> meson_secure_pwrc_domain *pwrc_domain)
>>                         pwrc_domain->index, 0, 0, 0, 0) < 0)
>>               pr_err("failed to get power domain status\n");
>>
>> -     return is_off;
>> +     return !!is_off;
> 
> Can you explain this ? the function returns bool, so if if_off is > 0, 
> it would return true,
> so I don't see why you would need to transform is_off into 1 or 0 using !!.
> 
I will remove this modify, in next version.
>>   }
>>
>>   static int meson_secure_pwrc_off(struct generic_pm_domain *domain)
>> @@ -222,6 +222,9 @@ static int meson_secure_pwrc_probe(struct 
>> platform_device *pdev)
>>               dom->base.power_on = meson_secure_pwrc_on;
>>               dom->base.power_off = meson_secure_pwrc_off;
>>
>> +             if (match->domains[i].is_off(dom) && (dom->base.flags & 
>> GENPD_FLAG_ALWAYS_ON))
>> +                     meson_secure_pwrc_on(&dom->base);
>> +
>>               pm_genpd_init(&dom->base, NULL, 
>> match->domains[i].is_off(dom));
>>
>>               pwrc->xlate.domains[i] = &dom->base;
>
diff mbox series

Patch

diff --git a/drivers/genpd/amlogic/meson-secure-pwrc.c b/drivers/genpd/amlogic/meson-secure-pwrc.c
index 76527f4946b4..3e7e3bd25d1f 100644
--- a/drivers/genpd/amlogic/meson-secure-pwrc.c
+++ b/drivers/genpd/amlogic/meson-secure-pwrc.c
@@ -55,7 +55,7 @@  static bool pwrc_secure_is_off(struct meson_secure_pwrc_domain *pwrc_domain)
 			  pwrc_domain->index, 0, 0, 0, 0) < 0)
 		pr_err("failed to get power domain status\n");
 
-	return is_off;
+	return !!is_off;
 }
 
 static int meson_secure_pwrc_off(struct generic_pm_domain *domain)
@@ -222,6 +222,9 @@  static int meson_secure_pwrc_probe(struct platform_device *pdev)
 		dom->base.power_on = meson_secure_pwrc_on;
 		dom->base.power_off = meson_secure_pwrc_off;
 
+		if (match->domains[i].is_off(dom) && (dom->base.flags & GENPD_FLAG_ALWAYS_ON))
+			meson_secure_pwrc_on(&dom->base);
+
 		pm_genpd_init(&dom->base, NULL, match->domains[i].is_off(dom));
 
 		pwrc->xlate.domains[i] = &dom->base;