gpio_to_irq(25) = -6

rreignier
rreignier New Member Posts: 67 ✭✭
edited January 2020 in UP Xtreme Linux

While following this thread to add a MCP2515 (CAN driver on SPI bus) on an Up Xtreme, the driver proposed by @nukular works to register the SPI device but the gpio_to_irq() always returns -6 so the SPI driver is not happy with it.

We have tried several GPIO numbers, from 1 to 26 but all are returning -6.

This same driver was working on an UpBoard.

We are currently running the 5.0 kernel from Up ppa has explained in the wiki.

Did anyone have success on using irq on pins from the 40-pin Raspberry Pi style connector?

I have tried to follow the kernel source code but I am not enough familiar with it so if anyone could point me to the right files, it would be nice too.

Thank you.

Comments

  • rreignier
    rreignier New Member Posts: 67 ✭✭

    I have checked all the GPIO pins available on the 40 pin connector with this small module and is was not possible to get any IRQ while it works on a classic UpBoard.

    Module:

    #include <linux/init.h>
    #include <linux/module.h>
    #include <linux/interrupt.h>
    #include <linux/gpio.h>
    
    static int __init list_irq_init(void)
    {
        int ret;
        int i;
    
        printk("list_irq: init\n");
    
        for(i = 0 ; i <= 27; i++)
        {
            printk("list_irq: Checking GPIO %d\n", i);
    
            ret = gpio_request(i, "list_irq");
            if(ret){
                gpio_free(i);
                continue;
            }
    
            gpio_direction_input(i);
    
            ret = gpio_to_irq(i);
            if(ret < 0){
                printk("list_irq: could not get irq of gpio %d\n", i);
                gpio_free(i);
                continue;
            }
    
            printk("list_irq: irq for pin %d is %d\n", i, ret);
            gpio_free(i);
        }
    
        return 0;
    }
    
    static void __exit list_irq_exit(void)
    {
        printk("list irq: exit\n");
    }
    
    module_init(list_irq_init);
    module_exit(list_irq_exit);
    MODULE_LICENSE("GPL");
    MODULE_AUTHOR("rre");
    MODULE_DESCRIPTION("List IRQ on GPIO");
    

    dmesg result on Up Xtreme:

    [ 6833.195326] list_irq: init
    [ 6833.195328] list_irq: Checking GPIO 0
    [ 6833.195427] list_irq: could not get irq of gpio 0
    [ 6833.195430] list_irq: Checking GPIO 1
    [ 6833.195528] list_irq: could not get irq of gpio 1
    [ 6833.195529] list_irq: Checking GPIO 2
    [ 6833.195619] list_irq: could not get irq of gpio 2
    [ 6833.195621] list_irq: Checking GPIO 3
    [ 6833.195710] list_irq: could not get irq of gpio 3
    [ 6833.195711] list_irq: Checking GPIO 4
    [ 6833.195800] list_irq: could not get irq of gpio 4
    [ 6833.195802] list_irq: Checking GPIO 5
    [ 6833.195891] list_irq: could not get irq of gpio 5
    [ 6833.195892] list_irq: Checking GPIO 6
    [ 6833.195981] list_irq: could not get irq of gpio 6
    [ 6833.195983] list_irq: Checking GPIO 7
    [ 6833.196071] list_irq: could not get irq of gpio 7
    [ 6833.196073] list_irq: Checking GPIO 8
    [ 6833.196162] list_irq: could not get irq of gpio 8
    [ 6833.196163] list_irq: Checking GPIO 9
    [ 6833.196252] list_irq: could not get irq of gpio 9
    [ 6833.196254] list_irq: Checking GPIO 10
    [ 6833.196343] list_irq: could not get irq of gpio 10
    [ 6833.196344] list_irq: Checking GPIO 11
    [ 6833.196434] list_irq: could not get irq of gpio 11
    [ 6833.196435] list_irq: Checking GPIO 12
    [ 6833.196525] list_irq: could not get irq of gpio 12
    [ 6833.196527] list_irq: Checking GPIO 13
    [ 6833.196625] list_irq: could not get irq of gpio 13
    [ 6833.196627] list_irq: Checking GPIO 14
    [ 6833.196714] list_irq: could not get irq of gpio 14
    [ 6833.196716] list_irq: Checking GPIO 15
    [ 6833.196804] list_irq: could not get irq of gpio 15
    [ 6833.196806] list_irq: Checking GPIO 16
    [ 6833.197119] list_irq: could not get irq of gpio 16
    [ 6833.197122] list_irq: Checking GPIO 17
    [ 6833.197212] list_irq: could not get irq of gpio 17
    [ 6833.197214] list_irq: Checking GPIO 18
    [ 6833.197306] list_irq: could not get irq of gpio 18
    [ 6833.197307] list_irq: Checking GPIO 19
    [ 6833.197397] list_irq: could not get irq of gpio 19
    [ 6833.197399] list_irq: Checking GPIO 20
    [ 6833.197498] list_irq: could not get irq of gpio 20
    [ 6833.197500] list_irq: Checking GPIO 21
    [ 6833.197590] list_irq: could not get irq of gpio 21
    [ 6833.197591] list_irq: Checking GPIO 22
    [ 6833.197665] list_irq: could not get irq of gpio 22
    [ 6833.197666] list_irq: Checking GPIO 23
    [ 6833.197739] list_irq: could not get irq of gpio 23
    [ 6833.197740] list_irq: Checking GPIO 24
    [ 6833.197817] list_irq: could not get irq of gpio 24
    [ 6833.197819] list_irq: Checking GPIO 25
    [ 6833.197891] list_irq: could not get irq of gpio 25
    [ 6833.197893] list_irq: Checking GPIO 26
    [ 6833.197965] list_irq: could not get irq of gpio 26
    [ 6833.197966] list_irq: Checking GPIO 27
    [ 6833.198030] list_irq: could not get irq of gpio 27
    [ 7076.588161] list irq: exit
    

    dmesg on UpBoard:

    [  178.728298] list_irq: init
    [  178.728303] list_irq: Checking GPIO 0
    [  178.729910] list_irq: irq for pin 0 is 157
    [  178.732915] list_irq: Checking GPIO 1
    [  178.734564] list_irq: irq for pin 1 is 158
    [  178.737612] list_irq: Checking GPIO 2
    [  178.739152] list_irq: irq for pin 2 is 159
    [  178.742197] list_irq: Checking GPIO 3
    [  178.743736] list_irq: irq for pin 3 is 160
    [  178.746763] list_irq: Checking GPIO 4
    [  178.748301] list_irq: irq for pin 4 is 161
    [  178.749841] list_irq: Checking GPIO 5
    [  178.749883] list_irq: irq for pin 5 is 162
    [  178.749891] list_irq: Checking GPIO 6
    [  178.749930] list_irq: irq for pin 6 is 163
    [  178.749938] list_irq: Checking GPIO 7
    [  178.749979] list_irq: irq for pin 7 is 164
    [  178.749987] list_irq: Checking GPIO 8
    [  178.750026] list_irq: irq for pin 8 is 165
    [  178.751530] list_irq: Checking GPIO 9
    [  178.751570] list_irq: irq for pin 9 is 166
    [  178.751577] list_irq: Checking GPIO 10
    [  178.751616] list_irq: irq for pin 10 is 167
    [  178.753120] list_irq: Checking GPIO 11
    [  178.753159] list_irq: irq for pin 11 is 168
    [  178.754688] list_irq: Checking GPIO 12
    [  178.754730] list_irq: irq for pin 12 is 169
    [  178.756234] list_irq: Checking GPIO 13
    [  178.756273] list_irq: irq for pin 13 is 170
    [  178.757800] list_irq: Checking GPIO 14
    [  178.757843] list_irq: irq for pin 14 is 171
    [  178.759347] list_irq: Checking GPIO 15
    [  178.759386] list_irq: irq for pin 15 is 172
    [  178.759393] list_irq: Checking GPIO 16
    [  178.759432] list_irq: irq for pin 16 is 173
    [  178.759440] list_irq: Checking GPIO 17
    [  178.759478] list_irq: irq for pin 17 is 174
    [  178.760982] list_irq: Checking GPIO 18
    [  178.761020] list_irq: irq for pin 18 is 175
    [  178.762546] list_irq: Checking GPIO 19
    [  178.762586] list_irq: irq for pin 19 is 176
    [  178.764090] list_irq: Checking GPIO 20
    [  178.764128] list_irq: irq for pin 20 is 177
    [  178.764135] list_irq: Checking GPIO 21
    [  178.764173] list_irq: irq for pin 21 is 178
    [  178.765697] list_irq: Checking GPIO 22
    [  178.765739] list_irq: irq for pin 22 is 179
    [  178.765747] list_irq: Checking GPIO 23
    [  178.765785] list_irq: irq for pin 23 is 180
    [  178.765793] list_irq: Checking GPIO 24
    [  178.765831] list_irq: irq for pin 24 is 181
    [  178.765839] list_irq: Checking GPIO 25
    [  178.765878] list_irq: irq for pin 25 is 182
    [  178.765886] list_irq: Checking GPIO 26
    [  178.765928] list_irq: irq for pin 26 is 183
    [  178.765936] list_irq: Checking GPIO 27
    [  178.765975] list_irq: irq for pin 27 is 184
    
  • rreignier
    rreignier New Member Posts: 67 ✭✭

    I have read the several up specific files in the kernel:

    • drivers/platform/x86/up_board.c
    • drivers/platform/x86/up_board_pinctrl.c
    • drivers/mfd/upboard-fpga.c
    • drivers/pinctrl/pinctrl-upboard.c
    • include/linux/mfd/upboard-fpga.h

    and did not found any major changes between UpBoard (original) and the Up Xtreme so I could not find any differences about the interrupts. So maybe there is something on the Bios or FPGA sides?

    I use kernel from Up repo: Linux up 5.0.0-1-generic #2~upboard4-Ubuntu SMP Thu Jul 25 13:35:27 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

    And the BIOS seems to be the latest version: DMI: AAEON UP-WHL01/UP-WHL01, BIOS UPW1AM14 10/17/2019.

    @DCleri or @Dan O'Donovan do you have any idea about that?

    Thanks.

  • rreignier
    rreignier New Member Posts: 67 ✭✭

    I have just seem in the wiki that the interrupts are not supported on Raspberry Pi pins and we should use linux numbering scheme.

    Currently interrupts are only supported using the linux gpio numbering scheme (e.g. use 432 gpio umber instead of Rpi gpio number 27).

    Source: https://wiki.up-community.org/Pinout_Xtreme#Interrupts

    So my question now is, how to get this number from the pinout on the wiki?

  • DCleri
    DCleri Administrator, AAEON Posts: 1,213 admin

    Hi @rreignier

    That is correct, we will update that table as soon as possible and include the necessary information (Linux Numbering for UP Xtreme Pins).

  • rreignier
    rreignier New Member Posts: 67 ✭✭

    Hi @DCleri

    Thanks a lot.

    For my experiments, and for others, the Linux gpio number for that pin 25 is 266. But I did not find a method to deduce it for every pins. So I am interested if anyone has a better solution.

  • Dan O'Donovan
    Dan O'Donovan Administrator, Moderator, Emutex Posts: 241 admin

    Hi @rreignier
    Until the wiki here is updated, you can find the Linux GPIO numbers for UP Xtreme here (see the column titled "Sysfs GPIO"): https://github.com/eclipse/mraa/blob/master/docs/up_xtreme.md#pin-mapping

  • rreignier
    rreignier New Member Posts: 67 ✭✭

    Hi @Dan O'Donovan

    Thanks a lot for the pointer, this table is quite convenient and should really be on the wiki.

    For my education, could you explain to figure out these numbers with kernel source code or sysfs information?

  • seekborrow
    seekborrow New Member Posts: 7

    @Dan O'Donovan said:
    Hi @rreignier penalty kick online
    Until the wiki here is updated, you can find the Linux GPIO numbers for UP Xtreme here (see the column titled "Sysfs GPIO"): https://github.com/eclipse/mraa/blob/master/docs/up_xtreme.md#pin-mapping

    Many thanks for that information. This table is quite useful, and it really ought to be uploaded to the wiki.

Privacy Policy