Hardware Timestamp Engine

Hello,

I want to test how the HTE driver works, I am creating a node based on what I see in the driver code:

diff --git a/hardware/nvidia/t23x/nv-public/tegra234.dtsi b/hardware/nvidia/t23x/nv-public/tegra234.dtsi
index f909b93..626c5d2 100644
--- a/hardware/nvidia/t23x/nv-public/tegra234.dtsi
+++ b/hardware/nvidia/t23x/nv-public/tegra234.dtsi
@@ -1766,6 +1766,19 @@
                        nvidia,gpio-controller = <&gpio_aon>;
                        #timestamp-cells = <1>;
                };
+
+#define GPIO_IN  TEGRA234_AON_GPIO(AA, 0)
+#define GPIO_OUT TEGRA234_AON_GPIO(AA, 1)
+
+               hte_test {
+                       status = "okay";
+                       compatible = "nvidia,tegra194-hte-test";
+                       in-gpios = <&gpio_aon GPIO_IN GPIO_ACTIVE_HIGH>;
+                       out-gpios = <&gpio_aon GPIO_OUT GPIO_ACTIVE_HIGH>;
+                       timestamps = <&hte_aon 0>;
+               };

But based on the errors, it seems is not defining the GPIOs correctly:

[    7.716209] tegra_hte_test bus@0:hte_test: failed to get gpio out
[    7.716212] tegra_hte_test: probe of bus@0:hte_test failed with error -22

I don’t understand why there is an error in the GPIO definition, Does someone know what the error is or Is there some reference to enable the tegra194-hte-test driver?

Thanks.

hello ManuelLeiva,

one thing strange here…
it should not being t194 since you’re working with AGX Orin, (which is t234 series)

Hello Jerry,

It is because the HTE driver is the same for t194 and t234

kernel-jammy-src/drivers/hte/hte-tegra194.c:

static const struct of_device_id tegra_hte_of_match[] = {
	{ .compatible = "nvidia,tegra194-gte-lic", .data = &t194_lic_hte},
	{ .compatible = "nvidia,tegra194-gte-aon", .data = &t194_aon_hte},
	{ .compatible = "nvidia,tegra234-gte-lic", .data = &t234_lic_hte},
	{ .compatible = "nvidia,tegra234-gte-aon", .data = &t234_aon_hte},
	{ }
};

Since is the same driver for t194 and t234, I would says that the test driver should work for T234.

kernel-jammy-src/drivers/hte/hte-tegra194-test.c:

static const struct of_device_id tegra_hte_test_of_match[] = {
	{ .compatible = "nvidia,tegra194-hte-test"},
	{ }
};

There is not a test driver for T234.

-Manuel

Hello Jerry,

The problem was solve, it was not related to the device tree.

Thanks.

hello ManuelLeiva,

thanks for status update,
could you please have a quick summarize about the root cause.

I think I was using the incorrect DT in extlinux configuration, but the GPIO configuration is correct.

Hello

I have enabled the HTE test driver but it seems the monitoring is successfully enabled.

The test driver sets an IRQ

ret = request_irq(ret, tegra_hte_test_gpio_isr,
			  IRQF_TRIGGER_RISING,
			  "tegra_hte_gpio_test_isr", &hte);

And I have added a debug message to this function

static irqreturn_t tegra_hte_test_gpio_isr(int irq, void *data)
{
	(void)irq;
	(void)data;

	pr_info("HTE tegra_hte_test_gpio_isr\n");

	return IRQ_HANDLED;
}

When the driver is loaded I can see the message below, It is receiving the interrupt correctly

[26491.796438] HTE tegra_hte_test_gpio_isr
[26508.179438] HTE tegra_hte_test_gpio_isr

The interrupt is received but If the monitoring is successfully enabled, the console should prints this message:

static enum hte_return process_hw_ts(struct hte_ts_data *ts, void *p)
{

	pr_info("HW timestamp(%u: %llu): %llu, edge: %s\n",
		desc->attr.line_id, ts->seq, ts->tsc,
		(ts->raw_level >= 0) ? ((ts->raw_level == 0) ?
					"falling" : "rising") : edge);

The message is not printed. The function process_hw_ts is the callback added when is enabled the enable the hardware timestamp.

