* [PATCH] iio: filter: admv8818: Force initialization of SDO
@ 2025-01-24 18:27 Sam Winchenbach
2025-01-25 12:26 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Sam Winchenbach @ 2025-01-24 18:27 UTC (permalink / raw)
To: linux-kernel@vger.kernel.org
Cc: linux-iio@vger.kernel.org, antoniu.miclaus@analog.com,
lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org
From f851ce8225fc239fcbfc2e06adaa93336a9242ae Mon Sep 17 00:00:00 2001
From: Sam Winchenbach <swinchenbach@arka.org>
Date: Thu, 23 Jan 2025 15:24:09 -0500
Subject: [PATCH] iio: filter: admv8818: Force initialization of SDO
When a weak pull-up is present on the SDO line, regmap_update_bits fails
to write both the SOFTRESET and SDOACTIVE bits because it incorrectly
reads them as already set.
Since the soft reset disables the SDO line, performing a
read-modify-write operation on ADI_SPI_CONFIG_A to enable the SDO line
doesn't make sense. This change directly writes to the register instead
of using regmap_update_bits.
Signed-off-by: Sam Winchenbach <swinchenbach@arka.org>
---
drivers/iio/filter/admv8818.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/filter/admv8818.c b/drivers/iio/filter/admv8818.c
index 195e58bc4..9cd1eee84 100644
--- a/drivers/iio/filter/admv8818.c
+++ b/drivers/iio/filter/admv8818.c
@@ -577,21 +577,15 @@ static int admv8818_init(struct admv8818_state *st)
struct spi_device *spi = st->spi;
unsigned int chip_id;
- ret = regmap_update_bits(st->regmap, ADMV8818_REG_SPI_CONFIG_A,
- ADMV8818_SOFTRESET_N_MSK |
- ADMV8818_SOFTRESET_MSK,
- FIELD_PREP(ADMV8818_SOFTRESET_N_MSK, 1) |
- FIELD_PREP(ADMV8818_SOFTRESET_MSK, 1));
+ ret = regmap_write(st->regmap, ADMV8818_REG_SPI_CONFIG_A,
+ ADMV8818_SOFTRESET_N_MSK | ADMV8818_SOFTRESET_MSK);
if (ret) {
dev_err(&spi->dev, "ADMV8818 Soft Reset failed.\n");
return ret;
}
- ret = regmap_update_bits(st->regmap, ADMV8818_REG_SPI_CONFIG_A,
- ADMV8818_SDOACTIVE_N_MSK |
- ADMV8818_SDOACTIVE_MSK,
- FIELD_PREP(ADMV8818_SDOACTIVE_N_MSK, 1) |
- FIELD_PREP(ADMV8818_SDOACTIVE_MSK, 1));
+ ret = regmap_write(st->regmap, ADMV8818_REG_SPI_CONFIG_A,
+ ADMV8818_SDOACTIVE_N_MSK | ADMV8818_SDOACTIVE_MSK);
if (ret) {
dev_err(&spi->dev, "ADMV8818 SDO Enable failed.\n");
return ret;
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] iio: filter: admv8818: Force initialization of SDO
2025-01-24 18:27 [PATCH] iio: filter: admv8818: Force initialization of SDO Sam Winchenbach
@ 2025-01-25 12:26 ` Jonathan Cameron
2025-01-31 12:30 ` Sam Winchenbach
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2025-01-25 12:26 UTC (permalink / raw)
To: Sam Winchenbach
Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
antoniu.miclaus@analog.com, lars@metafoo.de,
Michael.Hennerich@analog.com
On Fri, 24 Jan 2025 18:27:46 +0000
Sam Winchenbach <swinchenbach@arka.org> wrote:
> From f851ce8225fc239fcbfc2e06adaa93336a9242ae Mon Sep 17 00:00:00 2001
> From: Sam Winchenbach <swinchenbach@arka.org>
> Date: Thu, 23 Jan 2025 15:24:09 -0500
> Subject: [PATCH] iio: filter: admv8818: Force initialization of SDO
Hi Sam, we shouldn't be seeing the email header in the patch.
I can tidy that up if you can't fix it though.
>
> When a weak pull-up is present on the SDO line, regmap_update_bits fails
> to write both the SOFTRESET and SDOACTIVE bits because it incorrectly
> reads them as already set.
>
> Since the soft reset disables the SDO line, performing a
> read-modify-write operation on ADI_SPI_CONFIG_A to enable the SDO line
> doesn't make sense. This change directly writes to the register instead
> of using regmap_update_bits.
>
Sounds like a fix, so could you send an appropriate Fixes tag
in a v2 and/or a reply to this email.
> Signed-off-by: Sam Winchenbach <swinchenbach@arka.org>
> ---
> drivers/iio/filter/admv8818.c | 14 ++++----------
> 1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/iio/filter/admv8818.c b/drivers/iio/filter/admv8818.c
> index 195e58bc4..9cd1eee84 100644
> --- a/drivers/iio/filter/admv8818.c
> +++ b/drivers/iio/filter/admv8818.c
> @@ -577,21 +577,15 @@ static int admv8818_init(struct admv8818_state *st)
> struct spi_device *spi = st->spi;
> unsigned int chip_id;
>
> - ret = regmap_update_bits(st->regmap, ADMV8818_REG_SPI_CONFIG_A,
> - ADMV8818_SOFTRESET_N_MSK |
> - ADMV8818_SOFTRESET_MSK,
> - FIELD_PREP(ADMV8818_SOFTRESET_N_MSK, 1) |
> - FIELD_PREP(ADMV8818_SOFTRESET_MSK, 1));
> + ret = regmap_write(st->regmap, ADMV8818_REG_SPI_CONFIG_A,
> + ADMV8818_SOFTRESET_N_MSK | ADMV8818_SOFTRESET_MSK);
> if (ret) {
> dev_err(&spi->dev, "ADMV8818 Soft Reset failed.\n");
> return ret;
> }
>
> - ret = regmap_update_bits(st->regmap, ADMV8818_REG_SPI_CONFIG_A,
> - ADMV8818_SDOACTIVE_N_MSK |
> - ADMV8818_SDOACTIVE_MSK,
> - FIELD_PREP(ADMV8818_SDOACTIVE_N_MSK, 1) |
> - FIELD_PREP(ADMV8818_SDOACTIVE_MSK, 1));
> + ret = regmap_write(st->regmap, ADMV8818_REG_SPI_CONFIG_A,
> + ADMV8818_SDOACTIVE_N_MSK | ADMV8818_SDOACTIVE_MSK);
> if (ret) {
> dev_err(&spi->dev, "ADMV8818 SDO Enable failed.\n");
> return ret;
^ permalink raw reply [flat|nested] 3+ messages in thread* RE: Re: iio: filter: admv8818: Force initialization of SDO
2025-01-25 12:26 ` Jonathan Cameron
@ 2025-01-31 12:30 ` Sam Winchenbach
0 siblings, 0 replies; 3+ messages in thread
From: Sam Winchenbach @ 2025-01-31 12:30 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
antoniu.miclaus@analog.com, lars@metafoo.de,
Michael.Hennerich@analog.com
> Hi Sam, we shouldn't be seeing the email header in the patch.
>
> I can tidy that up if you can't fix it though.
> >
> > When a weak pull-up is present on the SDO line, regmap_update_bits
> > fails to write both the SOFTRESET and SDOACTIVE bits because it
> > incorrectly reads them as already set.
> >
> > Since the soft reset disables the SDO line, performing a
> > read-modify-write operation on ADI_SPI_CONFIG_A to enable the SDO line
> > doesn't make sense. This change directly writes to the register
> > instead of using regmap_update_bits.
> >
> Sounds like a fix, so could you send an appropriate Fixes tag in a v2 and/or a reply to this email.
Added the fixes tag and submitted as patch v2. Please let me know if there is anything else that is needed.
Thanks.
>
> > Signed-off-by: Sam Winchenbach <swinchenbach@arka.org>
> > ---
> > drivers/iio/filter/admv8818.c | 14 ++++----------
> > 1 file changed, 4 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/iio/filter/admv8818.c
> > b/drivers/iio/filter/admv8818.c index 195e58bc4..9cd1eee84 100644
> > --- a/drivers/iio/filter/admv8818.c
> > +++ b/drivers/iio/filter/admv8818.c
> > @@ -577,21 +577,15 @@ static int admv8818_init(struct admv8818_state *st)
> > struct spi_device *spi = st->spi;
> > unsigned int chip_id;
> >
> > - ret = regmap_update_bits(st->regmap, ADMV8818_REG_SPI_CONFIG_A,
> > - ADMV8818_SOFTRESET_N_MSK |
> > - ADMV8818_SOFTRESET_MSK,
> > - FIELD_PREP(ADMV8818_SOFTRESET_N_MSK, 1) |
> > - FIELD_PREP(ADMV8818_SOFTRESET_MSK, 1));
> > + ret = regmap_write(st->regmap, ADMV8818_REG_SPI_CONFIG_A,
> > + ADMV8818_SOFTRESET_N_MSK |
> > + ADMV8818_SOFTRESET_MSK);
> > if (ret) {
> > dev_err(&spi->dev, "ADMV8818 Soft Reset failed.\n");
> > return ret;
> > }
> >
> > - ret = regmap_update_bits(st->regmap, ADMV8818_REG_SPI_CONFIG_A,
> > - ADMV8818_SDOACTIVE_N_MSK |
> > - ADMV8818_SDOACTIVE_MSK,
> > - FIELD_PREP(ADMV8818_SDOACTIVE_N_MSK, 1) |
> > - FIELD_PREP(ADMV8818_SDOACTIVE_MSK, 1));
> > + ret = regmap_write(st->regmap, ADMV8818_REG_SPI_CONFIG_A,
> > + ADMV8818_SDOACTIVE_N_MSK |
> > + ADMV8818_SDOACTIVE_MSK);
> > if (ret) {
> > dev_err(&spi->dev, "ADMV8818 SDO Enable failed.\n");
> > return ret;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-31 12:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-24 18:27 [PATCH] iio: filter: admv8818: Force initialization of SDO Sam Winchenbach
2025-01-25 12:26 ` Jonathan Cameron
2025-01-31 12:30 ` Sam Winchenbach
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox