summaryrefslogtreecommitdiff
path: root/drivers/iio/dac/mcp4725.c
diff options
context:
space:
mode:
authorJean-Francois Dagenais <jeff.dagenais@gmail.com>2019-03-06 23:56:06 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-04-27 10:36:35 +0300
commit0e47edde91325efde88e937e1ccc5883c32b5a31 (patch)
tree406ea824ced5cbc0c7868a01be23f5ed457fccee /drivers/iio/dac/mcp4725.c
parent5ad173ea6c3a906c80c9e1afb3960c859d9ab037 (diff)
downloadlinux-0e47edde91325efde88e937e1ccc5883c32b5a31.tar.xz
iio: dac: mcp4725: add missing powerdown bits in store eeprom
commit 06003531502d06bc89d32528f6ec96bf978790f9 upstream. 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". Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/iio/dac/mcp4725.c')
-rw-r--r--drivers/iio/dac/mcp4725.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
index 8b5aad4c32d9..30dc2775cbfb 100644
--- a/drivers/iio/dac/mcp4725.c
+++ b/drivers/iio/dac/mcp4725.c
@@ -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;