Skip to content

Commit

Permalink
Force ADMV8818 soft reset and SDO initialization
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sam Winchenbach committed Jan 24, 2025
1 parent 8dda4f6 commit aee2d29
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions drivers/iio/filter/admv8818.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit aee2d29

Please sign in to comment.