Hi Graham,
after deeper looking into the code I am more and more wondering how
you could make it work (or I misunderstood something completely).
The reason is that the drivers/i2c/busses/i2c-jz47xx.c driver is
handling some strange 'unsigned long sub_addr' and sending that right
after sending the device address. This value is initialized to 0 and
sometimes incremented. But I could not find a setter for it.
Now, the PCF8563 driver calls
unsigned char buf[13] = { PCF8563_REG_ST1 };
struct i2c_msg msgs[] = {
{ client->addr, 0, 1, buf }, /* setup read ptr */
{ client->addr, I2C_M_RD, 13, buf }, /* read status + date */
};
/* read registers */
if ((i2c_transfer(client->adapter, msgs, 2)) != 2) {
dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
return -EIO;
}
which I interpret as the driver is setting (writing) the 1 byte
PCF8563_REG_ST1 into the "read ptr" (aka sub_addr) and then trying to
read back 13 bytes.
IMHO not ok is that each xfer sends the device address *plus* this
strange sub_addr byte (which is initialized to 0) and then followed by
the number of bytes specified in the message.
And, I understand the struct i2c_msg
http://ww2.cs.fsu.edu/~rosentha/linux/2.6.26.5/docs/DocBook/kernel-api/re1210.html
as a message *without* any subaddress (unless encoded into the message
body). Or am I wrong?
Here I found a description how subadressing should work on the i2c
side (in case or writes or reads):
http://www.8051projects.net/i2c-twi-tutorial/write-read-i2c-bus.php
I have got the impression that the i2c-jz47xx.c is just halfway
extracted/adapted from the i2c.c driver (which explicitly takes a
subaddress and is controlled correctly from the char-style pcf driver)
and hacked to make some EEPROM work. But the driver should probably
also recognize flags like I2C_M_NOSTART or I2C_M_NO_RD_ACK to
correctly interwork with the i2c-tools.
So it needs some deeper rework, but I does not appear to be very
difficult to do. So I will roll up my sleeves :)
BR,
Nikolaus
Am 04.05.2010 um 08:31 schrieb Graham Gower:
Ingenic's i2c driver from here almost works:
http://projects.qi-hardware.com/index.php/p/ingenic-linux-02os-linux-2-6-31-3/source/tree/HEAD/trunk/drivers/i2c/busses
I had to apply the following change to fix it for the pcf8563...
_______________________________________________
Mipsbook-devel mailing list
Mipsbook-devel@linuxtogo.org
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/mipsbook-devel