 		ret = devm_hte_request_ts_ns(hte.pdev, &hte.desc[i],
					     process_hw_ts, NULL,
					     &hte.desc[i]);

If I use the user space consumer gpio-event-mon.c, using the same GPIOs I can get the timestamp:

nvidia@tegra-ubuntu:~/gpio$ sudo ./gpio-event-mon -n gpiochip1 -o 1 -r -b 10000 -t
Monitoring line 1 on gpiochip1
Initial line value: 0
GPIO EVENT at 22948895457984 on line 1 (1|1) rising edge
GPIO EVENT at 22957495457984 on line 1 (2|2) rising edge
GPIO EVENT at 22959911457984 on line 1 (3|3) rising edge
GPIO EVENT at 22963127457984 on line 1 (4|4) rising edge

Do you know if something more need to be enabled to use the HTE from a driver?

Regards.

hello ManuelLeiva,

all GPIO pins are IRQ capable,
may I double confirm which GPIO pin you’re used? since there’re GPIO controllers in SoC/AON domains.

Hello JerryChang

I am using PAA.00 and PAA.01

For the tegra194-hte-test driver, (not working) this is the configuration applied:

#define GPIO_CAN0_DOUT TEGRA234_AON_GPIO(AA, 0)
#define GPIO_CAN0_DIN  TEGRA234_AON_GPIO(AA, 1)
		hte_test {
			status = "okay";
			compatible = "nvidia,tegra194-hte-test";
			in-gpios = <&gpio_aon GPIO_CAN0_DIN GPIO_ACTIVE_HIGH>;
			out-gpios = <&gpio_aon GPIO_CAN0_DOUT GPIO_ACTIVE_HIGH>;
			timestamps = <&hte_aon 0>;
		};

And for user space consumer gpio-event-mon (working)

nvidia@tegra-ubuntu:~/gpio$ sudo gpiofind PAA.00
gpiochip1 0
nvidia@tegra-ubuntu:~/gpio$ sudo gpiofind PAA.01
gpiochip1 1

sudo ./gpio-event-mon -n gpiochip1 -o 1 -r -b 10000 -t
sudo gpioset —mode=wait gpiochip1 0=1 # Set interruption

Regards,

hello ManuelLeiva,

here’s default GPIO pin config.
for instance,

