diff mbox series

[v2,3/7] drm: rcar-du: lvsd: Add reset control

Message ID 20230120085009.604797-4-tomi.valkeinen+renesas@ideasonboard.com (mailing list archive)
State Superseded
Delegated to: Kieran Bingham
Headers show
Series [v2,1/7] drm: rcar-du: dsi: add 'select RESET_CONTROLLER' | expand

Commit Message

Tomi Valkeinen Jan. 20, 2023, 8:50 a.m. UTC
Reset LVDS using the reset control as CPG reset/release is required in
the hardware manual sequence.

Based on a BSP patch from Koji Matsuoka <koji.matsuoka.xm@renesas.com>.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
---
 drivers/gpu/drm/rcar-du/Kconfig     |  1 +
 drivers/gpu/drm/rcar-du/rcar_lvds.c | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Jan. 20, 2023, 4:18 p.m. UTC | #1
Hi Tomi,

Thank you for the patch.

On Fri, Jan 20, 2023 at 10:50:05AM +0200, Tomi Valkeinen wrote:
> Reset LVDS using the reset control as CPG reset/release is required in
> the hardware manual sequence.
> 
> Based on a BSP patch from Koji Matsuoka <koji.matsuoka.xm@renesas.com>.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> ---
>  drivers/gpu/drm/rcar-du/Kconfig     |  1 +
>  drivers/gpu/drm/rcar-du/rcar_lvds.c | 19 ++++++++++++++++++-
>  2 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig
> index a8f862c68b4f..151e400b996d 100644
> --- a/drivers/gpu/drm/rcar-du/Kconfig
> +++ b/drivers/gpu/drm/rcar-du/Kconfig
> @@ -43,6 +43,7 @@ config DRM_RCAR_LVDS
>  	select DRM_PANEL
>  	select OF_FLATTREE
>  	select OF_OVERLAY
> +	select RESET_CONTROLLER
>  
>  config DRM_RCAR_USE_MIPI_DSI
>  	bool "R-Car DU MIPI DSI Encoder Support"
> diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> index 8e1be51fbee6..668604616bfd 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> @@ -17,6 +17,7 @@
>  #include <linux/of_graph.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/reset.h>
>  #include <linux/slab.h>
>  #include <linux/sys_soc.h>
>  
> @@ -61,6 +62,7 @@ struct rcar_lvds_device_info {
>  struct rcar_lvds {
>  	struct device *dev;
>  	const struct rcar_lvds_device_info *info;
> +	struct reset_control *rstc;
>  
>  	struct drm_bridge bridge;
>  
> @@ -845,6 +847,10 @@ static int rcar_lvds_probe(struct platform_device *pdev)
>  	if (ret < 0)
>  		return ret;
>  
> +	lvds->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
> +	if (IS_ERR(lvds->rstc))
> +		return dev_err_probe(&pdev->dev, PTR_ERR(lvds->rstc),
> +				     "failed to get cpg reset\n");

Missing blank line.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  	pm_runtime_enable(&pdev->dev);
>  
>  	drm_bridge_add(&lvds->bridge);
> @@ -924,6 +930,8 @@ static int rcar_lvds_runtime_suspend(struct device *dev)
>  
>  	clk_disable_unprepare(lvds->clocks.mod);
>  
> +	reset_control_assert(lvds->rstc);
> +
>  	return 0;
>  }
>  
> @@ -932,11 +940,20 @@ static int rcar_lvds_runtime_resume(struct device *dev)
>  	struct rcar_lvds *lvds = dev_get_drvdata(dev);
>  	int ret;
>  
> +	ret = reset_control_deassert(lvds->rstc);
> +	if (ret)
> +		return ret;
> +
>  	ret = clk_prepare_enable(lvds->clocks.mod);
>  	if (ret < 0)
> -		return ret;
> +		goto err_reset_assert;
>  
>  	return 0;
> +
> +err_reset_assert:
> +	reset_control_assert(lvds->rstc);
> +
> +	return ret;
>  }
>  
>  static const struct dev_pm_ops rcar_lvds_pm_ops = {
Laurent Pinchart Jan. 20, 2023, 5:05 p.m. UTC | #2
On Fri, Jan 20, 2023 at 06:18:07PM +0200, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.

Another small comment: in the commit message, s/lvsd/lvds/

> On Fri, Jan 20, 2023 at 10:50:05AM +0200, Tomi Valkeinen wrote:
> > Reset LVDS using the reset control as CPG reset/release is required in
> > the hardware manual sequence.
> > 
> > Based on a BSP patch from Koji Matsuoka <koji.matsuoka.xm@renesas.com>.
> > 
> > Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> > ---
> >  drivers/gpu/drm/rcar-du/Kconfig     |  1 +
> >  drivers/gpu/drm/rcar-du/rcar_lvds.c | 19 ++++++++++++++++++-
> >  2 files changed, 19 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig
> > index a8f862c68b4f..151e400b996d 100644
> > --- a/drivers/gpu/drm/rcar-du/Kconfig
> > +++ b/drivers/gpu/drm/rcar-du/Kconfig
> > @@ -43,6 +43,7 @@ config DRM_RCAR_LVDS
> >  	select DRM_PANEL
> >  	select OF_FLATTREE
> >  	select OF_OVERLAY
> > +	select RESET_CONTROLLER
> >  
> >  config DRM_RCAR_USE_MIPI_DSI
> >  	bool "R-Car DU MIPI DSI Encoder Support"
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> > index 8e1be51fbee6..668604616bfd 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> > @@ -17,6 +17,7 @@
> >  #include <linux/of_graph.h>
> >  #include <linux/platform_device.h>
> >  #include <linux/pm_runtime.h>
> > +#include <linux/reset.h>
> >  #include <linux/slab.h>
> >  #include <linux/sys_soc.h>
> >  
> > @@ -61,6 +62,7 @@ struct rcar_lvds_device_info {
> >  struct rcar_lvds {
> >  	struct device *dev;
> >  	const struct rcar_lvds_device_info *info;
> > +	struct reset_control *rstc;
> >  
> >  	struct drm_bridge bridge;
> >  
> > @@ -845,6 +847,10 @@ static int rcar_lvds_probe(struct platform_device *pdev)
> >  	if (ret < 0)
> >  		return ret;
> >  
> > +	lvds->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
> > +	if (IS_ERR(lvds->rstc))
> > +		return dev_err_probe(&pdev->dev, PTR_ERR(lvds->rstc),
> > +				     "failed to get cpg reset\n");
> 
> Missing blank line.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> >  	pm_runtime_enable(&pdev->dev);
> >  
> >  	drm_bridge_add(&lvds->bridge);
> > @@ -924,6 +930,8 @@ static int rcar_lvds_runtime_suspend(struct device *dev)
> >  
> >  	clk_disable_unprepare(lvds->clocks.mod);
> >  
> > +	reset_control_assert(lvds->rstc);
> > +
> >  	return 0;
> >  }
> >  
> > @@ -932,11 +940,20 @@ static int rcar_lvds_runtime_resume(struct device *dev)
> >  	struct rcar_lvds *lvds = dev_get_drvdata(dev);
> >  	int ret;
> >  
> > +	ret = reset_control_deassert(lvds->rstc);
> > +	if (ret)
> > +		return ret;
> > +
> >  	ret = clk_prepare_enable(lvds->clocks.mod);
> >  	if (ret < 0)
> > -		return ret;
> > +		goto err_reset_assert;
> >  
> >  	return 0;
> > +
> > +err_reset_assert:
> > +	reset_control_assert(lvds->rstc);
> > +
> > +	return ret;
> >  }
> >  
> >  static const struct dev_pm_ops rcar_lvds_pm_ops = {
> 
> -- 
> Regards,
> 
> Laurent Pinchart
Tomi Valkeinen Jan. 23, 2023, 8:07 a.m. UTC | #3
On 20/01/2023 19:05, Laurent Pinchart wrote:
> On Fri, Jan 20, 2023 at 06:18:07PM +0200, Laurent Pinchart wrote:
>> Hi Tomi,
>>
>> Thank you for the patch.
> 
> Another small comment: in the commit message, s/lvsd/lvds/

Yep.

>> On Fri, Jan 20, 2023 at 10:50:05AM +0200, Tomi Valkeinen wrote:
>>> Reset LVDS using the reset control as CPG reset/release is required in
>>> the hardware manual sequence.
>>>
>>> Based on a BSP patch from Koji Matsuoka <koji.matsuoka.xm@renesas.com>.
>>>
>>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
>>> ---
>>>   drivers/gpu/drm/rcar-du/Kconfig     |  1 +
>>>   drivers/gpu/drm/rcar-du/rcar_lvds.c | 19 ++++++++++++++++++-
>>>   2 files changed, 19 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig
>>> index a8f862c68b4f..151e400b996d 100644
>>> --- a/drivers/gpu/drm/rcar-du/Kconfig
>>> +++ b/drivers/gpu/drm/rcar-du/Kconfig
>>> @@ -43,6 +43,7 @@ config DRM_RCAR_LVDS
>>>   	select DRM_PANEL
>>>   	select OF_FLATTREE
>>>   	select OF_OVERLAY
>>> +	select RESET_CONTROLLER
>>>   
>>>   config DRM_RCAR_USE_MIPI_DSI
>>>   	bool "R-Car DU MIPI DSI Encoder Support"
>>> diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c
>>> index 8e1be51fbee6..668604616bfd 100644
>>> --- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
>>> +++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
>>> @@ -17,6 +17,7 @@
>>>   #include <linux/of_graph.h>
>>>   #include <linux/platform_device.h>
>>>   #include <linux/pm_runtime.h>
>>> +#include <linux/reset.h>
>>>   #include <linux/slab.h>
>>>   #include <linux/sys_soc.h>
>>>   
>>> @@ -61,6 +62,7 @@ struct rcar_lvds_device_info {
>>>   struct rcar_lvds {
>>>   	struct device *dev;
>>>   	const struct rcar_lvds_device_info *info;
>>> +	struct reset_control *rstc;
>>>   
>>>   	struct drm_bridge bridge;
>>>   
>>> @@ -845,6 +847,10 @@ static int rcar_lvds_probe(struct platform_device *pdev)
>>>   	if (ret < 0)
>>>   		return ret;
>>>   
>>> +	lvds->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
>>> +	if (IS_ERR(lvds->rstc))
>>> +		return dev_err_probe(&pdev->dev, PTR_ERR(lvds->rstc),
>>> +				     "failed to get cpg reset\n");
>>
>> Missing blank line.
>>
>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Thanks!

  Tomi
diff mbox series

Patch

diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig
index a8f862c68b4f..151e400b996d 100644
--- a/drivers/gpu/drm/rcar-du/Kconfig
+++ b/drivers/gpu/drm/rcar-du/Kconfig
@@ -43,6 +43,7 @@  config DRM_RCAR_LVDS
 	select DRM_PANEL
 	select OF_FLATTREE
 	select OF_OVERLAY
+	select RESET_CONTROLLER
 
 config DRM_RCAR_USE_MIPI_DSI
 	bool "R-Car DU MIPI DSI Encoder Support"
diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c
index 8e1be51fbee6..668604616bfd 100644
--- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
+++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
@@ -17,6 +17,7 @@ 
 #include <linux/of_graph.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/reset.h>
 #include <linux/slab.h>
 #include <linux/sys_soc.h>
 
@@ -61,6 +62,7 @@  struct rcar_lvds_device_info {
 struct rcar_lvds {
 	struct device *dev;
 	const struct rcar_lvds_device_info *info;
+	struct reset_control *rstc;
 
 	struct drm_bridge bridge;
 
@@ -845,6 +847,10 @@  static int rcar_lvds_probe(struct platform_device *pdev)
 	if (ret < 0)
 		return ret;
 
+	lvds->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
+	if (IS_ERR(lvds->rstc))
+		return dev_err_probe(&pdev->dev, PTR_ERR(lvds->rstc),
+				     "failed to get cpg reset\n");
 	pm_runtime_enable(&pdev->dev);
 
 	drm_bridge_add(&lvds->bridge);
@@ -924,6 +930,8 @@  static int rcar_lvds_runtime_suspend(struct device *dev)
 
 	clk_disable_unprepare(lvds->clocks.mod);
 
+	reset_control_assert(lvds->rstc);
+
 	return 0;
 }
 
@@ -932,11 +940,20 @@  static int rcar_lvds_runtime_resume(struct device *dev)
 	struct rcar_lvds *lvds = dev_get_drvdata(dev);
 	int ret;
 
+	ret = reset_control_deassert(lvds->rstc);
+	if (ret)
+		return ret;
+
 	ret = clk_prepare_enable(lvds->clocks.mod);
 	if (ret < 0)
-		return ret;
+		goto err_reset_assert;
 
 	return 0;
+
+err_reset_assert:
+	reset_control_assert(lvds->rstc);
+
+	return ret;
 }
 
 static const struct dev_pm_ops rcar_lvds_pm_ops = {