xref: /linux/Documentation/driver-api/hte/tegra-hte.rst (revision 200323768787a0ee02e01c35c1aff13dc9d77dde)
1.. SPDX-License-Identifier: GPL-2.0+
2
3HTE Kernel provider driver
4==========================
5
6Description
7-----------
8The Nvidia tegra HTE provider also known as GTE (Generic Timestamping Engine)
9driver implements two GTE instances: 1) GPIO GTE and 2) LIC
10(Legacy Interrupt Controller) IRQ GTE. Both GTE instances get the timestamp
11from the system counter TSC which has 31.25MHz clock rate, and the driver
12converts clock tick rate to nanoseconds before storing it as timestamp value.
13
14GPIO GTE
15--------
16
17This GTE instance timestamps GPIO in real time. For that to happen GPIO
18needs to be configured as input. Only the always on (AON) GPIO controller
19instance supports timestamping GPIOs in real time as it is tightly coupled with
20the GPIO GTE. To support this, GPIOLIB adds two optional APIs as mentioned
21below. The GPIO GTE code supports both kernel and userspace consumers. The
22kernel space consumers can directly talk to HTE subsystem while userspace
23consumers timestamp requests go through GPIOLIB CDEV framework to HTE
24subsystem. The hte devicetree binding described at
25``Documentation/devicetree/bindings/timestamp`` provides an example of how a
26consumer can request an GPIO line.
27
28See gpiod_enable_hw_timestamp_ns() and gpiod_disable_hw_timestamp_ns().
29
30For userspace consumers, GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE flag must be
31specified during IOCTL calls. Refer to ``tools/gpio/gpio-event-mon.c``, which
32returns the timestamp in nanoseconds.
33
34LIC (Legacy Interrupt Controller) IRQ GTE
35-----------------------------------------
36
37This GTE instance timestamps LIC IRQ lines in real time. The hte devicetree
38binding described at ``Documentation/devicetree/bindings/timestamp``
39provides an example of how a consumer can request an IRQ line. Since it is a
40one-to-one mapping with IRQ GTE provider, consumers can simply specify the IRQ
41number that they are interested in. There is no userspace consumer support for
42this GTE instance in the HTE framework.
43
44The provider source code of both IRQ and GPIO GTE instances is located at
45``drivers/hte/hte-tegra194.c``. The test driver
46``drivers/hte/hte-tegra194-test.c`` demonstrates HTE API usage for both IRQ
47and GPIO GTE.
48