問題描述
Linux I2C 通信問題 (Linux I2C communication issues)
我正在開發基於 iMX6Q 處理器的定制板,該處理器使用 linux‑imx 內核 4.9.11 (http://git.freescale.com/git/cgit.cgi/imx/linux‑imx.git/?h =imx_4.9.11_1.0.0_ga)。但是,當我向其中一個外圍設備發送 I2C 消息(我在 i2c‑2 總線上有 4 個從設備,處理器是唯一的主設備)時,控制器會出現以下錯誤:
[ 82.972843] i2c i2c‑2: ioctl, cmd=0x703, arg=0x5c
[ 82.972854] i2c i2c‑2: ioctl, cmd=0x720, arg=0x7ec06bbc
[ 82.972865] i2c i2c‑2: master_xfer[0] R, addr=0x5c, len=1
[ 82.972871] i2c i2c‑2: <i2c_imx_xfer>
[ 82.972877] i2c i2c‑2: <i2c_imx_start>
[ 82.973053] i2c i2c‑2: <i2c_imx_bus_busy>
[ 83.482804] i2c i2c‑2: <i2c_imx_bus_busy> I2C bus is busy
[ 83.482810] i2c i2c‑2: Trying i2c bus recovery
[ 83.482854] i2c i2c‑2: <i2c_imx_start>
[ 83.483029] i2c i2c‑2: <i2c_imx_bus_busy>
[ 83.992804] i2c i2c‑2: <i2c_imx_bus_busy> I2C bus is busy
[ 83.992816] i2c i2c‑2: <i2c_imx_xfer> exit with: error: ‑110
採取用示波器看一下,我可以看到總線處於空閒狀態時為高電平(如預期的那樣)。然而,當我嘗試開始傳輸時,主機在總線上設置啟動條件,然後,總線保持低電平(兩者,SDA 和 SCL),直到傳輸超時並且驅動程序警告總線正忙於超時錯誤(儘管它確實不是!)。我知道這不是硬件問題/錯誤,因為我可以通過 U‑Boot(以及較舊的內核版本,例如 4.1.15)通過 I2C 進行通信。
我已經檢查了 I2C 內核配置它似乎沒問題。此外,設備樹中的 I2C 總線控制器已正確配置。
PD:默認內核配置(imx_v7_defconfig)不起作用。
謝謝!
乾杯,
丹尼爾
我已經檢查了 I2C 內核配置,似乎沒問題。此外,設備樹中的 I2C 總線控制器已正確配置。PD:默認內核配置(imx_v7_defconfig)不起作用。
謝謝!
乾杯,
丹尼爾
我已經檢查了 I2C 內核配置,似乎沒問題。此外,設備樹中的 I2C 總線控制器已正確配置。PD:默認內核配置(imx_v7_defconfig)不起作用。
謝謝!
乾杯,
丹尼爾
參考解法
方法 1:
The issue has gone. I just had to change the i2c pin configuration (in the Device Tree) from 0x1b8b0 to 0x4001b8b1...It's still strange because those bits (Mask 0xFFFE0000) are marked as reserved in the iMX.6Q reference manual, though they seem not so reserved...In addition, the very same Device Tree file worked without problems with older Kernel versions...
Whatever the case, it is working as expected right now!