From: Angelos Manousarides <amanous@inaccessnetworks.com>
To: linux-kernel@vger.kernel.org
Subject: I2C bus implementation
Date: Mon, 09 Jan 2006 18:37:30 +0200 [thread overview]
Message-ID: <43C2914A.8080409@inaccessnetworks.com> (raw)
I am writting a driver for the I2C of the powerpc MPC82xx. I have read
various implementations of other busses and I2C drivers (drivers for I2C
devices that is). All the I2C drivers I have seen do something like this
on a read command:
struct i2c_msg msgs[2] = {
{client->addr, 0, 1, addr},
{client->addr, I2C_M_RD, len, buf}
};
...
ret = i2c_transfer(client->adapter, msgs, 2);
..
This sequence implements a I2C read, with a 1-byte write for the slave
address and a subsequent read. This is ok for a device that does direct
low level communication with the bus.
In the MPC82xx however, the I2C unit does almost all the work. All the
driver has to do is setup the buffers for input/output and wait for an
interrupt once the operation is over. In the example above it would just
setup a buffer for the outgoing data (1 byte wide), one buffer for the
incoming data and issue a "start" command.
The problem is that since all I2C device drivers are written in the way
above, I am having trouble writting the code for this I2C bus. The
master_xfer function accepts a list of i2c_msg. So for a I2c read my
driver would get 2 messages one with the first byte (address write) and
one with the read buffer, although this is a single I2C transaction!
How can I glue the I2C code to this interface?
Is there a bus similar to the MPC82xx implemented already?
Can I assume that the i2c_msg list passed to the master_xfer function
will always contain a single I2C transaction? This way I could setup the
buffers using the i2c_mgs elements and when the list finishes, I cound
issue the "I2C start" command.
--
Manousaridis Angelos
next reply other threads:[~2006-01-09 16:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-09 16:37 Angelos Manousarides [this message]
2006-01-09 23:12 ` I2C bus implementation Benjamin Herrenschmidt
2006-01-19 15:01 ` I2C bus implementation (for MPC82xx) Angelos Manousarides
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=43C2914A.8080409@inaccessnetworks.com \
--to=amanous@inaccessnetworks.com \
--cc=linux-kernel@vger.kernel.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