raspberrypi / linux

Kernel source tree for Raspberry Pi-provided kernel builds. Issues unrelated to the linux kernel should be posted on the community forum at https://forums.raspberrypi.com/
Other
11.01k stars 4.95k forks source link

The SMBus block reading of Synopsys DesignWare I2C adapter for raspberry pi 5 doesn't work #5796

Open davesliu opened 8 months ago

davesliu commented 8 months ago

Describe the bug

Hello

I found that the SMBus block reading feature of the Synopsys DesignWare I2C adapter of raspberry pi 5 doesn't work.

As shown in below snapshots in green box. A slave device that support SMBus block reading on its register address 0xAD. ( it uses SMBus block reading for this register with send back 4 bytes content) I can use I2C block reading to read 4 bytes from register 0xAD ( the first byte 0x4 is the length of data, followed with 4 byte data ) as shown in below green box.

But if I use the SMBus block read, it shows timeout ( both in shell and the kernel dmesg) as shown in red box of below snapshot. It seems that the I2C adapter truncate the SMBus block reading by sending NACK after it receive the length 0x04 and the first byte data 0x00....

image

Could you help to fix this issue?

Steps to reproduce the behaviour

Run smbus block reading command pi@raspberrypi:/sys/devices $ i2cget -y 1 0x4f 0xAD s Error: Read failed

Device (s)

raspberry pi 5 - 8GB

System

pi@raspberrypi:/sys/devices $ i2cdetect -F 1 Functionalities implemented by /dev/i2c-1: I2C yes SMBus Quick Command yes SMBus Send Byte yes SMBus Receive Byte yes SMBus Write Byte yes SMBus Read Byte yes SMBus Write Word yes SMBus Read Word yes SMBus Process Call no SMBus Block Write yes SMBus Block Read yes SMBus Block Process Call no SMBus PEC no I2C Block Write yes I2C Block Read yes pi@raspberrypi:/sys/devices $ i2cdetect -l 1 i2c-1 i2c Synopsys DesignWare I2C adapter I2C adapter i2c-3 i2c 300000002.i2c I2C adapter i2c-11 i2c 107d508200.i2c I2C adapter i2c-12 i2c 107d508280.i2c I2C adapter pi@raspberrypi:/sys/devices $ uname -a Linux raspberrypi 6.1.0-rpi7-rpi-2712 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64 GNU/Linux pi@raspberrypi:/sys/devices $ cat /etc/rpi-issue Raspberry Pi reference 2023-12-05 Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 70cd6f2a1e34d07f5cba7047aea5b92457372e05, stage4 pi@raspberrypi:/sys/devices $ vcgencmd version 2023/10/30 16:45:10 Copyright (c) 2012 Broadcom version 30de0ba5 (release) (embedded)

Logs

No response

Additional context

No response

davesliu commented 8 months ago

BTW, If the SMBus block reading sequence is correct, it should has sequence like below. The first received data 0x04 is the the length, and the adapter shall not send NACK after the 0x00. (It shall send ACK so slave device will send the left 3 bytes data content) image

The I2C adapter kernel info is shown below: image