1、 修改mt7620a.dts文件,把gpio管脚复用全都定义为通用gpio
/dts-v1/; /include/ "mt7620a.dtsi" / { compatible = "ralink,mt7620a-eval-board", "ralink,mt7620a-soc"; model = "Ralink MT7620a + MT7610e evaluation board"; [email protected]10000000 { gpio1: [email protected]638 { status = "okay"; }; gpio2: [email protected]660 { status = "okay"; }; gpio3: [email protected]688 { status = "okay"; }; [email protected] { status = "okay"; [email protected]0 { #address-cells = <1>; #size-cells = <1>; compatible = "en25q64"; reg = <0 0>; linux,modalias = "m25p80", "en25q64"; spi-max-frequency = <10000000>; [email protected]0 { label = "u-boot"; reg = <0x0 0x30000>; read-only; }; [email protected]30000 { label = "u-boot-env"; reg = <0x30000 0x10000>; read-only; }; factory: [email protected]40000 { label = "factory"; reg = <0x40000 0x10000>; read-only; }; [email protected]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"; }; }; }; [email protected]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
[email protected]:~# [email protected]:~# chmod 777 test [email protected]:~# ./test
3、可以得到如下管脚可以正常使用(打钩):
问题:
1、不知gpio7被什么占用了,会出现如下问题
2、 其他的可以创建gpio的io不知道为什么,手动敲入命令行没反应,但直接执行脚本命令就有效果。
参考:
http://blog.sina.com.cn/s/blog_9d074aae01012ytf.html
时间: 2024-10-15 18:41:48