Welcome, Guest

Author Topic: RT5350F GPIO Interrupts  (Read 1616 times)

igrinon

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
RT5350F GPIO Interrupts
« on: November 13, 2016, 03:04:48 AM »
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)

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

Request int
        irqNumber=gpio_to_irq(gpio20);
        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)
   iounmap(gpio_addr);

After linking gpio20 and gpio21 together, force a change on GPIO20
   gpio_set_value(gpio21,0);
   gpio_set_value(gpio21,1);
   gpio_set_value(gpio21,0);

Cat /proc/interrupts
        43:          0      GPIO  20  ebb_gpio_handler

Interrupts are the same, nothing happened  :(

igrinon

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
[SOLVED] RT5350F GPIO Interrupts
« Reply #1 on: December 03, 2016, 11:50:28 AM »
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_direction_input(gpioIn);
//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);

Syd

  • Newbie
  • *
  • Posts: 15
  • Karma: +1/-0
Re: RT5350F GPIO Interrupts
« Reply #2 on: January 13, 2017, 09:41:09 AM »
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" ?

thx