AM335x使用

am335x增加按鍵:
修改dts
編譯成dtb
替換sd卡里的dtb文件燒寫系統

設備節點 例子參考https://blog.csdn.net/weixin_33962923/article/details/85783144 


uboot 查看dts文件:

fdt addr 88000000
fdt print
fdt head 查看頭

查看系統下面有哪些設備樹節點:
# ls /sys/firmware
devicetree fdt

查看節點和節點名字 標籤等:

cd /sys/fireware/base/

ls 可以看到多個節點。一個節點對應一個文件夾。



# ./button_test /dev/led0 讀按鍵

定義
G PIO Controller 是芯片廠家的事,我們怎麼引用某個引腳呢 ?在自己的設備節點中使用屬性
"[< name>--] gpios",示例如下

gpios=<&gpio5 3 GPIO_ACTIVE_LOW>

或者 reset-gpios=<&gpio5 3 GPIO_ACTIVE_LOW>



同級別的設備樹下(相同級別的子節點)節點名要唯一,也就是同級別的子節點的節點名可以相同,但是要求 “單元 地址”不同。
比如

led@0 {
compatible = "leddrv";
pin = <GROUP_PIN(3, 1)>;
led@1 {
compatible = "leddrv";
pin = <GROUP_PIN(5, 8)>;

 

如何查看 input/event 下面的設備。
cat /proc/bus/input/devices
例如
# cat /proc/bus/input/devices
I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="mykeys@0"
P: Phys=gpio-keys/input0
S: Sysfs=/devices/platform/mykeys@0/input/input0
U: Uniq=
H: Handlers=kbd event0
B: PROP=0
B: EV=100003
B: KEY=80000 0 0 0

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="ti-tsc"
P: Phys=
S: Sysfs=/devices/platform/ocp/44e0d000.tscadc/TI-am335x-tsc/input/input1
U: Uniq=
H: Handlers=mouse0 event1
B: PROP=0
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=1000003

可以看出 mykeys@0 在input0下面

按鍵dts配置

設備樹節點

  • gpio_keys: mykeys@0 {
    compatible = "gpio-keys";
    #address-cells = <1>;
    #size-cells = <0>;
    autorepeat; //重複上報

    switch@1 {
    label = "reset_to_factory"; //恢復出廠設置
    linux,code = <115>;
    gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
    gpio-key,wakeup;
    };
    }

  • pinctrl節點

  • pinctrl-names = "default";
    pinctrl-0 = <&gpio_keys_pins>;
    gpio_keys_pins: gpio_keys_pins {
    pinctrl-single,pins = <
    0x21c ( PIN_INPUT | MUX_MODE7 ) /* (F16) USB0_DRVVBUS.gpio0[18] */
    >;
    };

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章