hisi3520dv400在操作gpio时,提示 sh: write error: No such device
/home/mnt/Hi3521DV100_SDK_V1.0.5.0/osdrv/tools/board/reg-tools-1.0.0/bin # echo
73 > /sys/class/gpio/export
sh: write error: No such device
73无法操作,在尝试一些小的号,比如7 6 等都可以。查看gpio的情况,发现有gpiochip0,gpiochip8,gpiochip16三个相关的gpio,正好是每组8个,这里有三组。
/sys/class/gpio # ls -l
total 0
--w------- 1 root root 4096 Jan 1 01:00 export
lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpio10 -> ../../devices/soc/12160000.gpio/gpio/gpio10
lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpio11 -> ../../devices/soc/12160000.gpio/gpio/gpio11
lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpio12 -> ../../devices/soc/12160000.gpio/gpio/gpio12
lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpio13 -> ../../devices/soc/12160000.gpio/gpio/gpio13
lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpio14 -> ../../devices/soc/12160000.gpio/gpio/gpio14
lrwxrwxrwx 1 root root 0 Jan 1 00:08 gpio15 -> ../../devices/soc/12160000.gpio/gpio/gpio15
lrwxrwxrwx 1 root root 0 Jan 1 01:00 gpio16 -> ../../devices/soc/12170000.gpio/gpio/gpio16
lrwxrwxrwx 1 root root 0 Jan 1 01:00 gpio17 -> ../../devices/soc/12170000.gpio/gpio/gpio17
lrwxrwxrwx 1 root root 0 Jan 1 00:08 gpio7 -> ../../devices/soc/12150000.gpio/gpio/gpio7
lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpio8 -> ../../devices/soc/12160000.gpio/gpio/gpio8
lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpio9 -> ../../devices/soc/12160000.gpio/gpio/gpio9
lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip0 -> ../../devices/soc/12150000.gpio/gpio/gpiochip0
lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip16 -> ../../devices/soc/12170000.gpio/gpio/gpiochip16
lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip8 -> ../../devices/soc/12160000.gpio/gpio/gpiochip8
--w------- 1 root root 4096 Jan 1 00:00 unexport
原因在于内核(linux-3.18.y)的配置:
进如内核目录:arch/arm/boot/dts
查看设备树hi3520dv400.dtsi文件:正好有gpio_chip0,gpio_chip1,chip2的配置,其它的没有配置而73属于gpio9_1。
中间省略一部分程序
根据例子,需要在dtsi中添加gpio9