element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
Software Application Development Configuring gpio-keys
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Avnet Boards Forums to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 7 replies
  • Subscribers 330 subscribers
  • Views 2636 views
  • Users 0 members are here
Related

Configuring gpio-keys

oscargomezf
oscargomezf over 8 years ago

Hi everyone,

 

I'm trying to configure the SW1, SW2, SW3, SW4 and SW5 of my PicoZed FMC Carrier FMC V2. But it doesn't work and right know I'm stucked. This is part of my device tree dts file where I configure this pins:

...
  amba_pl {
  #address-cells = <0x1>;
  #size-cells = <0x1>;
  compatible = "simple-bus";
  ranges;
   
  ...
   
  ps7_gpio_buttons: gpio@41210000 {
  #gpio-cells = <0x2>;
  compatible = "xlnx,xps-gpio-1.00.a";
  gpio-controller;
  reg = <0x41210000 0x10000>;
  xlnx,all-inputs = <0x1>;
  xlnx,all-inputs-2 = <0x0>;
  xlnx,all-outputs = <0x0>;
  xlnx,all-outputs-2 = <0x0>;
  xlnx,dout-default = <0x0>;
  xlnx,dout-default-2 = <0x0>;
  xlnx,gpio-width = <0x5>;
  xlnx,gpio2-width = <0x20>;
  xlnx,interrupt-present = <0x0>;
  xlnx,is-dual = <0x0>;
  xlnx,tri-default = <0xffffffff>;
  xlnx,tri-default-2 = <0xffffffff>;
  };
  };
...
 
