Hi Wolfram, Thank you for the review. Finally I got my setup out for this. On Thu, Apr 17, 2025 at 9:32 AM Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx> wrote: > > On Mon, Apr 07, 2025 at 01:18:59PM +0100, Prabhakar wrote: > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx> > > > > Implement bus recovery by reinitializing the hardware to reset the bus > > state and generating 9 clock cycles (and a stop condition) to release > > the SDA line. > > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx> > > Tested-by: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx> > > Reviewed-by: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx> > > Reviewed-by: Fabrizio Castro <fabrizio.castro.jz@xxxxxxxxxxx> > > Reviewed-by: Andy Shevchenko <andy@xxxxxxxxxx> > > As I wrote in the other thread: I took your generic_scl approach and > replaced bus_free() with get_sda(). Works fine here with my G3S: > As suggested I have the below now, (are there any changes Ive missed?) +static int riic_get_sda(struct i2c_adapter *adap) +{ + struct riic_dev *riic = i2c_get_adapdata(adap); + + /* Check if the bus is busy or SDA is not high */ + if ((riic_readb(riic, RIIC_ICCR2) & ICCR2_BBSY) || + !(riic_readb(riic, RIIC_ICCR1) & ICCR1_SDAI)) + return -EBUSY; + + return 1; +} + static const struct riic_irq_desc riic_irqs[] = { { .res_num = 0, .isr = riic_tend_isr, .name = "riic-tend" }, { .res_num = 1, .isr = riic_rdrf_isr, .name = "riic-rdrf" }, @@ -523,7 +568,11 @@ static const struct riic_irq_desc riic_irqs[] = { }; static struct i2c_bus_recovery_info riic_bri = { - .recover_bus = riic_recover_bus, + .get_scl = riic_get_scl, + .set_scl = riic_set_scl, + .set_sda = riic_set_sda, + .get_sda = riic_get_sda, + .recover_bus = i2c_generic_scl_recovery, } > # echo 0x1a > /sys/kernel/debug/i2c/i2c-2/incomplete_address_phase ; i2cget -f -y 0 0x1a 3 > 0x0c > > And I see 9 pulses in the scope. Can you try this with your setup > please? > This seems to be unreliable on my side below are my test results. root@smarc-rzg2l:~/i2c# cat ./incomplete_address_phase.sh cd /sys/kernel/debug/i2c/i2c-4/ for i in {1..1}; do echo 0x68 > incomplete_address_phase; val=$(i2cget -y -f 3 0x68 8) if [ "$?" != "0" ] || [ "${val}" != "0x83" ]; then echo "I2C Read error (ret:$?) ${val}!!" exit 1 fi echo "Read val:${val}" done root@smarc-rzg2l:~/i2c# root@smarc-rzg2l:~/i2c# ./incomplete_address_phase.sh Read val:0x83 root@smarc-rzg2l:~/i2c# ./incomplete_address_phase.sh Error: Read failed I2C Read error (ret:0) !! root@smarc-rzg2l:~/i2c# ./incomplete_address_phase.sh Read val:0x83 root@smarc-rzg2l:~/i2c# ./incomplete_address_phase.sh Error: Read failed I2C Read error (ret:0) !! root@smarc-rzg2l:~/i2c# root@smarc-rzg2l:~/i2c# ./incomplete_address_phase.sh Read val:0x83 root@smarc-rzg2l:~/i2c# ./incomplete_address_phase.sh Error: Read failed I2C Read error (ret:0) !! root@smarc-rzg2l:~/i2c# root@smarc-rzg2l:~/i2c# Cheers, Prabhakar