I’m using hikey960 kernel4.9 to write the i2c device driver.
Now I only use one gpio to trigger i2c read chip status (16 byte) by i2c_smbus_read_i2c_block_data.
But the function return time is too long, I use I2C0/I2C7 400KHz to do the experiment.
The result is different between I2C0/I2C7.
Below is my gpio isr code.
start = ktime_get();
/* pm_runtime_get_sync(chip->dev); /
ret = i2c_smbus_read_i2c_block_data(chip->i2c, 0xc0, 16, irq_data);
if (ret < 0)
/ pm_runtime_put(chip->dev); */
end = ktime_get();
use_us = ktime_to_ns(ktime_sub(end, start));
dev_info(chip->dev, “ns = %lld\n”, use_us)
0-0034: ns = 68640625 -> 68.640ms…
2-0034: ns = 1185416 -> 1.185ms… still too long
After that, I try to check i2c-designware-core.c, and add the ktime check
I attached the my modified i2c-designware-core.h/i2c-designware-core.c
Please find the below link:
Label is listed below:
start1 -> master xfer start
start2 -> after wait IP ready and init function
isr1 -> first INTR_ACTIVIVY, and put i2c xfer msgs.
isr2 -> IP xfer done
stop -> receive the complete notification and master xfer stop
each time is the offset. only final xfer time is "start1 stop,ns"
For I2C7 400K, 16 byte read, I think IP xfer time make sense for 400~500us.
[ 503.693059] i2c_designware ffd71000.i2c: start1 2, ns = 8194791
[ 503.699103] i2c_designware ffd71000.i2c: start2 isr1, ns = 11527604
[ 503.705490] i2c_designware ffd71000.i2c: isr1 isr2, ns = 31314584
[ 503.711679] i2c_designware ffd71000.i2c: isr2 stop, ns = 246354
[ 503.717700] i2c_designware ffd71000.i2c: start1 stop, ns = 51283333
[ 563.976657] i2c_designware fdf0b000.i2c: start1 2, ns = 69271
[ 563.982714] i2c_designware fdf0b000.i2c: start2 isr1, ns = 16666
[ 563.988953] i2c_designware fdf0b000.i2c: isr1 isr2, ns = 475521
[ 563.995074] i2c_designware fdf0b000.i2c: isr2 stop, ns = 344792
[ 564.001268] i2c_designware fdf0b000.i2c: start1 stop, ns = 906250
Please help to check this bug. The timing doesn’t make sense.