public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Wayne Tams <wayne.tams-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: MCP4728 address change
Date: Tue, 8 Nov 2011 08:45:45 +0100	[thread overview]
Message-ID: <20111108084545.7ed3db9d@endymion.delvare> (raw)
In-Reply-To: <CAN=k24=x1MQaSu2b-tz6-8BvwW4WfY5e47z21Vdf+B6D93xQtQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Hi Wayne,

On Mon, 7 Nov 2011 11:25:42 +0000, Wayne Tams wrote:
> I have been tasked with writing a driver for a Microchip Quad DAC with
> EEPROM memory, MCP4728 if you would like to look it up. This device
> has a feature that I have not come across before, the device's I2C
> address is set in software and stored in the EEPROM as opposed to
> using hardware. The factory default address for the MCP4728 is 0x60
> and to avoid conflict it needs to be changed. The datasheet tells me I
> must switch the LDAC pin from high to low at the last bit of the
> second byte in the I2C message and it must stay low until the end of
> the third byte.
> 
> I am wondering if there are any other devices within the kernel source
> that support this type of address setup? I am assuming that the normal
> set of I2C/SMBUS functions will not be enough to program a new address
> since I will need some sort of mechanism to switchthe LDAC pin?

I have never heard of anything like this before, and I confirm that you
won't be able to achieve this with the standard function set. If you
need to synchronize another action with the I2C transfer at bit level,
this pretty much implies that you need to do software bit-banging
(using the i2c-algo-bit driver.) Obviously this requires that you have
full control over the I2C bus pins.

One way to do it would be to write custom callback functions for
i2c-algo-bit. Usually getsda and getscl simply set a GPIO direction
and/or value, but in your case you would need to additionally keep
track of how many times you are called, so that you know when you have
to trigger the other actions. This won't be pretty, but with proper
locking in place, this should work.

Address selection through pin wiring is a lot saner than this IMHO.

-- 
Jean Delvare

  parent reply	other threads:[~2011-11-08  7:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-07 11:25 (unknown), Wayne Tams
     [not found] ` <CAN=k24=x1MQaSu2b-tz6-8BvwW4WfY5e47z21Vdf+B6D93xQtQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-11-08  7:45   ` Jean Delvare [this message]
     [not found]     ` <20111108084545.7ed3db9d-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2011-11-08 10:56       ` MCP4728 address change Wayne Tams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111108084545.7ed3db9d@endymion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=wayne.tams-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox