[2/3] media: vsp1: Add support to deassert/assert reset line
Commit Message
As the resets DT property is mandatory, and is present in all .dtsi
in mainline, add support to perform deassert/assert when required.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
RFC->v1:
* Added reset support as seperate patch
* Moved rstc just after the bus_master field in struct vsp1_device
*
RFC:
* https://patchwork.kernel.org/project/linux-renesas-soc/patch/20220112174612.10773-21-biju.das.jz@bp.renesas.com/
---
drivers/media/platform/vsp1/vsp1.h | 1 +
drivers/media/platform/vsp1/vsp1_drv.c | 21 ++++++++++++++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
Comments
Hi Biju,
On Mi, 2022-03-09 at 19:45 +0000, Biju Das wrote:
[...]
> @@ -569,7 +570,19 @@ static void vsp1_mask_all_interrupts(struct
> vsp1_device *vsp1)
> */
> int vsp1_device_get(struct vsp1_device *vsp1)
> {
> - return pm_runtime_resume_and_get(vsp1->dev);
> + int ret = reset_control_deassert(vsp1->rstc);
> +
> + if (ret < 0)
> + goto err;
> +
> + ret = pm_runtime_resume_and_get(vsp1->dev);
> + if (ret < 0)
> + goto err;
> +
> + return 0;
> +err:
> + reset_control_assert(vsp1->rstc);
> + return ret;
> }
>
> /*
> @@ -581,6 +594,7 @@ int vsp1_device_get(struct vsp1_device *vsp1)
> void vsp1_device_put(struct vsp1_device *vsp1)
> {
> pm_runtime_put_sync(vsp1->dev);
> + reset_control_assert(vsp1->rstc);
Now the comment above doesn't fit anymore, since reset_control_assert
is not reference counted in case vsp1->rstc has exclusive control:
/*
* vsp1_device_put - Release the VSP1 device
*
* Decrement the VSP1 reference count and cleanup the device if the last
* reference is released.
*/
regards
Philipp
Hi Philipp,
Thanks for the feedback.
> Subject: Re: [PATCH 2/3] media: vsp1: Add support to deassert/assert reset
> line
>
> Hi Biju,
>
> On Mi, 2022-03-09 at 19:45 +0000, Biju Das wrote:
> [...]
> > @@ -569,7 +570,19 @@ static void vsp1_mask_all_interrupts(struct
> > vsp1_device *vsp1)
> > */
> > int vsp1_device_get(struct vsp1_device *vsp1)
> > {
> > - return pm_runtime_resume_and_get(vsp1->dev);
> > + int ret = reset_control_deassert(vsp1->rstc);
> > +
> > + if (ret < 0)
> > + goto err;
> > +
> > + ret = pm_runtime_resume_and_get(vsp1->dev);
> > + if (ret < 0)
> > + goto err;
> > +
> > + return 0;
> > +err:
> > + reset_control_assert(vsp1->rstc);
> > + return ret;
> > }
> >
> > /*
> > @@ -581,6 +594,7 @@ int vsp1_device_get(struct vsp1_device *vsp1)
> > void vsp1_device_put(struct vsp1_device *vsp1)
> > {
> > pm_runtime_put_sync(vsp1->dev);
> > + reset_control_assert(vsp1->rstc);
>
> Now the comment above doesn't fit anymore, since reset_control_assert is
> not reference counted in case vsp1->rstc has exclusive control:
Thanks for pointing out. I will send v2 with shared reset instead of exclusive
control to match with the comment above.
Moreover for next patch, we need to use shared reset as reset line is shared
with DU Module.
Cheers,
Biju
>
> /*
> * vsp1_device_put - Release the VSP1 device
> *
> * Decrement the VSP1 reference count and cleanup the device if the last
> * reference is released.
> */
>
> regards
> Philipp
@@ -79,6 +79,7 @@ struct vsp1_device {
void __iomem *mmio;
struct rcar_fcp_device *fcp;
struct device *bus_master;
+ struct reset_control *rstc;
struct vsp1_brx *brs;
struct vsp1_brx *bru;
@@ -16,6 +16,7 @@
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
+#include <linux/reset.h>
#include <linux/videodev2.h>
#include <media/rcar-fcp.h>
@@ -569,7 +570,19 @@ static void vsp1_mask_all_interrupts(struct vsp1_device *vsp1)
*/
int vsp1_device_get(struct vsp1_device *vsp1)
{
- return pm_runtime_resume_and_get(vsp1->dev);
+ int ret = reset_control_deassert(vsp1->rstc);
+
+ if (ret < 0)
+ goto err;
+
+ ret = pm_runtime_resume_and_get(vsp1->dev);
+ if (ret < 0)
+ goto err;
+
+ return 0;
+err:
+ reset_control_assert(vsp1->rstc);
+ return ret;
}
/*
@@ -581,6 +594,7 @@ int vsp1_device_get(struct vsp1_device *vsp1)
void vsp1_device_put(struct vsp1_device *vsp1)
{
pm_runtime_put_sync(vsp1->dev);
+ reset_control_assert(vsp1->rstc);
}
/* -----------------------------------------------------------------------------
@@ -827,6 +841,11 @@ static int vsp1_probe(struct platform_device *pdev)
if (irq < 0)
return irq;
+ vsp1->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
+ if (IS_ERR(vsp1->rstc))
+ return dev_err_probe(&pdev->dev, PTR_ERR(vsp1->rstc),
+ "failed to get reset ctrl\n");
+
/* FCP (optional). */
fcp_node = of_parse_phandle(pdev->dev.of_node, "renesas,fcp", 0);
if (fcp_node) {