Atlas 200外设驱动开发和调试指南_ I2C-GPIO
调试基于Atlas 200 参考板驱动包进行重构调试,调试方法请参考https://support.huawei.com/enterprise/zh/doc/EDOC1100193743/3db58fa7
1 芯片型号
I2C转GPIO芯片使用pca9555芯片。
2 固件烧录
是否需要固件烧录:否
3 内核配置
DTS配置,在hi1910-fpga-i2c.dtsi的i2c0下增加如下配置:
pca9555_0: pca9555@20{
compatible = "nxp,pca9555";
reg = <0x20>;
};
pca9555_1: pca9555@24{
compatible = "nxp,pca9555";
reg = <0x24>;
};
获取驱动,按照如下配置内核模块:
Device Drivers --->
[*]GPIO Support --->
I2C GPIO expanders --->
<M> PCA95[357]x, PCA9698, TCA64xx, and MAX7310 I/O ports
编译内核和模块,获取驱动gpio-pca953x.ko
4 驱动调试
编译内核模块,获得驱动gpio-pca953x.ko,在系统启动后插入该驱动,完成芯片功能的初始化。
insmod gpio-pca953x.ko
芯片初始化成功后可使用GPIO功能。
root@davinci-mini:/usr/local/bluez_tools/bin# dmesg | grep pca9555
[ 12.138745] ÑfȎgìȎnmȎgݲÑȎflgäǿ can't parse 'reset-gpios' property of node'/i2c@0110130000/pca9555@20[0]'
[ 12.138751] ÑfȎgìȎnmȎgݲÑȎflgäǿ can't parse 'reset-gpio' property of node'/i2c@0110130000/pca9555@20[0]'
[ 12.151514] gpio gpiochip4: (pca9555): added GPIO chardev (254:4)
[ 12.151566] gpiochip_setup_dev: registered GPIOs 417 to 432 on device:
gpiochip4 (pca9555)
[ 12.151653] ÑfȎgìȎnmȎgݲÑȎflgäǿ can't parse 'reset-gpios' property of node
'/i2c@0110130000/pca9555@24[0]'
[ 12.151659] ÑfȎgìȎnmȎgݲÑȎflgäǿ can't parse 'reset-gpio' property of node
'/i2c@0110130000/pca9555@24[0]'
[ 12.164780] gpio gpiochip5: (pca9555): added GPIO chardev (254:5)
[ 12.164834] gpiochip_setup_dev: registered GPIOs 401 to 416 on device:
gpiochip5 (pca9555)
5 测试工具
GPIO的操作参考:https://support.huawei.com/enterprise/zh/doc/EDOC1100193743/a8140323
PCA9555的i2c地址为0x20和0x24,使用i2cdetect工具可以查询
root@davinci-mini:/usr/local/i2c_tools/sbin# ./i2cdetect -r -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- 09 -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: UU UU -- -- UU -- -- -- -- -- -- -- -- -- -- --
30: 30 -- UU -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- UU -- -- -- -- -- UU -- 59 -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
可以通过i2c工具获取pca9555的GPIO的值,比如当前开发板的Board ID为0xcd,即PCA9555的0寄存器的值。
root@davinci-mini:/usr/local/i2c_tools/sbin# ./i2cdump -f -y 0 0x20
No size äÝc²fi (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: cd c8 č č 00 00 č č 00 00 00 00 00 00 00 00 ??..............
10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Atlas 200外设驱动开发和调试指南_ I2C-GPIO
调试基于Atlas 200 参考板驱动包进行重构调试,调试方法请参考https://support.huawei.com/enterprise/zh/doc/EDOC1100193743/3db58fa7
1 芯片型号
I2C转GPIO芯片使用pca9555芯片。
2 固件烧录
是否需要固件烧录:否
3 内核配置
DTS配置,在hi1910-fpga-i2c.dtsi的i2c0下增加如下配置:
pca9555_0: pca9555@20{
compatible = "nxp,pca9555";
reg = <0x20>;
};
pca9555_1: pca9555@24{
compatible = "nxp,pca9555";
reg = <0x24>;
};
获取驱动,按照如下配置内核模块:
Device Drivers --->
[*]GPIO Support --->
I2C GPIO expanders --->
<M> PCA95[357]x, PCA9698, TCA64xx, and MAX7310 I/O ports
编译内核和模块,获取驱动gpio-pca953x.ko
4 驱动调试
编译内核模块,获得驱动gpio-pca953x.ko,在系统启动后插入该驱动,完成芯片功能的初始化。
insmod gpio-pca953x.ko
芯片初始化成功后可使用GPIO功能。
root@davinci-mini:/usr/local/bluez_tools/bin# dmesg | grep pca9555
[ 12.138745] ÑfȎgìȎnmȎgݲÑȎflgäǿ can't parse 'reset-gpios' property of node'/i2c@0110130000/pca9555@20[0]'
[ 12.138751] ÑfȎgìȎnmȎgݲÑȎflgäǿ can't parse 'reset-gpio' property of node'/i2c@0110130000/pca9555@20[0]'
[ 12.151514] gpio gpiochip4: (pca9555): added GPIO chardev (254:4)
[ 12.151566] gpiochip_setup_dev: registered GPIOs 417 to 432 on device:
gpiochip4 (pca9555)
[ 12.151653] ÑfȎgìȎnmȎgݲÑȎflgäǿ can't parse 'reset-gpios' property of node
'/i2c@0110130000/pca9555@24[0]'
[ 12.151659] ÑfȎgìȎnmȎgݲÑȎflgäǿ can't parse 'reset-gpio' property of node
'/i2c@0110130000/pca9555@24[0]'
[ 12.164780] gpio gpiochip5: (pca9555): added GPIO chardev (254:5)
[ 12.164834] gpiochip_setup_dev: registered GPIOs 401 to 416 on device:
gpiochip5 (pca9555)
5 测试工具
GPIO的操作参考:https://support.huawei.com/enterprise/zh/doc/EDOC1100193743/a8140323
PCA9555的i2c地址为0x20和0x24,使用i2cdetect工具可以查询
root@davinci-mini:/usr/local/i2c_tools/sbin# ./i2cdetect -r -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- 09 -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: UU UU -- -- UU -- -- -- -- -- -- -- -- -- -- --
30: 30 -- UU -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- UU -- -- -- -- -- UU -- 59 -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
可以通过i2c工具获取pca9555的GPIO的值,比如当前开发板的Board ID为0xcd,即PCA9555的0寄存器的值。
root@davinci-mini:/usr/local/i2c_tools/sbin# ./i2cdump -f -y 0 0x20
No size äÝc²fi (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: cd c8 č č 00 00 č č 00 00 00 00 00 00 00 00 ??..............
10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................