From: Yong Wu <yong.wu@mediatek.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Cc: Rob Herring <robh+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
"Joerg Roedel" <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Tomasz Figa <tfiga@chromium.org>,
<linux-mediatek@lists.infradead.org>,
<srv_heupstream@mediatek.com>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<iommu@lists.linux-foundation.org>, <youlin.pei@mediatek.com>,
<anan.sun@mediatek.com>, <ming-fan.chen@mediatek.com>,
<yi.kuo@mediatek.com>, <anthony.huang@mediatek.com>
Subject: Re: [PATCH 3/9] memory: mtk-smi: Use clk_bulk instead of the clk ops
Date: Sun, 11 Jul 2021 16:29:59 +0800 [thread overview]
Message-ID: <1625992199.22309.15.camel@mhfsdcap03> (raw)
In-Reply-To: <4047dfaf-f2f8-b6b2-52fd-41821475b162@canonical.com>
On Thu, 2021-07-08 at 11:32 +0200, Krzysztof Kozlowski wrote:
> On 16/06/2021 13:43, Yong Wu wrote:
> > smi have many clocks: apb/smi/gals.
> > This patch use clk_bulk interface instead of the orginal one to simply
> > the code.
> >
> > gals is optional clk(some larbs may don't have gals). use clk_bulk_optional
> > instead. and then remove the has_gals flag.
> >
> > Also remove clk fail logs since bulk interface already output fail log.
> >
> > Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> > ---
> > drivers/memory/mtk-smi.c | 124 +++++++++++----------------------------
> > 1 file changed, 34 insertions(+), 90 deletions(-)
> >
> > diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
> > index c5fb51f73b34..bcd2bf130655 100644
> > --- a/drivers/memory/mtk-smi.c
> > +++ b/drivers/memory/mtk-smi.c
> > @@ -60,9 +60,18 @@ enum mtk_smi_gen {
> > MTK_SMI_GEN2
> > };
> >
> > +#define MTK_SMI_CLK_NR_MAX 4
> > +
> > +static const char * const mtk_smi_common_clocks[] = {
> > + "apb", "smi", "gals0", "gals1", /* glas is optional */
>
> Typo here - glas.
Will Fix. Thanks.
>
> > +};
> > +
[snip]
> > @@ -493,7 +449,7 @@ static int mtk_smi_common_probe(struct platform_device *pdev)
> > struct device *dev = &pdev->dev;
> > struct mtk_smi *common;
> > struct resource *res;
> > - int ret;
> > + int i, ret;
> >
> > common = devm_kzalloc(dev, sizeof(*common), GFP_KERNEL);
> > if (!common)
> > @@ -501,23 +457,13 @@ static int mtk_smi_common_probe(struct platform_device *pdev)
> > common->dev = dev;
> > common->plat = of_device_get_match_data(dev);
> >
> > - common->clk_apb = devm_clk_get(dev, "apb");
> > - if (IS_ERR(common->clk_apb))
> > - return PTR_ERR(common->clk_apb);
> > -
> > - common->clk_smi = devm_clk_get(dev, "smi");
> > - if (IS_ERR(common->clk_smi))
> > - return PTR_ERR(common->clk_smi);
> > + common->clk_num = ARRAY_SIZE(mtk_smi_common_clocks);
> > + for (i = 0; i < common->clk_num; i++)
> > + common->clks[i].id = mtk_smi_common_clocks[i];
> >
> > - if (common->plat->has_gals) {
> > - common->clk_gals0 = devm_clk_get(dev, "gals0");
> > - if (IS_ERR(common->clk_gals0))
> > - return PTR_ERR(common->clk_gals0);
> > -
> > - common->clk_gals1 = devm_clk_get(dev, "gals1");
> > - if (IS_ERR(common->clk_gals1))
> > - return PTR_ERR(common->clk_gals1);
> > - }
> > + ret = devm_clk_bulk_get_optional(dev, common->clk_num, common->clks);
> > + if (ret)
> > + return ret;
>
> How do you handle now missing required clocks?
It looks this is a common issue for this function which supports all the
clocks could be optional. Is there common suggestion for this?
For our case, the apb/smi clocks are required while "gals" are optional.
thus, we should use devm_clk_bulk_get for the necessary clocks and
devm_clk_bulk_get_optional for the optional ones. right?
>
> >
> > /*
> > * for mtk smi gen 1, we need to get the ao(always on) base to config
> > @@ -561,11 +507,9 @@ static int __maybe_unused mtk_smi_common_resume(struct device *dev)
> > u32 bus_sel = common->plat->bus_sel;
> > int ret;
> >
> > - ret = mtk_smi_clk_enable(common);
> > - if (ret) {
> > - dev_err(common->dev, "Failed to enable clock(%d).\n", ret);
> > + ret = clk_bulk_prepare_enable(common->clk_num, common->clks);
> > + if (ret)
> > return ret;
> > - }
> >
> > if (common->plat->gen == MTK_SMI_GEN2 && bus_sel)
> > writel(bus_sel, common->base + SMI_BUS_SEL);
> > @@ -576,7 +520,7 @@ static int __maybe_unused mtk_smi_common_suspend(struct device *dev)
> > {
> > struct mtk_smi *common = dev_get_drvdata(dev);
> >
> > - mtk_smi_clk_disable(common);
> > + clk_bulk_disable_unprepare(common->clk_num, common->clks);
> > return 0;
> > }
> >
> >
>
>
> Best regards,
> Krzysztof
next prev parent reply other threads:[~2021-07-11 8:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-16 11:43 [PATCH 0/9] MT8195 SMI support Yong Wu
2021-06-16 11:43 ` [PATCH 1/9] dt-bindings: memory: mediatek: Add mt8195 smi binding Yong Wu
2021-07-08 9:26 ` Krzysztof Kozlowski
2021-07-11 8:24 ` Yong Wu
2021-06-16 11:43 ` [PATCH 2/9] dt-bindings: memory: mediatek: Add mt8195 smi sub common Yong Wu
2021-06-16 11:43 ` [PATCH 3/9] memory: mtk-smi: Use clk_bulk instead of the clk ops Yong Wu
2021-07-08 9:32 ` Krzysztof Kozlowski
2021-07-11 8:29 ` Yong Wu [this message]
2021-07-12 6:44 ` Krzysztof Kozlowski
2021-06-16 11:43 ` [PATCH 4/9] memory: mtk-smi: Rename smi_gen to smi_type Yong Wu
2021-07-08 9:34 ` Krzysztof Kozlowski
2021-07-11 8:24 ` Yong Wu
2021-06-16 11:43 ` [PATCH 5/9] memory: mtk-smi: Adjust some code position Yong Wu
2021-06-16 11:43 ` [PATCH 6/9] memory: mtk-smi: Add smi sub common support Yong Wu
2021-07-08 9:47 ` Krzysztof Kozlowski
2021-06-16 11:43 ` [PATCH 7/9] memory: mtk-smi: mt8195: Add smi support Yong Wu
2021-06-16 11:43 ` [PATCH 8/9] memory: mtk-smi: mt8195: Add initial setting for smi-common Yong Wu
2021-06-16 11:43 ` [PATCH 9/9] memory: mtk-smi: mt8195: Add initial setting for smi-larb Yong Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1625992199.22309.15.camel@mhfsdcap03 \
--to=yong.wu@mediatek.com \
--cc=anan.sun@mediatek.com \
--cc=anthony.huang@mediatek.com \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=krzk@kernel.org \
--cc=krzysztof.kozlowski@canonical.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=ming-fan.chen@mediatek.com \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--cc=srv_heupstream@mediatek.com \
--cc=tfiga@chromium.org \
--cc=will@kernel.org \
--cc=yi.kuo@mediatek.com \
--cc=youlin.pei@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).