Message ID | 20240318144225.30835-3-brnkv.i1@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Wave515 decoder IP support | expand |
Hi Ivan, On Mo, 2024-03-18 at 17:42 +0300, Ivan Bornyakov wrote: > Add initial support for optional reset lines. For now, simply deassert > resets on driver probe and assert them back on driver remove. > > Signed-off-by: Ivan Bornyakov <brnkv.i1@gmail.com> > --- > .../media/platform/chips-media/wave5/wave5-vpu.c | 13 +++++++++++++ > .../media/platform/chips-media/wave5/wave5-vpuapi.h | 1 + > 2 files changed, 14 insertions(+) > > diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu.c b/drivers/media/platform/chips-media/wave5/wave5-vpu.c > index 1b3df5b04249..f3ecadefd37a 100644 > --- a/drivers/media/platform/chips-media/wave5/wave5-vpu.c > +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu.c > @@ -10,6 +10,7 @@ > #include <linux/clk.h> > #include <linux/firmware.h> > #include <linux/interrupt.h> > +#include <linux/reset.h> > #include "wave5-vpu.h" > #include "wave5-regdefine.h" > #include "wave5-vpuconfig.h" > @@ -151,6 +152,17 @@ static int wave5_vpu_probe(struct platform_device *pdev) > dev_set_drvdata(&pdev->dev, dev); > dev->dev = &pdev->dev; > > + dev->resets = devm_reset_control_array_get_optional_exclusive(&pdev->dev); > + if (IS_ERR(dev->resets)) { > + return dev_err_probe(&pdev->dev, PTR_ERR(dev->resets), > + "Failed to get reset control\n"); > + } else { > + ret = reset_control_deassert(dev->resets); > + if (ret) > + return dev_err_probe(&pdev->dev, ret, > + "Failed to deassert resets\n"); This doesn't have to be in an else block, the error path above returns. > + } > + > ret = devm_clk_bulk_get_all(&pdev->dev, &dev->clks); I'd expect the reset control to be asserted in the error path. regards Philipp
diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu.c b/drivers/media/platform/chips-media/wave5/wave5-vpu.c index 1b3df5b04249..f3ecadefd37a 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu.c @@ -10,6 +10,7 @@ #include <linux/clk.h> #include <linux/firmware.h> #include <linux/interrupt.h> +#include <linux/reset.h> #include "wave5-vpu.h" #include "wave5-regdefine.h" #include "wave5-vpuconfig.h" @@ -151,6 +152,17 @@ static int wave5_vpu_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, dev); dev->dev = &pdev->dev; + dev->resets = devm_reset_control_array_get_optional_exclusive(&pdev->dev); + if (IS_ERR(dev->resets)) { + return dev_err_probe(&pdev->dev, PTR_ERR(dev->resets), + "Failed to get reset control\n"); + } else { + ret = reset_control_deassert(dev->resets); + if (ret) + return dev_err_probe(&pdev->dev, ret, + "Failed to deassert resets\n"); + } + ret = devm_clk_bulk_get_all(&pdev->dev, &dev->clks); /* continue without clock, assume externally managed */ @@ -256,6 +268,7 @@ static void wave5_vpu_remove(struct platform_device *pdev) mutex_destroy(&dev->dev_lock); mutex_destroy(&dev->hw_lock); + reset_control_assert(dev->resets); clk_bulk_disable_unprepare(dev->num_clks, dev->clks); wave5_vpu_enc_unregister_device(dev); wave5_vpu_dec_unregister_device(dev); diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h index 352f6e904e50..fa62a85080b5 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h +++ b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h @@ -757,6 +757,7 @@ struct vpu_device { struct ida inst_ida; struct clk_bulk_data *clks; int num_clks; + struct reset_control *resets; }; struct vpu_instance;
Add initial support for optional reset lines. For now, simply deassert resets on driver probe and assert them back on driver remove. Signed-off-by: Ivan Bornyakov <brnkv.i1@gmail.com> --- .../media/platform/chips-media/wave5/wave5-vpu.c | 13 +++++++++++++ .../media/platform/chips-media/wave5/wave5-vpuapi.h | 1 + 2 files changed, 14 insertions(+)