WhyCan Forum(哇酷开发者社区)

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn

您尚未登录。

#1 2019-04-26 23:50:07

晕哥
管理员
注册时间: 2017-09-06
累计积分: 9,190

V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

GPIO KEY 按键驱动(轮询)测试:

参考: https://github.com/ARM-software/u-boot/blob/master/arch/arm/dts/sun4i-a10-inet9f-rev03.dts


1. Linux驱动配置 gpio keys poll 驱动:

CONFIG_KEYBOARD_GPIO_POLLED=y


2. arch/arm/boot/dts/sun8i-v3s.dtsi 添加引脚定义:

key_pins: key_pins@0 {
               pins = "PB0", "PB1";
               function = "gpio_in";
               bias-pull-up;
               };

3. arch/arm/boot/dts/sun8i-v3s-licheepi-zero.dts 添加:

#include <dt-bindings/input/input.h>

       gpio_keys {
               compatible = "gpio-keys-polled";
               pinctrl-names = "default";
               pinctrl-0 = <&key_pins>;
               #address-cells = <1>;
               #size-cells = <0>;
               poll-interval = <20>;

               button@0 {
                       label = "Left Joystick Left";
                       linux,code = <ABS_X>;
                       linux,input-type = <EV_ABS>;
                       linux,input-value = <0xffffffff>; /* -1 */
                       gpios = <&pio 1 0 GPIO_ACTIVE_LOW>; /* PB0 */
               };

               button@1 {
                       label = "Left Joystick Right";
                       linux,code = <ABS_Z>;
                       linux,input-type = <EV_ABS>;
                       linux,input-value = <1>;
                       gpios = <&pio 1 1 GPIO_ACTIVE_LOW>; /* PB1 */
               };
       };

4. 编译烧录运行测试:

# evtest /dev/input/event0
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "gpio_keys"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
      Value      0
      Min       -1
      Max        0
    Event code 2 (ABS_Z)
      Value      0
      Min        0
      Max        1
Properties:
Testing ... (interrupt to exit)
Event: time 80.855039, type 3 (EV_ABS), code 2 (ABS_Z), value 1
Event: time 80.855039, -------------- SYN_REPORT ------------
Event: time 80.915049, type 3 (EV_ABS), code 2 (ABS_Z), value 0
Event: time 80.915049, -------------- SYN_REPORT ------------
Event: time 84.545066, type 3 (EV_ABS), code 2 (ABS_Z), value 1
Event: time 84.545066, -------------- SYN_REPORT ------------
Event: time 84.605043, type 3 (EV_ABS), code 2 (ABS_Z), value 0
Event: time 84.605043, -------------- SYN_REPORT ------------
Event: time 90.845038, type 3 (EV_ABS), code 2 (ABS_Z), value 1
Event: time 90.845038, -------------- SYN_REPORT ------------
Event: time 90.995036, type 3 (EV_ABS), code 2 (ABS_Z), value 0
Event: time 90.995036, -------------- SYN_REPORT ------------
Event: time 91.145036, type 3 (EV_ABS), code 2 (ABS_Z), value 1
Event: time 91.145036, -------------- SYN_REPORT ------------
Event: time 91.355035, type 3 (EV_ABS), code 2 (ABS_Z), value 0
Event: time 91.355035, -------------- SYN_REPORT ------------
Event: time 91.445037, type 3 (EV_ABS), code 2 (ABS_Z), value 1
Event: time 91.445037, -------------- SYN_REPORT ------------
Event: time 91.625037, type 3 (EV_ABS), code 2 (ABS_Z), value 0
Event: time 91.625037, -------------- SYN_REPORT ------------
Event: time 101.375037, type 3 (EV_ABS), code 0 (ABS_X), value -1
Event: time 101.375037, -------------- SYN_REPORT ------------

离线

#2 2019-04-27 09:23:07

晕哥
管理员
注册时间: 2017-09-06
累计积分: 9,190

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

--------------------------------------------------------------------------------

离线

#3 2019-04-27 09:28:27

