silverchris
Posts: 5
Joined: Thu Mar 21, 2013 4:36 am

gpio_to_irq and kernel 3.8

Wed Jun 05, 2013 6:42 am

Hello,
I am attempting to get a max3107 working with the raspberry pi usign the max310x driver. I am unfortunately stuck with trying to set up its IRQ. I am using GPIO pin 25 for its irq.

In arch/arm/mach-bcm2708/bcm2708.c I have a function to set the irq:

Code: Select all

static int __init bcm2708_max310x_init(void)
{
        int ret;
        ret = gpio_request(25, "MAX310x");
        if (ret) {
                printk("MAX310x init: failed to request GPIO with error %d\n", ret);
                return -EINVAL;
        }

        ret = gpio_direction_input(25);
        if (ret) {
                printk("MAX310x init: failed to set pin direction\n");
                gpio_free(25);
                return -EINVAL;
        }

        bcm2708_spi_devices[0].irq = gpio_to_irq(25);
        return 0;
}
This seems to be failing because the setup for the bcm2708 hasn't finished yet. Is there a way around this?

I have uploaded my modified bcm2708.c here as well.

Any help would be appreciated

elevation
Posts: 4
Joined: Sun Jan 05, 2014 9:18 am

Re: gpio_to_irq and kernel 3.8

Sat Jan 18, 2014 8:05 am

Any success with this, I'm thinking about building a board to get some more communication ports and has been checking out the MAX3107 chip also!

//Mattias

silverchris
Posts: 5
Joined: Thu Mar 21, 2013 4:36 am

Re: gpio_to_irq and kernel 3.8

Sat May 17, 2014 2:42 am

I have finally come back to this project after a long break. I have a max3107 hooked up, and works for a short period of time, but seems to cut out after a minute or so, I am not sure the exact reason, but have a feeling it has to do with the SPI driver, or the interrupt code

enthusiast
Posts: 1
Joined: Wed Feb 24, 2016 5:13 pm

Re: gpio_to_irq and kernel 3.8

Wed Feb 24, 2016 5:43 pm

@silverchris:

I realize that I'm just a little bit behind the times here, but I'm curious to know if you've made any progress with this project?

I have suddenly found myself in possession of a couple of MAX3100CPD (single SPI/Microwire to UART) chips. Being that virtually every electronic device I own has at least one on-board UART, they're not exactly critical, but I like to learn and hate to waste. Is there any chance you could share your code progress?
--- RPi V1 B+ Raspbian ---

larsth
Posts: 54
Joined: Sat Aug 27, 2011 9:51 pm
Contact: Website

Re: gpio_to_irq and kernel 3.8

Thu Apr 07, 2016 7:49 pm

I honestly think that https://github.com/raspberrypi/linux/bl ... /bcm2708.c is the wrong place in the kernel source tree.

/driver/tty/serial/max310x.c
Using LXR:
I find interrupt functionality, and other interesting stuff in /driver/tty/serial/max310x.c: https://lxr.missinglinkelectronics.com/ ... /max310x.c
Configuring a GPIO to become an interrupt pin is done in an entirely different place in the kernel, see /Documentation/gpio: https://lxr.missinglinkelectronics.com/ ... tion/gpio/[/url] ,
for user space /Documentation/gpio/sysfs.txt: https://lxr.missinglinkelectronics.com/ ... /sysfs.txt is very interesting.
Use fx the epoll system calls to let you program be notified about an interrupt on fx /sys/class/gpio/gpio27/value
to use BCM Pad 27 (BCM IC pin 27), write 27 (ASCII text) to /sys/class/gpio/export first.

Interactive Raspberry Pi GPIO header web page: http://pinout.xyz/pinout/

Return to “Linux Kernel”