Re: [PATCH 04/18] media: hantro: add reset controller support

From: Philipp Zabel
Date: Tue Oct 13 2020 - 04:12:51 EST


Hi Adrian,

On Mon, 2020-10-12 at 23:59 +0300, Adrian Ratiu wrote:
> Some SoCs might have a reset controller which disables clocks
> by default in reset state which then drivers need to unreset
> before being able to ungate a specific clock.
>
> In this specific case, the hantro driver needs to ensure the
> peripheral clock can be properly ungated otherwise MMIO reg
> values can't be accessed.
>
> If the SoC has no reset controller or there is no "resets" DT
> property defined, this new code will have no effect.
>
> Signed-off-by: Adrian Ratiu <adrian.ratiu@xxxxxxxxxxxxx>
> Signed-off-by: Ezequiel Garcia <ezequiel@xxxxxxxxxxxxx>
> ---
> drivers/staging/media/hantro/hantro.h | 1 +
> drivers/staging/media/hantro/hantro_drv.c | 8 ++++++++
> 2 files changed, 9 insertions(+)
>
> diff --git a/drivers/staging/media/hantro/hantro.h b/drivers/staging/media/hantro/hantro.h
> index 65f9f7ea7dcf..bb442eb1974e 100644
> --- a/drivers/staging/media/hantro/hantro.h
> +++ b/drivers/staging/media/hantro/hantro.h
> @@ -183,6 +183,7 @@ struct hantro_dev {
> struct platform_device *pdev;
> struct device *dev;
> struct clk_bulk_data *clocks;
> + struct reset_control *reset;
> void __iomem **reg_bases;
> void __iomem *enc_base;
> void __iomem *dec_base;
> diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
> index 3cd00cc0a364..c2ea54552ce9 100644
> --- a/drivers/staging/media/hantro/hantro_drv.c
> +++ b/drivers/staging/media/hantro/hantro_drv.c
> @@ -17,6 +17,7 @@
> #include <linux/pm.h>
> #include <linux/pm_runtime.h>
> #include <linux/slab.h>
> +#include <linux/reset.h>
> #include <linux/videodev2.h>
> #include <linux/workqueue.h>
> #include <media/v4l2-event.h>
> @@ -747,6 +748,13 @@ static int hantro_probe(struct platform_device *pdev)
>
> INIT_DELAYED_WORK(&vpu->watchdog_work, hantro_watchdog);
>
> + vpu->reset = devm_reset_control_get_optional_exclusive(&pdev->dev,
> + NULL);
> + if (IS_ERR(vpu->reset))
> + vpu->reset = NULL;

Please return the error. If the optional reset is missing from the
device tree, devm_reset_control_get_optional_exclusive() returns NULL
already.

regards
Philipp