linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	David Rhodes <david.rhodes@cirrus.com>,
	Richard Fitzgerald <rf@opensource.cirrus.com>,
	Lee Jones <lee@kernel.org>, Mark Brown <broonie@kernel.org>,
	Maciej Strozek <mstrozek@opensource.cirrus.com>,
	Andy Shevchenko <andy@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-sound@vger.kernel.org, patches@opensource.cirrus.com,
	linux-spi@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH RFT/RFC 2/2] mfd: cs42l43: use GPIO machine lookup for cs-gpios
Date: Wed, 19 Nov 2025 15:52:01 +0000	[thread overview]
Message-ID: <aR3noZXxma9vOXEI@opensource.cirrus.com> (raw)
In-Reply-To: <CAMRc=Md4jHrHxHUOM=eFuWRSaEO9jFEoHGTjEEJLj9w6E53gOA@mail.gmail.com>

On Wed, Nov 19, 2025 at 04:35:07PM +0100, Bartosz Golaszewski wrote:
> On Wed, Nov 19, 2025 at 4:21 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > Currently the SPI driver sets up a software node referencing the GPIO
> > controller exposing the chip-select GPIO but this node never gets
> > attached to the actual GPIO provider. The lookup uses the weird way GPIO
> > core performs the software node lookup by the swnode's name. We want to
> > switch to a true firmware node lookup in GPIO core but without the true
> > link, this driver will break.
> >
> > We can't use software nodes as only one software node per device is
> > allowed and the ACPI node the MFD device uses has a secondary node
> > already attached.
> >
> > Let's switch to GPIO machine lookup instead.
> >
> > Fixes: 439fbc97502a ("spi: cs42l43: Add bridged cs35l56 amplifiers")
> > Reported-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> > Closes: https://lore.kernel.org/all/aRyf7qDdHKABppP8@opensource.cirrus.com/
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > ---
> >
> > +static struct gpiod_lookup_table cs42l43_gpio_lookup = {
> > +       .dev_id = "cs42l43-spi",
> > +       .table = {
> > +               GPIO_LOOKUP("cs42l43-pinctrl", 0, "cs", GPIO_ACTIVE_LOW),
> > +               GPIO_LOOKUP(INIT_ERR_PTR(-ENOENT), 0, "cs", 0),
> 
> I sent the wrong version, sorry. This should have been:
> 
> GPIO_LOOKUP_IDX("cs42l43-pinctrl", 0, "cs", 0, GPIO_ACTIVE_LOW),
> GPIO_LOOKUP_IDX(INIT_ERR_PTR(-ENOENT), 0, "cs", 1, 0),
> 
> Charles: Can you fix it up yourself before testing?

Yeah can do, but I am still very nervous about how this approach
interacts with device tree and ACPI systems doing things
normally. Is this also ignored if the firmware specifies the
properties correctly? I feel like if we go this route I am going
to have to bring up a few extra things to test on as its quite a
big change.

Apologies for the delay on my suggestion but something weird is
happening deep in the swnode stuff and its taking me ages to peel
back all the layers of in abstraction there. It seems something
copies all the properties and somehow the fwnode I want doesn't
make it through that process. But the basic idea is like:

props = devm_kmemdup(priv->dev, cs42l43_cs_props,
		     sizeof(cs42l43_cs_props), GFP_KERNEL);
if (!props)
	return -ENOMEM;

args = devm_kmemdup(priv->dev, cs42l43_cs_refs,
		    sizeof(cs42l43_cs_refs), GFP_KERNEL);
if (!args)
	return -ENOMEM;

args[0].fwnode = fwnode;
props->pointer = props;

ie. As your patches add support for using the geniune firmware
node just do so.

Thanks,
Charles

  reply	other threads:[~2025-11-19 15:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-19 15:21 [PATCH RFT/RFC 0/2] mfd: cs42l43: fix GPIO lookup for chip selects Bartosz Golaszewski
2025-11-19 15:21 ` [PATCH RFT/RFC 1/2] gpiolib: support "undefined" GPIO machine lookup Bartosz Golaszewski
2025-11-19 16:49   ` Bartosz Golaszewski
2025-11-19 15:21 ` [PATCH RFT/RFC 2/2] mfd: cs42l43: use GPIO machine lookup for cs-gpios Bartosz Golaszewski
2025-11-19 15:35   ` Bartosz Golaszewski
2025-11-19 15:52     ` Charles Keepax [this message]
2025-11-19 16:13       ` Charles Keepax
2025-11-19 16:28       ` Bartosz Golaszewski
2025-11-19 16:43         ` Charles Keepax

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=aR3noZXxma9vOXEI@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=andy@kernel.org \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=david.rhodes@cirrus.com \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mstrozek@opensource.cirrus.com \
    --cc=p.zabel@pengutronix.de \
    --cc=patches@opensource.cirrus.com \
    --cc=rf@opensource.cirrus.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).