devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Friday Yang (杨阳)" <Friday.Yang@mediatek.com>
To: "p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"robh@kernel.org" <robh@kernel.org>,
	"Yong Wu (吴勇)" <Yong.Wu@mediatek.com>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"krzk@kernel.org" <krzk@kernel.org>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>
Cc: "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Project_Global_Chrome_Upstream_Group
	<Project_Global_Chrome_Upstream_Group@mediatek.com>
Subject: Re: [PATCH v3 2/2] memory: mtk-smi: mt8188: Add SMI reset and clamp for MT8188
Date: Wed, 22 Jan 2025 07:39:43 +0000	[thread overview]
Message-ID: <c4ce6e5c6350e6cfb5ff9bebf3118be0ac76edbd.camel@mediatek.com> (raw)
In-Reply-To: <98d064a635467dcc3937d1ec9c5b1659bd71eb91.camel@pengutronix.de>

On Tue, 2025-01-21 at 09:53 +0100, Philipp Zabel wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> On Di, 2025-01-21 at 14:49 +0800, Friday Yang wrote:
> > From: "friday.yang" <friday.yang@mediatek.com>
> > 
> > To prevent handling glitch signals during MTCMOS on/off
> > transitions,
> > SMI requires clamp and reset operations. Parse the reset settings
> > for
> > SMI LARBs and the clamp settings for the SMI Sub-Common. Register
> > genpd callback for the SMI LARBs located in image, camera and IPE
> > subsystems, and apply reset and clamp operations within the
> > callback.
> > 
> > Signed-off-by: Friday Yang <friday.yang@mediatek.com>
> > ---
> >  drivers/memory/mtk-smi.c | 141
> > +++++++++++++++++++++++++++++++++++++--
> >  1 file changed, 137 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
> > index 5710348f72f6..aaeb80379ec1 100644
> > --- a/drivers/memory/mtk-smi.c
> > +++ b/drivers/memory/mtk-smi.c
> 
> [...]
> > @@ -528,6 +598,53 @@ static int mtk_smi_dts_clk_init(struct device
> > *dev, struct mtk_smi *smi,
> >       return ret;
> >  }
> > 
> > +static int mtk_smi_larb_parse_clamp_optional(struct mtk_smi_larb
> > *larb)
> > +{
> > +     struct device *dev = larb->dev;
> > +     const struct mtk_smi_larb_gen *larb_gen = larb->larb_gen;
> > +     u32 larb_id;
> > +     int ret;
> > +
> > +     /**
> > +      * Only SMI LARBs in camera, image and IPE subsys need to
> > +      * apply clamp and reset operations, others can be skipped.
> > +      */
> > +     ret = of_property_read_u32(dev->of_node, "mediatek,larb-id",
> > &larb_id);
> > +     if (ret)
> > +             return -EINVAL;
> > +     if (!larb_gen->clamp_port || !larb_gen->clamp_port[larb_id])
> > +             return 0;
> > +
> > +     larb->sub_comm_inport = larb_gen->clamp_port[larb_id];
> > +     larb->sub_comm_syscon = syscon_regmap_lookup_by_phandle(dev-
> > >of_node, "mediatek,smi");
> > +     if (IS_ERR(larb->sub_comm_syscon)) {
> > +             larb->sub_comm_syscon = NULL;
> > +             return dev_err_probe(dev, -EINVAL,
> > +                                  "Unknown clamp port for larb
> > %d\n", larb_id);
> > +     }
> > +
> > +     return 0;
> > +}
> > +
> > +static int mtk_smi_larb_parse_reset_optional(struct mtk_smi_larb
> > *larb)
> > +{
> > +     struct device *dev = larb->dev;
> > +     int ret;
> > +
> > +     larb->rst_con = devm_reset_control_get(dev, "larb");
> 
> Please use devm_reset_control_get_exclusive() directly.
> Or use devm_reset_control_get_optional_exclusive(), which returns
> NULL
> instead of -ENOENT. That way you can ...

Thanks for your comment, I will fix it in this way.

> 
> > +     if (IS_ERR(larb->rst_con))
> > +             return dev_err_probe(dev, PTR_ERR(larb->rst_con),
> > +                                  "Failed to get larb reset
> > controller\n");
> 
> ... suppress this error message in case of -ENOENT and return with:
> 
>         if (!larb->rst_con)
>                 return 0;
> 
> here.
> 
> > +
> > +     larb->nb.notifier_call = mtk_smi_genpd_callback;
> > +     ret = dev_pm_genpd_add_notifier(dev, &larb->nb);
> > +     if (ret)
> > +             return dev_err_probe(dev, -EINVAL,
> > +                                  "Failed to add genpd callback
> > %d\n", ret);
> > +
> > +     return 0;
> > +}
> > +
> >  static int mtk_smi_larb_probe(struct platform_device *pdev)
> >  {
> >       struct mtk_smi_larb *larb;
> > @@ -538,6 +655,7 @@ static int mtk_smi_larb_probe(struct
> > platform_device *pdev)
> >       if (!larb)
> >               return -ENOMEM;
> > 
> > +     larb->dev = dev;
> >       larb->larb_gen = of_device_get_match_data(dev);
> >       larb->base = devm_platform_ioremap_resource(pdev, 0);
> >       if (IS_ERR(larb->base))
> > @@ -554,15 +672,24 @@ static int mtk_smi_larb_probe(struct
> > platform_device *pdev)
> >       if (ret < 0)
> >               return ret;
> > 
> > -     pm_runtime_enable(dev);
> > +     ret = mtk_smi_larb_parse_clamp_optional(larb);
> > +     if (ret)
> > +             goto err_link_remove;
> > +
> > +     ret = mtk_smi_larb_parse_reset_optional(larb);
> > +     if (ret && ret != -ENOENT)
> 
> The ret != -ENOENT check could be dropped if you use
> devm_reset_control_get_optional_exclusive() above.
> 

OK, I will fix it.

> 
> regards
> Philipp

      reply	other threads:[~2025-01-22  7:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-21  6:49 [PATCH v3 0/2] Add SMI reset and clamp for MediaTek MT8188 SoC Friday Yang
2025-01-21  6:49 ` [PATCH v3 1/2] dt-bindings: memory: mediatek: Add SMI reset and clamp for MT8188 Friday Yang
2025-01-21 10:14   ` Krzysztof Kozlowski
2025-01-22  7:39     ` Friday Yang (杨阳)
2025-01-21  6:49 ` [PATCH v3 2/2] memory: mtk-smi: mt8188: " Friday Yang
2025-01-21  8:53   ` Philipp Zabel
2025-01-22  7:39     ` Friday Yang (杨阳) [this message]

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=c4ce6e5c6350e6cfb5ff9bebf3118be0ac76edbd.camel@mediatek.com \
    --to=friday.yang@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=Yong.Wu@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk@kernel.org \
    --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=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    /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).