晕哥
管理员
注册时间: 2017-09-06
累计积分: 9,190

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

GPIO KEY 按键驱动(中断)测试:

参考: https://gitlab.labs.nic.cz/turris/u-boot-turris/commit/643ad899f545fd101aa7a67771e74d582a1829b2


1. Linux驱动配置 gpio keys 驱动:

CONFIG_KEYBOARD_GPIO=y


2. arch/arm/boot/dts/sun8i-v3s.dtsi 添加引脚定义:

key_pins: key_pins@0 {
pins = "PB0", "PB1";
function = "gpio_in";
allwinner,drive = <0>;
allwinner,pull = <1>;
};

3. arch/arm/boot/dts/sun8i-v3s-licheepi-zero.dts 添加:

#include <dt-bindings/input/input.h>

gpio_keys {
        compatible = "gpio-keys";
        pinctrl-names = "default";
        pinctrl-0 = <&key_pins>;
        #address-cells = <1>;
        #size-cells = <0>;
        autorepeat;
        button@0 {
                label = "Key back";
                linux,code = <KEY_BACK>;
                gpios = <&pio 1 0 GPIO_ACTIVE_LOW>; /* PB0 */
        };


         button@1 {
                 label = "Key home";
                 linux,code = <KEY_HOME>;
                 gpios = <&pio 1 1 GPIO_ACTIVE_LOW>; /* PB1 */
         };

};

4. 编译烧录运行测试, 支持长按:

# evtest /dev/input/event2
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "gpio_keys"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 102 (KEY_HOME)
    Event code 158 (KEY_BACK)
Key repeat handling:
  Repeat type 20 (EV_REP)
    Repeat code 0 (REP_DELAY)
      Value    250
    Repeat code 1 (REP_PERIOD)
      Value     33
Properties:
Testing ... (interrupt to exit)
Event: time 3606.960158, type 1 (EV_KEY), code 102 (KEY_HOME), value 1
Event: time 3606.960158, -------------- SYN_REPORT ------------
Event: time 3607.220140, type 1 (EV_KEY), code 102 (KEY_HOME), value 2
Event: time 3607.220140, -------------- SYN_REPORT ------------
Event: time 3607.270142, type 1 (EV_KEY), code 102 (KEY_HOME), value 2
Event: time 3607.270142, -------------- SYN_REPORT ------------
Event: time 3607.320136, type 1 (EV_KEY), code 102 (KEY_HOME), value 2
Event: time 3607.320136, -------------- SYN_REPORT ------------
Event: time 3607.370136, type 1 (EV_KEY), code 102 (KEY_HOME), value 2
Event: time 3607.370136, -------------- SYN_REPORT ------------
Event: time 3607.370277, type 1 (EV_KEY), code 102 (KEY_HOME), value 0
Event: time 3607.370277, -------------- SYN_REPORT ------------
Event: time 3616.220150, type 1 (EV_KEY), code 158 (KEY_BACK), value 1
Event: time 3616.220150, -------------- SYN_REPORT ------------
Event: time 3616.480130, type 1 (EV_KEY), code 158 (KEY_BACK), value 2
Event: time 3616.480130, -------------- SYN_REPORT ------------
Event: time 3616.530130, type 1 (EV_KEY), code 158 (KEY_BACK), value 2
Event: time 3616.530130, -------------- SYN_REPORT ------------
Event: time 3616.580139, type 1 (EV_KEY), code 158 (KEY_BACK), value 2
Event: time 3616.580139, -------------- SYN_REPORT ------------
Event: time 3616.630136, type 1 (EV_KEY), code 158 (KEY_BACK), value 2
Event: time 3616.630136, -------------- SYN_REPORT ------------
Event: time 3616.680132, type 1 (EV_KEY), code 158 (KEY_BACK), value 2
Event: time 3616.680132, -------------- SYN_REPORT ------------
Event: time 3616.730131, type 1 (EV_KEY), code 158 (KEY_BACK), value 2
Event: time 3616.730131, -------------- SYN_REPORT ------------
Event: time 3616.780134, type 1 (EV_KEY), code 158 (KEY_BACK), value 2
Event: time 3616.780134, -------------- SYN_REPORT ------------
Event: time 3616.830131, type 1 (EV_KEY), code 158 (KEY_BACK), value 2
Event: time 3616.830131, -------------- SYN_REPORT ------------
Event: time 3616.850155, type 1 (EV_KEY), code 158 (KEY_BACK), value 0
Event: time 3616.850155, -------------- SYN_REPORT ------------

