Skip to contentSkip to conversation

iio: dac: mcp4725: add missing powerdown bits in store eeprom

PATCH In review Jean-Francois Dagenais 2 participants 3 messages Mar 11, 2019 – Mar 16, 2019 IIO

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iio: dac: mcp4725: add missing powerdown bits in store eeprom

When issuing the write DAC register and write eeprom command, the two powerdown bits (PD0 and PD1) are assumed by the chip to be present in the bytes sent. Leaving them at 0 implies "powerdown disabled" which is a different state that the current one. By adding the current state of the powerdown in the i2c write, the chip will correctly power-on exactly like as it is at the moment of store_eeprom call.

This is documented in MCP4725's datasheet, FIGURE 6-2: "Write Commands for DAC Input Register and EEPROM" and MCP4726's datasheet, FIGURE 6-3:
"Write All Memory Command".

---
 drivers/iio/dac/mcp4725.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/dac/mcp4725.c +1 -0
index 6ab1f23e5a79..fe3e42defb33 100644
@@ -98,6 +98,7 @@ static ssize_t mcp4725_store_eeprom(struct device *dev,
 
 	inoutbuf[0] = 0x60; /* write EEPROM */
 	inoutbuf[0] |= data->ref_mode << 3;
+	inoutbuf[0] |= data->powerdown ? ((data->powerdown_mode + 1) << 1) : 0;
 	inoutbuf[1] = data->dac_value >> 4;
 	inoutbuf[2] = (data->dac_value & 0xf) << 4;
 
Signature · 1 line
2.11.0
author Acked-by Peter Meerwald-Stadler on v2 1/1
#1 lore raw
Quoted 11 lines · Jean-Francois Dagenais

When issuing the write DAC register and write eeprom command, the two powerdown bits (PD0 and PD1) are assumed by the chip to be present in the bytes sent. Leaving them at 0 implies "powerdown disabled" which is a different state that the current one. By adding the current state of the powerdown in the i2c write, the chip will correctly power-on exactly like as it is at the moment of store_eeprom call.

Quoted 6 lines

This is documented in MCP4725's datasheet, FIGURE 6-2: "Write Commands for DAC Input Register and EEPROM" and MCP4726's datasheet, FIGURE 6-3:
"Write All Memory Command".

---

I forgot to add:

in v2

v3 just for that?

maintainer
#2 lore raw
Quoted 16 lines · On Tue, 12 Mar 2019 08:32:22 -0400 Jean-Francois Dagenais…
Quoted 9 lines · Jean-Francois Dagenais

When issuing the write DAC register and write eeprom command, the two powerdown bits (PD0 and PD1) are assumed by the chip to be present in the bytes sent. Leaving them at 0 implies "powerdown disabled" which is a different state that the current one. By adding the current state of the powerdown in the i2c write, the chip will correctly power-on exactly like as it is at the moment of store_eeprom call.

Quoted 6 lines

This is documented in MCP4725's datasheet, FIGURE 6-2: "Write Commands for DAC Input Register and EEPROM" and MCP4726's datasheet, FIGURE 6-3:
"Write All Memory Command".

---

Quoted 7 lines

I forgot to add:

in v2

v3 just for that?

Ah, I picked up v1 and fixed it anyway. So don't bother ;)

Jonathan