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 2638 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
Parents
  • 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
Reply
  • 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
Children
No Data
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