离线

#4 2019-04-27 09:55:11

晕哥
管理员
注册时间: 2017-09-06
累计积分: 9,190

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

参考: https://www.kernel.org/doc/Documentation/devicetree/bindings/input/gpio-keys.txt

接上帖, GPIO 也可以换作 interrupts, Linux 官方文档提示 二选一

gpio_keys {
                compatible = "gpio-keys";
                pinctrl-names = "default";
                pinctrl-0 = <&key_pins>;
                #address-cells = <1>;
                #size-cells = <0>;
                autorepeat;
                button@0 {
                        label = "Key back";
                        linux,code = <KEY_BACK>;

                        interrupt-parent = <&pio>;
                        interrupts = <1 0 IRQ_TYPE_EDGE_FALLING>;//PB0

                };


                button@1 {
                        label = "Key home";
                        linux,code = <KEY_HOME>;

                        interrupt-parent = <&pio>;
                        interrupts = <1 1 IRQ_TYPE_EDGE_FALLING>; //PB1
                };

        };


查看中断:

# cat /proc/interrupts
           CPU0
17:          0     GIC-0  29 Level     arch_timer
18:       3375     GIC-0  30 Level     arch_timer
21:          0     GIC-0  50 Level     /soc/timer@01c20c00
22:          0     GIC-0  82 Level     1c02000.dma-controller
23:       9025     GIC-0  92 Level     sunxi-mmc
24:        479     GIC-0  93 Level     sunxi-mmc
25:         21     GIC-0 103 Level     musb-hdrc.1.auto
26:          0     GIC-0 104 Level     ehci_hcd:usb1
27:          0     GIC-0 105 Level     ohci_hcd:usb2
28:          0     GIC-0  72 Level     1c20400.rtc
34:          0     GIC-0  62 Level     sun4i-a10-lradc-keys
36:        226     GIC-0  32 Level     ttyS0
37:          0     GIC-0  38 Level     mv64xxx_i2c
39:          1  sunxi_pio_edge   0 Edge      Key back
40:         68  sunxi_pio_edge   1 Edge      Key home

IPI0:          0  CPU wakeup interrupts
IPI1:          0  Timer broadcast interrupts
IPI2:          0  Rescheduling interrupts
IPI3:          0  Function call interrupts
IPI4:          0  CPU stop interrupts
IPI5:          0  IRQ work interrupts
IPI6:          0  completion interrupts

离线

#5 2019-04-27 14:07:17

晕哥
管理员
注册时间: 2017-09-06
累计积分: 9,190

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

IMG_20190427_142043.jpg


旋转编码器(中断)测试:

参考: https://github.com/teknoid/dac/blob/master/misc/gpio-rotary.dts

接线方法:

PB0 - CLK
PB1 - DT
3V3
GND

1. Linux驱动配置 gpio keys 驱动:

CONFIG_INPUT_GPIO_ROTARY_ENCODER=y


2. arch/arm/boot/dts/sun8i-v3s.dtsi 添加引脚定义:

key_pins: key_pins@0 {
pins = "PB0", "PB1";
function = "gpio_in";
allwinner,drive = <0>;
allwinner,pull = <1>;
};

3. arch/arm/boot/dts/sun8i-v3s-licheepi-zero.dts 添加:

#include <dt-bindings/input/input.h>

