[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAFQd5C4hpz8DR101WYQ=9xeq3=yMbtbCasAUqGPpg9fLNORgA@mail.gmail.com>
Date: Fri, 31 Jul 2020 14:49:03 +0200
From: Tomasz Figa <tfiga@...omium.org>
To: Xia Jiang <xia.jiang@...iatek.com>
Cc: Hans Verkuil <hverkuil-cisco@...all.nl>,
Mauro Carvalho Chehab <mchehab+samsung@...nel.org>,
Rob Herring <robh+dt@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Rick Chang <rick.chang@...iatek.com>,
Linux Media Mailing List <linux-media@...r.kernel.org>,
linux-devicetree <devicetree@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
"list@....net:IOMMU DRIVERS <iommu@...ts.linux-foundation.org>, Joerg
Roedel <joro@...tes.org>," <linux-arm-kernel@...ts.infradead.org>,
"moderated list:ARM/Mediatek SoC support"
<linux-mediatek@...ts.infradead.org>,
Marek Szyprowski <m.szyprowski@...sung.com>,
srv_heupstream <srv_heupstream@...iatek.com>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
mojahsu@...omium.org, Nicolas Boichat <drinkcat@...omium.org>,
Maoguang Meng (孟毛广)
<maoguang.meng@...iatek.com>
Subject: Re: [PATCH v10 22/28] media: platform: Change the call functions of
getting/enable/disable the jpeg's clock
On Fri, Jul 31, 2020 at 5:20 AM Xia Jiang <xia.jiang@...iatek.com> wrote:
>
> On Thu, 2020-07-30 at 16:34 +0000, Tomasz Figa wrote:
> > Hi Xia,
> >
> > On Thu, Jul 23, 2020 at 11:04:45AM +0800, Xia Jiang wrote:
> > > Use the generic of_property_* helpers to get the clock_nums and clocks
> > > from device tree.
> > > Use the generic clk_bulk_* helpers to enable and disable clocks.
> > >
> > > Signed-off-by: Xia Jiang <xia.jiang@...iatek.com>
> > > ---
> > > v10: new add patch
> > > ---
> > > .../media/platform/mtk-jpeg/mtk_jpeg_core.c | 47 +++++++++++++++----
> > > .../media/platform/mtk-jpeg/mtk_jpeg_core.h | 8 ++--
> > > 2 files changed, 42 insertions(+), 13 deletions(-)
> > >
> >
> > Thank you for the patch. Please see my comments inline.
> >
> > > diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> > > index 7881e9c93df7..921ed21f7db3 100644
> > > --- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> > > +++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> > > @@ -783,14 +783,15 @@ static void mtk_jpeg_clk_on(struct mtk_jpeg_dev *jpeg)
> > > ret = mtk_smi_larb_get(jpeg->larb);
> > > if (ret)
> > > dev_err(jpeg->dev, "mtk_smi_larb_get larbvdec fail %d\n", ret);
> > > - clk_prepare_enable(jpeg->clk_jdec_smi);
> > > - clk_prepare_enable(jpeg->clk_jdec);
> > > +
> > > + ret = clk_bulk_prepare_enable(jpeg->num_clks, jpeg->clks);
> > > + if (ret)
> > > + dev_err(jpeg->dev, "Failed to open jpeg clk: %d\n", ret);
> > > }
> > >
> > > static void mtk_jpeg_clk_off(struct mtk_jpeg_dev *jpeg)
> > > {
> > > - clk_disable_unprepare(jpeg->clk_jdec);
> > > - clk_disable_unprepare(jpeg->clk_jdec_smi);
> > > + clk_bulk_disable_unprepare(jpeg->num_clks, jpeg->clks);
> > > mtk_smi_larb_put(jpeg->larb);
> > > }
> > >
> > > @@ -939,6 +940,7 @@ static int mtk_jpeg_clk_init(struct mtk_jpeg_dev *jpeg)
> > > {
> > > struct device_node *node;
> > > struct platform_device *pdev;
> > > + int ret, i;
> > >
> > > node = of_parse_phandle(jpeg->dev->of_node, "mediatek,larb", 0);
> > > if (!node)
> > > @@ -952,12 +954,39 @@ static int mtk_jpeg_clk_init(struct mtk_jpeg_dev *jpeg)
> > >
> > > jpeg->larb = &pdev->dev;
> > >
> > > - jpeg->clk_jdec = devm_clk_get(jpeg->dev, "jpgdec");
> > > - if (IS_ERR(jpeg->clk_jdec))
> > > - return PTR_ERR(jpeg->clk_jdec);
> > > + jpeg->num_clks =
> > > + of_property_count_strings(jpeg->dev->of_node, "clock-names");
> > > +
> > > + if (jpeg->num_clks > 0) {
> > > + jpeg->clks = devm_kcalloc(jpeg->dev, jpeg->num_clks,
> > > + sizeof(struct clk_bulk_data),
> > > + GFP_KERNEL);
> > > + if (!jpeg->clks)
> > > + return -ENOMEM;
> > > + } else {
> > > + dev_err(&pdev->dev, "Failed to get jpeg clock count\n");
> > > + return -EINVAL;
> > > + }
> > > +
> > > + for (i = 0; i < jpeg->num_clks; i++) {
> > > + ret = of_property_read_string_index(jpeg->dev->of_node,
> > > + "clock-names", i,
> > > + &jpeg->clks->id);
> >
> > The names of the clocks must be explicitly specified in the driver, as per
> > the DT bindings.
> Dear Tomasz,
>
> Thank you for your reply.
> You mean that I should keep the v9 version about names of the clocks in
> the match data.
> The v10 version about the names of the clocks follows the upstreamed
> mtk_venc/vdec.I think that this method is more generic. For example,when
> other project has more clocks, we can get the names of clocks from dtsi
> without changing the driver code.
> What about your further opinion?
The problem with that method is that one can put any random names in
the DT and the driver will happily accept them, without any
correctness checking. Moreover, if the other project has more clocks,
it already requires a different compatible string in the DT bindings,
so the kernel needs to be changed anyway.
Actually this is something that needs to be fixed in the mtk_venc/vdec
driver as well. I believe someone just overlooked it when the driver
was being reviewed.
Best regards,
Tomasz
Powered by blists - more mailing lists