MCP23017 GPIO中断处理(RPi)

时间:2016-08-04 16:22:56

标签: linux linux-kernel linux-device-driver interrupt gpio

我已将MCP23017 I2C GPIO扩展器芯片连接到RPi。我使用此设备驱动程序和mcp23017.dtbo覆盖文件。

我正在尝试使用gpio引脚检查中断处理。我做了以下连接引脚中断(496是MCP23017的GPA0的基础):

echo "496" > /sys/class/gpio/export
echo "both" > /sys/class/gpio/gpio496/edge

然后触发:

cat gpio496/value

但是当我检查/proc/interrupts时,它总是显示0个中断:

  root@raspberrypi:/sys/class/gpio# cat /proc/interrupts
       CPU0       CPU1       CPU2       CPU3
16:   0          0          0          0   bcm2836-timer   0 Edge arch_timer
17:   41827      52799      8260     86838  bcm2836-timer   1 Edge arch_timer
23:   67          0          0          0  ARMCTRL-level   1 Edge      3f00b880.mailbox
24:  248          0          0          0  ARMCTRL-level   2 Edge      VCHIQ doorbell
46:  0            0          0          0  ARMCTRL-level  48 Edge      bcm2708_fb dma
48:  4125         0          0          0  ARMCTRL-level  50 Edge      DMA IRQ
50:  0            0          0          0  ARMCTRL-level  52 Edge      DMA IRQ
62:     415706          0          0          0  ARMCTRL-level  64 Edge      dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
79:          0          0          0          0  ARMCTRL-level  81 Edge      3f200000.gpio:bank0
80:          0          0          0          0  ARMCTRL-level  82 Edge      3f200000.gpio:bank1
83:        945          0          0          0  ARMCTRL-level  85 Edge      3f804000.i2c
86:        502          0          0          0  ARMCTRL-level  88 Edge      mmc0
87:       5032          0          0          0  ARMCTRL-level  89 Edge      uart-pl011
92:       6828          0          0          0  ARMCTRL-level  94 Edge      mmc1
170:         0          0          0          0  pinctrl-bcm2835   4 Edge      1-0020, 1-0021, 1-0022, 1-0023
220:         0          0          0          0  gpio-mcp23xxx   0 Edge      gpiolib

此外,加载叠加层时,会调用探测功能,并收到以下消息:

genirq: irq 170 uses trigger mode 8; requested 2

我无法弄清楚问题。我不确定覆盖文件中是否有错误。以下是.dts重叠文件:

// Definitions for MCP23017 Gpio Extender from Microchip Semiconductor

/dts-v1/;
/plugin/;

/ {
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

fragment@0 {
    target = <&i2c1>;
    __overlay__ {
        status = "okay";
    };
};

fragment@1 {
    target = <&gpio>;
    __overlay__ {
        mcp23017_pins: mcp23017_pins {
            brcm,pins = <4>;
            brcm,function = <0>;
        };
    };
};

fragment@2 {
    target = <&i2c1>;
    __overlay__ {
        #address-cells = <1>;
        #size-cells = <0>;

        mcp20:mcp23017@20 {
            compatible = "microchip,mcp23017";
            reg = <0x20>;
            gpio-controller;
            #gpio-cells = <2>;

            interrupt-parent = <&gpio>;
            interrupts = <4 2>;
            interrupt-controller;
            #interrupt-cells=<2>;
            microchip,irq-mirror;

            status = "okay";
        };
    };
};
 __overrides__ {
    gpiopin = <&mcp23017_pins>,"brcm,pins:0",
            <&mcp20>,"interrupts:0";
    addr = <&mcp20>,"reg:0";
};
};

0 个答案:

没有答案