GPIO Interrupt

Hi,

I’m a beginner to jetson tx2. I am reading signal from GPIO pin to detect edges in signal. I want to go with interrupts but I do not have any idea to lead it with c language. can any on e help me to go with interrupt in GPIO?

hello sanjeewaapp,

you’re able to access the kernel sources via Jetson Download Center.
https://developer.nvidia.com/embedded/dlc/l4t-sources-28-1

please check the tegra_gpio_readl() functions for more details.
thanks

Hi Jerry,

Thanks for your reply. I’ll refer it. Where is it located?

hello sanjeewaapp,

you could check below for example,
R28.1_sources/kernel/kernel-4.4/drivers/gpio-tegra.c

Hi Jerry,

I got. Can I use it directly?

Thanks

Hi sanjeewaapp,

Have you tried the tegra_gpio_readl() function to get the result you want?
Any further support required?

Thanks

Hi kayccc,

I could not be able to figure it out. still I am searching a way to do it. Now I am looking to develop kernel module that can be used to interface GPIO. can you help me to figure it out readl() function?

Thanks

hello spke12,

you can refer to the tegra_gpio_readl() function to read the pin status, and implement your own interrupt function to handle that. thanks

hello Jerry,

You are saying that I have to implement my own kernel module aren’t you?

Thanks

hello spke12,

yes, please refer to that function and implement your own interrupt function.
thanks

Hello JerryChang,

we want to use the gpio pin as interrupt, just like spke12’s case.

I had saw the source code:
R28.1_sources/kernel/kernel-4.4/drivers/goio/gpio-tegra.c

And I also find some information in the /proc/interrupts.

256 tegra-gpio 125 Edge sdhci.cd

I had read the sourcecode:
R28.1_sources/kernel/kernel-4.4/drivers/mmc/host/sdhci-tegra.c

the cd detect pin is GPIO3_PP.05 and the device tree is
cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P,5) 0>

but in the sourcecode of sdhci-tegra.c

a.plat->cd_gpio = of_get_named_gpio(np, “cd-gpios”, 0);
b.gpio_is_valid(plat->cd_gpio)
c.tegra_host->cd_irq = gpio_to_irq(plat->cd_gpio);

d.disable_irq_wake(tegra_host->cd_irq);
e.enable_irq_wake(tegra_host->cd_irq);

then I try to find something like “request_irq or request_gpio_irq”

there is nothing here.

I don’t understand, how to bind the irq number to the interrupt respond server.

thanks.

hello wuyankun1986,

I don’t understand, how to bind the irq number to the interrupt respond server.
please refer to this function for more details,
thanks

r28.1_sources/kernel/kernel-4.4/drivers/gpio/gpiolib.c

int gpiod_to_irq(const struct gpio_desc *desc)
{
         struct gpio_chip        *chip;
         int                     offset;

         if (!desc)
                 return -EINVAL;
         chip = desc->chip;
         offset = gpio_chip_hwgpio(desc);
         return chip->to_irq ? chip->to_irq(chip, offset) : -ENXIO;
}
EXPORT_SYMBOL_GPL(gpiod_to_irq);