devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Chris Packham <Chris.Packham@alliedtelesis.co.nz>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	Bjorn Andersson <andersson@kernel.org>,
	 Konrad Dybcio <konrad.dybcio@linaro.org>,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Banajit Goswami <bgoswami@quicinc.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	 Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>, Peter Rosin <peda@axentia.se>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	 "linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"linux-sound@vger.kernel.org" <linux-sound@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>,
	Sean Anderson <sean.anderson@seco.com>
Subject: Re: [PATCH v3 5/5] i2c: muxes: pca954x: Allow sharing reset GPIO
Date: Wed, 17 Jan 2024 12:16:04 +0100	[thread overview]
Message-ID: <568f2bcb1bea01c36f59650d5cc5a84612197f8b.camel@pengutronix.de> (raw)
In-Reply-To: <4c6c5d07-ac53-4da9-93e0-1286ca5eb44b@alliedtelesis.co.nz>

On Di, 2024-01-16 at 19:58 +0000, Chris Packham wrote:
> On 17/01/24 04:18, Philipp Zabel wrote:
> > On Fr, 2024-01-12 at 17:36 +0100, Krzysztof Kozlowski wrote:
> > > From: Chris Packham <chris.packham@alliedtelesis.co.nz>
> > > 
> > > Some hardware designs with multiple PCA954x devices use a reset GPIO
> > > connected to all the muxes. Support this configuration by making use of
> > > the reset controller framework which can deal with the shared reset
> > > GPIOs. Fall back to the old GPIO descriptor method if the reset
> > > controller framework is not enabled.
> > > 
> > > Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> > > Acked-by: Peter Rosin <peda@axentia.se>
> > > Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > > Link: https://scanmail.trustwave.com/?c=20988&d=8p6m5Tfi2yYJWYV9xYGcYnz7UYxB6WTGTPkmGu7b8A&u=https%3a%2f%2flore%2ekernel%2eorg%2fr%2f20240108041913%2e7078-1-chris%2epackham%40alliedtelesis%2eco%2enz
> > > Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > > 
> > > ---
> > > 
> > > If previous patches are fine, then this commit is independent and could
> > > be taken via I2C.
> > > 
> > > Cc: Chris Packham <chris.packham@alliedtelesis.co.nz>
> > > Cc: Bartosz Golaszewski <brgl@bgdev.pl>
> > > Cc: Sean Anderson <sean.anderson@seco.com>
> > > ---
> > >   drivers/i2c/muxes/i2c-mux-pca954x.c | 46 ++++++++++++++++++++++++-----
> > >   1 file changed, 38 insertions(+), 8 deletions(-)
> > > 
> > > diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
> > > index 2219062104fb..1702e8d49b91 100644
> > > --- a/drivers/i2c/muxes/i2c-mux-pca954x.c
> > > +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
> > > @@ -49,6 +49,7 @@
> > >   #include <linux/pm.h>
> > >   #include <linux/property.h>
> > >   #include <linux/regulator/consumer.h>
> > > +#include <linux/reset.h>
> > >   #include <linux/slab.h>
> > >   #include <linux/spinlock.h>
> > >   #include <dt-bindings/mux/mux.h>
> > > @@ -102,6 +103,9 @@ struct pca954x {
> > >   	unsigned int irq_mask;
> > >   	raw_spinlock_t lock;
> > >   	struct regulator *supply;
> > > +
> > > +	struct gpio_desc *reset_gpio;
> > > +	struct reset_control *reset_cont;
> > >   };
> > >   
> > >   /* Provide specs for the MAX735x, PCA954x and PCA984x types we know about */
> > > @@ -477,6 +481,35 @@ static int pca954x_init(struct i2c_client *client, struct pca954x *data)
> > >   	return ret;
> > >   }
> > >   
> > > +static int pca954x_get_reset(struct device *dev, struct pca954x *data)
> > > +{
> > > +	data->reset_cont = devm_reset_control_get_optional_shared(dev, NULL);
> > > +	if (IS_ERR(data->reset_cont))
> > > +		return dev_err_probe(dev, PTR_ERR(data->reset_cont),
> > > +				     "Failed to get reset\n");
> > > +	else if (data->reset_cont)
> > > +		return 0;
> > > +
> > > +	/*
> > > +	 * fallback to legacy reset-gpios
> > > +	 */
> > devm_reset_control_get_optional_shared() won't return NULL if the
> > "reset-gpios" property is found in the device tree, so the GPIO
> > fallback is dead code.
> 
> Hmm, I was attempting to handle the case where CONFIG_RESET_GPIO wasn't 
> set [...]
> [...] it looks like we'd get -EPROBE_DEFER. I could change to check
> for that or just remove the GPIO fallback entirely. Any preference?

I hadn't considered this.

If CONFIG_RESET_GPIO=n, devm_reset_control_get_optional_shared()
probably shouldn't return -EPROBE_DEFER. If we change that, the GPIO
fallback here can stay as is.

The alternative would be to drop the fallback and select RESET_GPIO.
Using -EPROBE_DEFER for fallback detection is no good, as there could
be a valid probe deferral if reset-gpio is compiled as a module that
will be loaded later.

regards
Philipp

  reply	other threads:[~2024-01-17 11:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-12 16:36 [PATCH v3 0/5] reset: gpio: ASoC: shared GPIO resets Krzysztof Kozlowski
2024-01-12 16:36 ` [PATCH v3 1/5] reset: gpio: Add GPIO-based reset controller Krzysztof Kozlowski
2024-01-15 14:44   ` Bartosz Golaszewski
2024-01-12 16:36 ` [PATCH v3 2/5] reset: Instantiate reset GPIO controller for shared reset-gpios Krzysztof Kozlowski
2024-01-15 16:06   ` Bartosz Golaszewski
2024-01-15 16:13     ` Krzysztof Kozlowski
2024-01-15 17:32       ` Philipp Zabel
2024-01-22 13:02         ` Krzysztof Kozlowski
2024-01-15 16:55   ` Philipp Zabel
2024-01-22 13:11     ` Krzysztof Kozlowski
2024-01-17 11:26   ` Philipp Zabel
2024-01-22 13:14     ` Krzysztof Kozlowski
2024-01-12 16:36 ` [PATCH v3 3/5] ASoC: dt-bindings: qcom,wsa8840: Add reset-gpios for shared line Krzysztof Kozlowski
2024-01-16 18:27   ` Rob Herring
2024-01-12 16:36 ` [PATCH v3 4/5] ASoC: codecs: wsa884x: Allow sharing reset GPIO Krzysztof Kozlowski
2024-01-12 16:36 ` [PATCH v3 5/5] i2c: muxes: pca954x: " Krzysztof Kozlowski
2024-01-16 15:18   ` Philipp Zabel
2024-01-16 19:58     ` Chris Packham
2024-01-17 11:16       ` Philipp Zabel [this message]
2024-01-17 19:56         ` Chris Packham

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=568f2bcb1bea01c36f59650d5cc5a84612197f8b.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=Chris.Packham@alliedtelesis.co.nz \
    --cc=alsa-devel@alsa-project.org \
    --cc=andersson@kernel.org \
    --cc=bgoswami@quicinc.com \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=peda@axentia.se \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=sean.anderson@seco.com \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.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).