2010-08-10 23:55:42     GPIO irq fail

Document created by Aaronwu Employee on Aug 22, 2013Last modified by Aaronwu Employee on Aug 22, 2013
Version 2Show Document
  • View in full screen mode

2010-08-10 23:55:42     GPIO irq fail

nike tian (CHINA)

Message: 92301   

 

I was using kernel uClinux-2008R1-RC8,and my CPU is BF533,when i config GPIO PF1 as interrupt.

 

But,when the rising edge occour,two interrupt occours between 500us.here is my source code.when a rising edge occour,

 

I got output:

 

irq1

 

irq2

 

 

#include <linux/module.h>

#include <linux/errno.h>

#include <linux/sched.h>

#include <asm/uaccess.h>

#include <asm/io.h>

#include <linux/proc_fs.h>

#include <linux/platform_device.h>

#include <linux/fs.h>

#include <asm/uaccess.h>

 

#include <asm-blackfin/mach-bf533/irq.h>

#include <linux/interrupt.h>

 

 

MODULE_LICENSE("GPL");

MODULE_DESCRIPTION("Simple driver for GPIO irq");

MODULE_AUTHOR("NIKE TIAN");

 

 

static irqreturn_t gpio_irq_handle(int irq, void *dev_id)

{

unsigned short pin_value;

pin_value=bfin_read_FIO_FLAG_D();

 

if(pin_value  & PF1){  //rising edge protect off

  bfin_write_FIO_FLAG_S(PF14);

  //printk(KERN_INFO "irq 1\n");

}else{

  bfin_write_FIO_FLAG_C(PF14);

  //printk(KERN_INFO "irq 2\n");

}

 

//bfin_write_FIO_FLAG_T(PF14);

return IRQ_HANDLED;

}

static int __init gpio_irq_init(void)

{

//unsigned char value;

int ret;

unsigned short pin_value;

 

printk(KERN_INFO"gpio irq init\n");

bfin_write_FIO_DIR(bfin_read_FIO_DIR() & (~PF1));  //in put

bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF14);  //out put

bfin_write_FIO_INEN(bfin_read_FIO_INEN() | PF1);

 

ret=request_irq(IRQ_PF1,gpio_irq_handle,IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING ,"power_dect",NULL);

//ret=request_irq(IRQ_PF1,gpio_irq_handle,IRQF_TRIGGER_RISING ,"power_dect",NULL);

//ret=request_irq(IRQ_PF1,gpio_irq_handle,IRQF_TRIGGER_LOW,"power_dect",NULL);

if(ret){

  printk(KERN_WARNING"IRQ %d is not free.\n",IRQ_PF1);

  return ret;

}

return 0;

}

 

static void __exit ipsel_cleanup(void)

{

printk("gpio irq exit\n");

free_irq(IRQ_PF1, NULL);

}

 

module_init(gpio_irq_init);

module_exit(ipsel_cleanup);

 

irq.c

Makefile

QuoteReplyEditDelete

 

 

2010-08-11 00:09:56     Re: GPIO irq fail

Mike Frysinger (UNITED STATES)

Message: 92303   

 

you should not be modifying on any FIO MMRs yourself.  use the GPIO framework:

  docs.blackfin.uclinux.org/doku.php?id=gpio

 

are you sure your signal is clean ?  the BF533 doesnt do any hysteresis or schmitt triggering on the GPIO line.

QuoteReplyEditDelete

 

 

2010-08-11 01:51:01     Re: GPIO irq fail

nike tian (CHINA)

Message: 92304   

 

Thanks for your reply,Mike!

 

I did not modify FIO MMRs,and I dont know how t modify it!

 

I had read the  GPIO framework docs,but i dont know How can i do to my question!

 

I also check the signal,i am sure it it clean!

 

How can I do now?

QuoteReplyEditDelete

 

 

2010-08-11 02:08:16     Re: GPIO irq fail

Mike Frysinger (UNITED STATES)

Message: 92305   

 

your code is clearly using bfin_write_FIO_* and bfin_read_FIO_* functions.  do not use those.  rewrite your code to use the GPIO layer.

 

what exactly is the problem ?  if you configure a GPIO as an IRQ on both rising and falling, and then you start toggling its value, why do you expect IRQs to not fire ?

QuoteReplyEditDelete

Attachments

Outcomes