diff mbox series

[2/3] drm: rcar-du: lvds: Move LVDS enable code to separate code section

Message ID 20230214003736.18871-3-laurent.pinchart+renesas@ideasonboard.com (mailing list archive)
State Mainlined
Commit 650e788136db881a1896f0ce42a7cb121df65afc
Delegated to: Kieran Bingham
Headers show
Series drm: rcar-du: Fix vblank wait timeout when stopping LVDS output | expand

Commit Message

Laurent Pinchart Feb. 14, 2023, 12:37 a.m. UTC
To prepare for a rework of the LVDS disable code, which will need to be
called from rcar_lvds_pclk_disable(), move the LVDS enable code,
currently stored in the __rcar_lvds_atomic_enable() function, to a
separate code section separate from bridge operations. It will be then
extended with the LVDS disable code.

As part of this rework the __rcar_lvds_atomic_enable() function is
renamed to rcar_lvds_enable() to more clearly indicate its purpose.

No functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/gpu/drm/rcar-du/rcar_lvds.c | 97 +++++++++++++++--------------
 1 file changed, 50 insertions(+), 47 deletions(-)

Comments

Geert Uytterhoeven Feb. 14, 2023, 8:25 a.m. UTC | #1
On Tue, Feb 14, 2023 at 1:45 AM Laurent Pinchart
<laurent.pinchart+renesas@ideasonboard.com> wrote:
> To prepare for a rework of the LVDS disable code, which will need to be
> called from rcar_lvds_pclk_disable(), move the LVDS enable code,
> currently stored in the __rcar_lvds_atomic_enable() function, to a
> separate code section separate from bridge operations. It will be then
> extended with the LVDS disable code.
>
> As part of this rework the __rcar_lvds_atomic_enable() function is
> renamed to rcar_lvds_enable() to more clearly indicate its purpose.
>
> No functional change intended.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert
Tomi Valkeinen Feb. 15, 2023, 6:20 a.m. UTC | #2
On 14/02/2023 02:37, Laurent Pinchart wrote:
> To prepare for a rework of the LVDS disable code, which will need to be
> called from rcar_lvds_pclk_disable(), move the LVDS enable code,
> currently stored in the __rcar_lvds_atomic_enable() function, to a
> separate code section separate from bridge operations. It will be then
> extended with the LVDS disable code.
> 
> As part of this rework the __rcar_lvds_atomic_enable() function is
> renamed to rcar_lvds_enable() to more clearly indicate its purpose.
> 
> No functional change intended.

The desc is a bit confusing, as it talks about moving LVDS enable code, 
but the diff shows you moving the lvds pclk enable/disable code. Other 
than that:

Reviewed-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>

  Tomi

> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>   drivers/gpu/drm/rcar-du/rcar_lvds.c | 97 +++++++++++++++--------------
>   1 file changed, 50 insertions(+), 47 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> index 61de18af62e6..70cdd5ec64d5 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> @@ -311,46 +311,7 @@ static void rcar_lvds_pll_setup_d3_e3(struct rcar_lvds *lvds, unsigned int freq)
>   }
>   
>   /* -----------------------------------------------------------------------------
> - * Clock - D3/E3 only
> - */
> -
> -int rcar_lvds_pclk_enable(struct drm_bridge *bridge, unsigned long freq)
> -{
> -	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
> -	int ret;
> -
> -	if (WARN_ON(!(lvds->info->quirks & RCAR_LVDS_QUIRK_EXT_PLL)))
> -		return -ENODEV;
> -
> -	dev_dbg(lvds->dev, "enabling LVDS PLL, freq=%luHz\n", freq);
> -
> -	ret = pm_runtime_resume_and_get(lvds->dev);
> -	if (ret)
> -		return ret;
> -
> -	__rcar_lvds_pll_setup_d3_e3(lvds, freq, true);
> -
> -	return 0;
> -}
> -EXPORT_SYMBOL_GPL(rcar_lvds_pclk_enable);
> -
> -void rcar_lvds_pclk_disable(struct drm_bridge *bridge)
> -{
> -	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
> -
> -	if (WARN_ON(!(lvds->info->quirks & RCAR_LVDS_QUIRK_EXT_PLL)))
> -		return;
> -
> -	dev_dbg(lvds->dev, "disabling LVDS PLL\n");
> -
> -	rcar_lvds_write(lvds, LVDPLLCR, 0);
> -
> -	pm_runtime_put_sync(lvds->dev);
> -}
> -EXPORT_SYMBOL_GPL(rcar_lvds_pclk_disable);
> -
> -/* -----------------------------------------------------------------------------
> - * Bridge
> + * Enable/disable
>    */
>   
>   static enum rcar_lvds_mode rcar_lvds_get_lvds_mode(struct rcar_lvds *lvds,
> @@ -394,10 +355,10 @@ static enum rcar_lvds_mode rcar_lvds_get_lvds_mode(struct rcar_lvds *lvds,
>   	return mode;
>   }
>   
> -static void __rcar_lvds_atomic_enable(struct drm_bridge *bridge,
> -				      struct drm_atomic_state *state,
> -				      struct drm_crtc *crtc,
> -				      struct drm_connector *connector)
> +static void rcar_lvds_enable(struct drm_bridge *bridge,
> +			     struct drm_atomic_state *state,
> +			     struct drm_crtc *crtc,
> +			     struct drm_connector *connector)
>   {
>   	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
>   	u32 lvdhcr;
> @@ -410,8 +371,7 @@ static void __rcar_lvds_atomic_enable(struct drm_bridge *bridge,
>   
>   	/* Enable the companion LVDS encoder in dual-link mode. */
>   	if (lvds->link_type != RCAR_LVDS_SINGLE_LINK && lvds->companion)
> -		__rcar_lvds_atomic_enable(lvds->companion, state, crtc,
> -					  connector);
> +		rcar_lvds_enable(lvds->companion, state, crtc, connector);
>   
>   	/*
>   	 * Hardcode the channels and control signals routing for now.
> @@ -531,6 +491,49 @@ static void __rcar_lvds_atomic_enable(struct drm_bridge *bridge,
>   	rcar_lvds_write(lvds, LVDCR0, lvdcr0);
>   }
>   
> +/* -----------------------------------------------------------------------------
> + * Clock - D3/E3 only
> + */
> +
> +int rcar_lvds_pclk_enable(struct drm_bridge *bridge, unsigned long freq)
> +{
> +	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
> +	int ret;
> +
> +	if (WARN_ON(!(lvds->info->quirks & RCAR_LVDS_QUIRK_EXT_PLL)))
> +		return -ENODEV;
> +
> +	dev_dbg(lvds->dev, "enabling LVDS PLL, freq=%luHz\n", freq);
> +
> +	ret = pm_runtime_resume_and_get(lvds->dev);
> +	if (ret)
> +		return ret;
> +
> +	__rcar_lvds_pll_setup_d3_e3(lvds, freq, true);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(rcar_lvds_pclk_enable);
> +
> +void rcar_lvds_pclk_disable(struct drm_bridge *bridge)
> +{
> +	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
> +
> +	if (WARN_ON(!(lvds->info->quirks & RCAR_LVDS_QUIRK_EXT_PLL)))
> +		return;
> +
> +	dev_dbg(lvds->dev, "disabling LVDS PLL\n");
> +
> +	rcar_lvds_write(lvds, LVDPLLCR, 0);
> +
> +	pm_runtime_put_sync(lvds->dev);
> +}
> +EXPORT_SYMBOL_GPL(rcar_lvds_pclk_disable);
> +
> +/* -----------------------------------------------------------------------------
> + * Bridge
> + */
> +
>   static void rcar_lvds_atomic_enable(struct drm_bridge *bridge,
>   				    struct drm_bridge_state *old_bridge_state)
>   {
> @@ -542,7 +545,7 @@ static void rcar_lvds_atomic_enable(struct drm_bridge *bridge,
>   							     bridge->encoder);
>   	crtc = drm_atomic_get_new_connector_state(state, connector)->crtc;
>   
> -	__rcar_lvds_atomic_enable(bridge, state, crtc, connector);
> +	rcar_lvds_enable(bridge, state, crtc, connector);
>   }
>   
>   static void rcar_lvds_atomic_disable(struct drm_bridge *bridge,
Laurent Pinchart Feb. 15, 2023, 8:34 a.m. UTC | #3
On Wed, Feb 15, 2023 at 08:20:51AM +0200, Tomi Valkeinen wrote:
> On 14/02/2023 02:37, Laurent Pinchart wrote:
> > To prepare for a rework of the LVDS disable code, which will need to be
> > called from rcar_lvds_pclk_disable(), move the LVDS enable code,
> > currently stored in the __rcar_lvds_atomic_enable() function, to a
> > separate code section separate from bridge operations. It will be then
> > extended with the LVDS disable code.
> > 
> > As part of this rework the __rcar_lvds_atomic_enable() function is
> > renamed to rcar_lvds_enable() to more clearly indicate its purpose.
> > 
> > No functional change intended.
> 
> The desc is a bit confusing, as it talks about moving LVDS enable code, 
> but the diff shows you moving the lvds pclk enable/disable code. Other 
> than that:

I moved the enable code, but git showed the diff differently. As the
goal was to move the enable code to later add disable code next to it,
I'll keep the commit message as-is.

> Reviewed-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> >   drivers/gpu/drm/rcar-du/rcar_lvds.c | 97 +++++++++++++++--------------
> >   1 file changed, 50 insertions(+), 47 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> > index 61de18af62e6..70cdd5ec64d5 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> > @@ -311,46 +311,7 @@ static void rcar_lvds_pll_setup_d3_e3(struct rcar_lvds *lvds, unsigned int freq)
> >   }
> >   
> >   /* -----------------------------------------------------------------------------
> > - * Clock - D3/E3 only
> > - */
> > -
> > -int rcar_lvds_pclk_enable(struct drm_bridge *bridge, unsigned long freq)
> > -{
> > -	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
> > -	int ret;
> > -
> > -	if (WARN_ON(!(lvds->info->quirks & RCAR_LVDS_QUIRK_EXT_PLL)))
> > -		return -ENODEV;
> > -
> > -	dev_dbg(lvds->dev, "enabling LVDS PLL, freq=%luHz\n", freq);
> > -
> > -	ret = pm_runtime_resume_and_get(lvds->dev);
> > -	if (ret)
> > -		return ret;
> > -
> > -	__rcar_lvds_pll_setup_d3_e3(lvds, freq, true);
> > -
> > -	return 0;
> > -}
> > -EXPORT_SYMBOL_GPL(rcar_lvds_pclk_enable);
> > -
> > -void rcar_lvds_pclk_disable(struct drm_bridge *bridge)
> > -{
> > -	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
> > -
> > -	if (WARN_ON(!(lvds->info->quirks & RCAR_LVDS_QUIRK_EXT_PLL)))
> > -		return;
> > -
> > -	dev_dbg(lvds->dev, "disabling LVDS PLL\n");
> > -
> > -	rcar_lvds_write(lvds, LVDPLLCR, 0);
> > -
> > -	pm_runtime_put_sync(lvds->dev);
> > -}
> > -EXPORT_SYMBOL_GPL(rcar_lvds_pclk_disable);
> > -
> > -/* -----------------------------------------------------------------------------
> > - * Bridge
> > + * Enable/disable
> >    */
> >   
> >   static enum rcar_lvds_mode rcar_lvds_get_lvds_mode(struct rcar_lvds *lvds,
> > @@ -394,10 +355,10 @@ static enum rcar_lvds_mode rcar_lvds_get_lvds_mode(struct rcar_lvds *lvds,
> >   	return mode;
> >   }
> >   
> > -static void __rcar_lvds_atomic_enable(struct drm_bridge *bridge,
> > -				      struct drm_atomic_state *state,
> > -				      struct drm_crtc *crtc,
> > -				      struct drm_connector *connector)
> > +static void rcar_lvds_enable(struct drm_bridge *bridge,
> > +			     struct drm_atomic_state *state,
> > +			     struct drm_crtc *crtc,
> > +			     struct drm_connector *connector)
> >   {
> >   	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
> >   	u32 lvdhcr;
> > @@ -410,8 +371,7 @@ static void __rcar_lvds_atomic_enable(struct drm_bridge *bridge,
> >   
> >   	/* Enable the companion LVDS encoder in dual-link mode. */
> >   	if (lvds->link_type != RCAR_LVDS_SINGLE_LINK && lvds->companion)
> > -		__rcar_lvds_atomic_enable(lvds->companion, state, crtc,
> > -					  connector);
> > +		rcar_lvds_enable(lvds->companion, state, crtc, connector);
> >   
> >   	/*
> >   	 * Hardcode the channels and control signals routing for now.
> > @@ -531,6 +491,49 @@ static void __rcar_lvds_atomic_enable(struct drm_bridge *bridge,
> >   	rcar_lvds_write(lvds, LVDCR0, lvdcr0);
> >   }
> >   
> > +/* -----------------------------------------------------------------------------
> > + * Clock - D3/E3 only
> > + */
> > +
> > +int rcar_lvds_pclk_enable(struct drm_bridge *bridge, unsigned long freq)
> > +{
> > +	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
> > +	int ret;
> > +
> > +	if (WARN_ON(!(lvds->info->quirks & RCAR_LVDS_QUIRK_EXT_PLL)))
> > +		return -ENODEV;
> > +
> > +	dev_dbg(lvds->dev, "enabling LVDS PLL, freq=%luHz\n", freq);
> > +
> > +	ret = pm_runtime_resume_and_get(lvds->dev);
> > +	if (ret)
> > +		return ret;
> > +
> > +	__rcar_lvds_pll_setup_d3_e3(lvds, freq, true);
> > +
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(rcar_lvds_pclk_enable);
> > +
> > +void rcar_lvds_pclk_disable(struct drm_bridge *bridge)
> > +{
> > +	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
> > +
> > +	if (WARN_ON(!(lvds->info->quirks & RCAR_LVDS_QUIRK_EXT_PLL)))
> > +		return;
> > +
> > +	dev_dbg(lvds->dev, "disabling LVDS PLL\n");
> > +
> > +	rcar_lvds_write(lvds, LVDPLLCR, 0);
> > +
> > +	pm_runtime_put_sync(lvds->dev);
> > +}
> > +EXPORT_SYMBOL_GPL(rcar_lvds_pclk_disable);
> > +
> > +/* -----------------------------------------------------------------------------
> > + * Bridge
> > + */
> > +
> >   static void rcar_lvds_atomic_enable(struct drm_bridge *bridge,
> >   				    struct drm_bridge_state *old_bridge_state)
> >   {
> > @@ -542,7 +545,7 @@ static void rcar_lvds_atomic_enable(struct drm_bridge *bridge,
> >   							     bridge->encoder);
> >   	crtc = drm_atomic_get_new_connector_state(state, connector)->crtc;
> >   
> > -	__rcar_lvds_atomic_enable(bridge, state, crtc, connector);
> > +	rcar_lvds_enable(bridge, state, crtc, connector);
> >   }
> >   
> >   static void rcar_lvds_atomic_disable(struct drm_bridge *bridge,
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c
index 61de18af62e6..70cdd5ec64d5 100644
--- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
+++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
@@ -311,46 +311,7 @@  static void rcar_lvds_pll_setup_d3_e3(struct rcar_lvds *lvds, unsigned int freq)
 }
 
 /* -----------------------------------------------------------------------------
- * Clock - D3/E3 only
- */
-
-int rcar_lvds_pclk_enable(struct drm_bridge *bridge, unsigned long freq)
-{
-	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
-	int ret;
-
-	if (WARN_ON(!(lvds->info->quirks & RCAR_LVDS_QUIRK_EXT_PLL)))
-		return -ENODEV;
-
-	dev_dbg(lvds->dev, "enabling LVDS PLL, freq=%luHz\n", freq);
-
-	ret = pm_runtime_resume_and_get(lvds->dev);
-	if (ret)
-		return ret;
-
-	__rcar_lvds_pll_setup_d3_e3(lvds, freq, true);
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(rcar_lvds_pclk_enable);
-
-void rcar_lvds_pclk_disable(struct drm_bridge *bridge)
-{
-	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
-
-	if (WARN_ON(!(lvds->info->quirks & RCAR_LVDS_QUIRK_EXT_PLL)))
-		return;
-
-	dev_dbg(lvds->dev, "disabling LVDS PLL\n");
-
-	rcar_lvds_write(lvds, LVDPLLCR, 0);
-
-	pm_runtime_put_sync(lvds->dev);
-}
-EXPORT_SYMBOL_GPL(rcar_lvds_pclk_disable);
-
-/* -----------------------------------------------------------------------------
- * Bridge
+ * Enable/disable
  */
 
 static enum rcar_lvds_mode rcar_lvds_get_lvds_mode(struct rcar_lvds *lvds,
@@ -394,10 +355,10 @@  static enum rcar_lvds_mode rcar_lvds_get_lvds_mode(struct rcar_lvds *lvds,
 	return mode;
 }
 
-static void __rcar_lvds_atomic_enable(struct drm_bridge *bridge,
-				      struct drm_atomic_state *state,
-				      struct drm_crtc *crtc,
-				      struct drm_connector *connector)
+static void rcar_lvds_enable(struct drm_bridge *bridge,
+			     struct drm_atomic_state *state,
+			     struct drm_crtc *crtc,
+			     struct drm_connector *connector)
 {
 	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
 	u32 lvdhcr;
@@ -410,8 +371,7 @@  static void __rcar_lvds_atomic_enable(struct drm_bridge *bridge,
 
 	/* Enable the companion LVDS encoder in dual-link mode. */
 	if (lvds->link_type != RCAR_LVDS_SINGLE_LINK && lvds->companion)
-		__rcar_lvds_atomic_enable(lvds->companion, state, crtc,
-					  connector);
+		rcar_lvds_enable(lvds->companion, state, crtc, connector);
 
 	/*
 	 * Hardcode the channels and control signals routing for now.
@@ -531,6 +491,49 @@  static void __rcar_lvds_atomic_enable(struct drm_bridge *bridge,
 	rcar_lvds_write(lvds, LVDCR0, lvdcr0);
 }
 
+/* -----------------------------------------------------------------------------
+ * Clock - D3/E3 only
+ */
+
+int rcar_lvds_pclk_enable(struct drm_bridge *bridge, unsigned long freq)
+{
+	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
+	int ret;
+
+	if (WARN_ON(!(lvds->info->quirks & RCAR_LVDS_QUIRK_EXT_PLL)))
+		return -ENODEV;
+
+	dev_dbg(lvds->dev, "enabling LVDS PLL, freq=%luHz\n", freq);
+
+	ret = pm_runtime_resume_and_get(lvds->dev);
+	if (ret)
+		return ret;
+
+	__rcar_lvds_pll_setup_d3_e3(lvds, freq, true);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(rcar_lvds_pclk_enable);
+
+void rcar_lvds_pclk_disable(struct drm_bridge *bridge)
+{
+	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
+
+	if (WARN_ON(!(lvds->info->quirks & RCAR_LVDS_QUIRK_EXT_PLL)))
+		return;
+
+	dev_dbg(lvds->dev, "disabling LVDS PLL\n");
+
+	rcar_lvds_write(lvds, LVDPLLCR, 0);
+
+	pm_runtime_put_sync(lvds->dev);
+}
+EXPORT_SYMBOL_GPL(rcar_lvds_pclk_disable);
+
+/* -----------------------------------------------------------------------------
+ * Bridge
+ */
+
 static void rcar_lvds_atomic_enable(struct drm_bridge *bridge,
 				    struct drm_bridge_state *old_bridge_state)
 {
@@ -542,7 +545,7 @@  static void rcar_lvds_atomic_enable(struct drm_bridge *bridge,
 							     bridge->encoder);
 	crtc = drm_atomic_get_new_connector_state(state, connector)->crtc;
 
-	__rcar_lvds_atomic_enable(bridge, state, crtc, connector);
+	rcar_lvds_enable(bridge, state, crtc, connector);
 }
 
 static void rcar_lvds_atomic_disable(struct drm_bridge *bridge,