Using gpt1 capture in Linux

Module : IMX6ULL
BSP6 (TDX Wayland with XWayland Upstream 6.4.0-devel-20231110142117+build.0 (kirkstone))


I am trying to use the timer input capture pin to increase a count in a linux c program.

This is part of my device tree modifications

&iomuxc {
        pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_gpio1 &pinctrl_gpio2 &pinctrl_gpio3
		&pinctrl_gpio4 &pinctrl_gpio5>;

        pinctrl_gpt1cap: gpt1capgrp {
                fsl,pins = <
                        MX6UL_PAD_GPIO1_IO00__GPT1_CAPTURE1    0x1b040 /* SODIMM 8 */

. . .

&gpt1 {
        pinctrl-0 = <&pinctrl_gpt1cap>;
        status = "okay";

and on my device in ‘proc/interrupts’ i have

 25:      84966       GPC  55 Level     i.MX Timer Tick
164:          0  gpio-mxc   0 Edge      2190000.mmc cd
196:          0       GPC  94 Level     arm-pmu
197:        677       GPC  26 Level     2020000.serial
198:          0       GPC  28 Level     21ec000.serial
199:          0       GPC  29 Level     21f0000.serial
200:          0       GPC  30 Level     21f4000.serial
201:          0       GPC  17 Level     21fc000.serial
202:          2       GPC   6 Level     2284000.rng
203:        606       GPC   5 Level     mxsfb-drm
204:      25580       GPC  15 Level     bch
205:      26141       GPC  13 Level     mxs-dma
206:          0       GPC  31 Level     2008000.spi
207:          0       GPC  33 Level     2010000.spi
210:       8115       GPC 120 Level     20b4000.ethernet
211:          0       GPC 121 Level     20b4000.ethernet
212:          0       GPC  19 Level     rtc alarm
213:          0       GPC   8 Level     21cc000.pxp
214:          0       GPC  80 Level     20bc000.watchdog
215:        809       GPC  22 Level     mmc0
216:          0       GPC  46 Level     dcp-vmi-irq
217:          0       GPC  47 Level     dcp-irq
218:      28404       GPC  23 Level     mmc1
219:          0       GPC  42 Level     2184200.usb
220:          0       GPC  49 Level     imx_thermal
221:          0       GPC   2 Level     20ec000.dma-controller
IPI0:          0  CPU wakeup interrupts
IPI1:          0  Timer broadcast interrupts
IPI2:          0  Rescheduling interrupts
IPI3:          0  Function call interrupts
IPI4:          0  CPU stop interrupts
IPI5:      59574  IRQ work interrupts
IPI6:          0  completion interrupts
Err:          0

which is showing ‘GPC 55 Level i.MX Timer Tick’ so i believe my device tree is configured correctly.

I want to have a C program that takes pulses on this pin and either increases a timer count or lets me run an interrupt routine to increase a count or react to this input.

I have seen something like

#include <linux/interrupt.h>

if ( request_irq(irq_number, irq_handler, IRQF_SHARED, "interrupt_routine_name",
(void*)( &interrupt_data ) ) ) {
  printf("FAILED TO SETUP IRQ %i", irq_number);
  return -1;

but on my device i do not have interrupt.h in my usr/share/directory

I have found it within ‘/usr/src/linux-hwe-6.2-headers-6.2.0-37/include/linux’

I need some help on

(1) Which is the best way to do this and is using ‘request_irq’ the best method

(2) Do i need to add something to my kernel build (local.conf) to get the interrupt.h file added ?
[ I have looked online for the including the missing file BUT the responses i see, seem to think people know what they are doing with the Linux system and are not novices like me]

(3) Is there something i need to add to my GCC setup or make file ?

Hi @adrian !

Sorry for the delay.

Could you please share the output of tdx-info? (reference: Getting Device Information with Tdx-Info | Toradex Developer Center)

I don’t know if I understand this part.
When you say device, are you talking about your Colibri iMX6ULL module? Why would you a header to execute an application on your module?

Are you trying to develop a kernel driver/module?

To add the kernel sources to your SDK (that you will need to build yourself using Yocto), please refer to the article Linux SDKs | Toradex Developer Center (specifically the kernel-devsrc part :wink:).

Now trying to directly answer your questions:

AFAIK, if you need to use request_irq, you will need to develop a driver for it.

Please check the article shared above.

Please check the article shared above.

Please let me know if this helps you.

Best regards,