Zero interrupts

Has anyone used gpio interrupts on radax-zero? I have a problem with mraa and the kernel module both throw errors when trying to create an interrupt.

I’ve got the same question. The kernel documentation suggests that only certain of the GPIO pads are capable of generating interrupts, and that it varies from one SOC to another. I understand that not all of those pads are necessarily mapped to the 40-pin header. Does anyone happen to know which GPIO pins on the 40-pin header are capable of generating interrupts?

I think you misunderstood this. We do not have S905Y2’s datasheet, but you can take a look at page 244 for A311D and see all GPIO pins are capable of generating interrupt. It’s just that the IRQ space is larger than available pins, so higher part of it is unmapped and unusable.

You are correct, I did misunderstand. I spent some more time trying to make this work but still haven’t succeeded. I’m trying to implement a “gpio-keys” node in the device tree to use a hardware switch to send the “POWER_OFF” key event. I have this working fine with “gpio-keys-polled,” but I would prefer to have it generate a system interrupt rather than rely on polling.

The dts node I’m using is this:

   gpio-keys {
           compatible = "gpio-keys";

           power_key {
                   label = "PowerKey";
                   linux,code = <KEY_POWER>;
                   gpios = <&gpio_ao GPIOAO_3 GPIO_ACTIVE_LOW>;
                   interrupt-parent = <&gpio_intc>;
                   interrupts = <3 IRQ_TYPE_EDGE_RISING>;

On the “interrupts” line, I have also tried with IRQ_TYPE_BOTH and IRQ_TYPE_LEVEL_LOW but it doesn’t make a difference. I always get errors like this in dmesg:

[ 3.011323] genirq: Setting trigger mode 3 for irq 38 failed (meson_gpio_irq_set_type+0x0/0x100)
[ 3.022766] gpio-keys gpio-keys: Unable to claim irq 38; error -22
[ 3.028704] gpio-keys: probe of gpio-keys failed with error -22

I believe err -22 means invalid argument, but so far in testing I haven’t been able to figure out which argument is invalid or why it won’t work.

Incidentally, I based that dts block on the one for the sei610, which uses the same GPIO interrupt controller implementation as the Radxa Zero (in meson-g12-common.dts).

I’m doing my testing on mainline 5.10.90, patched with all of the commits to the official Radxa fork since Sept. 26, 2021.

Per doc try remove those 2 interrupt lines and see if that will work.

I should have mentioned that I did try it without the interrupts line but it did not make a difference. My next step is to start trying other GPIO pins to see if that works for some reason.

@theophile @RadxaYuntian I also meet this problem these days.

Per investigating into the source code of gpis-keys.c and ire-meson-gpio.c,
gpio-keys requests irqflags as 3 means IRQ_TYPE_EDGE_BOTH, see here in gpio_keys_setup_key().


While seems amlogic,meson-g12a-gpio-intc doesn’t support edge both, see drivers/irqchip/irq-meson-gpio.c:110

static const struct meson_gpio_irq_params axg_params = {

static const struct meson_gpio_irq_params sm1_params = {
	.support_edge_both = true,
	.edge_both_offset = 8,

static const struct of_device_id meson_irq_gpio_matches[] = {    
    { .compatible = "amlogic,meson-axg-gpio-intc", .data = &axg_params },
    { .compatible = "amlogic,meson-g12a-gpio-intc", .data = &axg_params },
    { .compatible = "amlogic,meson-sm1-gpio-intc", .data = &sm1_params },

And the -22 EINVAL throws here in meson_gpio_irq_type_setup()

	if (type == IRQ_TYPE_EDGE_BOTH) {
		if (!params->support_edge_both)
			return -EINVAL;

@RadxaYuntian I’ve read the A311D data sheet, and find that the GPIOAO lines has a dedicated interrupt chip called SCP, do you have detail of its usage? Is it possible to get edge triggered interrupts? So that we may use GPIOAO as gpio-keys irq source.

Sounds like gpio-keys can’t be used. Need both interrupts to handle button down and button up event.

I do not have any more details regarding this. Beware A311D belongs to g12b family so it may not work for Zero.