标签:
1、 修改mt7620a.dts文件,把gpio管脚复用全都定义为通用gpio
/dts-v1/; /include/ "mt7620a.dtsi" / { compatible = "ralink,mt7620a-eval-board", "ralink,mt7620a-soc"; model = "Ralink MT7620a + MT7610e evaluation board"; palmbus@10000000 { gpio1: gpio@638 { status = "okay"; }; gpio2: gpio@660 { status = "okay"; }; gpio3: gpio@688 { status = "okay"; }; spi@b00 { status = "okay"; m25p80@0 { #address-cells = <1>; #size-cells = <1>; compatible = "en25q64"; reg = <0 0>; linux,modalias = "m25p80", "en25q64"; spi-max-frequency = <10000000>; partition@0 { label = "u-boot"; reg = <0x0 0x30000>; read-only; }; partition@30000 { label = "u-boot-env"; reg = <0x30000 0x10000>; read-only; }; factory: partition@40000 { label = "factory"; reg = <0x40000 0x10000>; read-only; }; partition@50000 { label = "firmware"; reg = <0x50000 0x1fb0000>; }; }; }; }; pinctrl { state_default: pinctrl0 { gpio { ralink,group = "i2c", "uartf", "wdt", "pa", "mdio", "rgmii1", "pcie","spi refclk","ephy", "nd_sd", "rgmii2","wled"; ralink,function = "gpio"; }; }; }; ethernet@10100000 { mtd-mac-address = <&factory 0x4>; ralink,port-map = "llllw"; }; gpio-keys-polled { compatible = "gpio-keys"; #address-cells = <1>; #size-cells = <0>; poll-interval = <20>; s2 { label = "S2"; gpios = <&gpio0 1 1>; linux,code = <0x100>; }; s3 { label = "S3"; gpios = <&gpio0 2 1>; linux,code = <0x101>; }; }; };
2、 将如下放shell脚本放在/root文件夹下,命名为test,依次执行如下,就可以将gpio0 ~ gpio72都设为输出,输出为低电平。
#!/bin/sh cd /sys/class/gpio for i in 0 `seq 72` do echo $i >/sys/class/gpio/export echo out >./gpio$i/direction #echo out >/sys/devices/10000000.palmbus/10000600.gpio/gpio/gpio$i/direction echo 0 >./gpio$i/value done
root@OpenWrt:~# root@OpenWrt:~# chmod 777 test root@OpenWrt:~# ./test
3、可以得到如下管脚可以正常使用(打钩):
问题:
1、不知gpio7被什么占用了,会出现如下问题
2、 其他的可以创建gpio的io不知道为什么,手动敲入命令行没反应,但直接执行脚本命令就有效果。
参考:
http://blog.sina.com.cn/s/blog_9d074aae01012ytf.html
标签:
原文地址:http://www.cnblogs.com/smbx-ztbz/p/5223795.html