linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Abel Vesa <abel.vesa@linaro.org>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Konrad Dybcio <konrad.dybcio@linaro.org>,
	Stephen Boyd <sboyd@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Bjorn Andersson <andersson@kernel.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Srini Kandagatla <srinivas.kandagatla@linaro.org>,
	Johan Hovold <johan@kernel.org>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH RFC v3 3/4] spmi: pmic-arb: Make core resources acquiring a version operation
Date: Thu, 15 Feb 2024 15:32:08 +0200	[thread overview]
Message-ID: <Zc4SWIViTS0uf952@linaro.org> (raw)
In-Reply-To: <CAA8EJpq=kYeZfNbFtfQ_oLS0Xi4imyEGV+dDNO+h6LZfqmpxZg@mail.gmail.com>

On 24-02-15 11:30:23, Dmitry Baryshkov wrote:
> On Wed, 14 Feb 2024 at 23:36, Abel Vesa <abel.vesa@linaro.org> wrote:
> >
> > On 24-02-14 22:18:33, Konrad Dybcio wrote:
> > > On 14.02.2024 22:13, Abel Vesa wrote:
> > > > Rather than setting up the core, obsrv and chnls in probe by using
> > > > version specific conditionals, add a dedicated "get_core_resources"
> > > > version specific op and move the acquiring in there.
> > > >
> > > > Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
> > > > ---
> > > >  drivers/spmi/spmi-pmic-arb.c | 111 ++++++++++++++++++++++++++++++-------------
> > > >  1 file changed, 78 insertions(+), 33 deletions(-)
> > > >
> > > > diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
> > > > index 23939c0d225f..489556467a4c 100644
> > > > --- a/drivers/spmi/spmi-pmic-arb.c
> > > > +++ b/drivers/spmi/spmi-pmic-arb.c
> > > > @@ -203,6 +203,7 @@ struct spmi_pmic_arb {
> > > >   */
> > > >  struct pmic_arb_ver_ops {
> > > >     const char *ver_str;
> > > > +   int (*get_core_resources)(struct platform_device *pdev, void __iomem *core);
> > > >     int (*init_apid)(struct spmi_pmic_arb *pmic_arb, int index);
> > > >     int (*ppid_to_apid)(struct spmi_pmic_arb *pmic_arb, u16 ppid);
> > > >     /* spmi commands (read_cmd, write_cmd, cmd) functionality */
> > > > @@ -956,6 +957,19 @@ static int pmic_arb_init_apid_min_max(struct spmi_pmic_arb *pmic_arb)
> > > >     return 0;
> > > >  }
> > > >
> > > > +static int pmic_arb_get_core_resources_v1(struct platform_device *pdev,
> > > > +                                     void __iomem *core)
> > > > +{
> > > > +   struct spmi_pmic_arb *pmic_arb = platform_get_drvdata(pdev);
> > > > +
> > > > +   pmic_arb->wr_base = core;
> > > > +   pmic_arb->rd_base = core;
> > > > +
> > > > +   pmic_arb->max_periphs = PMIC_ARB_MAX_PERIPHS;
> > > > +
> > > > +   return 0;
> > > > +}
> > > > +
> > > >  static int pmic_arb_init_apid_v1(struct spmi_pmic_arb *pmic_arb, int index)
> > > >  {
> > > >     u32 *mapping_table;
> > > > @@ -1063,6 +1077,41 @@ static u16 pmic_arb_find_apid(struct spmi_pmic_arb *pmic_arb, u16 ppid)
> > > >     return apid;
> > > >  }
> > > >
> > > > +static int pmic_arb_get_obsrvr_chnls_v2(struct platform_device *pdev)
> > > > +{
> > > > +   struct spmi_pmic_arb *pmic_arb = platform_get_drvdata(pdev);
> > > > +   struct device *dev = &pdev->dev;
> > > > +   struct resource *res;
> > > > +
> > > > +   res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> > >
> > > It's no longer indented to deep, no need to keep such aggressive wrapping
> > >
> >
> > The pmic_arb_get_obsrvr_chnls_v2 is used by both:
> > pmic_arb_get_core_resources_v2
> > pmic_arb_get_core_resources_v7
> >
> > > > +                                      "obsrvr");
> > > > +   pmic_arb->rd_base = devm_ioremap(dev, res->start,
> > > > +                                    resource_size(res));
> > > > +   if (IS_ERR(pmic_arb->rd_base))
> > > > +           return PTR_ERR(pmic_arb->rd_base);
> > > > +
> > > > +   res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> > > > +                                      "chnls");
> > > > +   pmic_arb->wr_base = devm_ioremap(dev, res->start,
> > > > +                                    resource_size(res));
> > > > +   if (IS_ERR(pmic_arb->wr_base))
> > > > +           return PTR_ERR(pmic_arb->wr_base);
> > >
> > > Could probably make it "devm_platform_get_and_ioremap_resource "
> >
> > The reason this needs to stay as is is because of reason explained by
> > the following comment found in probe:
> >
> > /*
> >  * Please don't replace this with devm_platform_ioremap_resource() or
> >  * devm_ioremap_resource().  These both result in a call to
> >  * devm_request_mem_region() which prevents multiple mappings of this
> >  * register address range.  SoCs with PMIC arbiter v7 may define two
> >  * arbiter devices, for the two physical SPMI interfaces, which  share
> >  * some register address ranges (i.e. "core", "obsrvr", and "chnls").
> >  * Ensure that both devices probe successfully by calling devm_ioremap()
> >  * which does not result in a devm_request_mem_region() call.
> >  */
> >
> > Even though, AFAICT, there is no platform that adds a second node for
> > the second bus, currently, in mainline, we should probably allow the
> > "legacy" approach to still work.
> 
> If there were no DT files which used two SPMI devices, I think we
> should drop this comment and use existing helpers. We must keep
> compatibility with the existing DTs, not with the _possible_ device
> trees.