 	gpio@c2f0000 {
 		gpio-init-0 = <&gpio_aon_default>;
 		gpio_aon_default: default {
 			gpio-input = <
...
 				TEGRA234_AON_GPIO(AA, 0)
				TEGRA234_AON_GPIO(AA, 1)

according to pinmux spreadsheets, GPIO3_PAA.00/01 were all configured as input/Int PD,
please see-also developer guide, Changing the Pinmux.

JerryChang

Pinmux configuration was already applied. To be able to obtain the previous result reported I have to change the pinmux configuration like this:

		pinmux_aon: pinmux@c300000 {
			compatible = "nvidia,tegra234-pinmux-aon";
			reg = <0x0 0xc300000 0x0 0x4000>;
			pinctrl-names = "default";
			pinctrl-0 = <&jetson_io_pinmux_aon>;
			jetson_io_pinmux_aon: exp-header-pinmux {
				can0_dout_paa0 {
					nvidia,pins = "can0_dout_paa0";
					nvidia,function = "rsvd1";
					nvidia,pull = <TEGRA_PIN_PULL_NONE>;
					nvidia,tristate = <TEGRA_PIN_DISABLE>;
					nvidia,enable-input = <TEGRA_PIN_DISABLE>;
				};

				can1_stb_pbb0 {
					nvidia,pins = "can1_stb_pbb0";
					nvidia,function = "rsvd1";
					nvidia,pull = <TEGRA_PIN_PULL_NONE>;
					nvidia,tristate = <TEGRA_PIN_DISABLE>;
					nvidia,enable-input = <TEGRA_PIN_DISABLE>;
				};
			};
		};

For testing the GPIO configuration I shorted pins 29 and 31 on the carrier board’s 40-pin header.

After this change I confirmed the GPIOs are working, with the command: sudo gpioset --mode=wait gpiochip1 0=1 and sudo gpioget gpiochip1 1. Also gpio-event-mon works correctly and tegra194-hte-test reports the interrupt received, only the timestamp is not reported.

Regards,

Hi ManuelLeiva,

What’s the Jetpack version in use?

Have you referred to Generic Timestamp Engine — NVIDIA Jetson Linux Developer Guide 1 documentation for generic timestamp engine?

Please share the result of the following commands on your board.

$ sudo gpioinfo|grep -iE "PAA.00|PBB.00"

I am using Jetson Linux 36.3, JetPack 6.0

I am tring to enable the examples described in this documentation: Generic Timestamp Engine — NVIDIA Jetson Linux Developer Guide 1 documentation

This is the command output.

nvidia@tegra-ubuntu:~$ sudo gpioinfo|grep -iE "PAA.00|PBB.00"
	line   0:     "PAA.00"        "out"  output  active-high [used]
	line   8:     "PBB.00" "aon-output-high" output active-high [used]

Do you think I have and error in GPIO configuration? since I can read/write the GPIO and gpio-event-mon works correctly I think the configuratio is ok.
Pease notice the tegra194-hte-test is reporting an interrupt is received each 16 seconds, which is expected:

[ 1147.868889] HTE tegra_hte_test_gpio_isr
[ 1164.252883] HTE tegra_hte_test_gpio_isr
[ 1180.636887] HTE tegra_hte_test_gpio_isr
[ 1197.020885] HTE tegra_hte_test_gpio_isr

But there is no timestamp information, If the timestamp is read, the driver should print this message:

pr_info("HW timestamp(%u: %llu): %llu, edge: %s\n",...

Regards,

Hello

Since the user-space test application is working correctly, I am doing a comparison of the configuration applied in the HTE driver (hte-tegra194.c), by the user-space app and test driver

Test driver configuration

tegra_hte_line_xlate:
[  867.862586] tegra_hte c1e0000.hardware-timestamp: requested id:0, xlated id:75
tegra_hte_en_dis_common:
[  867.862607] tegra_hte c1e0000.hardware-timestamp: line: 75, slice 2, line_bit 11, reg:0x80

Test application configuration

tegra_hte_line_xlate
[ 1310.090943] tegra_hte c1e0000.hardware-timestamp: requested id:317, xlated id:74
tegra_hte_en_dis_common:
[ 1310.090965] tegra_hte c1e0000.hardware-timestamp: line: 74, slice 2, line_bit 10, reg:0x80

Since I am using the same GPIO to receive the event I was expecting a very similar configuration,

The main difference is the requested id:

  • test driver consumer: requested id:0
  • user space consumer: requested id:317

The other values are very similar, I have seen the differences between both configuration is because the driver has 2 different table for GPIO mapping. The driver explains this with this comment:

	 * There are two paths GPIO consumers can take as follows:
	 * 1) The consumer (gpiolib-cdev for example) which uses GPIO global
	 * number which gets assigned run time.
	 * 2) The consumer passing GPIO from the DT which is assigned
	 * statically for example by using TEGRA194_AON_GPIO gpio DT binding.

This is the table mapping used by:

  • Test driver consumer
struct tegra_hte_line_mapped tegra234_aon_gpio_sec_map[] = {
  • User space consumer
struct tegra_hte_line_mapped tegra234_aon_gpio_map[]

But about the difference in the requested id value, when I am using the the test driver consumer, this value is assigned here

static int tegra_hte_line_xlate(struct hte_chip *gc,
				const struct of_phandle_args *args,
				struct hte_ts_desc *desc, u32 *xlated_id)
{
...
	if (args) {
...
		desc->attr.line_id = args->args[0];
...

Currently I am loading the driver with no parameter (sudo insmod hte-tegra194-test.ko).

Do you know what the variable args->args[0]; represent? it seems is a variable taken from some parameters, Should I load the driver using some parameter?

Regards,

The args->args[0]; is read from the device tree:

			timestamps = <&hte_aon 1>;

Setting this value to 1, now I am getting the the timestamp.

nvidia@tegra-ubuntu:~$ sudo dmesg | grep "HW timestamp"                                                                                                                                                     
[   12.767845] HW timestamp(1: 1): 38507387040, edge: rising
[   29.151851] HW timestamp(1: 2): 54891386272, edge: rising
[   45.535847] HW timestamp(1: 3): 71275386240, edge: rising
[   61.919844] HW timestamp(1: 4): 87659378848, edge: rising
[   78.303843] HW timestamp(1: 5): 104043384768, edge: rising
[   94.687834] HW timestamp(1: 6): 120427378912, edge: rising
[  111.071833] HW timestamp(1: 7): 136811378880, edge: rising
[  127.455830] HW timestamp(1: 8): 153195381728, edge: rising
[  143.839841] HW timestamp(1: 9): 169579383296, edge: rising
[  160.223843] HW timestamp(1: 10): 185963378688, edge: rising

HTE Driver GPIO Debugging Guide
The error you’re seeing indicates that the driver is unable to acquire the GPIO you’re defining.
Based on your DTS changes, it looks like the issue is related to how the GPIOs are being defined
and passed to the device tree.

  1. Check GPIO Definition Format
    The in-gpios and out-gpios properties follow the general format for specifying GPIOs, but the
    macro definitions for GPIO_IN and GPIO_OUT may be incorrect.
  2. Correct GPIO Definition in Device Tree
    Make sure the correct GPIO controller and index are being passed.
    Example:
    hte_test {
    status = “okay”;
    compatible = “nvidia,tegra194-hte-test”;
    in-gpios = <&gpio_aon 0 GPIO_ACTIVE_HIGH>; // Assuming GPIO 0 for input
    out-gpios = <&gpio_aon 1 GPIO_ACTIVE_HIGH>; // Assuming GPIO 1 for output
    timestamps = <&hte_aon 0>;
    };
  3. Cross-Check GPIO Controller
    Verify that the gpio_aon node is correct and using the right base address.
    Example:
    gpio_aon: gpio@6000d000 {
    compatible = “nvidia,tegra234-gpio”, “nvidia,tegra194-gpio”;
    reg = <0x0 0x6000d000 0x0 0x1000>;
    #gpio-cells = <2>;
    gpio-controller;

    };
  4. Enable the HTE Test Driver
    Ensure that the nvidia,tegra194-hte-test driver is correctly enabled.
  5. Debugging the GPIO Allocation
    To debug further, modify the driver code to log more information when the GPIO is requested, or
    enable dynamic debug logs:
    echo ‘file drivers/gpio/gpiolib.c +p’ > /sys/kernel/debug/dynamic_debug/control
    This will provide more insight into why the GPIO allocation is failing