Dr. H. Nikolaus Schaller wrote:
> 
> Am 03.05.2010 um 22:18 schrieb Graham Gower:
> 
>> On 4 May 2010 05:18, Dr. H. Nikolaus Schaller <h...@computer.org> wrote:
>>>
>>> Am 03.05.2010 um 21:35 schrieb Dr. H. Nikolaus Schaller:
>>>
>>> So what can we learn? I think I should look into the sources of the
>>> old RTC
>>> driver to find out what it is doing differently (with respect to
>>> initialization, e.g. GPIO assignment?).
>>>
>>> Learings:
>>> 1. the working driver is at driver/character/rtc_pcf8563.c
>>
>> drivers/char/rtc_pcf8563.c has been hacked to support Ingenic's i2c code.
>>
>>
>>> 2. it directly calls i2c_open(), i2c_read(), i2c_close() etc. from
>>> arch/mips/jz4730/i2c.c
>>
>> Yes. This i2c driver does not register itself to the kernel as an i2c
>> bus driver. It is a total hack.
> 
> And that is enough reason to get rid of it...
> 
>>
>>
>>> 3. is initialized (pcf_rtc_init) many dmesg lines after hctosys fails
>>> (rtc_init)
>>> 4. no specific GPIO assignments found
>>> 5. i2c_open calls __i2c_enable
>>> 6. this is defined in kernel/include/asm/mach-jz4730/ops.h and sets some
>>> registers - maybe, this is missing for the "new" i2c driver (at least I
>>> haven't seen it in the code I copied from the Qi-Hardware project).
> 
> I had just not seen this call. And I found that the "new" driver also
> uses all the __i2c_something() calls.
> 
> What I have now additionally cross-ported from the Qi-JZ4740 kernel is
> the platform initialization of the i2c subsystem in
> arch/mips/jz4730/platform.c.
> 
> And voila: i2c-tools now find a bus! But I am not sure if it works since
> i2cdetect reports all addresses...
> 
> And the "new" RTC driver still does not initialize.
> 
> BR,
> Nikolaus

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...


--- 
/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*/
+
 /* I2C protocol */
 #define I2C_READ       1
 #define I2C_WRITE      0
@@ -107,11 +109,13 @@
        int cnt = length;
        int timeout = 5;
 
+#if 0
        /*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 (ret)
-                               return ret;
+                       if (ret != pmsg->len)
+                               return -1;
                        /* 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
        __i2c_set_clk(jz_clocks.extalclk, 10000); /* default 10 KHz */
        __i2c_enable();
 

_______________________________________________
Mipsbook-devel mailing list
Mipsbook-devel@linuxtogo.org
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/mipsbook-devel

Reply via email to