[beagleboard] Re: detecting interrupt on GPIO in kernel module
use of gpio_int_name On Tuesday, 26 August 2014 19:38:01 UTC+5:30, Siddarth Sharma wrote: > > I am toggling the input into a GPIO line on my BeagleBone from high to low > every 500 ms using an Atmel uC. I have registered a handler for this in my > Linux Kernel Module, but the handler is not being called for some reason. > > My module code is - > > #define GPIO 54 > #define GPIO_INT_NAME "gpio_int" > > #define GPIO_HIGH gpio_get_value(GPIO) > #define GPIO_LOW (gpio_get_value(GPIO) == 0) > short int irq_any_gpio= 0; > int count =0; > > enum { falling, rising } type; > static irqreturn_t r_irq_handler(int irq, void *dev_id) > { > count++; > printk(KERN_DEBUG "interrupt received (irq: %d)\n", irq); > if (irq == gpio_to_irq(GPIO)) > { > > type = GPIO_LOW ? falling : rising; > > if(type == falling) > { > printk("gpio pin is low\n"); > } > else > printk("gpio pin is high\n"); > > } > > return IRQ_HANDLED; > } > > > void r_int_config(void) { > >if (gpio_request(GPIO, GPIO_INT_NAME )) >{ > printk("GPIO request failure: %s\n", GPIO_INT_NAME ); > return; >} > >if ( (irq_any_gpio = gpio_to_irq(GPIO)) < 0 ) { > printk("GPIO to IRQ mapping failure %s\n",GPIO_INT_NAME ); > return; >} > >printk(KERN_NOTICE "Mapped int %d\n", irq_any_gpio); > >if (request_irq(irq_any_gpio,(irq_handler_t ) r_irq_handler, > IRQF_TRIGGER_HIGH, GPIO_INT_NAME, NULL)) >{ > printk("Irq Request failure\n"); > return; >} > >return; > } > > void r_int_release(void) { > >free_irq(gpio_to_irq(GPIO), NULL); > gpio_free(GPIO);; >return; > } > > int init_module(void) > { > printk("<1>Hello World\n"); > r_int_config(); > return 0; > } > > On calling insmod interrupt_test.ko, i get the following message > > [ 76.594543] Hello World > > [ 76.597137] Mapped int 214 > > But now when I start toggling the input into this gpio pin, the interrupt > handler doesn't get called and the message - "interrupt received" is not > being displayed. > > How do I solve this ? What's causing the problem? > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/58c134dc-0d16-4359-8406-c7ec9794895c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [beagleboard] Re: detecting interrupt on GPIO in kernel module
Hi Kavita A generic question regarding interrupts. If i register an interrupt using request_threaded_irq() or request_irq() will that be listed in /proc/interrupts ? On Tuesday, September 9, 2014 11:17:19 AM UTC+5:30, kavitha wrote: Does cat /proc/interrupts give show anything for 214. Check whether It is going to architecture specific impelemtation of gpio_to_irq On Tue, Sep 9, 2014 at 8:26 AM, neo star prag@gmail.com javascript: wrote: Hi I see that some function definitions are missing in your code. Can you share those as well, so that i too can try and figure out the problem. Especially the functions like gpio_to_irq() ... Thanks. On Tuesday, August 26, 2014 7:38:01 PM UTC+5:30, Siddarth Sharma wrote: I am toggling the input into a GPIO line on my BeagleBone from high to low every 500 ms using an Atmel uC. I have registered a handler for this in my Linux Kernel Module, but the handler is not being called for some reason. My module code is - #define GPIO 54 #define GPIO_INT_NAME gpio_int #define GPIO_HIGH gpio_get_value(GPIO) #define GPIO_LOW (gpio_get_value(GPIO) == 0) short int irq_any_gpio= 0; int count =0; enum { falling, rising } type; static irqreturn_t r_irq_handler(int irq, void *dev_id) { count++; printk(KERN_DEBUG interrupt received (irq: %d)\n, irq); if (irq == gpio_to_irq(GPIO)) { type = GPIO_LOW ? falling : rising; if(type == falling) { printk(gpio pin is low\n); } else printk(gpio pin is high\n); } return IRQ_HANDLED; } void r_int_config(void) { if (gpio_request(GPIO, GPIO_INT_NAME )) { printk(GPIO request failure: %s\n, GPIO_INT_NAME ); return; } if ( (irq_any_gpio = gpio_to_irq(GPIO)) 0 ) { printk(GPIO to IRQ mapping failure %s\n,GPIO_INT_NAME ); return; } printk(KERN_NOTICE Mapped int %d\n, irq_any_gpio); if (request_irq(irq_any_gpio,(irq_handler_t ) r_irq_handler, IRQF_TRIGGER_HIGH, GPIO_INT_NAME, NULL)) { printk(Irq Request failure\n); return; } return; } void r_int_release(void) { free_irq(gpio_to_irq(GPIO), NULL); gpio_free(GPIO);; return; } int init_module(void) { printk(1Hello World\n); r_int_config(); return 0; } On calling insmod interrupt_test.ko, i get the following message [ 76.594543] Hello World [ 76.597137] Mapped int 214 But now when I start toggling the input into this gpio pin, the interrupt handler doesn't get called and the message - interrupt received is not being displayed. How do I solve this ? What's causing the problem? -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups BeagleBoard group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups BeagleBoard group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [beagleboard] Re: detecting interrupt on GPIO in kernel module
Yes it does show in cat /proc/interrupts It doesnot matter you use request_threaded_irq or request_irq request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev) Here the handler will be run in interrupt context and request_threaded_irq(unsigned int irq, irq_handler_t handler, irq_handler_t thread_fn, unsigned long flags, const char *name, void *dev); In threaded IRQ irq_handler_t handle - Interrupt context irq_handler_t thread_fn- Process context This is the only difference. Thanks Kavitha On Wed, Sep 10, 2014 at 8:03 AM, neo prag.in...@gmail.com wrote: Hi Kavita A generic question regarding interrupts. If i register an interrupt using request_threaded_irq() or request_irq() will that be listed in /proc/interrupts ? On Tuesday, September 9, 2014 11:17:19 AM UTC+5:30, kavitha wrote: Does cat /proc/interrupts give show anything for 214. Check whether It is going to architecture specific impelemtation of gpio_to_irq On Tue, Sep 9, 2014 at 8:26 AM, neo star prag@gmail.com wrote: Hi I see that some function definitions are missing in your code. Can you share those as well, so that i too can try and figure out the problem. Especially the functions like gpio_to_irq() ... Thanks. On Tuesday, August 26, 2014 7:38:01 PM UTC+5:30, Siddarth Sharma wrote: I am toggling the input into a GPIO line on my BeagleBone from high to low every 500 ms using an Atmel uC. I have registered a handler for this in my Linux Kernel Module, but the handler is not being called for some reason. My module code is - #define GPIO 54 #define GPIO_INT_NAME gpio_int #define GPIO_HIGH gpio_get_value(GPIO) #define GPIO_LOW (gpio_get_value(GPIO) == 0) short int irq_any_gpio= 0; int count =0; enum { falling, rising } type; static irqreturn_t r_irq_handler(int irq, void *dev_id) { count++; printk(KERN_DEBUG interrupt received (irq: %d)\n, irq); if (irq == gpio_to_irq(GPIO)) { type = GPIO_LOW ? falling : rising; if(type == falling) { printk(gpio pin is low\n); } else printk(gpio pin is high\n); } return IRQ_HANDLED; } void r_int_config(void) { if (gpio_request(GPIO, GPIO_INT_NAME )) { printk(GPIO request failure: %s\n, GPIO_INT_NAME ); return; } if ( (irq_any_gpio = gpio_to_irq(GPIO)) 0 ) { printk(GPIO to IRQ mapping failure %s\n,GPIO_INT_NAME ); return; } printk(KERN_NOTICE Mapped int %d\n, irq_any_gpio); if (request_irq(irq_any_gpio,(irq_handler_t ) r_irq_handler, IRQF_TRIGGER_HIGH, GPIO_INT_NAME, NULL)) { printk(Irq Request failure\n); return; } return; } void r_int_release(void) { free_irq(gpio_to_irq(GPIO), NULL); gpio_free(GPIO);; return; } int init_module(void) { printk(1Hello World\n); r_int_config(); return 0; } On calling insmod interrupt_test.ko, i get the following message [ 76.594543] Hello World [ 76.597137] Mapped int 214 But now when I start toggling the input into this gpio pin, the interrupt handler doesn't get called and the message - interrupt received is not being displayed. How do I solve this ? What's causing the problem? -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups BeagleBoard group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups BeagleBoard group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups BeagleBoard group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [beagleboard] Re: detecting interrupt on GPIO in kernel module
Hi Kavita Thanks for clarifying On Wednesday, September 10, 2014 10:00:06 AM UTC+5:30, kavitha wrote: Yes it does show in cat /proc/interrupts It doesnot matter you use request_threaded_irq or request_irq request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev) Here the handler will be run in interrupt context and request_threaded_irq(unsigned int irq, irq_handler_t handler, irq_handler_t thread_fn, unsigned long flags, const char *name, void *dev); In threaded IRQ irq_handler_t handle - Interrupt context irq_handler_t thread_fn- Process context This is the only difference. Thanks Kavitha On Wed, Sep 10, 2014 at 8:03 AM, neo prag@gmail.com javascript: wrote: Hi Kavita A generic question regarding interrupts. If i register an interrupt using request_threaded_irq() or request_irq() will that be listed in /proc/interrupts ? On Tuesday, September 9, 2014 11:17:19 AM UTC+5:30, kavitha wrote: Does cat /proc/interrupts give show anything for 214. Check whether It is going to architecture specific impelemtation of gpio_to_irq On Tue, Sep 9, 2014 at 8:26 AM, neo star prag@gmail.com wrote: Hi I see that some function definitions are missing in your code. Can you share those as well, so that i too can try and figure out the problem. Especially the functions like gpio_to_irq() ... Thanks. On Tuesday, August 26, 2014 7:38:01 PM UTC+5:30, Siddarth Sharma wrote: I am toggling the input into a GPIO line on my BeagleBone from high to low every 500 ms using an Atmel uC. I have registered a handler for this in my Linux Kernel Module, but the handler is not being called for some reason. My module code is - #define GPIO 54 #define GPIO_INT_NAME gpio_int #define GPIO_HIGH gpio_get_value(GPIO) #define GPIO_LOW (gpio_get_value(GPIO) == 0) short int irq_any_gpio= 0; int count =0; enum { falling, rising } type; static irqreturn_t r_irq_handler(int irq, void *dev_id) { count++; printk(KERN_DEBUG interrupt received (irq: %d)\n, irq); if (irq == gpio_to_irq(GPIO)) { type = GPIO_LOW ? falling : rising; if(type == falling) { printk(gpio pin is low\n); } else printk(gpio pin is high\n); } return IRQ_HANDLED; } void r_int_config(void) { if (gpio_request(GPIO, GPIO_INT_NAME )) { printk(GPIO request failure: %s\n, GPIO_INT_NAME ); return; } if ( (irq_any_gpio = gpio_to_irq(GPIO)) 0 ) { printk(GPIO to IRQ mapping failure %s\n,GPIO_INT_NAME ); return; } printk(KERN_NOTICE Mapped int %d\n, irq_any_gpio); if (request_irq(irq_any_gpio,(irq_handler_t ) r_irq_handler, IRQF_TRIGGER_HIGH, GPIO_INT_NAME, NULL)) { printk(Irq Request failure\n); return; } return; } void r_int_release(void) { free_irq(gpio_to_irq(GPIO), NULL); gpio_free(GPIO);; return; } int init_module(void) { printk(1Hello World\n); r_int_config(); return 0; } On calling insmod interrupt_test.ko, i get the following message [ 76.594543] Hello World [ 76.597137] Mapped int 214 But now when I start toggling the input into this gpio pin, the interrupt handler doesn't get called and the message - interrupt received is not being displayed. How do I solve this ? What's causing the problem? -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups BeagleBoard group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups BeagleBoard group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups BeagleBoard group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[beagleboard] Re: detecting interrupt on GPIO in kernel module
Hi I see that some function definitions are missing in your code. Can you share those as well, so that i too can try and figure out the problem. Especially the functions like gpio_to_irq() ... Thanks. On Tuesday, August 26, 2014 7:38:01 PM UTC+5:30, Siddarth Sharma wrote: I am toggling the input into a GPIO line on my BeagleBone from high to low every 500 ms using an Atmel uC. I have registered a handler for this in my Linux Kernel Module, but the handler is not being called for some reason. My module code is - #define GPIO 54 #define GPIO_INT_NAME gpio_int #define GPIO_HIGH gpio_get_value(GPIO) #define GPIO_LOW (gpio_get_value(GPIO) == 0) short int irq_any_gpio= 0; int count =0; enum { falling, rising } type; static irqreturn_t r_irq_handler(int irq, void *dev_id) { count++; printk(KERN_DEBUG interrupt received (irq: %d)\n, irq); if (irq == gpio_to_irq(GPIO)) { type = GPIO_LOW ? falling : rising; if(type == falling) { printk(gpio pin is low\n); } else printk(gpio pin is high\n); } return IRQ_HANDLED; } void r_int_config(void) { if (gpio_request(GPIO, GPIO_INT_NAME )) { printk(GPIO request failure: %s\n, GPIO_INT_NAME ); return; } if ( (irq_any_gpio = gpio_to_irq(GPIO)) 0 ) { printk(GPIO to IRQ mapping failure %s\n,GPIO_INT_NAME ); return; } printk(KERN_NOTICE Mapped int %d\n, irq_any_gpio); if (request_irq(irq_any_gpio,(irq_handler_t ) r_irq_handler, IRQF_TRIGGER_HIGH, GPIO_INT_NAME, NULL)) { printk(Irq Request failure\n); return; } return; } void r_int_release(void) { free_irq(gpio_to_irq(GPIO), NULL); gpio_free(GPIO);; return; } int init_module(void) { printk(1Hello World\n); r_int_config(); return 0; } On calling insmod interrupt_test.ko, i get the following message [ 76.594543] Hello World [ 76.597137] Mapped int 214 But now when I start toggling the input into this gpio pin, the interrupt handler doesn't get called and the message - interrupt received is not being displayed. How do I solve this ? What's causing the problem? -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups BeagleBoard group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [beagleboard] Re: detecting interrupt on GPIO in kernel module
Does cat /proc/interrupts give show anything for 214. Check whether It is going to architecture specific impelemtation of gpio_to_irq On Tue, Sep 9, 2014 at 8:26 AM, neo star prag.in...@gmail.com wrote: Hi I see that some function definitions are missing in your code. Can you share those as well, so that i too can try and figure out the problem. Especially the functions like gpio_to_irq() ... Thanks. On Tuesday, August 26, 2014 7:38:01 PM UTC+5:30, Siddarth Sharma wrote: I am toggling the input into a GPIO line on my BeagleBone from high to low every 500 ms using an Atmel uC. I have registered a handler for this in my Linux Kernel Module, but the handler is not being called for some reason. My module code is - #define GPIO 54 #define GPIO_INT_NAME gpio_int #define GPIO_HIGH gpio_get_value(GPIO) #define GPIO_LOW (gpio_get_value(GPIO) == 0) short int irq_any_gpio= 0; int count =0; enum { falling, rising } type; static irqreturn_t r_irq_handler(int irq, void *dev_id) { count++; printk(KERN_DEBUG interrupt received (irq: %d)\n, irq); if (irq == gpio_to_irq(GPIO)) { type = GPIO_LOW ? falling : rising; if(type == falling) { printk(gpio pin is low\n); } else printk(gpio pin is high\n); } return IRQ_HANDLED; } void r_int_config(void) { if (gpio_request(GPIO, GPIO_INT_NAME )) { printk(GPIO request failure: %s\n, GPIO_INT_NAME ); return; } if ( (irq_any_gpio = gpio_to_irq(GPIO)) 0 ) { printk(GPIO to IRQ mapping failure %s\n,GPIO_INT_NAME ); return; } printk(KERN_NOTICE Mapped int %d\n, irq_any_gpio); if (request_irq(irq_any_gpio,(irq_handler_t ) r_irq_handler, IRQF_TRIGGER_HIGH, GPIO_INT_NAME, NULL)) { printk(Irq Request failure\n); return; } return; } void r_int_release(void) { free_irq(gpio_to_irq(GPIO), NULL); gpio_free(GPIO);; return; } int init_module(void) { printk(1Hello World\n); r_int_config(); return 0; } On calling insmod interrupt_test.ko, i get the following message [ 76.594543] Hello World [ 76.597137] Mapped int 214 But now when I start toggling the input into this gpio pin, the interrupt handler doesn't get called and the message - interrupt received is not being displayed. How do I solve this ? What's causing the problem? -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups BeagleBoard group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups BeagleBoard group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[beagleboard] Re: detecting interrupt on GPIO in kernel module
Does the problem have something to do with dev id paramter in the interrupt handler? On Tuesday, August 26, 2014 3:08:01 PM UTC+1, Siddarth Sharma wrote: I am toggling the input into a GPIO line on my BeagleBone from high to low every 500 ms using an Atmel uC. I have registered a handler for this in my Linux Kernel Module, but the handler is not being called for some reason. My module code is - #define GPIO 54 #define GPIO_INT_NAME gpio_int #define GPIO_HIGH gpio_get_value(GPIO) #define GPIO_LOW (gpio_get_value(GPIO) == 0) short int irq_any_gpio= 0; int count =0; enum { falling, rising } type; static irqreturn_t r_irq_handler(int irq, void *dev_id) { count++; printk(KERN_DEBUG interrupt received (irq: %d)\n, irq); if (irq == gpio_to_irq(GPIO)) { type = GPIO_LOW ? falling : rising; if(type == falling) { printk(gpio pin is low\n); } else printk(gpio pin is high\n); } return IRQ_HANDLED; } void r_int_config(void) { if (gpio_request(GPIO, GPIO_INT_NAME )) { printk(GPIO request failure: %s\n, GPIO_INT_NAME ); return; } if ( (irq_any_gpio = gpio_to_irq(GPIO)) 0 ) { printk(GPIO to IRQ mapping failure %s\n,GPIO_INT_NAME ); return; } printk(KERN_NOTICE Mapped int %d\n, irq_any_gpio); if (request_irq(irq_any_gpio,(irq_handler_t ) r_irq_handler, IRQF_TRIGGER_HIGH, GPIO_INT_NAME, NULL)) { printk(Irq Request failure\n); return; } return; } void r_int_release(void) { free_irq(gpio_to_irq(GPIO), NULL); gpio_free(GPIO);; return; } int init_module(void) { printk(1Hello World\n); r_int_config(); return 0; } On calling insmod interrupt_test.ko, i get the following message [ 76.594543] Hello World [ 76.597137] Mapped int 214 But now when I start toggling the input into this gpio pin, the interrupt handler doesn't get called and the message - interrupt received is not being displayed. How do I solve this ? What's causing the problem? -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups BeagleBoard group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.