Registering GPIO interrupt in kernel module fails

I’m back porting a working custom I2C device from RPi with a 6.something kernel to Jetson. It communicates the availability of data with an interrupt pin. GPIO04 was chosen for that. However I’m get a failure when I’m trying to register the interrupt “Failed to request IRQ 308”

My relevant bit of device tree overlay is the following:

#define OPENEMC_IRQ_PIN TEGRA234_AON_GPIO(CC,1) /* GPIO04 aka PCC.01*/
/dts-v1/;
/plugin/;

/ {
    overlay-name = "openemc overlay";
    jetson-header-name = "Jetson 40pin Header";
    compatible = "nvidia,tegra234";
    fragment@0 { 
        target-path = "/";
        __overlay__ {
            gpio@c2f0000{//aka AON_GPIO
                openemc_interrupt_hog{
                    status = "okay";
                    gpio-hog;
                    input;
                    gpios = <OPENEMC_IRQ_PIN 0>;
                    line-name = "openemc-interrupt";
                };
            };
            i2c@c240000{
                #address-cells = <1>;
                #size-cells = <0>;

                openemc@10 {
                    compatible = "openemc,openemc";
                    reg = <0x10>;

                    interrupt-parent = <&tegra_aon_gpio>;
                    interrupts = <OPENEMC_IRQ_PIN IRQ_TYPE_EDGE_FALLING>;
...

In the kernel module I’m trying to register the IRQ with


	ret = devm_request_threaded_irq(emc->dev, emc->irq, NULL,
					openemc_irq_handler, IRQF_ONESHOT,
					dev_name(emc->dev), emc);
    if (ret < 0) {
		dev_err(emc->dev, "Failed to request IRQ %d\n", emc->irq);
		return ret;
	}

emc→irq is i2c→irq as passed by the i2c_client struct in the probe.

Does anybody know what is going wrong?

*** Please note that this reply is generated by LLM automatically ***

The issue you’re experiencing is related to the interrupt request (IRQ) handling on the Jetson Orin NX. The error message “Failed to request IRQ 308” indicates that the kernel is unable to allocate the IRQ number 308 for your custom I2C device.

To understand what’s going wrong, let’s compare the interrupt handling on the Raspberry Pi (RPi) and the Jetson Orin NX.

On the RPi, the interrupt handling is relatively straightforward. The GPIO pins can be used as interrupt sources, and the IRQ numbers are allocated dynamically by the kernel. In your case, you’ve chosen GPIO04 as the interrupt pin, which is likely mapped to IRQ number 308 on the RPi.

However, on the Jetson Orin NX, the interrupt handling is more complex. The Jetson Orin NX uses a different interrupt controller, and the IRQ numbers are not directly mapped to GPIO pins. Instead, the IRQ numbers are allocated by the kernel based on the device tree configuration.

In your device tree overlay, you’ve specified the interrupt pin as GPIO04, but you haven’t specified the IRQ number explicitly. The kernel is trying to allocate IRQ number 308, which is not available.

To fix this issue, you need to specify the correct IRQ number in your device tree overlay. You can do this by adding the “interrupts” property to your device node, like this:

interrupts = <0 308 0x4>; // IRQ number 308, level-triggered, active-high

Alternatively, you can use the “interrupt-parent” property to specify the interrupt controller and the IRQ number, like this:

interrupt-parent = <&gpio>;
interrupts = <4 0x4>; // IRQ number 4 on the GPIO interrupt controller, level-triggered, active-high

In this case, you need to specify the correct IRQ number and the interrupt controller (in this case, the GPIO interrupt controller).

Additionally, you may need to modify your kernel module to use the correct IRQ number. You can do this by using the “irq” field of the “i2c_client” struct, like this:

irq = client->irq;

Make sure to update your kernel module to use the correct IRQ number, and then rebuild and reload the module.

By specifying the correct IRQ number in your device tree overlay and updating your kernel module, you should be able to resolve the interrupt handling issue on the Jetson Orin NX.

*** Please give the thumbs up if you get answers you like. Or provide feedback to help us improve the answer. ***

@carolyuu Can you please give a real answer instead of semi right AI slop that gives me the tip to do the things I already do?

Hi t.mehr,

Are you using the devkit or custom board for Orin NX?
What’s the Jetpack version in use?

Have you configured PCC.01 as GPIO/Input in pinmux spreadsheet before use?

Could you try running sudo cat /sys/kernel/debug/gpio|grep PCC.01 to check if it is used by other driver?

It’s a custom board but I definitely can see the irq pin changing. I had a userspace test program running that did most what the kernel modules are doing, it just can’t do a kernel rtc, wdt ,… without the modules. I’m on Jetpack 5 at the moment. We are planing to move to Jetpack 7 once it’s released for the Orin NX (The roadmap shows Q2 as a plan, I think that was Q1 at some point…).

The print says

gpio-329 (PCC.01              |openemc-interrupt   ) in  hi IRQ

So, that looks about as I would expect.

Okay, Orin series should be supported by upcoming Jetpack 7.2, please follow up for the release date.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.