rotary@0 {
        compatible = "rotary-encoder";

        pinctrl-names = "default";
        pinctrl-0 = <&key_pins>;

        gpios = <&pio 1 0 GPIO_ACTIVE_LOW>, <&pio 1 1 GPIO_ACTIVE_LOW>; /* PB0, PB1 */
        linux,axis = <0>; /* REL_X */
        rotary-encoder,encoding = "gray";
        rotary-encoder,relative-axis;
};

4. 编译烧录运行测试, 支持长按:

# evtest /dev/input/event1
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x0 product 0x0 version 0x0
Input device name: "rotary@0"
Supported events:
  Event type 0 (EV_SYN)
  Event type 2 (EV_REL)
    Event code 0 (REL_X)
Properties:
Testing ... (interrupt to exit)
Event: time 2474.959560, type 2 (EV_REL), code 0 (REL_X), value 1
Event: time 2474.959560, -------------- SYN_REPORT ------------
Event: time 2476.204760, type 2 (EV_REL), code 0 (REL_X), value 1
Event: time 2476.204760, -------------- SYN_REPORT ------------
Event: time 2476.907228, type 2 (EV_REL), code 0 (REL_X), value 1
Event: time 2476.907228, -------------- SYN_REPORT ------------
Event: time 2477.565278, type 2 (EV_REL), code 0 (REL_X), value 1
Event: time 2477.565278, -------------- SYN_REPORT ------------
Event: time 2478.140605, type 2 (EV_REL), code 0 (REL_X), value 1
Event: time 2478.140605, -------------- SYN_REPORT ------------
Event: time 2478.548095, type 2 (EV_REL), code 0 (REL_X), value -1
Event: time 2478.548095, -------------- SYN_REPORT ------------
Event: time 2479.051748, type 2 (EV_REL), code 0 (REL_X), value -1
Event: time 2479.051748, -------------- SYN_REPORT ------------
Event: time 2479.541767, type 2 (EV_REL), code 0 (REL_X), value -1
Event: time 2479.541767, -------------- SYN_REPORT ------------
Event: time 2479.924168, type 2 (EV_REL), code 0 (REL_X), value -1
Event: time 2479.924168, -------------- SYN_REPORT ------------
Event: time 2480.279108, type 2 (EV_REL), code 0 (REL_X), value -1
Event: time 2480.279108, -------------- SYN_REPORT ------------

离线

#6 2019-04-27 19:57:18

晕哥
管理员
注册时间: 2017-09-06
累计积分: 9,190

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

荔枝派zero 旋转编码器演示视频

离线

#7 2020-01-29 15:58:55

smartcar
会员
注册时间: 2018-02-19
累计积分: 683

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

牛叉,学习了。

在线

#8 2020-04-06 10:11:11

ubuntu
会员
注册时间: 2020-03-30
累计积分: 60

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

牛叉,学习了, 正需要这个demo到A33测试, 晚点过来报告。

离线

#9 2020-04-06 16:34:58

ubuntu
会员
注册时间: 2020-03-30
累计积分: 60

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

我的A33 linux5.x 按 4# 的操作步奏,中断申请到了, 但是根本不触发。

