Re: [PATCH v6 4/6] soc: qcom: Extend RPMh power controller driver to register warming devices.

2020-06-16 Thread Ulf Hansson
On Thu, 4 Jun 2020 at 03:53, Thara Gopinath  wrote:
>
> RPMh power control hosts power domains that can be used as
> thermal warming devices. Register these power domains
> with the generic power domain warming device thermal framework.
>
> Signed-off-by: Thara Gopinath 

Reviewed-by: Ulf Hansson 

Kind regards
Uffe


> ---
>
> v3->v4:
> - Introduce a boolean value is_warming_dev in rpmhpd structure to
>   indicate if a generic power domain can be used as a warming
>   device or not.With this change, device tree no longer has to
>   specify which power domain inside the rpmh power domain provider
>   is a warming device.
> - Move registering of warming devices into a late initcall to
>   ensure that warming devices are registered after thermal
>   framework is initialized.
>
> v5->v6:
> - Moved back registering of warming devices into probe since
>   Bjorn pointed out that now the driver can be initialized as
>   as a module, late_initcall will not work. Thermal framework
>   takes care of binding a cooling device to a thermal zone even
>   if the cooling device is registered before the thermal framework
>   is initialized.
>
>  drivers/soc/qcom/rpmhpd.c | 17 -
>  1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c
> index a9c597143525..29e1eb4d11af 100644
> --- a/drivers/soc/qcom/rpmhpd.c
> +++ b/drivers/soc/qcom/rpmhpd.c
> @@ -12,6 +12,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -49,6 +50,7 @@ struct rpmhpd {
> boolenabled;
> const char  *res_name;
> u32 addr;
> +   boolis_warming_dev;
>  };
>
>  struct rpmhpd_desc {
> @@ -90,6 +92,7 @@ static struct rpmhpd sdm845_mx = {
> .pd = { .name = "mx", },
> .peer = _mx_ao,
> .res_name = "mx.lvl",
> +   .is_warming_dev = true,
>  };
>
>  static struct rpmhpd sdm845_mx_ao = {
> @@ -472,7 +475,19 @@ static int rpmhpd_probe(struct platform_device *pdev)
>[i]->pd);
> }
>
> -   return of_genpd_add_provider_onecell(pdev->dev.of_node, data);
> +   ret = of_genpd_add_provider_onecell(pdev->dev.of_node, data);
> +
> +   if (ret)
> +   return ret;
> +
> +   if (!of_find_property(dev->of_node, "#cooling-cells", NULL))
> +   return 0;
> +
> +   for (i = 0; i < num_pds; i++)
> +   if (rpmhpds[i]->is_warming_dev)
> +   of_pd_warming_register(rpmhpds[i]->dev, i);
> +
> +   return 0;
>  }
>
>  static struct platform_driver rpmhpd_driver = {
> --
> 2.20.1
>


[PATCH v6 4/6] soc: qcom: Extend RPMh power controller driver to register warming devices.

2020-06-03 Thread Thara Gopinath
RPMh power control hosts power domains that can be used as
thermal warming devices. Register these power domains
with the generic power domain warming device thermal framework.

Signed-off-by: Thara Gopinath 
---

v3->v4:
- Introduce a boolean value is_warming_dev in rpmhpd structure to
  indicate if a generic power domain can be used as a warming
  device or not.With this change, device tree no longer has to
  specify which power domain inside the rpmh power domain provider
  is a warming device.
- Move registering of warming devices into a late initcall to
  ensure that warming devices are registered after thermal
  framework is initialized.

v5->v6:
- Moved back registering of warming devices into probe since
  Bjorn pointed out that now the driver can be initialized as
  as a module, late_initcall will not work. Thermal framework
  takes care of binding a cooling device to a thermal zone even
  if the cooling device is registered before the thermal framework
  is initialized.

 drivers/soc/qcom/rpmhpd.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c
index a9c597143525..29e1eb4d11af 100644
--- a/drivers/soc/qcom/rpmhpd.c
+++ b/drivers/soc/qcom/rpmhpd.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -49,6 +50,7 @@ struct rpmhpd {
boolenabled;
const char  *res_name;
u32 addr;
+   boolis_warming_dev;
 };
 
 struct rpmhpd_desc {
@@ -90,6 +92,7 @@ static struct rpmhpd sdm845_mx = {
.pd = { .name = "mx", },
.peer = _mx_ao,
.res_name = "mx.lvl",
+   .is_warming_dev = true,
 };
 
 static struct rpmhpd sdm845_mx_ao = {
@@ -472,7 +475,19 @@ static int rpmhpd_probe(struct platform_device *pdev)
   [i]->pd);
}
 
-   return of_genpd_add_provider_onecell(pdev->dev.of_node, data);
+   ret = of_genpd_add_provider_onecell(pdev->dev.of_node, data);
+
+   if (ret)
+   return ret;
+
+   if (!of_find_property(dev->of_node, "#cooling-cells", NULL))
+   return 0;
+
+   for (i = 0; i < num_pds; i++)
+   if (rpmhpds[i]->is_warming_dev)
+   of_pd_warming_register(rpmhpds[i]->dev, i);
+
+   return 0;
 }
 
 static struct platform_driver rpmhpd_driver = {
-- 
2.20.1