分类: 嵌入式
2026-05-20 11:23:06
1. 查看 dtbo 反编译后的设备树文件dtsi
2. 查看设备树上的 i3c master 和 master 下的 device
ls /proc/device-tree/soc | grep -E 'i2c|i3c'
ls /proc/device-tree/soc/i3c-master-0@84808000
3. 查看所有 i2c/i3c 下的 bus 和 bus 下挂载成功的 device:
ls -la /sys/bus/i2c/devices
ls -la /sys/bus/i3c/devices
# bus. 如 i2c-11 或 NA 出现,表示 i2c/i3c controller driver probe 成功. 即会产生了 /dev/i2c-x 或 NA (Linux 不为 I3C master 创建 /dev 节点, I3C master 不允许 userspace 做“裸总线访问” (ENTDAA、IBI、HDR、CCC 都是 kernel policy)).
# bus 下的 device. 如 2-68200001000 或 3-23400000000 出现,表示 i2c device 被实例化成功(来自device tree, i2c_register_board_info),而非 device driver probe 成功。
4. (device driver probe 成功后) 查看 device:
ls /dev/i2c/paccx
ls /dev/bus/i3c/x-x
5. list/read device:
#查看所有的 I2C bus
i2cdetect -l
#查看 I2C bus 10 和 11 上挂的 devices
i2cdetect -y 10 # 实际访问的是 /dev/i2c-10
i2cdetect -y 11
# 读取 branch4 对应的 device chip id
i2cset -y 11 0x54 0x1 0 s
i2cget -y 11 0x54 0x40 w
#读取电流(TI:大端序)
i2cget -y 10 0x51 0x18 w
i2cget -y 10 0x51 0x19 w
# 读取 branch0 对应的 device chip id
i3ctool -d /dev/bus/i3c/3-23400000000 -w "0 0" -r 2
#读取电流(TI:大端序)
i3ctool -d /dev/bus/i3c/3-23400000000 -w "18 0" -r 2 # bgmc1210 驱动一次写事务实际发 4 字节(2 地址(由 /paCtrlDevice:0/addressBitLength 决定) + 2 数据(由驱动自己选择 Reg16 方法决定)),一次读事务发 2 字节地址再读回 2 字节数据