Generic Timestamp Engine

Applies to: Jetson AGX Orin series

Note

This driver is experimental, and is not promised to be stable.

The API is subject to change in future releases, and is not enabled by default.

GPIO direction change falling and rising information is not reliable using GTE, but GTE monitoring LIC IRQ can convey that information correctly.

The Jetson Generic Timestamp Engine (GTE) provides real-time timestamping for the state change of the Legacy Interrupt Controller (LIC) interrupt lines and the Always On (AON) domain GPIOs. The GPIOs that will be monitored must be configured as input and as GPIO IRQ. The GTE kernel device driver provides APIs for clients to register, retrieve, and unregister LIC and AON GPIO lines. This guide provides information about how use GTE the kernel driver. Follow the device tree binding documentation tegra-gte.yaml that comes with the kernel sources for more information.

The GTE kernel driver is enabled by default and is loaded on boot. After it is loaded, it creates the /dev/gtechip0 character device node that will be used by a user space utility to monitor AON GPIO lines the from user space.

The GTE kernel driver is accompanied by a kernel sample test driver which demonstrates how to monitor a LIC interrupt line and AON GPIO for state changes. When a monitored line’s state changes, the GTE hardware on the NVIDIA® Jetson™ device timestamps the change. A client program can use the GTE kernel driver API to retrieve the timestamp for the configured signal. The sample test driver is the kernel module tegra194_gte_test.ko and comes pre-installed.

The GTE kernel driver is also accompanied by a user space sample application which demonstrates how to monitor AON GPIO from user space.

Note

You must ensure that GPIOs are not being used by any other kernel drivers or user space applications, and are programmed with appropriate pinmux configurations.

Running Sample GTE Tests

Running tests is described for the GTE feature’s default setup. If you modify the setup, change the test procedures appropriately.

To run sample GTE tests, you must short pins 32 and 16 on the carrier board’s 40-pin header, where pin 32 is AON GPIO BB-1 configured as input, and pin 16 is AON GPIO BB-0 configured as output.

You must log in to the Jetson device as root to run any of the sample GTE tests.

To run the GTE test kernel driver

  1. Enter this command:

    $ insmod <path to tegra194_gte_test.ko> lic_irq=25 gpio_in=314 gpio_out=313
    

    In this example:

    • tegra194_gte_test.ko refers to the sample test driver and is pre-installed in the rootfs.

    • lic_irq specifies the physical LIC (Legacy Interrupt Controller) IRQ number for 3160000.i2c device.

    • gpio_in and gpio_out, for GPIO pins BB1 and BB0 respectively, can be derived from reading the file /sys/kernel/debug/gpio.

    • The GPIO and LIC IRQ number differs between supported devices and kernel versions.

    The parameter values shown are suggested as starting points. You may change any of them.

  2. Enter this command to enable kernel debug messages:

    $ dmesg -n8
    
  3. Enter this command to enable GTE monitoring of GPIO 314:

    $ echo 1 >/sys/kernel/tegra_gte_test/gpio_en_dis
    

    If GTE monitoring is successfully enabled, the Jetson device’s console prints this message:

    GPIO HW Timestamp: raw xxxx, ns yyyy
    

    Where xxxx represents the GTE timestamp in raw form, and yyyy represents the timestamp in nanoseconds.

  4. Enter this command to enable GTE monitoring of LIC IRQ line 25 (the I2C0 controller interrupt line):

    $ echo 1 >/sys/kernel/tegra_gte_test/lic_irq_en_dis
    
  5. Enter this command to test LIC IRQ by reading the EEPROM and generating I2C interrupts:

    $ i2cdump -y 0 0x50
    
  6. Enter this command to read the LIC IRQ timestamp:

    $ cat /sys/kernel/tegra_gte_test/lic_irq_ts
    

    If the timestamp is read successfully, the Jetson device’s console prints this message:

    ts_raw: xxxx, ts_ns: yyyy
    

    Where xxxx represents the GTE timestamp in raw form, and yyyy represents the timestamp in nanoseconds.

  7. Enter this command to disable GTE GPIO monitoring:

    $ echo 0 >/sys/kernel/tegra_gte_test/gpio_en_dis
    
  8. Enter this command to disable GTE LIC IRQ monitoring:

    $ echo 0 >/sys/kernel/tegra_gte_test/lic_irq_en_dis
    

To run the GTE user space sample application

  1. If gcc is not already installed on the Jetson device, enter this command on the Jetson device to install it:

    $ apt install -y gcc
    
  2. From the host, copy <kernel_source>/nvidia-oot/tools/tegra-gte/tegra_gte_mon.c to a directory on the Jetson device.

  3. Compile tegra_gte_mon.c:

    $ gcc -I /usr/src/nvidia/nvidia-oot/include/uapi tegra_gte_mon.c -o gte_mon
    
  4. Run the following command to start the sample application, which starts the timestamping events:

    $ ./gte_mon -d gtechip0 -g 314 -r -f &
    

-g 314 specifies the AON (Always On) BB 1 GPIO pin. You may change this value to use gte_mon on different pins.

-r and -f specify timestamping events on rising and falling edges.

-d gtechip0 specifies GTE chip device 0, which internally maps to GTE instance for monitoring AON events.

Note

This command prints a description of the application’s usage:

$ ./gte_mon -h
  1. Start toggling GPIO 313 to generate observable events by following generic GPIO subsystem related documentation available at kernel-source/Documentation/driver-api/gpio/.

    The sample application prints this message:

    HW timestamp GPIO EVENT yyyy
    
  2. To close the sample application, run the following command:

    $ fg
    

    Then press Ctrl+C.