diff mbox series

[11/15] drm/panfrost: set devfreq clock name

Message ID 20200510165538.19720-12-peron.clem@gmail.com (mailing list archive)
State New, archived
Headers show
Series Add regulator devfreq support to Panfrost | expand

Commit Message

Clément Péron May 10, 2020, 4:55 p.m. UTC
Some SoCs have  several clocks defined and the OPP core
needs to know the exact name of the clk to use.

Set the clock name to "core".

Signed-off-by: Clément Péron <peron.clem@gmail.com>
---
 drivers/gpu/drm/panfrost/panfrost_devfreq.c | 13 +++++++++++++
 drivers/gpu/drm/panfrost/panfrost_devfreq.h |  1 +
 2 files changed, 14 insertions(+)

Comments

Steven Price May 28, 2020, 1:23 p.m. UTC | #1
On 10/05/2020 17:55, Clément Péron wrote:
> Some SoCs have  several clocks defined and the OPP core
> needs to know the exact name of the clk to use.
> 
> Set the clock name to "core".
> 
> Signed-off-by: Clément Péron <peron.clem@gmail.com>

This is unfortunately a regression for the RK3288. The device tree 
binding doesn't require "clock-names", and for the RK3288 it currently 
isn't specified. So this breaks the platform.

Adding the "clock-names" to the device tree 'fixes' it, but we really 
need to keep backwards compatibility.

Steve

