All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] iio: dac: mcp4725: add missing powerdown bits in store eeprom
@ 2019-03-11 11:42 Jean-Francois Dagenais
  2019-03-12 12:32 ` Jean-Francois Dagenais
  0 siblings, 1 reply; 3+ messages in thread
From: Jean-Francois Dagenais @ 2019-03-11 11:42 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, 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.

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>
---
 drivers/iio/dac/mcp4725.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
index 6ab1f23e5a79..fe3e42defb33 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;
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] iio: dac: mcp4725: add missing powerdown bits in store eeprom
  2019-03-11 11:42 [PATCH v2] iio: dac: mcp4725: add missing powerdown bits in store eeprom Jean-Francois Dagenais
@ 2019-03-12 12:32 ` Jean-Francois Dagenais
  2019-03-16 16:00   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Jean-Francois Dagenais @ 2019-03-12 12:32 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23



> On Mar 11, 2019, at 07:42, Jean-Francois Dagenais <jeff.dagenais@gmail.com> wrote:
> 
> 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>
> ---

I forgot to add:

Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>

in v2

v3 just for that?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] iio: dac: mcp4725: add missing powerdown bits in store eeprom
  2019-03-12 12:32 ` Jean-Francois Dagenais
@ 2019-03-16 16:00   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2019-03-16 16:00 UTC (permalink / raw)
  To: Jean-Francois Dagenais; +Cc: linux-iio

On Tue, 12 Mar 2019 08:32:22 -0400
Jean-Francois Dagenais <jeff.dagenais@gmail.com> wrote:

> > On Mar 11, 2019, at 07:42, Jean-Francois Dagenais <jeff.dagenais@gmail.com> wrote:
> > 
> > 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>
> > ---  
> 
> I forgot to add:
> 
> Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
> 
> in v2
> 
> v3 just for that?
Ah,  I picked up v1 and fixed it anyway.  So don't bother ;)

Jonathan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-16 16:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11 11:42 [PATCH v2] iio: dac: mcp4725: add missing powerdown bits in store eeprom Jean-Francois Dagenais
2019-03-12 12:32 ` Jean-Francois Dagenais
2019-03-16 16:00   ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.