Quantcast
Channel: banana pi single board computer open source project official forum BPI team - Latest posts
Viewing all articles
Browse latest Browse all 43592

How to get IRQ number for GPIO?

$
0
0

Do you really think it is helpful? I was expecting an answer about software rather than hardware.

Actually I think I am close to the answer but some real help would be very appreciated.

First of all, I was right about gpio 71 on pin 13.

GPIO#71 is PC7 = SUNXI_PC_BASE+7 = 64+7 = 71.

For anybody else who will look for the same information: looks like command gpio readall shows correct gpio numbers in columns CPU. The source code where you can find useful information about GPIOs ( see https://github.com/BPI-SINOVOIP/BPI-M3-bsp ):

  • linux-sunxi/arch/arm/mach-sunxi/include/mach/pinctrl.h defines base numbers for banks (in my case SUNXI_PC_BASE=64).
  • linux-sunxi/drivers/pinctrl/pinctrl-sun8iw6.c defines GPIO banks:
`
static struct sunxi_pin_bank sun8i_w6_banks[] = {
    SUNXI_PIN_BANK(SUNXI_PIO_VBASE,   SUNXI_PB_BASE, 11, SUNXI_EINT_TYPE_GPIO, "PB", SUNXI_IRQ_EINTB),
    SUNXI_PIN_BANK(SUNXI_PIO_VBASE,   SUNXI_PC_BASE, 19, SUNXI_EINT_TYPE_NONE, "PC", SUNXI_IRQ_MAX  ),
    SUNXI_PIN_BANK(SUNXI_PIO_VBASE,   SUNXI_PD_BASE, 24, SUNXI_EINT_TYPE_NONE, "PD", SUNXI_IRQ_MAX  ),
    SUNXI_PIN_BANK(SUNXI_PIO_VBASE,   SUNXI_PE_BASE, 20, SUNXI_EINT_TYPE_NONE, "PE", SUNXI_IRQ_MAX  ),
    SUNXI_PIN_BANK(SUNXI_PIO_VBASE,   SUNXI_PF_BASE,  7, SUNXI_EINT_TYPE_NONE, "PF", SUNXI_IRQ_MAX  ),
    SUNXI_PIN_BANK(SUNXI_PIO_VBASE,   SUNXI_PG_BASE, 14, SUNXI_EINT_TYPE_GPIO, "PG", SUNXI_IRQ_EINTG),
    SUNXI_PIN_BANK(SUNXI_PIO_VBASE,   SUNXI_PH_BASE, 12, SUNXI_EINT_TYPE_GPIO, "PH", SUNXI_IRQ_EINTH),
    SUNXI_PIN_BANK(SUNXI_R_PIO_VBASE, SUNXI_PL_BASE, 13, SUNXI_EINT_TYPE_GPIO, "PL", SUNXI_IRQ_EINTL),
};

`

As we can see it specifies irq SUNXI_IRQ_MAX for PC bank. * linux-sunxi/drivers/pinctrl/pinctrl-sunxi.h defines the macros SUNXI_PIN_BANK:

`

 #define SUNXI_PIN_BANK(_mem_base, _pin_base, _number, _eint_type, _name, _irq)\
        {                            \
         .membase = (void __iomem *)_mem_base,        \
         .pin_base = _pin_base,                \
         .nr_pins  = _number,                \
         .eint_type = _eint_type,            \
         .name     = _name,                \
         .irq      = _irq,                \
        }

`

  • linux-sunxi/arch/arm/mach-sunxi/include/mach/sun8i/irqs-sun8iw6p1.h:

    #define SUNXI_IRQ_MAX (SUNXI_GIC_START + 256)

  • linux-sunxi/drivers/pinctrl/pinctrl-sunxi.c contains implementation of functions that I need but it is not clear how to call it and why it does not work through gpio_to_irq.


Viewing all articles
Browse latest Browse all 43592

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>