Skip to contentSkip to conversation

mfd: da9052-spi: change read-mask to write-mask

PATCH Applied Marcus Folkesson 3 participants 6 messages Sep 25, 2024 – Oct 2, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mfd: da9052-spi: change read-mask to write-mask

Driver has mixed up the R/W bit.
The LSB bit is set on write rather than read.
Change it to avoid nasty things to happen.

Fixes e9e9d3973594 ("mfd: da9052: Avoid setting read_flag_mask for da9052-i2c driver")

---
Changes in v2:
Reword the commit message and add Fixes: tag.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 drivers/mfd/da9052-spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/da9052-spi.c +1 -1
index be5f2b34e18aebc7a9506123b366af5a5447df43..80fc5c0cac2fb0e5e99e6db8972f80ae4155b226 100644
@@ -37,7 +37,7 @@ static int da9052_spi_probe(struct spi_device *spi)
 	spi_set_drvdata(spi, da9052);
 
 	config = da9052_regmap_config;
-	config.read_flag_mask = 1;
+	config.write_flag_mask = 1;
 	config.reg_bits = 7;
 	config.pad_bits = 1;
 	config.val_bits = 8;

---
base-commit: 200289db261f0c8131a5756133e9d30966289c3b
change-id: 20240918-da9052-df843a1b9d0e

Best regards,

Signature · 1 line
Marcus Folkesson <[email protected]>
maintainer Applied
#1 lore raw

Re: (subset) [PATCH v2] mfd: da9052-spi: change read-mask to write-mask

Quoted 5 lines · Marcus Folkesson

Driver has mixed up the R/W bit.
The LSB bit is set on write rather than read.
Change it to avoid nasty things to happen.

Applied, thanks!

[1/1] mfd: da9052-spi: change read-mask to write-mask

      commit: f77c2e93771be2d66c639c8eb0b463de2c321579

--
Lee Jones [李琼斯]

#2 lore raw
In reply to Marcus Folkesson

Hello Marcus,

Quoted 6 lines · Marcus Folkesson

Driver has mixed up the R/W bit.
The LSB bit is set on write rather than read.
Change it to avoid nasty things to happen.

Fixes e9e9d3973594 ("mfd: da9052: Avoid setting read_flag_mask for da9052-i2c driver")

Your patch breaks DA9053 SPI communication (for me, at least) on the 6.1.y branch (I have not tested on master).

The datasheets [1] and [2] both refer to R/Wn in the SPI signalling.

What led to the assertion that "The LSB bit is set on write rather than read."?

In the original code "config.read_flag_mask = 1;", is OR'd into the buffer in regmap_set_work_buf_flag_mask. This sets the "R" bit as expected.

[1] DA9052 CFR0011-120-00 Rev 5, Revision 2.5, 13-Feb-2017, page 67.
[2] DA9053 DA9053-00-IDS2n_131017, page 54.

Blue skies,
Ian

#3 lore raw

Hello Ian,

Quoted 13 lines · Ian Ray

Hello Marcus,

Quoted 6 lines · Marcus Folkesson

Driver has mixed up the R/W bit.
The LSB bit is set on write rather than read.
Change it to avoid nasty things to happen.

Fixes e9e9d3973594 ("mfd: da9052: Avoid setting read_flag_mask for da9052-i2c driver")

Your patch breaks DA9053 SPI communication (for me, at least) on the 6.1.y branch (I have not tested on master).

Quoted 8 lines

The datasheets [1] and [2] both refer to R/Wn in the SPI signalling.

What led to the assertion that "The LSB bit is set on write rather than read."?

In the original code "config.read_flag_mask = 1;", is OR'd into the buffer in regmap_set_work_buf_flag_mask. This sets the "R" bit as expected.

Hrm.

I follow you and agree with what you say.
Could you please read out R19 INTERFACE register?
Bit 3, R/W POL, deviates from the default value (1) in my setup, which is probably the reason why it doesn't work for me without the patch.

Your datasheet revision is later than mine, could you plese verify that the default value is still 1 for DA9052 in your revision?

If that is the case, either the datasheet is wrong or my chips must somehow been preloaded with some values.

As nobody else has reported any issue I guess it is safer to revert this patch.

Quoted 6 lines

[1] DA9052 CFR0011-120-00 Rev 5, Revision 2.5, 13-Feb-2017, page 67.
[2] DA9053 DA9053-00-IDS2n_131017, page 54.

Blue skies,
Ian

Best regards,
Marcus Folkesson

#4 lore raw
Quoted 25 lines · Marcus Folkesson

