Hi Graham,
I got it working (mostly) by fixing some things in the Ingenic jz47xx- i2c.c!

1. I removed all sub_addr components
2. I added      __i2c_enable();   to i2c_jz_xfer()

I think 2. is needed because some other drivers are using the bare bones i2c.c driver and finally close it.

Only i2cdetect is still not working correctly. It does not timeout or report NACK on write to addresses where I suspect that there is no device connected.

Interestingly, i2cdetect does a probe by reading 1 byte for addresses 0x30..0x37 and 0x50.0x5f. Other addresses are written to. And that times out as expected.

But the driver is still a little unreliable. And, the time to process the 'hwclock --show' command is quite noticeable (0.2 .. 0.9 seconds)... And once a while it times out.

My driver code is at:

        
http://projects.goldelico.com/p/letux-400/source/tree/v0.2/drivers/i2c/busses/i2c-jz47xx.c

Am 05.05.2010 um 02:28 schrieb Graham Gower:

The xfer_read and xfer_write functions return the number of bytes read/written.

Ah, you are right. I got confused by the cnt-- and final length - cnt...

So if they successfully do a transfer, the loop here will be broken and the
function will return. So subsequent transfers in the i2c message will
not occur. Hence the change below is required for drivers that have more than
one transfer in any given i2c message.

And some do more than one i2c_transfer like the pcf driver...

-                       if (ret)
-                               return ret;

so this is definitively wrong.

+                       if (ret != pmsg->len)
+                               return -1;

Much better. I would do a return -EIO instead. I have now return ret < 0 ? ret : -EIO;

Well, I've already attempted to rewrite the i2c driver in a much cleaner way, for use with 2.6.33, unfortunately I couldn't get it to work. I've attached
the file for your perusal in case you find it useful.

Thanks! I will add it to my kernel tree and give it a try...

I'm not using autodetection as far as I can tell. I have the following in my
board file.

static struct i2c_board_info pcf8563_rtc_board_info[] = {
        [0] = {
                .type = "pcf8563",
                .addr = 0x51,
        }
};


With this in an arch_initcall:
i2c_register_board_info(0, pcf8563_rtc_board_info, 1);

That is much better than my workaround since it is independent of updates of the PCF drivers and puts the i2c address configuration where it belongs to.

But strangely it does not work for me.

BR,
Nikolaus

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

Reply via email to