Hi Graham,
I have done more or less the same to make I2C work (plus adding some
lines to platform.c and Kconfig/Makefile).
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 should look if I did hit the latest version or an older one. Yes, I
have based my patches on the same.
I had to apply the following change to fix it for the pcf8563...
Did you have to fix anything else in the pcf driver or board
configuration?
--- /home/grg/rcs/ingenic-linux-02os-linux-2-6-31-3/drivers/i2c/
busses/i2c-jz47xx.c 2010-01-20 12:08:11.000000000 +1030
+++ i2c-jz47xx.c 2010-02-08 11:00:37.000000000 +1030
@@ -30,6 +30,8 @@
#include <asm/jzsoc.h>
#include "i2c-jz47xx.h"
+#define EEPROM_DEVICE_NUMBER 0x50 /*eeprom device number.
20091027*/
+
Yes. I also did enclose it in a #ifndef EEPROM_DEVICE_NUMBER
/* I2C protocol */
#define I2C_READ 1
#define I2C_WRITE 0
@@ -107,11 +109,13 @@
int cnt = length;
int timeout = 5;
+#if 0
If we do that, we won't need the #define EEPROM_DEVICE_NUMBER
So I have replaced the #if 0 it by a #ifndef CONFIG_SOC_JZ4730
/*eeprom device address transfer*/
if(EEPROM_DEVICE_NUMBER == (device & 0xf0)){
device = device | ((sub_addr & 0x0700) >> 8);
sub_addr = sub_addr & 0xff;
}
+#endif
L_try_again:
@@ -178,11 +182,13 @@
int timeout = 5;
unsigned char *tmpbuf;
+#if 0
/*eeprom device address transfer*/
if(EEPROM_DEVICE_NUMBER == (device & 0xf0)){
device = device | ((sub_addr & 0x0700) >> 8);
sub_addr = sub_addr & 0xff;
}
+#endif
__i2c_send_nack(); /* Master does not send ACK, slave sends it */
W_try_again:
@@ -251,8 +257,8 @@
ret = xfer_write(pmsg->addr, pmsg->buf,
pmsg->len);
If I do i2cdetect, the dmesg has tons of reports from jz47xx_xfer.
They report "writing 0 byte to 0x43" (counting through all addresses).
That is strange and of course always successful.
i2cdump reports 256 bytes where the device address is shifted left by
1 bit and the LSB = 1. I.e. I get back the address byte as data...
}
- if (ret)
- return ret;
+ if (ret != pmsg->len)
+ return -1;
Ah, that is quite different. But has no visible effect :(
/* Wait until transfer is finished */
}
dev_dbg(&adap->dev, "transfer complete\n");
@@ -277,7 +283,9 @@
struct jz_i2c *i2c;
struct i2c_jz_platform_data *plat = dev->dev.platform_data;
int ret;
+#ifndef CONFIG_SOC_JZ4730
__gpio_as_i2c(); // open i2c 20091027
+#endif
Yes.
__i2c_set_clk(jz_clocks.extalclk, 10000); /* default 10 KHz */
I had to do a little more with the jz_clocks struct components to get
it compiled:
#ifdef CONFIG_SOC_JZ4730
__i2c_set_clk(jz_clocks.devclk, 10000); /* default 10 KHz */
#else
__gpio_as_i2c(); // open i2c 20091027
__i2c_set_clk(jz_clocks.extalclk, 10000); /* default 10 KHz */
#endif
__i2c_enable();
BR,
Nikolaus
_______________________________________________
Mipsbook-devel mailing list
Mipsbook-devel@linuxtogo.org
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/mipsbook-devel