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 ------------
离线
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 ------------
离线
参考: 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
离线
旋转编码器(中断)测试:
参考: 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 ------------
离线
牛叉,学习了。
离线
牛叉,学习了, 正需要这个demo到A33测试, 晚点过来报告。
离线
我的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
离线
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 也没有并入?
离线
https://lore.kernel.org/patchwork/patch/934382/
这里貌似有icenowy 关于 A33/V3s 外部IO中断的 patch
离线
我的设备树:
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
老铁们帮我瞅瞅。
离线
晕, 搞错了
linux = <KEY_DOWN>;
应该是
linux,code = <KEY_DOWN>;
现在可以了。 奇怪了, 居然还能通过编译。
离线
晕哥,我的v3s和你的中断代码一模一样,cat/proc/interrupt也一样,就是我的是event1,但是信息和你的event2一样,但是死活进不了中断。试了下你的那个轮训key可以触发,io口都一样的。请问有什么解决办法可以尝试吗?会不会是内核原因?
离线
晕哥,我的v3s和你的中断代码一模一样,cat/proc/interrupt也一样,就是我的是event1,但是信息和你的event2一样,但是死活进不了中断。试了下你的那个轮训key可以触发,io口都一样的。请问有什么解决办法可以尝试吗?会不会是内核原因?
写一个简单的V3s@linux4.13-y 中断驱动
http://whycan.cn/t_1261.html
(出处:哇酷开发者社区【全志 V3S/F1C100s/X3】)
先用这个简单的驱动程序测试一下中断.
离线
您好,V3s linux的系统如何裁剪出来的?V3s 不是自带的camdroid系统么,我用的我在lichee下build.sh pack编译出来的sun8iw8p1_linux_tiger-cdr_uart0.img镜像使用PhoenixUSBPRO无法烧写,但是编译成camdroid就可以烧写,介质时nand,能告诉如何编译linux可烧写的系统镜像么
离线
我在用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>;里的上拉作用
不知道为什么会这样
离线
根据楼主代码,在V3S上编码器测试成功!
离线
我也想知道为什么会这样?
我在用f1c100s的测按键轮询 在对应的设备树文件添加内容
我查了设备树 发现根本没占用 换了几个IO都是这样
然后我把这句屏蔽掉了 pinctrl-0 = <&key_pins>;
发现就可以了 有相应的/dev/evenX 测试也有效 只是没有pinctrl-0 = <&key_pins>;里的上拉作用
不知道为什么会这样
离线
晕哥 我想问一下如果v3s没有程序的话,正常连接芯片的usb端口,在设备管理器有显示是什么设备吗
离线
酷酷酷 说:晕哥 我想问一下如果v3s没有程序的话,正常连接芯片的usb端口,在设备管理器有显示是什么设备吗
会进入吗USB烧录模式,系统设备里面会出现改该设备,需要安装驱动配合烧录软件可以用。
晕哥 我这设备管理器提示
USB 设置地址请求失败。是不是说芯片坏掉了呀
离线
截图看下显示啥
重新发个帖吧
请求 USB 配置描述符失败。 还要一个是获取设备地址失败
离线
那应该是无了我明天重新焊一个试试
最近编辑记录 酷酷酷 (2021-04-13 19:58:35)
离线
但是插上有镜像的sd卡 直接就没有反应了
离线
挖一下(
F1C200S,亲测可用
pio {
............
key_pins: key-pins {
pins = "PD1","PD2","PD11","PD15";
function = "gpio_in";
drive = <0>;
pull = <1>;
bias-pull-up;
};
}
\ 下
gpio_keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&key_pins>;
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
autorepeat;
button@0 {
label = "Key back";
linux,code = <130>;
interrupt-parent = <&pio>;
interrupts = <3 1 IRQ_TYPE_LEVEL_LOW>;//PB0
};
button@1 {
label = "Key home";
linux,code = <131>;
interrupt-parent = <&pio>;
interrupts = <3 2 IRQ_TYPE_LEVEL_LOW>;//PB0
};
};
关于pinctrl-0 = <&key_pins>;管脚冲突,我提一点我的看法,单纯是全志的BUG(可能性很大)。另外pinctrl子系统和gpio-key子系统貌似是互相独立的,可能互相之间的支持不是很好?pinctrl中申请使用管脚,然后gpio-key又申请了一遍?用我上面的代码,中断+pinctrl就没报错。
离线
牛叉,我一直都是用轮询的,效率太低了,学习了
离线
F1C200S 可用?接那个管脚?
离线
PD1","PD2","PD11","PD15"是LED的 可以成功?
离线
这个太好了。不用外加芯片了
离线
大佬们,f1c100s的tina,加载编码器的驱动,内核直接奔溃了,这是怎么回事啊?
root@TinaLinux:/etc# insmod rotary_encoder.ko
[ 39.997294] of_get_named_gpio_flags exited with status 133
[ 40.003424] of_get_named_gpio_flags exited with status 134
[ 40.009732] drivers/input/misc/rotary_encoder.c 213 rotary_encoder_probe
[ 40.017248] drivers/input/misc/rotary_encoder.c 236 rotary_encoder_probe
[ 40.035130] drivers/input/misc/rotary_encoder.c 243 rotary_encoder_probe
[ 40.045594] drivers/input/misc/rotary_encoder.c 249 rotary_encoder_probe
[ 40.053235] drivers/input/misc/rotary_encoder.c 252 rotary_encoder_probe
[ 40.060782] drivers/input/misc/rotary_encoder.c 260 rotary_encoder_probe
[ 40.068404] drivers/input/misc/rotary_encoder.c 268 rotary_encoder_probe
[ 40.076026] drivers/input/misc/rotary_encoder.c 276 rotary_encoder_probe
[ 40.086303] input: rotary.4 as /devices/soc/rotary.4/input/input2
[ 40.104447] evbug: Connected device: input2 (rotary.4 at unknown)
[ 40.111381] drivers/input/misc/rotary_encoder.c 282 rotary_encoder_probe
[ 40.118905] drivers/input/misc/rotary_encoder.c 284 rotary_encoder_probe
[ 40.140230] Unable to handle kernel NULL pointer dereference at virtual address 00000005
[ 40.149363] pgd = c33f0000
[ 40.152419] [00000005] *pgd=833e7831, *pte=00000000, *ppte=00000000
[ 40.159468] Internal error: Oops: 1 [#1] ARM
[ 40.164201] Modules linked in: rotary_encoder(+) snd_pcm_oss snd_mixer_oss snd_pcm snd_page_alloc snd_timer snd_seq_device snd soundcore
[ 40.177864] CPU: 0 PID: 149 Comm: insmod Not tainted 3.10.65 #298
[ 40.184629] task: c339cb00 ti: c3350000 task.ti: c3350000
[ 40.190649] PC is at driver_bound+0x10/0x88
[ 40.195302] LR is at driver_probe_device+0x154/0x1f8
[ 40.200813] pc : [<c01dcb68>] lr : [<c01dce10>] psr: 60000013
[ 40.200813] sp : c3351d48 ip : c3351d60 fp : c3351d5c
[ 40.213540] r10: 00000013 r9 : 00000000 r8 : 00000002
[ 40.219333] r7 : bf04ca08 r6 : 00000000 r5 : 00000006 r4 : 00000001
[ 40.226572] r3 : 60000013 r2 : c04cd65c r1 : 00000000 r0 : 00000001
[ 40.233810] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[ 40.241722] Control: 0005317f Table: 833f0000 DAC: 00000015
[ 40.248089]
[ 40.248089] PC: 0xc01dcae8:
[ 40.252823] cae8 e595000c ebf94e98 e1a00004 eafffff6 c0452a12 0002000a c0452658 c05c4fe4
[ 40.261936] cb08 c0452a1a e1a0c00d e92dd830 e24cb004 e1a04000 e59f0030 eb06cef7 e5943004
[ 40.271047] cb28 e5931040 e2832040 e1520001 15930044 15810004 15801000 15832040 15832044
[ 40.280155] cb48 e59f0004 eb06cf05 e89da830 c05984b0 e1a0c00d e92dd830 e24cb004 e1a04000
[ 40.289266] cb68 e5900004 e2800020 eb06b78f e3500000 0a000004 e5942008 e59f1050 e59f0050
[ 40.298374] cb88 eb06c58f e89da830 e5943044 e5940004 e5931038 e2800020 e2811024 eb06b841
[ 40.307484] cba8 e1a00004 ebffffd6 ebffff8a e5943040 e3530000 089da830 e593003c e1a02004
[ 40.316594] cbc8 e3a01004 e280006c ebf97f16 e89da830 c03ad5a8 c0452a2c e1a0c00d e92dd830
[ 40.325709]
[ 40.325709] LR: 0xc01dcd90:
[ 40.330442] cd90 e59f1110 e1a00004 ebfff3f8 e1a00006 eb06ce57 e5943004 e59f00f4 e5931040
[ 40.339551] cdb0 e2832040 e1520001 05961020 05862020 0286601c 05836040 05831044 05812000
[ 40.348659] cdd0 eb06ce64 e5953008 e1580003 1a00001e e3a04000 ea00000a e5943040 e5933020
[ 40.357770] cdf0 e3530000 0a000014 e1a00004 e12fff33 e2506000 1affffd4 e1a00004 ebffff51
[ 40.366877] ce10 e3a04001 e10f2000 e3823080 e121f003 e5953000 e2433001 e5853000 e121f002
[ 40.375988] ce30 e3a03000 e3a02001 e3a01003 e59f0068 ebf9871d e1a00004 e89dabf0 e597301c
[ 40.385098] ce50 e3530000 1affffe7 eaffffea ebfffedf eaffffde e3760006 13760013 0affffdb
[ 40.394207] ce70 e594202c e5971000 e3520000 05942008 e1a03006 e59f0024 eb06c4cf eaffffd3
[ 40.403321]
[ 40.403321] SP: 0xc3351cc8:
[ 40.408053] 1cc8 c3066610 bf04c6a4 c3351cfc c3351ce0 c038e208 c001d4f0 c01dcb68 60000013
[ 40.417161] 1ce8 ffffffff c3351d34 c3351d5c c3351d00 c000f4b8 c000a1a0 00000001 00000000
[ 40.426269] 1d08 c04cd65c 60000013 00000001 00000006 00000000 bf04ca08 00000002 00000000
[ 40.435376] 1d28 00000013 c3351d5c c3351d60 c3351d48 c01dce10 c01dcb68 60000013 ffffffff
[ 40.444484] 1d48 00000001 00000006 c3351d84 c3351d60 c01dce10 c01dcb68 c3066610 c3066644
[ 40.453593] 1d68 bf04ca08 00000000 00000000 00000000 c3351da4 c3351d88 c01dcf54 c01dcccc
[ 40.462703] 1d88 00000000 bf04ca08 c01dcf00 00000000 c3351dcc c3351da8 c01db450 c01dcf10
[ 40.471811] 1da8 c3023f4c c305cf90 c33dd3f4 bf04ca08 c33dd3c0 c05985f0 c3351ddc c3351dd0
[ 40.480923]
[ 40.480923] IP: 0xc3351ce0:
[ 40.485655] 1ce0 c01dcb68 60000013 ffffffff c3351d34 c3351d5c c3351d00 c000f4b8 c000a1a0
[ 40.494763] 1d00 00000001 00000000 c04cd65c 60000013 00000001 00000006 00000000 bf04ca08
[ 40.503869] 1d20 00000002 00000000 00000013 c3351d5c c3351d60 c3351d48 c01dce10 c01dcb68
[ 40.512979] 1d40 60000013 ffffffff 00000001 00000006 c3351d84 c3351d60 c01dce10 c01dcb68
[ 40.522088] 1d60 c3066610 c3066644 bf04ca08 00000000 00000000 00000000 c3351da4 c3351d88
[ 40.531195] 1d80 c01dcf54 c01dcccc 00000000 bf04ca08 c01dcf00 00000000 c3351dcc c3351da8
[ 40.540304] 1da0 c01db450 c01dcf10 c3023f4c c305cf90 c33dd3f4 bf04ca08 c33dd3c0 c05985f0
[ 40.549411] 1dc0 c3351ddc c3351dd0 c01dc8b0 c01db3d8 c3351e0c c3351de0 c01dc4e0 c01dc8a0
[ 40.558523]
[ 40.558523] FP: 0xc3351cdc:
[ 40.563256] 1cdc c001d4f0 c01dcb68 60000013 ffffffff c3351d34 c3351d5c c3351d00 c000f4b8
[ 40.572366] 1cfc c000a1a0 00000001 00000000 c04cd65c 60000013 00000001 00000006 00000000
[ 40.581471] 1d1c bf04ca08 00000002 00000000 00000013 c3351d5c c3351d60 c3351d48 c01dce10
[ 40.590579] 1d3c c01dcb68 60000013 ffffffff 00000001 00000006 c3351d84 c3351d60 c01dce10
[ 40.599684] 1d5c c01dcb68 c3066610 c3066644 bf04ca08 00000000 00000000 00000000 c3351da4
[ 40.608793] 1d7c c3351d88 c01dcf54 c01dcccc 00000000 bf04ca08 c01dcf00 00000000 c3351dcc
[ 40.617902] 1d9c c3351da8 c01db450 c01dcf10 c3023f4c c305cf90 c33dd3f4 bf04ca08 c33dd3c0
[ 40.627013] 1dbc c05985f0 c3351ddc c3351dd0 c01dc8b0 c01db3d8 c3351e0c c3351de0 c01dc4e0
[ 40.636125]
[ 40.636125] R2: 0xc04cd5dc:
[ 40.640859] d5dc 00000001 00000002 00000003 00000004 00000005 00000006 00000007 00000008
[ 40.649964] d5fc 00000009 0000000a 0000000b 0000000c 0000000d 0000000e 0000000f 00000010
[ 40.659070] d61c 00000011 00000012 00000013 00000014 00000015 00000016 00000017 00000018
[ 40.668173] d63c 00000019 0000001a 0000001b 0000001c 0000001d 0000001e 0000001f c05b09f8
[ 40.677275] d65c c04cd65c c04cd65c 00000001 c04cd668 c04cd668 00004000 00000001 c04cd678
[ 40.686386] d67c c04cd678 000001f4 0000000a 00000000 00000000 00000000 00000000 0000000f
[ 40.695493] d69c 00000004 00000001 00000007 00000001 ffffffff ffffffff 00000000 00000000
[ 40.704599] d6bc 00000004 00000000 c001e110 00000000 00000000 00000000 00000000 00000000
[ 40.713716] Process insmod (pid: 149, stack limit = 0xc33501b8)
[ 40.720280] Stack: (0xc3351d48 to 0xc3352000)
[ 40.762742] 1d40: 00000001 00000006 c3351d84 c3351d60 c01dce10 c01dcb68
[ 40.772842] 1d60: c3066610 c3066644 bf04ca08 00000000 00000000 00000000 c3351da4 c3351d88
[ 40.782912] 1d80: c01dcf54 c01dcccc 00000000 bf04ca08 c01dcf00 00000000 c3351dcc c3351da8
[ 40.793003] 1da0: c01db450 c01dcf10 c3023f4c c305cf90 c33dd3f4 bf04ca08 c33dd3c0 c05985f0
[ 40.803008] 1dc0: c3351ddc c3351dd0 c01dc8b0 c01db3d8 c3351e0c c3351de0 c01dc4e0 c01dc8a0
[ 40.813062] 1de0: bf04c81f bf04ca90 c3351e0c bf04ca08 bf04e000 c05af580 bf04ca90 00000000
[ 40.823150] 1e00: c3351e34 c3351e10 c01dd504 c01dc3a8 c3350000 bf04e000 c05af580 bf04ca90
[ 40.833208] 1e20: 00000000 00000000 c3351e44 c3351e38 c01de58c c01dd46c c3351e54 c3351e48
[ 40.843265] 1e40: bf04e014 c01de550 c3351e94 c3351e58 c000a4d4 bf04e010 c3351e84 bf04ca48
[ 40.853349] 1e60: c3351f48 c335c600 bf04ca90 bf04ca48 c3351f48 c335c600 bf04ca90 c335c754
[ 40.863396] 1e80: 00000000 00000013 c3351f44 c3351e98 c0054e5c c000a3c8 bf04ca54 00007fff
[ 40.873484] 1ea0: c0051fc8 00000000 c3351ecc b6ee9ab0 bf04cb88 c48eb96c c00529c0 00000028
[ 40.883577] 1ec0: c3350000 bf04ca54 c008ada8 c008a4e0 ff000000 000000d2 c0055498 00000000
[ 40.893629] 1ee0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 40.903725] 1f00: 00000000 00000000 00000000 00000000 00000000 00000000 ffffffff 01953010
[ 40.913705] 1f20: b6ee9ab0 000019bc 00000080 c000fa28 c3350000 00000000 c3351fa4 c3351f48
[ 40.923762] 1f40: c0055518 c0053a1c c48ea000 000019bc c48eb6c4 c48eb624 c48eb0d4 00000b9c
[ 40.933853] 1f60: 00000c8c 00000000 00000000 00000000 00000011 00000012 0000000c 00000000
[ 40.943953] 1f80: 00000008 00000000 00000000 00000000 00000000 00000003 00000000 c3351fa8
[ 40.953997] 1fa0: c000f8a0 c0055458 00000000 00000000 01953010 000019bc b6ee9ab0 00005d30
[ 40.964092] 1fc0: 00000000 00000000 00000003 00000080 000019bc 00000000 00000020 00000000
[ 40.974155] 1fe0: be9c1c3c be9c1c20 00011ae8 b6f3c4cc 60000010 01953010 00000000 00000000
[ 40.983446] Backtrace:
[ 40.986303] [<c01dcb58>] (driver_bound+0x0/0x88) from [<c01dce10>] (driver_probe_device+0x154/0x1f8)
[ 40.996512] r5:00000006 r4:00000001
[ 41.000532] [<c01dccbc>] (driver_probe_device+0x0/0x1f8) from [<c01dcf54>] (__driver_attach+0x54/0x94)
[ 41.010915] r9:00000000 r8:00000000 r7:00000000 r6:bf04ca08 r5:c3066644
r4:c3066610
[ 41.019712] [<c01dcf00>] (__driver_attach+0x0/0x94) from [<c01db450>] (bus_for_each_dev+0x88/0x98)
[ 41.029702] r7:00000000 r6:c01dcf00 r5:bf04ca08 r4:00000000
[ 41.036073] [<c01db3c8>] (bus_for_each_dev+0x0/0x98) from [<c01dc8b0>] (driver_attach+0x20/0x28)
[ 41.045870] r6:c05985f0 r5:c33dd3c0 r4:bf04ca08
[ 41.051041] [<c01dc890>] (driver_attach+0x0/0x28) from [<c01dc4e0>] (bus_add_driver+0x148/0x220)
[ 41.060873] [<c01dc398>] (bus_add_driver+0x0/0x220) from [<c01dd504>] (driver_register+0xa8/0x124)
[ 41.070856] r8:00000000 r7:bf04ca90 r6:c05af580 r5:bf04e000 r4:bf04ca08
[ 41.078424] [<c01dd45c>] (driver_register+0x0/0x124) from [<c01de58c>] (platform_driver_register+0x4c/0x60)
[ 41.089291] r9:00000000 r8:00000000 r7:bf04ca90 r6:c05af580 r5:bf04e000
r4:c3350000
[ 41.098106] [<c01de540>] (platform_driver_register+0x0/0x60) from [<bf04e014>] (init_module+0x14/0x1c [rotary_encoder])
[ 41.110168] [<bf04e000>] (init_module+0x0/0x1c [rotary_encoder]) from [<c000a4d4>] (do_one_initcall+0x11c/0x148)
[ 41.121551] [<c000a3b8>] (do_one_initcall+0x0/0x148) from [<c0054e5c>] (load_module+0x1450/0x1a3c)
[ 41.131557] [<c0053a0c>] (load_module+0x0/0x1a3c) from [<c0055518>] (SyS_init_module+0xd0/0xd4)
[ 41.141299] [<c0055448>] (SyS_init_module+0x0/0xd4) from [<c000f8a0>] (ret_fast_syscall+0x0/0x2c)
[ 41.151189] r6:00000003 r5:00000000 r4:00000000
[ 41.157540] Code: e1a0c00d e92dd830 e24cb004 e1a04000 (e5900004)
[ 41.164335] ---[ end trace 583c5997cde2296d ]---
这是我设备树的配置:
rotary@0 {
compatible = "rotary-encoder";
gpios = <&pio PE 5 0 6 1 0>, <&pio PE 6 0 6 1 0>;
linux,axis = <0>; /* REL_X */
rotary-encoder,relative-axis;
status = "okay";
};
离线
@jkl
我记得PE没有中断
我看了芯片手册,PE有外部中断
我怀疑可能是这个帖子的原因:
https://bbs.aw-ol.com/topic/1253/linux4 … 3229721575
离线
问题已解决
离线
@晕哥
我用的是V3S linux5.2
代码复制过去的,event出不来,原有的matrix key是evet0,lradc是event1,触摸屏是event2,串口2也注释掉了,开机没有打印PB2中断对应的inputx
离线
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
};
};
离线
搞定了,引脚定义没放在pinctrl下面
离线