]>
Commit | Line | Data |
---|---|---|
9d0aa67b GKH |
1 | From 06003531502d06bc89d32528f6ec96bf978790f9 Mon Sep 17 00:00:00 2001 |
2 | From: Jean-Francois Dagenais <jeff.dagenais@gmail.com> | |
3 | Date: Wed, 6 Mar 2019 15:56:06 -0500 | |
4 | Subject: iio: dac: mcp4725: add missing powerdown bits in store eeprom | |
5 | ||
6 | From: Jean-Francois Dagenais <jeff.dagenais@gmail.com> | |
7 | ||
8 | commit 06003531502d06bc89d32528f6ec96bf978790f9 upstream. | |
9 | ||
10 | When issuing the write DAC register and write eeprom command, the two | |
11 | powerdown bits (PD0 and PD1) are assumed by the chip to be present in | |
12 | the bytes sent. Leaving them at 0 implies "powerdown disabled" which is | |
13 | a different state that the current one. By adding the current state of | |
14 | the powerdown in the i2c write, the chip will correctly power-on exactly | |
15 | like as it is at the moment of store_eeprom call. | |
16 | ||
17 | This is documented in MCP4725's datasheet, FIGURE 6-2: "Write Commands | |
18 | for DAC Input Register and EEPROM" and MCP4726's datasheet, FIGURE 6-3: | |
19 | "Write All Memory Command". | |
20 | ||
21 | Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com> | |
22 | Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net> | |
23 | Cc: <Stable@vger.kernel.org> | |
24 | Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> | |
25 | Signed-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 |