Hello Ian,

Quoted 13 lines · Ian Ray

Hello Marcus,

Quoted 6 lines · Marcus Folkesson

Driver has mixed up the R/W bit.
The LSB bit is set on write rather than read.
Change it to avoid nasty things to happen.

Fixes e9e9d3973594 ("mfd: da9052: Avoid setting read_flag_mask for da9052-i2c driver")

Your patch breaks DA9053 SPI communication (for me, at least) on the 6.1.y branch (I have not tested on master).

Quoted 8 lines

The datasheets [1] and [2] both refer to R/Wn in the SPI signalling.

What led to the assertion that "The LSB bit is set on write rather than read."?

In the original code "config.read_flag_mask = 1;", is OR'd into the buffer in regmap_set_work_buf_flag_mask. This sets the "R" bit as expected.

Quoted 6 lines

Hrm.

I follow you and agree with what you say.
Could you please read out R19 INTERFACE register?
Bit 3, R/W POL, deviates from the default value (1) in my setup, which is probably the reason why it doesn't work for me without the patch.

-- >8 --

# cat /sys/kernel/debug/regmap/spi2.0/registers |grep "^13:"
13: 88
-- >8 -- 
Quoted 3 lines

Your datasheet revision is later than mine, could you plese verify that the default value is still 1 for DA9052 in your revision?

Yes it is still 1 (the complete set of defaults for R19 is 10011000).

Quoted 3 lines

If that is the case, either the datasheet is wrong or my chips must somehow been preloaded with some values.

Yes, in my understanding these PMICs are highly configurable via OTP. (Almost every register can be customized.)

Quoted 3 lines

As nobody else has reported any issue I guess it is safer to revert this patch.

Agree -- following the datasheet default is probably the right thing to do here.

For the future, we could consider an optional device tree property to describe this read/write bit polarity.

Thanks,
Ian

Quoted 11 lines
Quoted 7 lines

[1] DA9052 CFR0011-120-00 Rev 5, Revision 2.5, 13-Feb-2017, page 67.
[2] DA9053 DA9053-00-IDS2n_131017, page 54.

Blue skies,
Ian

Best regards,
Marcus Folkesson

#5 lore raw

Hello Ian,

Quoted 52 lines · Ian Ray
Quoted 25 lines · Marcus Folkesson

Hello Ian,

Quoted 13 lines · Ian Ray

Hello Marcus,

Quoted 6 lines · Marcus Folkesson

Driver has mixed up the R/W bit.
The LSB bit is set on write rather than read.
Change it to avoid nasty things to happen.

Fixes e9e9d3973594 ("mfd: da9052: Avoid setting read_flag_mask for da9052-i2c driver")

Your patch breaks DA9053 SPI communication (for me, at least) on the 6.1.y branch (I have not tested on master).

Quoted 8 lines

The datasheets [1] and [2] both refer to R/Wn in the SPI signalling.

What led to the assertion that "The LSB bit is set on write rather than read."?

In the original code "config.read_flag_mask = 1;", is OR'd into the buffer in regmap_set_work_buf_flag_mask. This sets the "R" bit as expected.

Quoted 6 lines

Hrm.

I follow you and agree with what you say.
Could you please read out R19 INTERFACE register?
Bit 3, R/W POL, deviates from the default value (1) in my setup, which is probably the reason why it doesn't work for me without the patch.

-- >8 --

# cat /sys/kernel/debug/regmap/spi2.0/registers |grep "^13:"
13: 88
-- >8 -- 
Quoted 3 lines

Your datasheet revision is later than mine, could you plese verify that the default value is still 1 for DA9052 in your revision?

Yes it is still 1 (the complete set of defaults for R19 is 10011000).

Quoted 3 lines

If that is the case, either the datasheet is wrong or my chips must somehow been preloaded with some values.

Yes, in my understanding these PMICs are highly configurable via OTP. (Almost every register can be customized.)

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

As nobody else has reported any issue I guess it is safer to revert this patch.

Agree -- following the datasheet default is probably the right thing to do here.

For the future, we could consider an optional device tree property to describe this read/write bit polarity.

Yes, I'm actually working on a patch for this, I will send it out shortly.

Quoted 15 lines

Thanks,
Ian

Quoted 11 lines
Quoted 7 lines

[1] DA9052 CFR0011-120-00 Rev 5, Revision 2.5, 13-Feb-2017, page 67.
[2] DA9053 DA9053-00-IDS2n_131017, page 54.

Blue skies,
Ian

Best regards,
Marcus Folkesson

Best regards,
Marcus Folkesson