Sure.

Should I drop the qcom,bus-id from the driver as well? It is optional
after all.

> 
> >
> > >
> > > Konrad
> 
> 
> 
> -- 
> With best wishes
> Dmitry

  reply	other threads:[~2024-02-15 13:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 21:13 [PATCH RFC v3 0/4] spmi: pmic-arb: Add support for multiple buses Abel Vesa
2024-02-14 21:13 ` [PATCH RFC v3 1/4] dt-bindings: spmi: Add PMIC ARB v7 schema Abel Vesa
2024-02-15  8:54   ` Krzysztof Kozlowski
2024-02-15  9:25     ` Abel Vesa
2024-02-14 21:13 ` [PATCH RFC v3 2/4] spmi: pmic-arb: Make the APID init a version operation Abel Vesa
2024-02-14 21:16   ` Konrad Dybcio
2024-02-14 21:37     ` Abel Vesa
2024-02-14 21:13 ` [PATCH RFC v3 3/4] spmi: pmic-arb: Make core resources acquiring " Abel Vesa
2024-02-14 21:18   ` Konrad Dybcio
2024-02-14 21:36     ` Abel Vesa
2024-02-14 21:44       ` Konrad Dybcio
2024-02-15  9:26         ` Abel Vesa
2024-02-15  9:30       ` Dmitry Baryshkov
2024-02-15 13:32         ` Abel Vesa [this message]
2024-02-15 14:42           ` Dmitry Baryshkov
2024-02-14 21:13 ` [PATCH RFC v3 4/4] spmi: pmic-arb: Add multi bus support Abel Vesa

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=Zc4SWIViTS0uf952@linaro.org \
    --to=abel.vesa@linaro.org \
    --cc=andersson@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=johan@kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=neil.armstrong@linaro.org \
    --cc=sboyd@kernel.org \
    --cc=srinivas.kandagatla@linaro.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).