RT5350F GPIO Interrupts

Started by igrinon, November 13, 2016, 03:04:48 am

Previous topic - Next topic


Hello @ all,

I'm trying to make a hi freq counter on a GPIO but is impossible to make it work.
Please can sombebody give me help on how to enable ints on GPIO?
Thanks in advance.

Setup GPIOS on kern-mod
   gpio_request(gpio20, "sysfs");
   gpio_request(gpio21, "sysfs");
   gpio_direction_output(gpio20, false);
   gpio_direction_output(gpio21, true);
   gpio_export(gpio20, false);
   gpio_export(gpio21, false);

Created an int hanndler func
        static irq_handler_t irq_handler(unsigned int irq, void *dev_id, struct pt_regs *regs)

        printk(KERN_INFO "GPIO_TEST: Interrupt! (presses %d)\n", numberPresses);

Request int
        result=request_irq(irqNumber, (irq_handler_t) irq_handler, IRQF_TRIGGER_RISING, "ebb_gpio_handler", NULL);   

Cat /proc/interrupts
        43:          0      GPIO  20  ebb_gpio_handler

Getting interrupt enable regs
   gpio_addr = ioremap(GPIO_START_ADDR, GPIO_SIZE);
   data = ioread32(gpio_addr+0x0008);
   printk("Read 0x0008: %d\n", data);     -> This reads ok 0 (nothing enabled on GPIO21_00_RENA)
   data = ioread32(gpio_addr+0x000c);
   printk("Read 0x000c): %d\n", data);    -> This reads ok 1048576 (bit 20 enabled on GPIO21_00_FENA)

After linking gpio20 and gpio21 together, force a change on GPIO20

Cat /proc/interrupts
        43:          0      GPIO  20  ebb_gpio_handler

Interrupts are the same, nothing happened  :(


Ok, solved

static irq_handler_t mxarnix_irq_handler(unsigned int irq, void *dev_id, struct pt_regs *regs){
   printk(KERN_INFO "GPIO_XARNIX: mxarnix_irq_handler (%s)\n", testPtr);
   return (irq_handler_t) IRQ_HANDLED;

char *testPtr = "TEST POINTER";
static unsigned int gpioIn = 20;
static unsigned int gpioIrq;

gpio_request(gpioIn, "sysfs");
//gpio_set_debounce(gpioIn, 200);
gpio_export(gpioIn, false);

gpioIrq = gpio_to_irq(gpioIn);
printk(KERN_INFO "GPIO_XARNIX: IRQ: %d\n", gpioIrq);

result = request_irq(gpioIrq, (irq_handler_t) mxarnix_irq_handler, IRQF_TRIGGER_RISING, "mxarnix_interrupts",  testPtr);
printk(KERN_INFO "GPIO_XARNIX: request_irq result: %d\n", result);


ok, "gpio_direction_input" is the issu .

I have a kmod like your handler GPIO, it's work ... but in didn't find how to use UIO , and if there are a link with MMO.

How are you used this interrupt/handler on the "userspace" ?