arch/arm/boot/dts/sun8i-a23-a33.dtsi

                pio: pinctrl@1c20800 {
                        /* compatible gets set in SoC specific dtsi file */
                        reg = <0x01c20800 0x400>;
                        
....

                        key_pins: key_pins@0 {
                                pins = "PB5";
                                function = "gpio_in";
                                allwinner,drive = <0>;
                                allwinner,pull = <1>;
                        };



arch/arm/boot/dts/sun8i-a33.dtsi

        keys{
                compatible = "gpio-keys";
                pinctrl-names = "default";
                pinctrl-0 = <&key_pins>;
                #address-cells = <1>;
                #size-cells = <0>;
                autorepeat;

                g-keys_up {
                        label = "GPIO KEY_UP";
                        linux,code = <103>; /* KEY_UP, see /usr/include/linux/input-event-codes.h */
//                        gpios = <&pio 1 5 1>; /* PA7 GPIO_ACTIVE_LOW */

                        interrupt-parent = <&pio>;
                        interrupts = <1 5 IRQ_TYPE_EDGE_FALLING>;//PB0
                };

                /*status = "okay";*/
        };

        iio-hwmon {
                compatible = "iio-hwmon";
                io-channels = <&ths>;
        };

根本不触发:

# cat /proc/interrupts
           CPU0       CPU1       CPU2       CPU3
 18:          0          0          0          0     GICv2  29 Level     arch_timer
 19:        401       1735        205        225     GICv2  30 Level     arch_timer
 22:          0          0          0          0     GICv2  50 Level     timer@1c20c00
 23:          0          0          0          0     GICv2  82 Level     1c02000.dma-controller
 25:       4072          0          0          0     GICv2  92 Level     sunxi-mmc
 26:          0          0          0          0     GICv2 103 Level     musb-hdrc.1.auto
 27:          0          0          0          0     GICv2 104 Level     ehci_hcd:usb1
 28:          0          0          0          0     GICv2 105 Level     ohci_hcd:usb2
 34:       1705          0          0          0     GICv2  32 Level     ttyS0
 56:          0          0          0          0  sunxi_pio_edge   5 Edge      GPIO KEY_UP
 60:          0          0          0          0  sunxi_pio_edge   9 Edge      1c0f000.mmc cd
IPI0:          0          0          0          0  CPU wakeup interrupts
IPI1:          0          0          0          0  Timer broadcast interrupts
IPI2:        749        723        125       1223  Rescheduling interrupts
IPI3:          1         12         22         43  Function call interrupts
IPI4:          0          0          0          0  CPU stop interrupts
IPI5:          0          0          0          0  IRQ work interrupts
IPI6:          0          0          0          0  completion interrupts
Err:          0

离线

#10 2020-04-06 16:43:34

ubuntu
会员
注册时间: 2020-03-30
累计积分: 60

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

https://github.com/torvalds/linux/blob/master/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c

https://patchwork.kernel.org/patch/8572141/

diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
index 00265f0..8b381d6 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
@@ -485,6 +485,7 @@  static const struct sunxi_pinctrl_desc sun8i_a33_pinctrl_data = {
 	.pins = sun8i_a33_pins,
 	.npins = ARRAY_SIZE(sun8i_a33_pins),
 	.irq_banks = 2,
+	.irq_bank_base = 1,
 };

2016 的bug patch 也没有并入?

离线

#11 2020-04-06 16:49:42

ubuntu
会员
注册时间: 2020-03-30
累计积分: 60

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

https://lore.kernel.org/patchwork/patch/934382/

这里貌似有icenowy 关于 A33/V3s 外部IO中断的 patch

离线

#12 2020-04-06 20:03:27

qiushan
会员
注册时间: 2020-01-16
累计积分: 26

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

mark

离线

#13 2020-05-26 14:09:03

CAT.1
会员
注册时间: 2020-05-22
累计积分: 18

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

我的设备树:

       gpio_keys {
               compatible = "gpio-keys-polled";
               pinctrl-names = "default";
/*               pinctrl-0 = <&key_pins>;*/
               #address-cells = <1>;
               #size-cells = <0>;
               poll-interval = <20>;



               button@0 {
                        label = "GPIO Key Up";
                        linux,code = <KEY_UP>;
                        gpios = <&pio 7 1 GPIO_ACTIVE_LOW>; /* PH1 */
               };
               button@1 {
                        label = "GPIO Key Enter";
                        linux,code = <KEY_ENTER>;
                        gpios = <&pio 7 8 GPIO_ACTIVE_LOW>; /* PH8 */
               };

               button@2 {
                        label = "GPIO Key Down";
                        linux = <KEY_DOWN>;
                        gpios = <&pio 7 7 GPIO_ACTIVE_LOW>; /* PH7 */
               };

       };

安装驱动, 并不能生成 event 设备:

# modprobe gpio_keys_polled
[  567.156253] gpio-keys-polled gpio_keys: button without keycode
[  567.162193] gpio-keys-polled: probe of gpio_keys failed with error -22

老铁们帮我瞅瞅。

离线

#14 2020-05-26 15:54:40

CAT.1
会员
注册时间: 2020-05-22
累计积分: 18

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

晕, 搞错了

                        linux = <KEY_DOWN>;


应该是
                        linux,code = <KEY_DOWN>;


现在可以了。 奇怪了, 居然还能通过编译。

离线

#15 2020-09-05 10:31:06

夜空中最亮的灯
会员
注册时间: 2020-05-14
累计积分: 11

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

晕哥,我的v3s和你的中断代码一模一样,cat/proc/interrupt也一样,就是我的是event1,但是信息和你的event2一样,但是死活进不了中断。试了下你的那个轮训key可以触发,io口都一样的。请问有什么解决办法可以尝试吗?会不会是内核原因?

离线

#16 2020-09-05 10:42:49

哇酷小二
管理员
注册时间: 2020-04-22
累计积分: 1,807

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

夜空中最亮的灯 说:

晕哥,我的v3s和你的中断代码一模一样,cat/proc/interrupt也一样,就是我的是event1,但是信息和你的event2一样,但是死活进不了中断。试了下你的那个轮训key可以触发,io口都一样的。请问有什么解决办法可以尝试吗?会不会是内核原因?



写一个简单的V3s@linux4.13-y 中断驱动
http://whycan.cn/t_1261.html
(出处:哇酷开发者社区【全志 V3S/F1C100s/X3】)



先用这个简单的驱动程序测试一下中断.

在线

#17 2020-09-08 16:52:49

1501257472
会员
注册时间: 2020-09-08
累计积分: 2

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

您好,V3s linux的系统如何裁剪出来的?V3s 不是自带的camdroid系统么,我用的我在lichee下build.sh pack编译出来的sun8iw8p1_linux_tiger-cdr_uart0.img镜像使用PhoenixUSBPRO无法烧写,但是编译成camdroid就可以烧写,介质时nand,能告诉如何编译linux可烧写的系统镜像么

离线

#18 2020-09-09 21:33:08

逸俊晨晖
会员
注册时间: 2018-08-29
累计积分: 82

Re: V3s/S3 Linux 测试 轮询/中断 GPIO 按钮驱动程序 / 旋转编码器 等

我在用f1c100s的测按键轮询 在对应的设备树文件添加内容

key_pins: key_pins@0 {
                                pins =  "PE4";

                                function = "gpio_in";
                                bias-pull-up;
                        };


gpio_keys {
               compatible = "gpio-keys-polled";
               pinctrl-names = "default";
               pinctrl-0 = <&key_pins>;
               #address-cells = <1>;
               #size-cells = <0>;
               poll-interval = <20>;

               button@0 {
                       label = "Left Joystick Right";
                       linux,code = <ABS_Z>;
                       linux,input-type = <EV_ABS>;
                       linux,input-value = <1>;
                       gpios = <&pio 4 4 GPIO_ACTIVE_LOW>; /* PE4 */
               };
       };

然后编译打包烧录 开机提示io被占用 没有相应的/dev/evenX

[    0.944905] suniv-f1c100s-pinctrl 1c20800.pinctrl: pin PE4 already requested by gpio_keys; cannot claim for 1c20800.pinctrl:132                                 
[    0.956462] suniv-f1c100s-pinctrl 1c20800.pinctrl: pin-132 (1c20800.pinctrl:132) status -22                                                                     
[    0.964843] gpio-keys-polled gpio_keys: failed to get gpio: -22                                                                                                 
[    0.970843] gpio-keys-polled: probe of gpio_keys failed with error -22                                                                                          
[    0.978318] input: 1c23400.lradc as /devices/platform/soc/1c23400.lradc/input/input1              

我查了设备树 发现根本没占用 换了几个IO都是这样
然后我把这句屏蔽掉了 pinctrl-0 = <&key_pins>;
发现就可以了 有相应的/dev/evenX 测试也有效 只是没有pinctrl-0 = <&key_pins>;里的上拉作用
不知道为什么会这样

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB