]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.0.10/iio-dac-mcp4725-add-missing-powerdown-bits-in-store-eeprom.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 5.0.10 / iio-dac-mcp4725-add-missing-powerdown-bits-in-store-eeprom.patch
CommitLineData
9d0aa67b
GKH
1From 06003531502d06bc89d32528f6ec96bf978790f9 Mon Sep 17 00:00:00 2001
2From: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
3Date: Wed, 6 Mar 2019 15:56:06 -0500
4Subject: iio: dac: mcp4725: add missing powerdown bits in store eeprom
5
6From: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
7
8commit 06003531502d06bc89d32528f6ec96bf978790f9 upstream.
9
10When issuing the write DAC register and write eeprom command, the two
11powerdown bits (PD0 and PD1) are assumed by the chip to be present in
12the bytes sent. Leaving them at 0 implies "powerdown disabled" which is
13a different state that the current one. By adding the current state of
14the powerdown in the i2c write, the chip will correctly power-on exactly
15like as it is at the moment of store_eeprom call.
16
17This is documented in MCP4725's datasheet, FIGURE 6-2: "Write Commands
18for DAC Input Register and EEPROM" and MCP4726's datasheet, FIGURE 6-3:
19"Write All Memory Command".
20
21Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
22Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
23Cc: <Stable@vger.kernel.org>
24Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
25Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26
27---
28 drivers/iio/dac/mcp4725.c | 1 +
29 1 file changed, 1 insertion(+)
30
31--- a/drivers/iio/dac/mcp4725.c
32+++ b/drivers/iio/dac/mcp4725.c
33@@ -92,6 +92,7 @@ static ssize_t mcp4725_store_eeprom(stru
34
35 inoutbuf[0] = 0x60; /* write EEPROM */
36 inoutbuf[0] |= data->ref_mode << 3;
37+ inoutbuf[0] |= data->powerdown ? ((data->powerdown_mode + 1) << 1) : 0;
38 inoutbuf[1] = data->dac_value >> 4;
39 inoutbuf[2] = (data->dac_value & 0xf) << 4;
40