> ---
>   drivers/gpu/drm/panfrost/panfrost_devfreq.c | 13 +++++++++++++
>   drivers/gpu/drm/panfrost/panfrost_devfreq.h |  1 +
>   2 files changed, 14 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> index 9ffea0d4a087..6bf3541b4d53 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> @@ -103,6 +103,14 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
>   
>   	spin_lock_init(&pfdevfreq->lock);
>   
> +	opp_table = dev_pm_opp_set_clkname(dev, "core");
> +	if (IS_ERR(opp_table)) {
> +		ret = PTR_ERR(opp_table);
> +		goto err_fini;
> +	}
> +
> +	pfdevfreq->clkname_opp_table = opp_table;
> +
>   	opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names,
>   					      pfdev->comp->num_supplies);
>   	if (IS_ERR(opp_table)) {
> @@ -176,6 +184,11 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev)
>   		dev_pm_opp_put_regulators(pfdevfreq->regulators_opp_table);
>   		pfdevfreq->regulators_opp_table = NULL;
>   	}
> +
> +	if (pfdevfreq->clkname_opp_table) {
> +		dev_pm_opp_put_clkname(pfdevfreq->clkname_opp_table);
> +		pfdevfreq->clkname_opp_table = NULL;
> +	}
>   }
>   
>   void panfrost_devfreq_resume(struct panfrost_device *pfdev)
> diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.h b/drivers/gpu/drm/panfrost/panfrost_devfreq.h
> index 347cde4786cf..1f2475e1d034 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.h
> +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.h
> @@ -16,6 +16,7 @@ struct panfrost_device;
>   struct panfrost_devfreq {
>   	struct devfreq *devfreq;
>   	struct opp_table *regulators_opp_table;
> +	struct opp_table *clkname_opp_table;
>   	struct thermal_cooling_device *cooling;
>   	bool opp_of_table_added;
>   
>
Clément Péron May 29, 2020, 12:35 p.m. UTC | #2
Hi Steven,

On Thu, 28 May 2020 at 15:23, Steven Price <steven.price@arm.com> wrote:
>
> On 10/05/2020 17:55, Clément Péron wrote:
> > Some SoCs have  several clocks defined and the OPP core
> > needs to know the exact name of the clk to use.
> >
> > Set the clock name to "core".
> >
> > Signed-off-by: Clément Péron <peron.clem@gmail.com>
>
> This is unfortunately a regression for the RK3288. The device tree
> binding doesn't require "clock-names", and for the RK3288 it currently
> isn't specified. So this breaks the platform.
>
> Adding the "clock-names" to the device tree 'fixes' it, but we really
> need to keep backwards compatibility.

Yes you're right, thanks for cathing this.

Regards,
Clement

>
> Steve
>
> > ---
> >   drivers/gpu/drm/panfrost/panfrost_devfreq.c | 13 +++++++++++++
> >   drivers/gpu/drm/panfrost/panfrost_devfreq.h |  1 +
> >   2 files changed, 14 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> > index 9ffea0d4a087..6bf3541b4d53 100644
> > --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> > +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> > @@ -103,6 +103,14 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
> >
> >       spin_lock_init(&pfdevfreq->lock);
> >
> > +     opp_table = dev_pm_opp_set_clkname(dev, "core");
> > +     if (IS_ERR(opp_table)) {
> > +             ret = PTR_ERR(opp_table);
> > +             goto err_fini;
> > +     }
> > +
> > +     pfdevfreq->clkname_opp_table = opp_table;
> > +
> >       opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names,
> >                                             pfdev->comp->num_supplies);
> >       if (IS_ERR(opp_table)) {
> > @@ -176,6 +184,11 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev)
> >               dev_pm_opp_put_regulators(pfdevfreq->regulators_opp_table);
> >               pfdevfreq->regulators_opp_table = NULL;
> >       }
> > +
> > +     if (pfdevfreq->clkname_opp_table) {
> > +             dev_pm_opp_put_clkname(pfdevfreq->clkname_opp_table);
> > +             pfdevfreq->clkname_opp_table = NULL;
> > +     }
> >   }
> >
> >   void panfrost_devfreq_resume(struct panfrost_device *pfdev)
> > diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.h b/drivers/gpu/drm/panfrost/panfrost_devfreq.h
> > index 347cde4786cf..1f2475e1d034 100644
> > --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.h
> > +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.h
> > @@ -16,6 +16,7 @@ struct panfrost_device;
> >   struct panfrost_devfreq {
> >       struct devfreq *devfreq;
> >       struct opp_table *regulators_opp_table;
> > +     struct opp_table *clkname_opp_table;
> >       struct thermal_cooling_device *cooling;
> >       bool opp_of_table_added;
> >
> >
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
index 9ffea0d4a087..6bf3541b4d53 100644
--- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
+++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
@@ -103,6 +103,14 @@  int panfrost_devfreq_init(struct panfrost_device *pfdev)
 
 	spin_lock_init(&pfdevfreq->lock);
 
+	opp_table = dev_pm_opp_set_clkname(dev, "core");
+	if (IS_ERR(opp_table)) {
+		ret = PTR_ERR(opp_table);
+		goto err_fini;
+	}
+
+	pfdevfreq->clkname_opp_table = opp_table;
+
 	opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names,
 					      pfdev->comp->num_supplies);
 	if (IS_ERR(opp_table)) {
@@ -176,6 +184,11 @@  void panfrost_devfreq_fini(struct panfrost_device *pfdev)
 		dev_pm_opp_put_regulators(pfdevfreq->regulators_opp_table);
 		pfdevfreq->regulators_opp_table = NULL;
 	}
+
+	if (pfdevfreq->clkname_opp_table) {
+		dev_pm_opp_put_clkname(pfdevfreq->clkname_opp_table);
+		pfdevfreq->clkname_opp_table = NULL;
+	}
 }
 
 void panfrost_devfreq_resume(struct panfrost_device *pfdev)
diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.h b/drivers/gpu/drm/panfrost/panfrost_devfreq.h
index 347cde4786cf..1f2475e1d034 100644
--- a/drivers/gpu/drm/panfrost/panfrost_devfreq.h
+++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.h
@@ -16,6 +16,7 @@  struct panfrost_device;
 struct panfrost_devfreq {
 	struct devfreq *devfreq;
 	struct opp_table *regulators_opp_table;
+	struct opp_table *clkname_opp_table;
 	struct thermal_cooling_device *cooling;
 	bool opp_of_table_added;