keypad {
compatible = "gpio-keys";
#address-cells = <1>;
#size-cells = <0>;
sw1 {
label = "sw1";
gpios = <&ps7_gpio_buttons 0 0>;
linux,code = <100>; /* up */
};
sw2 {
label = "sw2";
gpios = <&ps7_gpio_buttons 1 0>;
linux,code = <101>; /* down */
 
};
sw3 {
label = "sw3";
gpios = <&ps7_gpio_buttons 2 0>;
linux,code = <102>; /* right */
 
};
sw4 {
label = "sw4";
pios = <&ps7_gpio_buttons 3 0>;
linux,code = <103>; /* left */
};
sw5 {
label = "sw5";
gpios = <&ps7_gpio_buttons 4 0>;
linux,code = <104>; /* center */

...

I can see the associated gpio  in /sys/class/gpio897

 

But I've got this error and it doesn't work:

 

gpio-keys keypad: Unable to get irq number for GPIO 897, error -6

 

 

Could anyone help me?

 

Best regards.

  • Sign in to reply
  • Cancel
  • oscargomezf
    0 oscargomezf over 8 years ago

    Hi everyone,

     

    I've tried to do the same but using a GPIO from PS, the PS_MIO51 due to the fact the picoZed FMC Carrier V2 has a SW called SW6, and it's very easy to try it. This is my device tree:

    ...

    ps7_gpios: gpio@e000a000 {
        compatible = "xlnx,zynq-gpio-1.0";
        #gpio-cells = <0x2>;
        #interrupt-cells = <0x2>;
        clocks = <0x1 0x2a>;
        gpio-controller;
        interrupt-controller;
        interrupt-parent = <0x3>;
        interrupts = <0x0 0x14 0x4>;
        reg = <0xe000a000 0x1000>;
        emio-gpio-width = <0x40>;
        gpio-mask-high = <0x0>;
        gpio-mask-low = <0x5600>;
        linux,phandle = <0x5>;
        phandle = <0x5>;
    };

    ...

    keypad {
        sw6 {
            label = "sw6";
            gpios = <&ps7_gpios 51 0>;
            linux,code = <150>; /* SW6: PS_PB */
        };
    };

    ...

    And it works perfectly, I can see the file event0:

    root@picoted:/dev/input# ls -l
    crw-rw----    1 root     root       13,  64 Jan  1 00:00 event0
    crw-rw----    1 root     root       13,  63 Jan  1 00:00 mice
     

    And I can see thw SW6 interrupt in the file /proc/interrupts:

    root@picoted:/dev/input# cat /proc/interrupts
               CPU0       CPU1       
     16:          1          0       GIC  27 Edge      gt
     17:          0          0       GIC  43 Level     ttc_clockevent
     18:       2436       4051       GIC  29 Edge      twd
     21:         43          0       GIC  39 Level     f8007100.adc
     74:         53          0  zynq-gpio  51 Edge      sw6
    141:          0          0       GIC  57 Level     cdns-i2c
    142:          0          0       GIC  80 Level     cdns-i2c
    144:          0          0       GIC  35 Level     f800c000.ocmc
    145:        761          0       GIC  82 Level     xuartps
    146:          0          0       GIC  51 Level     e000d000.spi
    147:        554          0       GIC  54 Level     eth0
    148:         75          0       GIC  56 Level     mmc0
    149:          0          0       GIC  45 Level     f8003000.dmac
    150:          0          0       GIC  46 Level     f8003000.dmac
    151:          0          0       GIC  47 Level     f8003000.dmac
    152:          0          0       GIC  48 Level     f8003000.dmac
    153:          0          0       GIC  49 Level     f8003000.dmac
    154:          0          0       GIC  72 Level     f8003000.dmac
    155:          0          0       GIC  73 Level     f8003000.dmac
    156:          0          0       GIC  74 Level     f8003000.dmac
    157:          0          0       GIC  75 Level     f8003000.dmac
    158:          0          0       GIC  40 Level     f8007000.devcfg
    165:          0          0       GIC  41 Edge      f8005000.watchdog
    IPI1:          0          0  Timer broadcast interrupts
    IPI2:        843       1413  Rescheduling interrupts
    IPI3:          0          0  Function call interrupts
    IPI4:         24         24  Single function call interrupts
    IPI5:          0          0  CPU stop interrupts
    IPI6:          0          0  IRQ work interrupts
    IPI7:          0          0  completion interrupts
    Err:          0
     
    So I think it's something related to the type of GPIO used, PS (Processing System) vs PL (Programmble Logic).
     
    Any suggestion?
     
    Best regards.
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 8 years ago

    Oscar, 

      Depending on the version of Linux you are using, the answers are different, so please supply  which distribution (Pulsar 7, Pulsar 8, PetaLinux, other) and what version of the kernel you are using (uname -a) when asking a question.

    Now having said that, there are working examples using user board components for both Pulsar and PetaLinux posted.  For PetaLinux, this is part of the default BSPs supplied for each release and posted on this site.  If you refer to some of the posted tutorials for Linux, there is an example that shows how to access the components from command line.  

    For Pulsar, there is a software repository at:

    www.github.com/Avnet/Software

    If you clone this repository and look at the Bluemix or Quickstart source code, you will see gpio code that accesses the LED and pushbutton. Using the switch block follows the same procedure in source and device tree.

    Ron

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • oscargomezf
    0 oscargomezf over 8 years ago in reply to Former Member

    Hi hockeyman1972,

     

    I'm using petalinux v2016.2 and the kernel version is:

    root@picoted:~# uname -a

    Linux picoted 4.4.0-xilinx #34 SMP PREEMPT Thu Oct 13 10:33:12 CEST 2016 armv7l GNU/Linux 

     

    I've managed to run the gpio from the PS like a gpio-keys, and now I can see the /dev/input/event0 file and I can see this in the file /proc/interrupts:

     

    root@picoted:~# cat /proc/interrupts 
               CPU0       CPU1       
     16:          1          0       GIC  27 Edge      gt
     17:          0          0       GIC  43 Level     ttc_clockevent
     18:       1605        593       GIC  29 Edge      twd
     21:         43          0       GIC  39 Level     f8007100.adc
     74:          0          0  zynq-gpio  51 Edge      sw6
    141:          0          0       GIC  57 Level     cdns-i2c
    142:          0          0       GIC  80 Level     cdns-i2c
    ...
     
    I 've used this .dts file:
     
    ...
      keypad {
      compatible = "gpio-keys";
      #address-cells = <1>;
      #size-cells = <0>;
          sw6 {
              label = "sw6";
              gpios = <&ps7_gpios 51 0>;
              linux,code = <0x105>; /* SW6: PS_PB */
          };
      };
    ...
     
    But I wasn't be able to manage the pins from PL usign the same way. Any suggestion?
     
     
    Best regards.
     
     
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • jafoste4
    0 jafoste4 over 8 years ago

    Hello Oscar,

    These posts may be of help to you.

    http://zedboard.org/content/which-tutorial-linux-pl-access

    http://zedboard.org/content/gpio-pl-mapping

    https://forums.xilinx.com/t5/Zynq-All-Programmable-SoC/How-to-use-part-of-GPIO-in-PL/td-p/531575

    --Josh

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • oscargomezf
    0 oscargomezf over 8 years ago
    Hi Josh,
     
     
    I've realised that I had improperly connected my PL GPIOS because I didn't activate the interrupt checkbox in the IP AXI_GPIO and I haven't connected this signal to the PS7.
     
    I've followed the next instructions: http://www.isusantha.com/axi-gpio-interrupt-handling
     
    So now I think my block design is ok.
     
    I've activated the CONFIG_DEBUG_GPIO option in the Linux kernel to see what really happens.
    And these are the messages I've got:
     
    gpiochip_find_base: found new base at 902
    gpiochip_add: registered GPIOs 902 to 905 on device: /amba_pl/gpio@41200000
    GPIO IRQ not connected
    XGpio: /amba_pl/gpio@41200000: registered, base is 902
    gpiochip_find_base: found new base at 897
    gpiochip_add: registered GPIOs 897 to 901 on device: /amba_pl/gpio@41210000
    IRQ Base: 167, Pin 0 = IRQ 167
    IRQ Base: 167, Pin 1 = IRQ 168
    IRQ Base: 167, Pin 2 = IRQ 169
    IRQ Base: 167, Pin 3 = IRQ 170
    IRQ Base: 167, Pin 4 = IRQ 171
    XGpio: /amba_pl/gpio@41210000: registered, base is 897
     
     
    It seems to be the configuration is ok, this is my dts file:
     
    ...
    ps7_gpios: gpio@e000a000 {
    compatible = "xlnx,zynq-gpio-1.0";
    #gpio-cells = <0x2>;
    #interrupt-cells = <0x2>;
    clocks = <0x1 0x2a>;
    gpio-controller;
    interrupt-controller;
    interrupt-parent = <0x3>;
    interrupts = <0x0 0x14 0x4>;
    reg = <0xe000a000 0x1000>;
    emio-gpio-width = <0x40>;
    gpio-mask-high = <0x0>;
    gpio-mask-low = <0x5600>;
    linux,phandle = <0x5>;
    phandle = <0x5>;
    };
    ...
    amba_pl {
    #address-cells = <0x1>;
    #size-cells = <0x1>;
    compatible = "simple-bus";
    ranges;
     
    pl7_gpio_leds: gpio@41200000 {
    #gpio-cells = <0x2>;
    compatible = "xlnx,xps-gpio-1.00.a";
    gpio-controller;
    reg = <0x41200000 0x10000>;
    xlnx,all-inputs = <0x0>;
    xlnx,all-inputs-2 = <0x0>;
    xlnx,all-outputs = <0x1>;
    xlnx,all-outputs-2 = <0x0>;
    xlnx,dout-default = <0x0>;
    xlnx,dout-default-2 = <0x0>;
    xlnx,gpio-width = <0x4>;
    xlnx,gpio2-width = <0x20>;
    xlnx,interrupt-present = <0x0>;
    xlnx,is-dual = <0x0>;
    xlnx,tri-default = <0xffffffff>;
    xlnx,tri-default-2 = <0xffffffff>;
    };
     
    pl7_gpio_buttons: gpio@41210000 {
    #gpio-cells = <0x2>;
    #interrupt-cells = <0x2>;
    compatible = "xlnx,xps-gpio-1.00.a";
    gpio-controller;
    interrupt-controller;
    interrupt-parent = <0x3>;
    interrupts = <0x0 0x1d 0x4>;
    reg = <0x41210000 0x10000>;
    xlnx,all-inputs = <0x1>;
    xlnx,all-inputs-2 = <0x0>;
    xlnx,all-outputs = <0x0>;
    xlnx,all-outputs-2 = <0x0>;
    xlnx,dout-default = <0x0>;
    xlnx,dout-default-2 = <0x0>;
    xlnx,gpio-width = <0x5>;
    xlnx,gpio2-width = <0x20>;
    xlnx,interrupt-present = <0x1>;
    xlnx,is-dual = <0x0>;
    xlnx,tri-default = <0xffffffff>;
    xlnx,tri-default-2 = <0xffffffff>;
    };
    };
     
    ...
    leds {
    compatible = "gpio-leds";
    led-d1 {
    label = "led-d1";
    gpios = <&pl7_gpio_leds 0 0>;
    default-state = "on";
    linux,default-trigger = "heartbeat";
    };
    led-d2 {
    label = "led-d2";
    gpios = <&pl7_gpio_leds 1 0>;
    default-state = "off";
    linux,default-trigger = "none";
    };
    led-d3 {
    label = "led-d3";
    gpios = <&pl7_gpio_leds 2 0>;
    default-state = "off";
    linux,default-trigger = "none";
    };
    led-d4 {
    label = "led-d4";
    gpios = <&pl7_gpio_leds 3 0>;
    default-state = "off";
    linux,default-trigger = "none";
    };
     
    ...
     
    keypad {
    compatible = "gpio-keys";
    #address-cells = <1>;
    #size-cells = <0>;
    autorepeat;
     
    sw1 {
    label = "sw1";
    gpios = <&pl7_gpio_buttons 0 0>;
    linux,code = <0x100>; /* up */
    gpio-key,wakeup;
    autorepeat;
    };
    sw2 {
    label = "sw2";
    gpios = <&pl7_gpio_buttons 1 0>;
    linux,code = <0x101>; /* down */
    gpio-key,wakeup;
    autorepeat;
    };
    sw3 {
    label = "sw3";
    gpios = <&pl7_gpio_buttons 2 0>;
    linux,code = <0x102>; /* right */
    gpio-key,wakeup;
    autorepeat;
    };
    sw4 {
    label = "sw4";
    gpios = <&pl7_gpio_buttons 3 0>;
    linux,code = <0x103>; /* left */
    gpio-key,wakeup;
    autorepeat;
    };
    sw5 {
    label = "sw5";
    gpios = <&pl7_gpio_buttons 4 0>;
    linux,code = <0x104>; /* center */
    gpio-key,wakeup;
    autorepeat;
    };
    sw6 {
    label = "sw6";
    gpios = <&ps7_gpios 51 0>;
    linux,code = <0x105>; /* SW6: PS_PB */
    gpio-key,wakeup;
    autorepeat;
    };
    };
    ...
     
    And I've got these messages too:
     
    ...
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw1[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw2[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw3[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw4[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw5[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw6[0]' - status (0)
    gpio-897 (sw1): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 0 irq, irq_enable_mask 0x0
    gpio-898 (sw2): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 1 irq, irq_enable_mask 0x1
    gpio-899 (sw3): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 2 irq, irq_enable_mask 0x3
    gpio-900 (sw4): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 3 irq, irq_enable_mask 0x7
    gpio-901 (sw5): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 4 irq, irq_enable_mask 0xf
    gpio-957 (sw6): gpiod_set_debounce: missing set() or set_debounce() operations
    input: keypad as /devices/soc0/keypad/input/input0
    ...
     
    And I can see the buttons in the file /proc/interrupts:
     
    # cat /proc/interrupts 
               CPU0       CPU1       
     16:          0          0       GIC  27 Edge      gt
     17:          0          0       GIC  43 Level     ttc_clockevent
     18:      22271       1048       GIC  29 Edge      twd
     21:         43          0       GIC  39 Level     f8007100.adc
     74:          1          0  zynq-gpio  51 Edge      sw6
    ...
    167:          1          0     xgpio   0 Edge      sw1
    168:          1          0     xgpio   1 Edge      sw2
    169:          1          0     xgpio   2 Edge      sw3
    170:          1          0     xgpio   3 Edge      sw4
    171:          1          0     xgpio   4 Edge      sw5
     
    So now, everything is working fine.
     
    Thank you very much for your help.
     
    Best regards.
     
     
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • oscargomezf
    0 oscargomezf over 8 years ago
    Hi Josh,
     
     
    I've realised that I had improperly connected my PL GPIOS because I didn't activate the interrupt checkbox in the IP AXI_GPIO and I haven't connected this signal to the PS7.
     
    I've followed the next instructions: http://www.isusantha.com/axi-gpio-interrupt-handling
     
    So now I think my block design is ok.
     
    I've activated the CONFIG_DEBUG_GPIO option in the Linux kernel to see what really happens.
    And these are the messages I've got:
     
    gpiochip_find_base: found new base at 902
    gpiochip_add: registered GPIOs 902 to 905 on device: /amba_pl/gpio@41200000
    GPIO IRQ not connected
    XGpio: /amba_pl/gpio@41200000: registered, base is 902
    gpiochip_find_base: found new base at 897
    gpiochip_add: registered GPIOs 897 to 901 on device: /amba_pl/gpio@41210000
    IRQ Base: 167, Pin 0 = IRQ 167
    IRQ Base: 167, Pin 1 = IRQ 168
    IRQ Base: 167, Pin 2 = IRQ 169
    IRQ Base: 167, Pin 3 = IRQ 170
    IRQ Base: 167, Pin 4 = IRQ 171
    XGpio: /amba_pl/gpio@41210000: registered, base is 897
     
     
    It seems to be the configuration is ok, this is my dts file:
     
    ...
    ps7_gpios: gpio@e000a000 {
    compatible = "xlnx,zynq-gpio-1.0";
    #gpio-cells = <0x2>;
    #interrupt-cells = <0x2>;
    clocks = <0x1 0x2a>;
    gpio-controller;
    interrupt-controller;
    interrupt-parent = <0x3>;
    interrupts = <0x0 0x14 0x4>;
    reg = <0xe000a000 0x1000>;
    emio-gpio-width = <0x40>;
    gpio-mask-high = <0x0>;
    gpio-mask-low = <0x5600>;
    linux,phandle = <0x5>;
    phandle = <0x5>;
    };
    ...
    amba_pl {
    #address-cells = <0x1>;
    #size-cells = <0x1>;
    compatible = "simple-bus";
    ranges;
     
    pl7_gpio_leds: gpio@41200000 {
    #gpio-cells = <0x2>;
    compatible = "xlnx,xps-gpio-1.00.a";
    gpio-controller;
    reg = <0x41200000 0x10000>;
    xlnx,all-inputs = <0x0>;
    xlnx,all-inputs-2 = <0x0>;
    xlnx,all-outputs = <0x1>;
    xlnx,all-outputs-2 = <0x0>;
    xlnx,dout-default = <0x0>;
    xlnx,dout-default-2 = <0x0>;
    xlnx,gpio-width = <0x4>;
    xlnx,gpio2-width = <0x20>;
    xlnx,interrupt-present = <0x0>;
    xlnx,is-dual = <0x0>;
    xlnx,tri-default = <0xffffffff>;
    xlnx,tri-default-2 = <0xffffffff>;
    };
     
    pl7_gpio_buttons: gpio@41210000 {
    #gpio-cells = <0x2>;
    #interrupt-cells = <0x2>;
    compatible = "xlnx,xps-gpio-1.00.a";
    gpio-controller;
    interrupt-controller;
    interrupt-parent = <0x3>;
    interrupts = <0x0 0x1d 0x4>;
    reg = <0x41210000 0x10000>;
    xlnx,all-inputs = <0x1>;
    xlnx,all-inputs-2 = <0x0>;
    xlnx,all-outputs = <0x0>;
    xlnx,all-outputs-2 = <0x0>;
    xlnx,dout-default = <0x0>;
    xlnx,dout-default-2 = <0x0>;
    xlnx,gpio-width = <0x5>;
    xlnx,gpio2-width = <0x20>;
    xlnx,interrupt-present = <0x1>;
    xlnx,is-dual = <0x0>;
    xlnx,tri-default = <0xffffffff>;
    xlnx,tri-default-2 = <0xffffffff>;
    };
    };
     
    ...
    leds {
    compatible = "gpio-leds";
    led-d1 {
    label = "led-d1";
    gpios = <&pl7_gpio_leds 0 0>;
    default-state = "on";
    linux,default-trigger = "heartbeat";
    };
    led-d2 {
    label = "led-d2";
    gpios = <&pl7_gpio_leds 1 0>;
    default-state = "off";
    linux,default-trigger = "none";
    };
    led-d3 {
    label = "led-d3";
    gpios = <&pl7_gpio_leds 2 0>;
    default-state = "off";
    linux,default-trigger = "none";
    };
    led-d4 {
    label = "led-d4";
    gpios = <&pl7_gpio_leds 3 0>;
    default-state = "off";
    linux,default-trigger = "none";
    };
     
    ...
     
    keypad {
    compatible = "gpio-keys";
    #address-cells = <1>;
    #size-cells = <0>;
    autorepeat;
     
    sw1 {
    label = "sw1";
    gpios = <&pl7_gpio_buttons 0 0>;
    linux,code = <0x100>; /* up */
    gpio-key,wakeup;
    autorepeat;
    };
    sw2 {
    label = "sw2";
    gpios = <&pl7_gpio_buttons 1 0>;
    linux,code = <0x101>; /* down */
    gpio-key,wakeup;
    autorepeat;
    };
    sw3 {
    label = "sw3";
    gpios = <&pl7_gpio_buttons 2 0>;
    linux,code = <0x102>; /* right */
    gpio-key,wakeup;
    autorepeat;
    };
    sw4 {
    label = "sw4";
    gpios = <&pl7_gpio_buttons 3 0>;
    linux,code = <0x103>; /* left */
    gpio-key,wakeup;
    autorepeat;
    };
    sw5 {
    label = "sw5";
    gpios = <&pl7_gpio_buttons 4 0>;
    linux,code = <0x104>; /* center */
    gpio-key,wakeup;
    autorepeat;
    };
    sw6 {
    label = "sw6";
    gpios = <&ps7_gpios 51 0>;
    linux,code = <0x105>; /* SW6: PS_PB */
    gpio-key,wakeup;
    autorepeat;
    };
    };
    ...
     
    And I've got these messages too:
     
    ...
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw1[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw2[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw3[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw4[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw5[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw6[0]' - status (0)
    gpio-897 (sw1): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 0 irq, irq_enable_mask 0x0
    gpio-898 (sw2): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 1 irq, irq_enable_mask 0x1
    gpio-899 (sw3): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 2 irq, irq_enable_mask 0x3
    gpio-900 (sw4): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 3 irq, irq_enable_mask 0x7
    gpio-901 (sw5): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 4 irq, irq_enable_mask 0xf
    gpio-957 (sw6): gpiod_set_debounce: missing set() or set_debounce() operations
    input: keypad as /devices/soc0/keypad/input/input0
    ...
     
    And I can see the buttons in the file /proc/interrupts:
     
    # cat /proc/interrupts 
               CPU0       CPU1       
     16:          0          0       GIC  27 Edge      gt
     17:          0          0       GIC  43 Level     ttc_clockevent
     18:      22271       1048       GIC  29 Edge      twd
     21:         43          0       GIC  39 Level     f8007100.adc
     74:          1          0  zynq-gpio  51 Edge      sw6
    ...
    167:          1          0     xgpio   0 Edge      sw1
    168:          1          0     xgpio   1 Edge      sw2
    169:          1          0     xgpio   2 Edge      sw3
    170:          1          0     xgpio   3 Edge      sw4
    171:          1          0     xgpio   4 Edge      sw5
     
    So now, everything is working fine.
     
    Thank you very much for your help.
     
    Best regards.
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • oscargomezf
    0 oscargomezf over 8 years ago
    Hi Josh,
     
     
    I've realised that I had improperly connected my PL GPIOS because I didn't activate the interrupt checkbox in the IP AXI_GPIO and I haven't connected this signal to the PS7.
     
    I've followed the next instructions: http://www.isusantha.com/axi-gpio-interrupt-handling
     
    So now I think my block design is ok.
     
    I've activated the CONFIG_DEBUG_GPIO option in the Linux kernel to see what really happens.
    And these are the messages I've got:
     
    gpiochip_find_base: found new base at 902
    gpiochip_add: registered GPIOs 902 to 905 on device: /amba_pl/gpio@41200000
    GPIO IRQ not connected
    XGpio: /amba_pl/gpio@41200000: registered, base is 902
    gpiochip_find_base: found new base at 897
    gpiochip_add: registered GPIOs 897 to 901 on device: /amba_pl/gpio@41210000
    IRQ Base: 167, Pin 0 = IRQ 167
    IRQ Base: 167, Pin 1 = IRQ 168
    IRQ Base: 167, Pin 2 = IRQ 169
    IRQ Base: 167, Pin 3 = IRQ 170
    IRQ Base: 167, Pin 4 = IRQ 171
    XGpio: /amba_pl/gpio@41210000: registered, base is 897
     
     
    It seems to be the configuration is ok, this is my dts file:
     
    ...
    ps7_gpios: gpio@e000a000 {
    compatible = "xlnx,zynq-gpio-1.0";
    #gpio-cells = <0x2>;
    #interrupt-cells = <0x2>;
    clocks = <0x1 0x2a>;
    gpio-controller;
    interrupt-controller;
    interrupt-parent = <0x3>;
    interrupts = <0x0 0x14 0x4>;
    reg = <0xe000a000 0x1000>;
    emio-gpio-width = <0x40>;
    gpio-mask-high = <0x0>;
    gpio-mask-low = <0x5600>;
    linux,phandle = <0x5>;
    phandle = <0x5>;
    };
    ...
    amba_pl {
    #address-cells = <0x1>;
    #size-cells = <0x1>;
    compatible = "simple-bus";
    ranges;
     
    pl7_gpio_leds: gpio@41200000 {
    #gpio-cells = <0x2>;
    compatible = "xlnx,xps-gpio-1.00.a";
    gpio-controller;
    reg = <0x41200000 0x10000>;
    xlnx,all-inputs = <0x0>;
    xlnx,all-inputs-2 = <0x0>;
    xlnx,all-outputs = <0x1>;
    xlnx,all-outputs-2 = <0x0>;
    xlnx,dout-default = <0x0>;
    xlnx,dout-default-2 = <0x0>;
    xlnx,gpio-width = <0x4>;
    xlnx,gpio2-width = <0x20>;
    xlnx,interrupt-present = <0x0>;
    xlnx,is-dual = <0x0>;
    xlnx,tri-default = <0xffffffff>;
    xlnx,tri-default-2 = <0xffffffff>;
    };
     
    pl7_gpio_buttons: gpio@41210000 {
    #gpio-cells = <0x2>;
    #interrupt-cells = <0x2>;
    compatible = "xlnx,xps-gpio-1.00.a";
    gpio-controller;
    interrupt-controller;
    interrupt-parent = <0x3>;
    interrupts = <0x0 0x1d 0x4>;
    reg = <0x41210000 0x10000>;
    xlnx,all-inputs = <0x1>;
    xlnx,all-inputs-2 = <0x0>;
    xlnx,all-outputs = <0x0>;
    xlnx,all-outputs-2 = <0x0>;
    xlnx,dout-default = <0x0>;
    xlnx,dout-default-2 = <0x0>;
    xlnx,gpio-width = <0x5>;
    xlnx,gpio2-width = <0x20>;
    xlnx,interrupt-present = <0x1>;
    xlnx,is-dual = <0x0>;
    xlnx,tri-default = <0xffffffff>;
    xlnx,tri-default-2 = <0xffffffff>;
    };
    };
     
    ...
    leds {
    compatible = "gpio-leds";
    led-d1 {
    label = "led-d1";
    gpios = <&pl7_gpio_leds 0 0>;
    default-state = "on";
    linux,default-trigger = "heartbeat";
    };
    led-d2 {
    label = "led-d2";
    gpios = <&pl7_gpio_leds 1 0>;
    default-state = "off";
    linux,default-trigger = "none";
    };
    led-d3 {
    label = "led-d3";
    gpios = <&pl7_gpio_leds 2 0>;
    default-state = "off";
    linux,default-trigger = "none";
    };
    led-d4 {
    label = "led-d4";
    gpios = <&pl7_gpio_leds 3 0>;
    default-state = "off";
    linux,default-trigger = "none";
    };
     
    ...
     
    keypad {
    compatible = "gpio-keys";
    #address-cells = <1>;
    #size-cells = <0>;
    autorepeat;
     
    sw1 {
    label = "sw1";
    gpios = <&pl7_gpio_buttons 0 0>;
    linux,code = <0x100>; /* up */
    gpio-key,wakeup;
    autorepeat;
    };
    sw2 {
    label = "sw2";
    gpios = <&pl7_gpio_buttons 1 0>;
    linux,code = <0x101>; /* down */
    gpio-key,wakeup;
    autorepeat;
    };
    sw3 {
    label = "sw3";
    gpios = <&pl7_gpio_buttons 2 0>;
    linux,code = <0x102>; /* right */
    gpio-key,wakeup;
    autorepeat;
    };
    sw4 {
    label = "sw4";
    gpios = <&pl7_gpio_buttons 3 0>;
    linux,code = <0x103>; /* left */
    gpio-key,wakeup;
    autorepeat;
    };
    sw5 {
    label = "sw5";
    gpios = <&pl7_gpio_buttons 4 0>;
    linux,code = <0x104>; /* center */
    gpio-key,wakeup;
    autorepeat;
    };
    sw6 {
    label = "sw6";
    gpios = <&ps7_gpios 51 0>;
    linux,code = <0x105>; /* SW6: PS_PB */
    gpio-key,wakeup;
    autorepeat;
    };
    };
    ...
     
    And I've got these messages too:
     
    ...
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw1[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw2[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw3[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw4[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw5[0]' - status (0)
    of_get_named_gpiod_flags: parsed 'gpios' property of node '/keypad/sw6[0]' - status (0)
    gpio-897 (sw1): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 0 irq, irq_enable_mask 0x0
    gpio-898 (sw2): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 1 irq, irq_enable_mask 0x1
    gpio-899 (sw3): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 2 irq, irq_enable_mask 0x3
    gpio-900 (sw4): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 3 irq, irq_enable_mask 0x7
    gpio-901 (sw5): gpiod_set_debounce: missing set() or set_debounce() operations
    xgpio_irq_unmask: Enable 4 irq, irq_enable_mask 0xf
    gpio-957 (sw6): gpiod_set_debounce: missing set() or set_debounce() operations
    input: keypad as /devices/soc0/keypad/input/input0
    ...
     
    And I can see the buttons in the file /proc/interrupts:
     
    # cat /proc/interrupts 
               CPU0       CPU1       
     16:          0          0       GIC  27 Edge      gt
     17:          0          0       GIC  43 Level     ttc_clockevent
     18:      22271       1048       GIC  29 Edge      twd
     21:         43          0       GIC  39 Level     f8007100.adc
     74:          1          0  zynq-gpio  51 Edge      sw6
    ...
    167:          1          0     xgpio   0 Edge      sw1
    168:          1          0     xgpio   1 Edge      sw2
    169:          1          0     xgpio   2 Edge      sw3
    170:          1          0     xgpio   3 Edge      sw4
    171:          1          0     xgpio   4 Edge      sw5
     
    So now, everything is working fine.
     
    Thank you very much for your help.
     
    Best regards.
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube