diff mbox series

[2/3] soc: c3: Add support for power domains controller

Message ID 20230703093142.2028500-3-xianwei.zhao@amlogic.com
State New
Headers show
Series None | expand

Commit Message

Xianwei Zhao July 3, 2023, 9:31 a.m. UTC
From: Xianwei Zhao <xianwei.zhao@amlogic.com>

Add support for C3 Power controller. C3 power control
registers are in secure domain, and should be accessed by SMC.

Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
 drivers/soc/amlogic/meson-secure-pwrc.c | 28 ++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

Comments

Xianwei Zhao July 4, 2023, 2:20 a.m. UTC | #1
Hi Neil,
     Thanks for your reply.

On 2023/7/3 21:29, Neil Armstrong wrote:
> [ EXTERNAL EMAIL ]
> 
> Hi,
> 
> On 03/07/2023 11:31, =Xianwei Zhao wrote:
>> From: Xianwei Zhao <xianwei.zhao@amlogic.com>
>>
>> Add support for C3 Power controller. C3 power control
>> registers are in secure domain, and should be accessed by SMC.
>>
>> Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
>> ---
>>   drivers/soc/amlogic/meson-secure-pwrc.c | 28 ++++++++++++++++++++++++-
>>   1 file changed, 27 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/soc/amlogic/meson-secure-pwrc.c 
>> b/drivers/soc/amlogic/meson-secure-pwrc.c
>> index 25b4b71df9b8..39ccc8f2e630 100644
>> --- a/drivers/soc/amlogic/meson-secure-pwrc.c
>> +++ b/drivers/soc/amlogic/meson-secure-pwrc.c
>> @@ -12,6 +12,7 @@
>>   #include <linux/pm_domain.h>
>>   #include <dt-bindings/power/meson-a1-power.h>
>>   #include <dt-bindings/power/meson-s4-power.h>
>> +#include <dt-bindings/power/amlogic-c3-power.h>
>>   #include <linux/arm-smccc.h>
>>   #include <linux/firmware/meson/meson_sm.h>
>>   #include <linux/module.h>
>> @@ -132,6 +133,22 @@ static struct meson_secure_pwrc_domain_desc 
>> s4_pwrc_domains[] = {
>>       SEC_PD(S4_AUDIO,        0),
>>   };
>>
>> +static struct meson_secure_pwrc_domain_desc c3_pwrc_domains[] = {
>> +     SEC_PD(C3_NNA,  0),
>> +     SEC_PD(C3_AUDIO,        GENPD_FLAG_ALWAYS_ON),
>> +     SEC_PD(C3_SDIOA,        GENPD_FLAG_ALWAYS_ON),
>> +     SEC_PD(C3_EMMC, GENPD_FLAG_ALWAYS_ON),
>> +     SEC_PD(C3_USB_COMB, GENPD_FLAG_ALWAYS_ON),
>> +     SEC_PD(C3_SDCARD,       GENPD_FLAG_ALWAYS_ON),
>> +     SEC_PD(C3_ETH,  GENPD_FLAG_ALWAYS_ON),
>> +     SEC_PD(C3_GE2D, GENPD_FLAG_ALWAYS_ON),
>> +     SEC_PD(C3_CVE,  GENPD_FLAG_ALWAYS_ON),
>> +     SEC_PD(C3_GDC_WRAP,     GENPD_FLAG_ALWAYS_ON),
>> +     SEC_PD(C3_ISP_TOP,              GENPD_FLAG_ALWAYS_ON),
>> +     SEC_PD(C3_MIPI_ISP_WRAP, GENPD_FLAG_ALWAYS_ON),
>> +     SEC_PD(C3_VCODEC,       0),
>> +};
> 
> Please move this struct before _s4_
> 
Will do.
>> +
>>   static int meson_secure_pwrc_probe(struct platform_device *pdev)
>>   {
>>       int i;
>> @@ -179,7 +196,7 @@ static int meson_secure_pwrc_probe(struct 
>> platform_device *pdev)
>>       for (i = 0 ; i < match->count ; ++i) {
>>               struct meson_secure_pwrc_domain *dom = &pwrc->domains[i];
>>
>> -             if (!match->domains[i].index)
>> +             if (!match->domains[i].name)
> 
> Is this change necessary ? If yes please move it to another patch
> and explain it's purpose. If it fixes something, add a Fixes tag so
> it can be backported.
> 
This variable for C3 could be equal to zero. I will move it to another 
patch.
> Thanks,
> Neil
> 
>>                       continue;
>>
>>               dom->pwrc = pwrc;
>> @@ -207,6 +224,11 @@ static struct meson_secure_pwrc_domain_data 
>> meson_secure_s4_pwrc_data = {
>>       .count = ARRAY_SIZE(s4_pwrc_domains),
>>   };
>>
>> +static struct meson_secure_pwrc_domain_data 
>> amlogic_secure_c3_pwrc_data = {
>> +     .domains = c3_pwrc_domains,
>> +     .count = ARRAY_SIZE(c3_pwrc_domains),
>> +};
> 
> Please move this struct before _s4_
> 
>> +
>>   static const struct of_device_id meson_secure_pwrc_match_table[] = {
>>       {
>>               .compatible = "amlogic,meson-a1-pwrc",
>> @@ -216,6 +238,10 @@ static const struct of_device_id 
>> meson_secure_pwrc_match_table[] = {
>>               .compatible = "amlogic,meson-s4-pwrc",
>>               .data = &meson_secure_s4_pwrc_data,
>>       },
>> +     {
>> +             .compatible = "amlogic,c3-pwrc",
>> +             .data = &amlogic_secure_c3_pwrc_data,
>> +     },
> 
> Please move this entry before _s4_Will do.
> 
>>       { /* sentinel */ }
>>   };
>>   MODULE_DEVICE_TABLE(of, meson_secure_pwrc_match_table);
> 
> Thanks,
> Neil
>
Xianwei Zhao July 4, 2023, 2:43 a.m. UTC | #2
Hi Dmitry,
    Thanks for your advise.

On 2023/7/4 03:37, Dmitry Rokosov wrote:
> [ EXTERNAL EMAIL ]
> 
> On Mon, Jul 03, 2023 at 03:29:31PM +0200, Neil Armstrong wrote:
>> Hi,
>>
>> On 03/07/2023 11:31, =Xianwei Zhao wrote:
>>> From: Xianwei Zhao <xianwei.zhao@amlogic.com>
>>>
>>> Add support for C3 Power controller. C3 power control
>>> registers are in secure domain, and should be accessed by SMC.
>>>
>>> Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
>>> ---
>>>    drivers/soc/amlogic/meson-secure-pwrc.c | 28 ++++++++++++++++++++++++-
>>>    1 file changed, 27 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/soc/amlogic/meson-secure-pwrc.c b/drivers/soc/amlogic/meson-secure-pwrc.c
>>> index 25b4b71df9b8..39ccc8f2e630 100644
>>> --- a/drivers/soc/amlogic/meson-secure-pwrc.c
>>> +++ b/drivers/soc/amlogic/meson-secure-pwrc.c
>>> @@ -12,6 +12,7 @@
>>>    #include <linux/pm_domain.h>
>>>    #include <dt-bindings/power/meson-a1-power.h>
>>>    #include <dt-bindings/power/meson-s4-power.h>
>>> +#include <dt-bindings/power/amlogic-c3-power.h>
>>>    #include <linux/arm-smccc.h>
>>>    #include <linux/firmware/meson/meson_sm.h>
>>>    #include <linux/module.h>
>>> @@ -132,6 +133,22 @@ static struct meson_secure_pwrc_domain_desc s4_pwrc_domains[] = {
>>>      SEC_PD(S4_AUDIO,        0),
>>>    };
>>> +static struct meson_secure_pwrc_domain_desc c3_pwrc_domains[] = {
>>> +   SEC_PD(C3_NNA,  0),
>>> +   SEC_PD(C3_AUDIO,        GENPD_FLAG_ALWAYS_ON),
>>> +   SEC_PD(C3_SDIOA,        GENPD_FLAG_ALWAYS_ON),
>>> +   SEC_PD(C3_EMMC, GENPD_FLAG_ALWAYS_ON),
>>> +   SEC_PD(C3_USB_COMB, GENPD_FLAG_ALWAYS_ON),
>>> +   SEC_PD(C3_SDCARD,       GENPD_FLAG_ALWAYS_ON),
>>> +   SEC_PD(C3_ETH,  GENPD_FLAG_ALWAYS_ON),
>>> +   SEC_PD(C3_GE2D, GENPD_FLAG_ALWAYS_ON),
>>> +   SEC_PD(C3_CVE,  GENPD_FLAG_ALWAYS_ON),
>>> +   SEC_PD(C3_GDC_WRAP,     GENPD_FLAG_ALWAYS_ON),
>>> +   SEC_PD(C3_ISP_TOP,              GENPD_FLAG_ALWAYS_ON),
>>> +   SEC_PD(C3_MIPI_ISP_WRAP, GENPD_FLAG_ALWAYS_ON),
>>> +   SEC_PD(C3_VCODEC,       0),
>>> +};
>>
>> Please move this struct before _s4_
>>
>>> +
>>>    static int meson_secure_pwrc_probe(struct platform_device *pdev)
>>>    {
>>>      int i;
>>> @@ -179,7 +196,7 @@ static int meson_secure_pwrc_probe(struct platform_device *pdev)
>>>      for (i = 0 ; i < match->count ; ++i) {
>>>              struct meson_secure_pwrc_domain *dom = &pwrc->domains[i];
>>> -           if (!match->domains[i].index)
>>> +           if (!match->domains[i].name)
>>
>> Is this change necessary ? If yes please move it to another patch
>> and explain it's purpose. If it fixes something, add a Fixes tag so
>> it can be backported.
>>
>> Thanks,
>> Neil
>>
> 
> I suppose, this change fixes the situation with SEC_PD(C3_NNA, 0)
> domain, because it has index == 0.
That's true.
> May be it's better to introduce the separate struct member for that? For
> example, 'present' (true or false).
> I think code would be more readable and clean.
> > [...]
> 
> --
> Thank you,
> Dmitry
diff mbox series

Patch

diff --git a/drivers/soc/amlogic/meson-secure-pwrc.c b/drivers/soc/amlogic/meson-secure-pwrc.c
index 25b4b71df9b8..39ccc8f2e630 100644
--- a/drivers/soc/amlogic/meson-secure-pwrc.c
+++ b/drivers/soc/amlogic/meson-secure-pwrc.c
@@ -12,6 +12,7 @@ 
 #include <linux/pm_domain.h>
 #include <dt-bindings/power/meson-a1-power.h>
 #include <dt-bindings/power/meson-s4-power.h>
+#include <dt-bindings/power/amlogic-c3-power.h>
 #include <linux/arm-smccc.h>
 #include <linux/firmware/meson/meson_sm.h>
 #include <linux/module.h>
@@ -132,6 +133,22 @@  static struct meson_secure_pwrc_domain_desc s4_pwrc_domains[] = {
 	SEC_PD(S4_AUDIO,	0),
 };
 
+static struct meson_secure_pwrc_domain_desc c3_pwrc_domains[] = {
+	SEC_PD(C3_NNA,	0),
+	SEC_PD(C3_AUDIO,	GENPD_FLAG_ALWAYS_ON),
+	SEC_PD(C3_SDIOA,	GENPD_FLAG_ALWAYS_ON),
+	SEC_PD(C3_EMMC,	GENPD_FLAG_ALWAYS_ON),
+	SEC_PD(C3_USB_COMB, GENPD_FLAG_ALWAYS_ON),
+	SEC_PD(C3_SDCARD,	GENPD_FLAG_ALWAYS_ON),
+	SEC_PD(C3_ETH,	GENPD_FLAG_ALWAYS_ON),
+	SEC_PD(C3_GE2D,	GENPD_FLAG_ALWAYS_ON),
+	SEC_PD(C3_CVE,	GENPD_FLAG_ALWAYS_ON),
+	SEC_PD(C3_GDC_WRAP,	GENPD_FLAG_ALWAYS_ON),
+	SEC_PD(C3_ISP_TOP,		GENPD_FLAG_ALWAYS_ON),
+	SEC_PD(C3_MIPI_ISP_WRAP, GENPD_FLAG_ALWAYS_ON),
+	SEC_PD(C3_VCODEC,	0),
+};
+
 static int meson_secure_pwrc_probe(struct platform_device *pdev)
 {
 	int i;
@@ -179,7 +196,7 @@  static int meson_secure_pwrc_probe(struct platform_device *pdev)
 	for (i = 0 ; i < match->count ; ++i) {
 		struct meson_secure_pwrc_domain *dom = &pwrc->domains[i];
 
-		if (!match->domains[i].index)
+		if (!match->domains[i].name)
 			continue;
 
 		dom->pwrc = pwrc;
@@ -207,6 +224,11 @@  static struct meson_secure_pwrc_domain_data meson_secure_s4_pwrc_data = {
 	.count = ARRAY_SIZE(s4_pwrc_domains),
 };
 
+static struct meson_secure_pwrc_domain_data amlogic_secure_c3_pwrc_data = {
+	.domains = c3_pwrc_domains,
+	.count = ARRAY_SIZE(c3_pwrc_domains),
+};
+
 static const struct of_device_id meson_secure_pwrc_match_table[] = {
 	{
 		.compatible = "amlogic,meson-a1-pwrc",
@@ -216,6 +238,10 @@  static const struct of_device_id meson_secure_pwrc_match_table[] = {
 		.compatible = "amlogic,meson-s4-pwrc",
 		.data = &meson_secure_s4_pwrc_data,
 	},
+	{
+		.compatible = "amlogic,c3-pwrc",
+		.data = &amlogic_secure_c3_pwrc_data,
+	},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, meson_secure_pwrc_match_table);