diff mbox series

[v2,29/48] soc/tegra: pmc: Link domains to the parent Core domain

Message ID 20201217180638.22748-30-digetx@gmail.com
State New
Headers show
Series [v2,01/48] dt-bindings: memory: tegra20: emc: Replace core regulator with power domain | expand

Commit Message

Dmitry Osipenko Dec. 17, 2020, 6:06 p.m. UTC
The Core domain is a parent of PMC power domains, hence PMC domains
should be set up as a sub-domains of the parent (Core) domain if
"power-domains" phandle presents in a device-tree node of PMC domain.

This allows to propagate GENPD performance changes to the parent Core
domain if performance change is applied to PMC domain.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/soc/tegra/pmc.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Ulf Hansson Jan. 12, 2021, 1:30 p.m. UTC | #1
- trimmed cc-list

On Thu, 17 Dec 2020 at 19:07, Dmitry Osipenko <digetx@gmail.com> wrote:
>
> The Core domain is a parent of PMC power domains, hence PMC domains
> should be set up as a sub-domains of the parent (Core) domain if
> "power-domains" phandle presents in a device-tree node of PMC domain.
>
> This allows to propagate GENPD performance changes to the parent Core
> domain if performance change is applied to PMC domain.
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/soc/tegra/pmc.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
> index 4f96dc7745c4..1a659d1c06d7 100644
> --- a/drivers/soc/tegra/pmc.c
> +++ b/drivers/soc/tegra/pmc.c
> @@ -1236,6 +1236,7 @@ static int tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np)
>  static int tegra_powergate_init(struct tegra_pmc *pmc,
>                                 struct device_node *parent)
>  {
> +       struct of_phandle_args child_args, parent_args;
>         struct device_node *np, *child;
>         int err = 0;
>
> @@ -1249,6 +1250,24 @@ static int tegra_powergate_init(struct tegra_pmc *pmc,
>                         of_node_put(child);
>                         break;
>                 }
> +
> +               if (of_parse_phandle_with_args(child, "power-domains",
> +                                              "#power-domain-cells",
> +                                              0, &parent_args))
> +                       continue;
> +
> +               child_args.np = child;
> +               child_args.args_count = 0;
> +
> +               err = of_genpd_add_subdomain(&parent_args, &child_args);
> +               of_node_put(parent_args.np);
> +               if (err) {
> +                       if (err == -ENOENT)
> +                               err = -EPROBE_DEFER;

Okay. So this special error treatment is needed because
of_genpd_add_subdomain may return -ENOENT, in case the providers for
the parent-domain and child-domain haven't been registered yet.

I suggest we move this into of_genpd_add_subdomain() instead, thus
letting it return -EPROBE_DEFER when there are parent/child nodes
specified in DT, but the providers are lacking.

> +
> +                       of_node_put(child);
> +                       break;
> +               }
>         }
>
>         of_node_put(np);
> --
> 2.29.2
>

Kind regards
Uffe
Dmitry Osipenko Jan. 12, 2021, 4:22 p.m. UTC | #2
12.01.2021 16:30, Ulf Hansson пишет:
> - trimmed cc-list
> 
> On Thu, 17 Dec 2020 at 19:07, Dmitry Osipenko <digetx@gmail.com> wrote:
>>
>> The Core domain is a parent of PMC power domains, hence PMC domains
>> should be set up as a sub-domains of the parent (Core) domain if
>> "power-domains" phandle presents in a device-tree node of PMC domain.
>>
>> This allows to propagate GENPD performance changes to the parent Core
>> domain if performance change is applied to PMC domain.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/soc/tegra/pmc.c | 19 +++++++++++++++++++
>>  1 file changed, 19 insertions(+)
>>
>> diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
>> index 4f96dc7745c4..1a659d1c06d7 100644
>> --- a/drivers/soc/tegra/pmc.c
>> +++ b/drivers/soc/tegra/pmc.c
>> @@ -1236,6 +1236,7 @@ static int tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np)
>>  static int tegra_powergate_init(struct tegra_pmc *pmc,
>>                                 struct device_node *parent)
>>  {
>> +       struct of_phandle_args child_args, parent_args;
>>         struct device_node *np, *child;
>>         int err = 0;
>>
>> @@ -1249,6 +1250,24 @@ static int tegra_powergate_init(struct tegra_pmc *pmc,
>>                         of_node_put(child);
>>                         break;
>>                 }
>> +
>> +               if (of_parse_phandle_with_args(child, "power-domains",
>> +                                              "#power-domain-cells",
>> +                                              0, &parent_args))
>> +                       continue;
>> +
>> +               child_args.np = child;
>> +               child_args.args_count = 0;
>> +
>> +               err = of_genpd_add_subdomain(&parent_args, &child_args);
>> +               of_node_put(parent_args.np);
>> +               if (err) {
>> +                       if (err == -ENOENT)
>> +                               err = -EPROBE_DEFER;
> 
> Okay. So this special error treatment is needed because
> of_genpd_add_subdomain may return -ENOENT, in case the providers for
> the parent-domain and child-domain haven't been registered yet.
> 
> I suggest we move this into of_genpd_add_subdomain() instead, thus
> letting it return -EPROBE_DEFER when there are parent/child nodes
> specified in DT, but the providers are lacking.

Alright
diff mbox series

Patch

diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 4f96dc7745c4..1a659d1c06d7 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -1236,6 +1236,7 @@  static int tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np)
 static int tegra_powergate_init(struct tegra_pmc *pmc,
 				struct device_node *parent)
 {
+	struct of_phandle_args child_args, parent_args;
 	struct device_node *np, *child;
 	int err = 0;
 
@@ -1249,6 +1250,24 @@  static int tegra_powergate_init(struct tegra_pmc *pmc,
 			of_node_put(child);
 			break;
 		}
+
+		if (of_parse_phandle_with_args(child, "power-domains",
+					       "#power-domain-cells",
+					       0, &parent_args))
+			continue;
+
+		child_args.np = child;
+		child_args.args_count = 0;
+
+		err = of_genpd_add_subdomain(&parent_args, &child_args);
+		of_node_put(parent_args.np);
+		if (err) {
+			if (err == -ENOENT)
+				err = -EPROBE_DEFER;
+
+			of_node_put(child);
+			break;
+		}
 	}
 
 	of_node_put(np);