Intro to Hardware timestamping engine
Subsystems (6)
Dipen Patel
maintainerv5 cover Intro to Hardware timestamping engine
This patch series introduces new subsystem called hardware timestamping engine (HTE). It offers functionality such as timestamping through hardware means in realtime. The HTE subsystem centralizes HTE provider and consumers where providers can register themselves and the consumers can request interested entity which could be lines, GPIO, signals or buses. The HTE subsystem provides timestamp in nano seconds, having said that the provider need to convert the timestamp if its not in that unit. There was upstream discussion about the HTE at
https://lore.kernel.org/lkml/[email protected]/
To summarize upstream discussion:
- It was suggested by Linus and Kent to extend GPIOLIB and supporting GPIO drivers to add HTE functionality and I agreed to experiment with it. This patch series implements and extends GPIOLIB, GPIOLIB-CDEV and GPIO tegra driver.
- Discussed possibility to add HTE provider as irqchip instead which was argued against as HTE devices are not necessarily event emitting devices. From RFC version 2 however, emulated threaded irq style implementation.
- Discussed other possibility if HTE device can be added as posix clock type like PTP clocks. That was argued against since HTE devices are not necessarily tightly coupled with hardware clock.
Typical HTE provider does following:
- Register itself with HTE subsystem
- Provide request, release, enable, disable timestamp and get_clk_src_info callbacks to HTE subsystem.
- Provide optional xlate callback to the subsystem which can translate consumer provided logical ids into actual ids of the entity, where entity here is the provider dependent and could be GPIO, in chip lines or signals, buses etc...This converted id is used as communication token between HTE subsystem and the provider.
- Push timestamps to the subsystem.
- Unregister itself on exit.
Typical HTE consumer does following:
- Request interested entity it wishes to timestamp in realtime to the subsystem.
- The subsystem does necessary communications with the provider to complete the request, which includes translating logical id of the entity to provider dependent physical/actual id and enabling hardware timestamping on requested id.
- The request includes callbacks, it will be used to push timestamps. Optionally, the consumer can provided threaded callback, if specified, the HTE subsystem uses workqueue executing the secondary callback.
- Release entity and its resources.
HTE and GPIOLIB:
- For the HTE provider which can timestamp GPIO lines.
- For the userspace GPIO consumers, the GPIOLIB CDEV framework are extended as a frontend to the HTE. The kernel space consumers request GPIO lines directly to HTE subsystem.
- Tegra194 AON GPIO controller has HTE support known as GTE (Generic Timestamping Engine). The tegra gpio driver is modified to accommodate HTE functionality.
Changes in V2:
- Removed buffer management and related APIs from the HTE core.
- Removed timestamp retrieve APIs from the HTE core.
- Modified request API with two callbacks, second callback is invoked in thread context and is optional, while first callback is mandatory and used to push timestamp data to consumers.
- Replaced hte with hardware-timestamping in DT bindings as hte appeared too short according to review comments.
Changes in V3:
- Corrected grammatical errors in HTE documentation and its bindings documents.
- Removed multi-plural words in the HTE DT bindings.
- Reflected changes done in DT bindings in the respective source codes.
- Separated previous patch 07 into two patches in this series as 07 and 08.
- Corrections in MAINTAINERS file.
Changes in V4:
- Removed hardware-timestamp-engine device tree property from gpio.txt.
- Added hte_req_ts_by_linedata_ns.
- Removed hte_req_ts_by_hte_name.
- Renamed devm_of_hte_request_ts to devm_of_hte_request_ts_ns.
- Corrected hte ts seqeunce counter handling in hte related code in gpiolib-cdev code.
- Added line level detection in Tegra GPIO HTE provider.
- Corrected GPIO line level calculation in gpiolib-cdev.
Changes in V5:
- Minor changes in dt-bindings
- Removed kernel thread in the HTE core.
There are patches pending to add HTE provider for another Nvidia Tegra chip which will be pushed after this patch set.
Dipen Patel (11):
Documentation: Add HTE subsystem guide
drivers: Add hardware timestamp engine (HTE)
hte: Add tegra194 HTE kernel provider
dt-bindings: Add HTE bindings
hte: Add Tegra194 IRQ HTE test driver
gpiolib: Add HTE support
gpio: tegra186: Add HTE in gpio-tegra186 driver
gpiolib: cdev: Add hardware timestamp clock type
tools: gpio: Add new hardware clock type
hte: Add tegra GPIO HTE test driver
MAINTAINERS: Added HTE Subsystem
.../hte/hardware-timestamps-common.yaml | 29 + .../devicetree/bindings/hte/hte-consumer.yaml | 43 + .../bindings/hte/nvidia,tegra194-hte.yaml | 82 ++ Documentation/hte/hte.rst | 83 ++ Documentation/hte/index.rst | 22 + Documentation/hte/tegra194-hte.rst | 52 ++ Documentation/index.rst | 1 + MAINTAINERS | 8 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/gpio/gpio-tegra186.c | 81 +- drivers/gpio/gpiolib-cdev.c | 247 +++++- drivers/gpio/gpiolib.c | 58 ++ drivers/gpio/gpiolib.h | 1 + drivers/hte/Kconfig | 50 ++ drivers/hte/Makefile | 5 + drivers/hte/hte-tegra194-gpio-test.c | 273 ++++++ drivers/hte/hte-tegra194-irq-test.c | 179 ++++ drivers/hte/hte-tegra194.c | 690 +++++++++++++++ drivers/hte/hte.c | 828 ++++++++++++++++++ include/linux/gpio/consumer.h | 16 +- include/linux/gpio/driver.h | 10 + include/linux/hte.h | 253 ++++++ include/uapi/linux/gpio.h | 3 + tools/gpio/gpio-event-mon.c | 6 +- 25 files changed, 2986 insertions(+), 37 deletions(-) create mode 100644 Documentation/devicetree/bindings/hte/hardware-timestamps-common.yaml create mode 100644 Documentation/devicetree/bindings/hte/hte-consumer.yaml create mode 100644 Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yaml create mode 100644 Documentation/hte/hte.rst create mode 100644 Documentation/hte/index.rst create mode 100644 Documentation/hte/tegra194-hte.rst create mode 100644 drivers/hte/Kconfig create mode 100644 drivers/hte/Makefile create mode 100644 drivers/hte/hte-tegra194-gpio-test.c create mode 100644 drivers/hte/hte-tegra194-irq-test.c create mode 100644 drivers/hte/hte-tegra194.c create mode 100644 drivers/hte/hte.c create mode 100644 include/linux/hte.h
base-commit: f8833a2b23562be2dae91775127c8014c44d8566
Signature · 1 line
2.17.1
Dipen Patel
maintainerPATCH v5 1/11 Documentation: Add HTE subsystem guide
Adding hte document which can help understand various APIs implemented in HTE framework for the HTE producers and the consumers.
---
Changes in v2:
- Removed explanation, instead added kernel-doc references.
Changes in v3:
- Addressed grammatical errors.
Changes in v4:
- Added new API hte_req_ts_by_linedata_ns description.
- Removed hte_req_ts_by_hte_name.
Documentation/hte/hte.rst | 83 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Documentation/hte/hte.rst
Documentation/hte/hte.rst new file +83 -0
@@ -0,0 +1,83 @@ +============================================ +The Linux Hardware Timestamping Engine (HTE) +============================================ + +:Author: Dipen Patel + +Introduction +------------ + +Certain devices have built in hardware timestamping engines which can +monitor sets of system signals, lines, buses etc... in realtime for state +change; upon detecting the change they can automatically store the timestamp at +the moment of occurrence. Such functionality may help achieve better accuracy +in obtaining timestamps than using software counterparts i.e. ktime and +friends. + +This document describes the API that can be used by hardware timestamping +engine provider and consumer drivers that want to use the hardware timestamping +engine (HTE) framework. Both consumers and providers must include +#include <linux/hte.h>. + +The HTE framework APIs for the providers +---------------------------------------- + +.. kernel-doc:: drivers/hte/hte.c + :functions: devm_hte_register_chip hte_push_ts_ns + +The HTE framework APIs for the consumers +---------------------------------------- + +.. kernel-doc:: drivers/hte/hte.c + :functions: devm_of_hte_request_ts_ns hte_req_ts_by_linedata_ns hte_release_ts hte_enable_ts hte_disable_ts hte_get_clk_src_info + +The HTE framework public structures +----------------------------------- +.. kernel-doc:: include/linux/hte.h + +More on the HTE timestamp data +------------------------------ +The struct hte_ts_data is used to pass timestamp details between the consumers +and the providers. It expresses timestamp data in nanoseconds in u64 data +type. For now all the HTE APIs using struct hte_ts_data require tsc to be in +nanoseconds. An example of the typical hte_ts_data data life cycle, for the +GPIO line is as follows:: + + - Monitors GPIO line change. + - Detects the state change on GPIO line. + - Converts timestamps in nanoseconds and stores it in tsc. + - Stores GPIO raw level in raw_level variable if the provider has that + hardware capability. + - Pushes this hte_ts_data object to HTE subsystem. + - HTE subsystem increments seq counter and invokes consumer provided callback. + Based on callback return value, the HTE core invokes secondary callback in + the thread context. + +HTE subsystem debugfs attributes +-------------------------------- +HTE subsystem creates debugfs attributes at ``/sys/kernel/debug/hte/``. +It also creates line/signal-related debugfs attributes at +``/sys/kernel/debug/hte/<provider>/<label or line id>/``. + +`ts_requested` + The total number of entities requested from the given provider, + where entity is specified by the provider and could represent + lines, GPIO, chip signals, buses etc... + The attribute will be available at + ``/sys/kernel/debug/hte/<provider>/``. + + Read-only value + +`total_ts` + The total number of entities supported by the provider. + The attribute will be available at + ``/sys/kernel/debug/hte/<provider>/``. + + Read-only value + +`dropped_timestamps` + The dropped timestamps for a given line. + The attribute will be available at + ``/sys/kernel/debug/hte/<provider>/<label or line id>/``. + + Read-only value
Signature · 1 line
2.17.1
Re: [PATCH v5 01/11] Documentation: Add HTE subsystem guide
Documentation/hte/hte.rst line 6
Quoted 6 lines · Dipen Patel
+============================================
Documentation/hte/hte.rst new file +5
-0+The Linux Hardware Timestamping Engine (HTE) +============================================ + +:Author: Dipen Patel +
Please learn how to convey semantics with rst format, see further comments below.
Documentation/hte/hte.rst line 21
Quoted 5 lines
Documentation/hte/hte.rst new file +5
-0+This document describes the API that can be used by hardware timestamping +engine provider and consumer drivers that want to use the hardware timestamping +engine (HTE) framework. Both consumers and providers must include +#include <linux/hte.h>. +
Maybe it's better to write as `... providers must ``#include <linux/hte.h>```.
Quoted 14 lines
Documentation/hte/hte.rst new file +14
-0+The HTE framework APIs for the providers +---------------------------------------- + +.. kernel-doc:: drivers/hte/hte.c + :functions: devm_hte_register_chip hte_push_ts_ns + +The HTE framework APIs for the consumers +---------------------------------------- + +.. kernel-doc:: drivers/hte/hte.c + :functions: devm_of_hte_request_ts_ns hte_req_ts_by_linedata_ns hte_release_ts hte_enable_ts hte_disable_ts hte_get_clk_src_info + +The HTE framework public structures +-----------------------------------
Documentation/hte/hte.rst line 45
Quoted 10 lines
Documentation/hte/hte.rst new file +10
-0+.. kernel-doc:: include/linux/hte.h + +More on the HTE timestamp data +------------------------------ +The struct hte_ts_data is used to pass timestamp details between the consumers +and the providers. It expresses timestamp data in nanoseconds in u64 data +type. For now all the HTE APIs using struct hte_ts_data require tsc to be in +nanoseconds. An example of the typical hte_ts_data data life cycle, for the +GPIO line is as follows:: +
When we talk about name terms found in actual code (like keywords or variable names), it is customary to enclose them inside inline code (for example, ``struct what`` or ``u64 what``).
Quoted 28 lines
+ - Monitors GPIO line change.
+ - Detects the state change on GPIO line.
+ - Converts timestamps in nanoseconds and stores it in tsc.
+ - Stores GPIO raw level inraw_levelvariable if the provider has that
+ hardware capability.
+ - Pushes thishte_ts_dataobject to HTE subsystem.
+ - HTE subsystem increments seq counter and invokes consumer provided callback.
+ Based on callback return value, the HTE core invokes secondary callback in
+ the thread context.Documentation/hte/hte.rst new file +19
-0+ +HTE subsystem debugfs attributes +-------------------------------- +HTE subsystem creates debugfs attributes at ``/sys/kernel/debug/hte/``. +It also creates line/signal-related debugfs attributes at +``/sys/kernel/debug/hte/<provider>/<label or line id>/``. + +`ts_requested` + The total number of entities requested from the given provider, + where entity is specified by the provider and could represent + lines, GPIO, chip signals, buses etc... + The attribute will be available at + ``/sys/kernel/debug/hte/<provider>/``. + + Read-only value + +`total_ts` + The total number of entities supported by the provider. + The attribute will be available at
Documentation/hte/hte.rst line 83
Quoted 10 lines
Documentation/hte/hte.rst new file +10
-0+ ``/sys/kernel/debug/hte/<provider>/``. + + Read-only value + +`dropped_timestamps` + The dropped timestamps for a given line. + The attribute will be available at + ``/sys/kernel/debug/hte/<provider>/<label or line id>/``. + + Read-only value
Since all these debugfs variables are read-only, we can say "Note that all these values are read-only".
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Jonathan Corbet
maintainerRe: [PATCH v5 01/11] Documentation: Add HTE subsystem guide
Quoted 10 lines · Bagas Sanjaya
Documentation/hte/hte.rst line 6
Quoted 6 lines · Dipen Patel
+============================================
Documentation/hte/hte.rst new file +5
-0+The Linux Hardware Timestamping Engine (HTE) +============================================ + +:Author: Dipen Patel +Please learn how to convey semantics with rst format, see further comments below.
That is the Sphinx "field list" syntax; it's pretty heavily used throughout the kernel documentation and doesn't seem to merit that sort of response...?
[...]
Quoted 10 lines
Documentation/hte/hte.rst line 45
Quoted 6 lines
Documentation/hte/hte.rst new file +6
-0+The struct hte_ts_data is used to pass timestamp details between the consumers +and the providers. It expresses timestamp data in nanoseconds in u64 data +type. For now all the HTE APIs using struct hte_ts_data require tsc to be in +nanoseconds. An example of the typical hte_ts_data data life cycle, for the +GPIO line is as follows:: +When we talk about name terms found in actual code (like keywords or variable names), it is customary to enclose them inside inline code (for example, ``struct what`` or ``u64 what``).
It's also customary to minimize markup. In the case of "struct whatever" the markup is actively harmful since it interferes with the automatic recognition and cross-referencing of the type.
jon
Dipen Patel
maintainerRe: [PATCH v5 01/11] Documentation: Add HTE subsystem guide
Hi,
Quoted 26 lines · Jonathan Corbet
Quoted 9 lines · Bagas Sanjaya
Documentation/hte/hte.rst line 6
Quoted 6 lines · Dipen Patel
+============================================
Documentation/hte/hte.rst new file +5
-0+The Linux Hardware Timestamping Engine (HTE) +============================================ + +:Author: Dipen Patel +Please learn how to convey semantics with rst format, see further comments below.
That is the Sphinx "field list" syntax; it's pretty heavily used throughout the kernel documentation and doesn't seem to merit that sort of response...?
[...]
Quoted 9 lines
Documentation/hte/hte.rst line 45
Quoted 6 lines
Documentation/hte/hte.rst new file +6
-0+The struct hte_ts_data is used to pass timestamp details between the consumers +and the providers. It expresses timestamp data in nanoseconds in u64 data +type. For now all the HTE APIs using struct hte_ts_data require tsc to be in +nanoseconds. An example of the typical hte_ts_data data life cycle, for the +GPIO line is as follows:: +When we talk about name terms found in actual code (like keywords or variable names), it is customary to enclose them inside inline code (for example, ``struct what`` or ``u64 what``).
Quoted 3 lines
It's also customary to minimize markup. In the case of "struct whatever" the markup is actively harmful since it interferes with the automatic recognition and cross-referencing of the type.
I agree, I will keep only necessary reference in this section.
Quoted 2 lines
jon
Dipen Patel
maintainerRe: [PATCH v5 01/11] Documentation: Add HTE subsystem guide
In reply to Bagas SanjayaHi Sanjaya,
I will address your comments in next patch version. Thanks for the comment.
Best,
Dipen Patel
Quoted 90 lines · Bagas Sanjaya
Documentation/hte/hte.rst line 6
Quoted 6 lines · Dipen Patel
+============================================
Documentation/hte/hte.rst new file +5
-0+The Linux Hardware Timestamping Engine (HTE) +============================================ + +:Author: Dipen Patel +Please learn how to convey semantics with rst format, see further comments below.
Documentation/hte/hte.rst line 21
Quoted 5 lines
Documentation/hte/hte.rst new file +5
-0+This document describes the API that can be used by hardware timestamping +engine provider and consumer drivers that want to use the hardware timestamping +engine (HTE) framework. Both consumers and providers must include +#include <linux/hte.h>. +Maybe it's better to write as `... providers must ``#include <linux/hte.h>```.
Quoted 14 lines
Documentation/hte/hte.rst new file +14
-0+The HTE framework APIs for the providers +---------------------------------------- + +.. kernel-doc:: drivers/hte/hte.c + :functions: devm_hte_register_chip hte_push_ts_ns + +The HTE framework APIs for the consumers +---------------------------------------- + +.. kernel-doc:: drivers/hte/hte.c + :functions: devm_of_hte_request_ts_ns hte_req_ts_by_linedata_ns hte_release_ts hte_enable_ts hte_disable_ts hte_get_clk_src_info + +The HTE framework public structures +-----------------------------------Documentation/hte/hte.rst line 45
Quoted 10 lines
Documentation/hte/hte.rst new file +10
-0+.. kernel-doc:: include/linux/hte.h + +More on the HTE timestamp data +------------------------------ +The struct hte_ts_data is used to pass timestamp details between the consumers +and the providers. It expresses timestamp data in nanoseconds in u64 data +type. For now all the HTE APIs using struct hte_ts_data require tsc to be in +nanoseconds. An example of the typical hte_ts_data data life cycle, for the +GPIO line is as follows:: +When we talk about name terms found in actual code (like keywords or variable names), it is customary to enclose them inside inline code (for example, ``struct what`` or ``u64 what``).
Quoted 28 lines
+ - Monitors GPIO line change.
+ - Detects the state change on GPIO line.
+ - Converts timestamps in nanoseconds and stores it in tsc.
+ - Stores GPIO raw level inraw_levelvariable if the provider has that
+ hardware capability.
+ - Pushes thishte_ts_dataobject to HTE subsystem.
+ - HTE subsystem increments seq counter and invokes consumer provided callback.
+ Based on callback return value, the HTE core invokes secondary callback in
+ the thread context.Documentation/hte/hte.rst new file +19
-0+ +HTE subsystem debugfs attributes +-------------------------------- +HTE subsystem creates debugfs attributes at ``/sys/kernel/debug/hte/``. +It also creates line/signal-related debugfs attributes at +``/sys/kernel/debug/hte/<provider>/<label or line id>/``. + +`ts_requested` + The total number of entities requested from the given provider, + where entity is specified by the provider and could represent + lines, GPIO, chip signals, buses etc... + The attribute will be available at + ``/sys/kernel/debug/hte/<provider>/``. + + Read-only value + +`total_ts` + The total number of entities supported by the provider. + The attribute will be available atDocumentation/hte/hte.rst line 83
Quoted 10 lines
Documentation/hte/hte.rst new file +10
-0+ ``/sys/kernel/debug/hte/<provider>/``. + + Read-only value + +`dropped_timestamps` + The dropped timestamps for a given line. + The attribute will be available at + ``/sys/kernel/debug/hte/<provider>/<label or line id>/``. + + Read-only valueSince all these debugfs variables are read-only, we can say "Note that all these values are read-only".
Dipen Patel
maintainerPATCH v5 2/11 drivers: Add hardware timestamp engine (HTE)
In reply to Dipen PatelSome devices can timestamp system lines/signals/Buses in real-time using the hardware counter or other hardware means which can give finer granularity and help avoid jitter introduced by software timestamping. To utilize such functionality, this patchset creates HTE subsystem where devices can register themselves as providers so that the consumers devices can request specific line from the providers.
It provides below APIs for the provider:
- devm_hte_register_chip -- To register the HTE provider.
- hte_push_ts_ns() -- To push timestamp data into HTE subsystem.
It provides below APIs for the consumer:
- devm_of_hte_request_ts_ns() -- Request timestamp functionality.
- hte_req_ts_by_linedata_ns -- To request timestamp functionality by using line data information provided by the consumer.
- hte_enable_ts() -- To disable timestamp functionality.
- hte_disable_ts() -- To enable timestamp functionality.
- hte_release_ts() -- To release timestamp functionality and its associated resources.
- hte_get_clk_src_info() -- To query clock source information from the provider
The detail about parameters and API usage are described in each functions definitions in drivers/hte/hte.c file.
The patch adds compilation support in Makefile and menu options in Kconfig.
---
Changes in v2:
- Removed buffer abstraction layer as well related APIs, HTE now will not store any data, instead will pass to consumer as soon as it is available.
- Removed unnecessary dynamical allocations
- Removed timestamp retrieve API
- Removed release, unregister related APIs as their counterpart are resource managed.
- Added kernel thread implementation if consumer indicates threaded callback during request API time.
- Changed hte_req_ts_by_dt_node API to remove device node exposure from the interface, instead consumer will their device node with property name that indicates the provider it wants to use.
Changes in v3:
- Addressed grammatical/spelling errors.
Changes in v4:
- Added hte_req_ts_by_linedata_ns and removed hte_req_ts_by_hte_name.
- Corrected API descriptions based on review comments.
- Droped HTE_CB_ERROR and HTE_CB_TS_DROPPED enums.
- Added line attribute structure in hte ts descriptor.
- Added raw_level field in hte ts data structure.
- Added match_from_linedata callback for the providers.
- Added edge setup related flags should consumer requests, HTE now can help setup should provider supports it.
Changes in v5:
- Replaced kernel thread with workqueue.
drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/hte/Kconfig | 22 ++ drivers/hte/Makefile | 2 + drivers/hte/hte.c | 828 +++++++++++++++++++++++++++++++++++++++++++ include/linux/hte.h | 253 +++++++++++++ 6 files changed, 1108 insertions(+) create mode 100644 drivers/hte/Kconfig create mode 100644 drivers/hte/Makefile create mode 100644 drivers/hte/hte.c create mode 100644 include/linux/hte.h
drivers/Kconfig +2 -0
@@ -239,4 +239,6 @@ source "drivers/most/Kconfig" source "drivers/peci/Kconfig" +source "drivers/hte/Kconfig" + endmenu
drivers/Makefile +1 -0
@@ -188,3 +188,4 @@ obj-$(CONFIG_INTERCONNECT) += interconnect/ obj-$(CONFIG_COUNTER) += counter/ obj-$(CONFIG_MOST) += most/ obj-$(CONFIG_PECI) += peci/ +obj-$(CONFIG_HTE) += hte/
drivers/hte/Kconfig new file +22 -0
@@ -0,0 +1,22 @@ +# SPDX-License-Identifier: GPL-2.0-only +menuconfig HTE + bool "Hardware Timestamping Engine (HTE) Support" + help + Hardware Timestamping Engine (HTE) Support. + + Some devices provide a hardware timestamping engine which can + timestamp certain device lines/signals in realtime. This provides a + hardware-assisted timestamp to generic signals like GPIOs or IRQs + lines. It comes with a benefit for applications like autonomous + machines needing accurate timestamping event with less jitter. + + This framework provides a generic interface to such HTE devices + within the Linux kernel. It provides an API to register and + unregister a HTE provider chip, configurable software buffer to + store the timestamps, push the timestamp from the HTE providers and + retrieve timestamps for the consumers. It also provides means for the + consumers to request signals it wishes to hardware timestamp and + release them if not required. + + If unsure, say no. +
drivers/hte/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_HTE) += hte.o +
drivers/hte/hte.c new file +828 -0
828 lines not on this page · raw message
include/linux/hte.h new file +253 -0
253 lines not on this page · raw message
Signature · 1 line
2.17.1
Dipen Patel
maintainerPATCH v5 3/11 hte: Add tegra194 HTE kernel provider
In reply to Dipen PatelTegra194 device has multiple HTE instances also known as GTE (Generic hardware Timestamping Engine) which can timestamp subset of SoC lines/signals. This provider driver focuses on IRQ and GPIO lines and exposes timestamping ability on those lines to the consumers through HTE subsystem.
Also, with this patch, added:
- documentation about this provider and its capabilities at Documentation/hte.
- Compilation support in Makefile and Kconfig
---
Changes in v3:
- Addressed grammatical/spelling errors.
Changes in v4:
- Added gpio line level detection.
- Added edge setup for GPIO lines if requested.
- Added match_from_linedata callback to help hte_req_ts_by_linedata_ns HTE API.
Documentation/hte/index.rst | 22 + Documentation/hte/tegra194-hte.rst | 52 +++ Documentation/index.rst | 1 + drivers/hte/Kconfig | 12 + drivers/hte/Makefile | 1 + drivers/hte/hte-tegra194.c | 690 +++++++++++++++++++++++++++++ 6 files changed, 778 insertions(+) create mode 100644 Documentation/hte/index.rst create mode 100644 Documentation/hte/tegra194-hte.rst create mode 100644 drivers/hte/hte-tegra194.c
Documentation/hte/index.rst new file +22 -0
@@ -0,0 +1,22 @@ +.. SPDX-License-Identifier: GPL-2.0 + +============================================ +The Linux Hardware Timestamping Engine (HTE) +============================================ + +The HTE Subsystem +================= + +.. toctree:: + :maxdepth: 1 + + hte + +HTE Tegra Provider +================== + +.. toctree:: + :maxdepth: 1 + + tegra194-hte +
Documentation/hte/tegra194-hte.rst new file +52 -0
52 lines not on this page · raw message
Documentation/index.rst +1 -0
@@ -140,6 +140,7 @@ needed). mhi/index tty/index peci/index + hte/index Architecture-agnostic documentation -----------------------------------
drivers/hte/Kconfig +12 -0
@@ -20,3 +20,15 @@ menuconfig HTE If unsure, say no. +if HTE + +config HTE_TEGRA194 + tristate "NVIDIA Tegra194 HTE Support" + depends on ARCH_TEGRA_194_SOC + help + Enable this option for integrated hardware timestamping engine also + known as generic timestamping engine (GTE) support on NVIDIA Tegra194 + systems-on-chip. The driver supports 352 LIC IRQs and 39 AON GPIOs + lines for timestamping in realtime. + +endif
drivers/hte/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_HTE) += hte.o +obj-$(CONFIG_HTE_TEGRA194) += hte-tegra194.o
drivers/hte/hte-tegra194.c new file +690 -0
690 lines not on this page · raw message
Signature · 1 line
2.17.1
Dipen Patel
maintainerPATCH v5 4/11 dt-bindings: Add HTE bindings
In reply to Dipen PatelIntroduces HTE devicetree binding details for the HTE subsystem. It includes examples for the consumers, binding details for the providers and specific binding details for the Tegra194 based HTE providers.
---
Changes in v2:
- Replace hte with hardware-timestamp for property names
- Renamed file
- Removed example from the common dt binding file.
Changes in v3:
- Addressed grammatical errors.
- Removed double plural from the respective properties.
- Added dual license.
- Prefixed "nvidia" in nvidia specific properties.
Changes in v4:
- Corrected make dt_binding_check error.
Changes in v5:
- Addressed review comments.
.../hte/hardware-timestamps-common.yaml | 29 +++++++ .../devicetree/bindings/hte/hte-consumer.yaml | 43 ++++++++++ .../bindings/hte/nvidia,tegra194-hte.yaml | 82 +++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 Documentation/devicetree/bindings/hte/hardware-timestamps-common.yaml create mode 100644 Documentation/devicetree/bindings/hte/hte-consumer.yaml create mode 100644 Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yaml
Documentation/devicetree/bindings/hte/hardware-timestamps-common.yaml new file +29 -0
@@ -0,0 +1,29 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hte/hardware-timestamps-common.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Hardware timestamp providers + +maintainers: + - Dipen Patel <[email protected]> + +description: + Some devices/SoCs have hardware time stamping engines which can use hardware + means to timestamp entity in realtime. The entity could be anything from + GPIOs, IRQs, Bus and so on. The hardware timestamp engine (HTE) present + itself as a provider with the bindings described in this document. + +properties: + $nodename: + pattern: "^hardware-timestamp(@.*|-[0-9a-f])?$" + + "#hardware-timestamp-cells": + description: + Number of cells in a HTE specifier. + +required: + - "#hardware-timestamp-cells" + +additionalProperties: true
Documentation/devicetree/bindings/hte/hte-consumer.yaml new file +43 -0
43 lines not on this page · raw message
Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yaml new file +82 -0
82 lines not on this page · raw message
Signature · 1 line
2.17.1
Rob Herring
maintainerRe: [PATCH v5 04/11] dt-bindings: Add HTE bindings
Quoted 79 lines · Dipen Patel
Introduces HTE devicetree binding details for the HTE subsystem. It includes examples for the consumers, binding details for the providers and specific binding details for the Tegra194 based HTE providers.
Signed-off-by Dipen Patel <[email protected]>Reviewed-by Linus Walleij <[email protected]>---
Changes in v2:
- Replace hte with hardware-timestamp for property names
- Renamed file
- Removed example from the common dt binding file.Changes in v3:
- Addressed grammatical errors.
- Removed double plural from the respective properties.
- Added dual license.
- Prefixed "nvidia" in nvidia specific properties.Changes in v4:
- Corrected makedt_binding_checkerror.Changes in v5:
- Addressed review comments..../hte/hardware-timestamps-common.yaml | 29 +++++++ .../devicetree/bindings/hte/hte-consumer.yaml | 43 ++++++++++ .../bindings/hte/nvidia,tegra194-hte.yaml | 82 +++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 Documentation/devicetree/bindings/hte/hardware-timestamps-common.yaml create mode 100644 Documentation/devicetree/bindings/hte/hte-consumer.yaml create mode 100644 Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yamlDocumentation/devicetree/bindings/hte/hardware-timestamps-common.yaml new file +29
-0@@ -0,0 +1,29 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hte/hardware-timestamps-common.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Hardware timestamp providers + +maintainers: + - Dipen Patel <[email protected]> + +description: + Some devices/SoCs have hardware time stamping engines which can use hardware + means to timestamp entity in realtime. The entity could be anything from + GPIOs, IRQs, Bus and so on. The hardware timestamp engine (HTE) present + itself as a provider with the bindings described in this document. + +properties: + $nodename: + pattern: "^hardware-timestamp(@.*|-[0-9a-f])?$" + + "#hardware-timestamp-cells": + description: + Number of cells in a HTE specifier. + +required: + - "#hardware-timestamp-cells" + +additionalProperties: trueDocumentation/devicetree/bindings/hte/hte-consumer.yaml new file +6
-0@@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hte/hte-consumer.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# +
Documentation/devicetree/bindings/hte/hte-consumer.yaml line 16
Quoted 10 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml new file +10
-0+title: HTE Consumer Device Tree Bindings + +maintainers: + - Dipen Patel <[email protected]> + +select: true + +description: + HTE properties should be named "hardware-timestamps". The exact meaning of + each hardware-timestamps property must be documented in the device tree
The meaning of the cells needs to be documented. You are documenting the meaning of 'hardware-timestamps' here.
Documentation/devicetree/bindings/hte/hte-consumer.yaml line 22
Quoted 6 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml new file +6
-0+ binding for each device. An optional property "hardware-timestamp-names" may + contain a list of strings to label each of the HTE devices listed in the + "hardware-timestamps" property. + +properties: + hardware-timestamps:
I'm wondering if we should just drop 'hardware'. What other kind of timestamps are we going to have in DT? software-timestamps? No.
Quoted 67 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml new file +21
-0+ $ref: /schemas/types.yaml#/definitions/phandle-array + description: + The list of HTE provider phandle. The provider must document the number + of cell that must be passed in this property along with phandle. + + hardware-timestamp-names: + $ref: /schemas/types.yaml#/definitions/string-array + description: + An optional string property. + +dependencies: + hardware-timestamp-names: [ hardware-timestamps ] + +additionalProperties: true + +examples: + - | + hte_irq_consumer { + hardware-timestamps = <&tegra_hte_lic 0x19>; + hardware-timestamp-names = "hte-irq"; + };Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yaml new file +40
-0@@ -0,0 +1,82 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hte/nvidia,tegra194-hte.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Tegra194 on chip generic hardware timestamping engine (HTE) + +maintainers: + - Dipen Patel <[email protected]> + +description: + Tegra194 SoC has multiple generic hardware timestamping engines (GTE) which + can monitor subset of GPIO and on chip IRQ lines for the state change, upon + detection it will record timestamp (taken from system counter) in its + internal hardware FIFO. It has a bitmap array arranged in 32bit slices where + each bit represent signal/line to enable or disable for the hardware + timestamping. + +properties: + compatible: + enum: + - nvidia,tegra194-gte-aon + - nvidia,tegra194-gte-lic + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + nvidia,int-threshold: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + HTE device generates its interrupt based on this u32 FIFO threshold + value. The recommended value is 1. + minimum: 1 + maximum: 256 + + nvidia,slices:
Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yaml line 50
Quoted 10 lines
Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yaml new file +10
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + description: + HTE lines are arranged in 32 bit slice where each bit represents different + line/signal that it can enable/configure for the timestamp. It is u32 + property and depends on the HTE instance in the chip. The value 3 is for + GPIO GTE and 11 for IRQ GTE. + enum: [3, 11] + + '#hardware-timestamp-cells': + const: 1
Need to describe what the cell represents.
Quoted 36 lines
Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yaml new file +32
-0+ +required: + - compatible + - reg + - interrupts + - nvidia,slices + - "#hardware-timestamp-cells" + +additionalProperties: false + +examples: + - | + tegra_hte_aon: hardware-timestamp@c1e0000 { + compatible = "nvidia,tegra194-gte-aon"; + reg = <0xc1e0000 0x10000>; + interrupts = <0 13 0x4>; + nvidia,int-threshold = <1>; + nvidia,slices = <3>; + #hardware-timestamp-cells = <1>; + }; + + - | + tegra_hte_lic: hardware-timestamp@3aa0000 { + compatible = "nvidia,tegra194-gte-lic"; + reg = <0x3aa0000 0x10000>; + interrupts = <0 11 0x4>; + nvidia,int-threshold = <1>; + nvidia,slices = <11>; + #hardware-timestamp-cells = <1>; + }; + +...Signature · 1 line
2.17.1
Dipen Patel
maintainerRe: [PATCH v5 04/11] dt-bindings: Add HTE bindings
Hi,
Quoted 84 lines · Rob Herring
Quoted 83 lines · Dipen Patel
Introduces HTE devicetree binding details for the HTE subsystem. It includes examples for the consumers, binding details for the providers and specific binding details for the Tegra194 based HTE providers.
Signed-off-by Dipen Patel <[email protected]>Reviewed-by Linus Walleij <[email protected]>---
Changes in v2:
- Replace hte with hardware-timestamp for property names
- Renamed file
- Removed example from the common dt binding file.Changes in v3:
- Addressed grammatical errors.
- Removed double plural from the respective properties.
- Added dual license.
- Prefixed "nvidia" in nvidia specific properties.Changes in v4:
- Corrected makedt_binding_checkerror.Changes in v5:
- Addressed review comments..../hte/hardware-timestamps-common.yaml | 29 +++++++ .../devicetree/bindings/hte/hte-consumer.yaml | 43 ++++++++++ .../bindings/hte/nvidia,tegra194-hte.yaml | 82 +++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 Documentation/devicetree/bindings/hte/hardware-timestamps-common.yaml create mode 100644 Documentation/devicetree/bindings/hte/hte-consumer.yaml create mode 100644 Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yamlDocumentation/devicetree/bindings/hte/hardware-timestamps-common.yaml new file +29
-0@@ -0,0 +1,29 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fschemas%2Fhte%2Fhardware-timestamps-common.yaml%23&data=04%7C01%7Cdipenp%40nvidia.com%7C5793b3be05fd48a97ad108da11db79a7%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637841931589163420%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=oyeG06oNMukYew%2Bkji%2FlXsDyGwIIrIvwxLHKxaiFBto%3D&reserved=0 +$schema: https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fmeta-schemas%2Fcore.yaml%23&data=04%7C01%7Cdipenp%40nvidia.com%7C5793b3be05fd48a97ad108da11db79a7%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637841931589163420%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=JOY3MmZlMo6Mopr5dwjUky%2BaQX4b0QSiDt8zo3mSu1k%3D&reserved=0 + +title: Hardware timestamp providers + +maintainers: + - Dipen Patel <[email protected]> + +description: + Some devices/SoCs have hardware time stamping engines which can use hardware + means to timestamp entity in realtime. The entity could be anything from + GPIOs, IRQs, Bus and so on. The hardware timestamp engine (HTE) present + itself as a provider with the bindings described in this document. + +properties: + $nodename: + pattern: "^hardware-timestamp(@.*|-[0-9a-f])?$" + + "#hardware-timestamp-cells": + description: + Number of cells in a HTE specifier. + +required: + - "#hardware-timestamp-cells" + +additionalProperties: trueDocumentation/devicetree/bindings/hte/hte-consumer.yaml new file +10
-0@@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fschemas%2Fhte%2Fhte-consumer.yaml%23&data=04%7C01%7Cdipenp%40nvidia.com%7C5793b3be05fd48a97ad108da11db79a7%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637841931589319655%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=0f1FFB1IotZESaxDlXX5mo9YyMN25BlFAyq%2FOQJtVoE%3D&reserved=0 +$schema: https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fmeta-schemas%2Fcore.yaml%23&data=04%7C01%7Cdipenp%40nvidia.com%7C5793b3be05fd48a97ad108da11db79a7%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637841931589319655%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=B%2FvVGGwp9JghUpT33cGk0EZHDRlaOAzCbtv93Z%2Fa9YY%3D&reserved=0 + +title: HTE Consumer Device Tree Bindings + +maintainers: + - Dipen Patel <[email protected]>
Quoted 8 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml line 16
Quoted 6 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml new file +6
-0+ +select: true + +description: + HTE properties should be named "hardware-timestamps". The exact meaning of + each hardware-timestamps property must be documented in the device treeThe meaning of the cells needs to be documented. You are documenting the meaning of 'hardware-timestamps' here.
This is for the consumer side, meaning of the cells will be documented in the provider
binding document.
Quoted 9 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml line 22
Quoted 7 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml new file +6
-0+ binding for each device. An optional property "hardware-timestamp-names" may + contain a list of strings to label each of the HTE devices listed in the + "hardware-timestamps" property. + +properties: + hardware-timestamps:I'm wondering if we should just drop 'hardware'. What other kind of timestamps are we going to have in DT? software-timestamps? No.
I believe this makes it explicit and leaves no room for second guess. If
only timestamps, ambiguity then will be which timestamp it is i.e. through hardware
engine, pps, ptp and so on...
Quoted 72 lines
Quoted 72 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml new file +21
-0+ $ref: /schemas/types.yaml#/definitions/phandle-array + description: + The list of HTE provider phandle. The provider must document the number + of cell that must be passed in this property along with phandle. + + hardware-timestamp-names: + $ref: /schemas/types.yaml#/definitions/string-array + description: + An optional string property. + +dependencies: + hardware-timestamp-names: [ hardware-timestamps ] + +additionalProperties: true + +examples: + - | + hte_irq_consumer { + hardware-timestamps = <&tegra_hte_lic 0x19>; + hardware-timestamp-names = "hte-irq"; + };Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yaml new file +43
-0@@ -0,0 +1,82 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fschemas%2Fhte%2Fnvidia%2Ctegra194-hte.yaml%23&data=04%7C01%7Cdipenp%40nvidia.com%7C5793b3be05fd48a97ad108da11db79a7%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637841931589319655%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=op7oS69fzQyvxJjQkPq8ScLuEEd32eCRjL%2BuCOPIKko%3D&reserved=0 +$schema: https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fmeta-schemas%2Fcore.yaml%23&data=04%7C01%7Cdipenp%40nvidia.com%7C5793b3be05fd48a97ad108da11db79a7%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637841931589319655%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=B%2FvVGGwp9JghUpT33cGk0EZHDRlaOAzCbtv93Z%2Fa9YY%3D&reserved=0 + +title: Tegra194 on chip generic hardware timestamping engine (HTE) + +maintainers: + - Dipen Patel <[email protected]> + +description: + Tegra194 SoC has multiple generic hardware timestamping engines (GTE) which + can monitor subset of GPIO and on chip IRQ lines for the state change, upon + detection it will record timestamp (taken from system counter) in its + internal hardware FIFO. It has a bitmap array arranged in 32bit slices where + each bit represent signal/line to enable or disable for the hardware + timestamping. + +properties: + compatible: + enum: + - nvidia,tegra194-gte-aon + - nvidia,tegra194-gte-lic + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + nvidia,int-threshold: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + HTE device generates its interrupt based on this u32 FIFO threshold + value. The recommended value is 1. + minimum: 1 + maximum: 256 + + nvidia,slices: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + HTE lines are arranged in 32 bit slice where each bit represents different
Quoted 8 lines
Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yaml line 50
Quoted 7 lines
Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yaml new file +7
-0+ line/signal that it can enable/configure for the timestamp. It is u32 + property and depends on the HTE instance in the chip. The value 3 is for + GPIO GTE and 11 for IRQ GTE. + enum: [3, 11] + + '#hardware-timestamp-cells': + const: 1Need to describe what the cell represents.
Agree...
Quoted 37 lines
Quoted 37 lines
Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yaml new file +32
-0+ +required: + - compatible + - reg + - interrupts + - nvidia,slices + - "#hardware-timestamp-cells" + +additionalProperties: false + +examples: + - | + tegra_hte_aon: hardware-timestamp@c1e0000 { + compatible = "nvidia,tegra194-gte-aon"; + reg = <0xc1e0000 0x10000>; + interrupts = <0 13 0x4>; + nvidia,int-threshold = <1>; + nvidia,slices = <3>; + #hardware-timestamp-cells = <1>; + }; + + - | + tegra_hte_lic: hardware-timestamp@3aa0000 { + compatible = "nvidia,tegra194-gte-lic"; + reg = <0x3aa0000 0x10000>; + interrupts = <0 11 0x4>; + nvidia,int-threshold = <1>; + nvidia,slices = <11>; + #hardware-timestamp-cells = <1>; + }; + +...Signature · 1 line
2.17.1
Rob Herring
maintainerRe: [PATCH v5 04/11] dt-bindings: Add HTE bindings
Quoted 96 lines · Dipen Patel
Hi,
Quoted 84 lines · Rob Herring
Quoted 83 lines · Dipen Patel
Introduces HTE devicetree binding details for the HTE subsystem. It includes examples for the consumers, binding details for the providers and specific binding details for the Tegra194 based HTE providers.
Signed-off-by Dipen Patel <[email protected]>Reviewed-by Linus Walleij <[email protected]>---
Changes in v2:
- Replace hte with hardware-timestamp for property names
- Renamed file
- Removed example from the common dt binding file.Changes in v3:
- Addressed grammatical errors.
- Removed double plural from the respective properties.
- Added dual license.
- Prefixed "nvidia" in nvidia specific properties.Changes in v4:
- Corrected makedt_binding_checkerror.Changes in v5:
- Addressed review comments..../hte/hardware-timestamps-common.yaml | 29 +++++++ .../devicetree/bindings/hte/hte-consumer.yaml | 43 ++++++++++ .../bindings/hte/nvidia,tegra194-hte.yaml | 82 +++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 Documentation/devicetree/bindings/hte/hardware-timestamps-common.yaml create mode 100644 Documentation/devicetree/bindings/hte/hte-consumer.yaml create mode 100644 Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yamlDocumentation/devicetree/bindings/hte/hardware-timestamps-common.yaml new file +29
-0@@ -0,0 +1,29 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fschemas%2Fhte%2Fhardware-timestamps-common.yaml%23&data=04%7C01%7Cdipenp%40nvidia.com%7C5793b3be05fd48a97ad108da11db79a7%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637841931589163420%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=oyeG06oNMukYew%2Bkji%2FlXsDyGwIIrIvwxLHKxaiFBto%3D&reserved=0 +$schema: https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fmeta-schemas%2Fcore.yaml%23&data=04%7C01%7Cdipenp%40nvidia.com%7C5793b3be05fd48a97ad108da11db79a7%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637841931589163420%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=JOY3MmZlMo6Mopr5dwjUky%2BaQX4b0QSiDt8zo3mSu1k%3D&reserved=0 + +title: Hardware timestamp providers + +maintainers: + - Dipen Patel <[email protected]> + +description: + Some devices/SoCs have hardware time stamping engines which can use hardware + means to timestamp entity in realtime. The entity could be anything from + GPIOs, IRQs, Bus and so on. The hardware timestamp engine (HTE) present + itself as a provider with the bindings described in this document. + +properties: + $nodename: + pattern: "^hardware-timestamp(@.*|-[0-9a-f])?$" + + "#hardware-timestamp-cells": + description: + Number of cells in a HTE specifier. + +required: + - "#hardware-timestamp-cells" + +additionalProperties: trueDocumentation/devicetree/bindings/hte/hte-consumer.yaml new file +10
-0@@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fschemas%2Fhte%2Fhte-consumer.yaml%23&data=04%7C01%7Cdipenp%40nvidia.com%7C5793b3be05fd48a97ad108da11db79a7%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637841931589319655%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=0f1FFB1IotZESaxDlXX5mo9YyMN25BlFAyq%2FOQJtVoE%3D&reserved=0 +$schema: https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fmeta-schemas%2Fcore.yaml%23&data=04%7C01%7Cdipenp%40nvidia.com%7C5793b3be05fd48a97ad108da11db79a7%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637841931589319655%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=B%2FvVGGwp9JghUpT33cGk0EZHDRlaOAzCbtv93Z%2Fa9YY%3D&reserved=0 + +title: HTE Consumer Device Tree Bindings + +maintainers: + - Dipen Patel <[email protected]>Quoted 8 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml line 16
Quoted 6 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml new file +6
-0+ +select: true + +description: + HTE properties should be named "hardware-timestamps". The exact meaning of + each hardware-timestamps property must be documented in the device treeThe meaning of the cells needs to be documented. You are documenting the meaning of 'hardware-timestamps' here.
Quoted 3 lines
This is for the consumer side, meaning of the cells will be documented in the provider
binding document.
Right cells are opaque to the consumer. What bothered me is hardware-timestamps already has an 'exact meaning'. You need to me more exact as to what should be documented. We don't want what 'hardware-timestamps' is described again. What needs to be documented is how many entries, what each entry is (for the consumer), and the order.
Quoted 9 lines
Quoted 8 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml line 22
Quoted 6 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml new file +6
-0+ binding for each device. An optional property "hardware-timestamp-names" may + contain a list of strings to label each of the HTE devices listed in the + "hardware-timestamps" property. + +properties: + hardware-timestamps:I'm wondering if we should just drop 'hardware'. What other kind of timestamps are we going to have in DT? software-timestamps? No.
Quoted 5 lines
I believe this makes it explicit and leaves no room for second guess. If
only timestamps, ambiguity then will be which timestamp it is i.e. through hardware
engine, pps, ptp and so on...
Those aren't hardware timestamps, too? If those needed a similar binding, couldn't they use this binding? PTP at least is sometimes an separate, external chip IIRC.
Rob
Dipen Patel
maintainerRe: [PATCH v5 04/11] dt-bindings: Add HTE bindings
Quoted 114 lines · Rob Herring
Quoted 95 lines · Dipen Patel
Hi,
Quoted 84 lines · Rob Herring
Quoted 83 lines · Dipen Patel
Introduces HTE devicetree binding details for the HTE subsystem. It includes examples for the consumers, binding details for the providers and specific binding details for the Tegra194 based HTE providers.
Signed-off-by Dipen Patel <[email protected]>Reviewed-by Linus Walleij <[email protected]>---
Changes in v2:
- Replace hte with hardware-timestamp for property names
- Renamed file
- Removed example from the common dt binding file.Changes in v3:
- Addressed grammatical errors.
- Removed double plural from the respective properties.
- Added dual license.
- Prefixed "nvidia" in nvidia specific properties.Changes in v4:
- Corrected makedt_binding_checkerror.Changes in v5:
- Addressed review comments..../hte/hardware-timestamps-common.yaml | 29 +++++++ .../devicetree/bindings/hte/hte-consumer.yaml | 43 ++++++++++ .../bindings/hte/nvidia,tegra194-hte.yaml | 82 +++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 Documentation/devicetree/bindings/hte/hardware-timestamps-common.yaml create mode 100644 Documentation/devicetree/bindings/hte/hte-consumer.yaml create mode 100644 Documentation/devicetree/bindings/hte/nvidia,tegra194-hte.yamlDocumentation/devicetree/bindings/hte/hardware-timestamps-common.yaml new file +29
-0@@ -0,0 +1,29 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fschemas%2Fhte%2Fhardware-timestamps-common.yaml%23&data=04%7C01%7Cdipenp%40nvidia.com%7C0e094f6ae7b642c970f308da125c64d4%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637842485301457320%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=4UcTV375zNF44HeIpQcDV%2Bp3VJXdtjomZYGWWsUJf%2FA%3D&reserved=0 +$schema: https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fmeta-schemas%2Fcore.yaml%23&data=04%7C01%7Cdipenp%40nvidia.com%7C0e094f6ae7b642c970f308da125c64d4%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637842485301457320%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=fGoLuKpVFMNOsh%2BbJ6dLhpky63Y6zQ1oNkiOHDQ%2Bud0%3D&reserved=0 + +title: Hardware timestamp providers + +maintainers: + - Dipen Patel <[email protected]> + +description: + Some devices/SoCs have hardware time stamping engines which can use hardware + means to timestamp entity in realtime. The entity could be anything from + GPIOs, IRQs, Bus and so on. The hardware timestamp engine (HTE) present + itself as a provider with the bindings described in this document. + +properties: + $nodename: + pattern: "^hardware-timestamp(@.*|-[0-9a-f])?$" + + "#hardware-timestamp-cells": + description: + Number of cells in a HTE specifier. + +required: + - "#hardware-timestamp-cells" + +additionalProperties: trueDocumentation/devicetree/bindings/hte/hte-consumer.yaml new file +10
-0@@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fschemas%2Fhte%2Fhte-consumer.yaml%23&data=04%7C01%7Cdipenp%40nvidia.com%7C0e094f6ae7b642c970f308da125c64d4%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637842485301457320%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=E3fspCvDDE5%2F6opK%2FdtpaY5%2FscsPURvDV7O7%2B%2FdbtEQ%3D&reserved=0 +$schema: https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fmeta-schemas%2Fcore.yaml%23&data=04%7C01%7Cdipenp%40nvidia.com%7C0e094f6ae7b642c970f308da125c64d4%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637842485301457320%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=fGoLuKpVFMNOsh%2BbJ6dLhpky63Y6zQ1oNkiOHDQ%2Bud0%3D&reserved=0 + +title: HTE Consumer Device Tree Bindings + +maintainers: + - Dipen Patel <[email protected]>Quoted 8 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml line 16
Quoted 6 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml new file +6
-0+ +select: true + +description: + HTE properties should be named "hardware-timestamps". The exact meaning of + each hardware-timestamps property must be documented in the device treeThe meaning of the cells needs to be documented. You are documenting the meaning of 'hardware-timestamps' here.
Quoted 3 lines
This is for the consumer side, meaning of the cells will be documented in the provider
binding document.
Right cells are opaque to the consumer. What bothered me is hardware-timestamps already has an 'exact meaning'. You need to me more exact as to what should be documented. We don't want what 'hardware-timestamps' is described again. What needs to be documented is how many entries, what each entry is (for the consumer), and the order.
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml line 22
Quoted 6 lines
Documentation/devicetree/bindings/hte/hte-consumer.yaml new file +6
-0+ binding for each device. An optional property "hardware-timestamp-names" may + contain a list of strings to label each of the HTE devices listed in the + "hardware-timestamps" property. + +properties: + hardware-timestamps:I'm wondering if we should just drop 'hardware'. What other kind of timestamps are we going to have in DT? software-timestamps? No.
Quoted 8 lines
Quoted 5 lines
I believe this makes it explicit and leaves no room for second guess. If
only timestamps, ambiguity then will be which timestamp it is i.e. through hardware
engine, pps, ptp and so on...
Those aren't hardware timestamps, too? If those needed a similar binding, couldn't they use this binding? PTP at least is sometimes an separate, external chip IIRC.
I am fine with this idea of dropping "hardware" prefix, will update the patch.
I believe this will be applicable to all other properties for example hardware-timestamp-cell
as well, right?
Quoted 2 lines
Rob
Dipen Patel
maintainerPATCH v5 5/11 hte: Add Tegra194 IRQ HTE test driver
In reply to Dipen PatelTegra194 has IRQ HTE provider which can timestamp IRQ lines in realtime , this test driver implements consumer side which tests such provider through HTE subsystem. During its probe, it registers sysfs interface to easily navigate from userspace as below.
All the files are at /sys/kernel/tegra_hte_irq_test/.
- en_dis - Write only, Value 1 enables HTE line, 0 disables it
This driver can be compiled as loadable module and is tested on Jetson AGX platform using 0x19 IRQ line which belongs to i2c controller 3160000.i2c.
i2cdetect -y 1 from the userspace on this platform should be enough to generate LIC I2C IRQ. The HTE should be able to generate timestamps for each interrupts.
--- drivers/hte/Kconfig | 7 ++ drivers/hte/Makefile | 1 + drivers/hte/hte-tegra194-irq-test.c | 179 ++++++++++++++++++++++++++++ 3 files changed, 187 insertions(+) create mode 100644 drivers/hte/hte-tegra194-irq-test.c
drivers/hte/Kconfig +7 -0
@@ -31,4 +31,11 @@ config HTE_TEGRA194 systems-on-chip. The driver supports 352 LIC IRQs and 39 AON GPIOs lines for timestamping in realtime. +config HTE_TEGRA194_IRQ_TEST + tristate "NVIDIA Tegra194 HTE LIC IRQ Test" + depends on HTE_TEGRA194 + help + The NVIDIA Tegra194 GTE IRQ test driver demonstrates HTE subsystem + usage for the LIC IRQ hardware timestamp. + endif
drivers/hte/Makefile +1 -0
@@ -1,3 +1,4 @@ obj-$(CONFIG_HTE) += hte.o obj-$(CONFIG_HTE_TEGRA194) += hte-tegra194.o +obj-$(CONFIG_HTE_TEGRA194_IRQ_TEST) += hte-tegra194-irq-test.o
drivers/hte/hte-tegra194-irq-test.c new file +179 -0
179 lines not on this page · raw message
Signature · 1 line
2.17.1
Dipen Patel
maintainerPATCH v5 6/11 gpiolib: Add HTE support
In reply to Dipen PatelSome GPIO chip can provide hardware timestamp support on its GPIO lines , in order to support that, additional API needs to be added which can talk to both GPIO chip and HTE (hardware timestamping engine) providers if there is any dependencies. This patch introduces optional hooks to enable and disable hardware timestamping related features in the GPIO controller chip.
---
Changes in v2:
- removed get timestamp and is timestamp enabled APIs
Changes in v4:
- Removed gpiod_req_hw_timestamp_ns and gpiod_rel_hw_timestamp_ns APIs.
- Added callbacks for the GPIO driver to enable hardware timestamping functionality if supported which takes gpio desc and flags as arguments.
- Added APIs are called from GPIO provider rather than gpiolib-cdev framework.
drivers/gpio/gpiolib.c | 58 +++++++++++++++++++++++++++++++++++ drivers/gpio/gpiolib.h | 1 + include/linux/gpio/consumer.h | 16 ++++++++-- include/linux/gpio/driver.h | 10 ++++++ 4 files changed, 83 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib.c +58 -0
@@ -2422,6 +2422,64 @@ int gpiod_direction_output(struct gpio_desc *desc, int value) }EXPORT_SYMBOL_GPL (gpiod_direction_output); +/** +* gpiod_enable_hw_timestamp_ns - Enable hardware timestamp in nanoseconds. +* +* @desc: GPIO to enable. +* @flags: Flags related to GPIO edge. +* +* Return 0 in case of success, else negative error code. +*/ +int gpiod_enable_hw_timestamp_ns (struct gpio_desc *desc,unsigned long flags) +{ +int ret =0 ; +struct gpio_chip *gc; + +VALIDATE_DESC (desc); + + gc = desc->gdev->chip; +if (!gc->en_hw_timestamp) { +gpiod_warn (desc,"%s: hw ts not supported\n" , __func__); +return -ENOTSUPP ; + } + + ret = gc->en_hw_timestamp (gc,gpio_chip_hwgpio (desc), flags); +if (ret) +gpiod_warn (desc,"%s: hw ts request failed\n" , __func__); + +return ret; +} +EXPORT_SYMBOL_GPL (gpiod_enable_hw_timestamp_ns); + +/** +* gpiod_disable_hw_timestamp_ns - Disable hardware timestamp. +* +* @desc: GPIO to disable. +* @flags: Flags related to GPIO edge, same value as used during enable call. +* +* Return 0 in case of success, else negative error code. +*/ +int gpiod_disable_hw_timestamp_ns (struct gpio_desc *desc,unsigned long flags) +{ +int ret =0 ; +struct gpio_chip *gc; + +VALIDATE_DESC (desc); + + gc = desc->gdev->chip; +if (!gc->dis_hw_timestamp) { +gpiod_warn (desc,"%s: hw ts not supported\n" , __func__); +return -ENOTSUPP ; + } + + ret = gc->dis_hw_timestamp (gc,gpio_chip_hwgpio (desc), flags); +if (ret) +gpiod_warn (desc,"%s: hw ts release failed\n" , __func__); + +return ret; +} +EXPORT_SYMBOL_GPL (gpiod_disable_hw_timestamp_ns); +/** * gpiod_set_config - sets @config for a GPIO * @desc: descriptor of the GPIO for which to set the configuration
drivers/gpio/gpiolib.h +1 -0
@@ -158,6 +158,7 @@ struct gpio_desc {#define FLAG_EDGE_RISING 16/* GPIO CDEV detects rising edge events */ #define FLAG_EDGE_FALLING 17/* GPIO CDEV detects falling edge events */ #define FLAG_EVENT_CLOCK_REALTIME 18/* GPIO CDEV reports REALTIME timestamps in events */ +#define FLAG_EVENT_CLOCK_HTE 19/* GPIO CDEV reports hardware timestamps in events */ /* Connection label */ const char *label;
include/linux/gpio/consumer.h +14 -2
@@ -109,6 +109,8 @@ int gpiod_get_direction(struct gpio_desc *desc);int gpiod_direction_input (struct gpio_desc *desc);int gpiod_direction_output (struct gpio_desc *desc,int value);int gpiod_direction_output_raw (struct gpio_desc *desc,int value); +int gpiod_enable_hw_timestamp_ns (struct gpio_desc *desc,unsigned long flags); +int gpiod_disable_hw_timestamp_ns (struct gpio_desc *desc,unsigned long flags);/* Value get/set from non-sleeping context */ int gpiod_get_value (const struct gpio_desc *desc);
@@ -350,8 +352,18 @@ static inline int gpiod_direction_output_raw(struct gpio_desc *desc, int value)WARN_ON (desc);return -ENOSYS ; } - - +static inline int gpiod_enable_hw_timestamp_ns (struct gpio_desc *desc, +unsigned long flags) +{ +WARN_ON (desc); +return -ENOSYS ; +} +static inline int gpiod_disable_hw_timestamp_ns (struct gpio_desc *desc, +unsigned long flags) +{ +WARN_ON (desc); +return -ENOSYS ; +}static inline int gpiod_get_value (const struct gpio_desc *desc) {/* GPIO can never have been requested */
include/linux/gpio/driver.h +10 -0
@@ -320,6 +320,10 @@ struct gpio_irq_chip {* @add_pin_ranges: optional routine to initialize pin ranges, to be used when * requires special mapping of the pins that provides GPIO functionality. * It is called after adding GPIO chip and before adding IRQ chip. +* @en_hw_timestamp: Dependent on GPIO chip, an optional routine to +* enable hardware timestamp. +* @dis_hw_timestamp: Dependent on GPIO chip, an optional routine to +* disable hardware timestamp. * @base: identifies the first GPIO number handled by this chip; * or, if negative during registration, requests dynamic ID allocation. * DEPRECATION: providing anything non-negative and nailing the base
@@ -416,6 +420,12 @@ struct gpio_chip {int (*add_pin_ranges)(struct gpio_chip *gc); +int (*en_hw_timestamp)(struct gpio_chip *gc, +u32 offset, +unsigned long flags); +int (*dis_hw_timestamp)(struct gpio_chip *gc, +u32 offset, +unsigned long flags);int base;u16 ngpio;u16 offset;
Signature · 1 line
2.17.1
Dipen Patel
maintainerPATCH v5 7/11 gpio: tegra186: Add HTE in gpio-tegra186 driver
In reply to Dipen PatelTegra194 AON GPIO controller with the use of its internal hardware timestamping engine (HTE) also known as GTE can timestamp GPIO lines through system counter. This patch implements enable/disable callbacks for the GPIO controller. In enable call, it will set timestamp function bit and GPIO line rising/falling edges in the config register. In disable call, it restores the state.
---
Changes in v4:
- Added edge setup and hardware timestamping enable/disable APIs.
drivers/gpio/gpio-tegra186.c | 81 +++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-)
drivers/gpio/gpio-tegra186.c +80 -1
@@ -1,8 +1,9 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (c) 2016-2017 NVIDIA Corporation +* Copyright (c) 2016-2022 NVIDIA Corporation * * Author: Thierry Reding <[email protected]> +* Dipen Patel <[email protected]> */ #include <linux/gpio/driver.h>
@@ -11,6 +12,7 @@#include <linux/module.h> #include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/hte.h> #include <dt-bindings/gpio/tegra186-gpio.h> #include <dt-bindings/gpio/tegra194-gpio.h>
@@ -36,6 +38,7 @@#define TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_LEVEL BIT(4)#define TEGRA186_GPIO_ENABLE_CONFIG_DEBOUNCE BIT(5)#define TEGRA186_GPIO_ENABLE_CONFIG_INTERRUPT BIT(6) +#define TEGRA186_GPIO_ENABLE_CONFIG_TIMESTAMP_FUNC BIT(7)#define TEGRA186_GPIO_DEBOUNCE_CONTROL 0x04#define TEGRA186_GPIO_DEBOUNCE_CONTROL_THRESHOLD (x) ((x) & 0xff)
@@ -76,6 +79,7 @@ struct tegra_gpio_soc {const struct tegra186_pin_range *pin_ranges;unsigned int num_pin_ranges;const char *pinmux; +bool has_gte; };struct tegra_gpio {
@@ -194,6 +198,76 @@ static int tegra186_gpio_direction_output(struct gpio_chip *chip,return 0 ; } +#define HTE_BOTH_EDGES (HTE_RISING_EDGE_TS | HTE_FALLING_EDGE_TS) + +static int tegra186_gpio_en_hw_ts (struct gpio_chip *gc,u32 offset, +unsigned long flags) +{ +struct tegra_gpio *gpio; +void __iomem *base; +int value; + +if (!gc) +return -EINVAL ; + + gpio =gpiochip_get_data (gc); +if (!gpio) +return -ENODEV ; + + base =tegra186_gpio_get_base (gpio, offset); +if (WARN_ON (base ==NULL )) +return -EINVAL ; + + value =readl (base +TEGRA186_GPIO_ENABLE_CONFIG ); + value |=TEGRA186_GPIO_ENABLE_CONFIG_TIMESTAMP_FUNC ; + +if (flags ==HTE_BOTH_EDGES ) { + value |=TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_DOUBLE_EDGE ; + }else if (flags ==HTE_RISING_EDGE_TS ) { + value |=TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_SINGLE_EDGE ; + value |=TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_LEVEL ; + }else if (flags ==HTE_FALLING_EDGE_TS ) { + value |=TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_SINGLE_EDGE ; + } + +writel (value, base +TEGRA186_GPIO_ENABLE_CONFIG ); + +return 0 ; +} + +static int tegra186_gpio_dis_hw_ts (struct gpio_chip *gc,u32 offset, +unsigned long flags) +{ +struct tegra_gpio *gpio; +void __iomem *base; +int value; + +if (!gc) +return -EINVAL ; + + gpio =gpiochip_get_data (gc); +if (!gpio) +return -ENODEV ; + + base =tegra186_gpio_get_base (gpio, offset); +if (WARN_ON (base ==NULL )) +return -EINVAL ; + + value =readl (base +TEGRA186_GPIO_ENABLE_CONFIG ); + value &= ~TEGRA186_GPIO_ENABLE_CONFIG_TIMESTAMP_FUNC ; +if (flags ==HTE_BOTH_EDGES ) { + value &= ~TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_DOUBLE_EDGE ; + }else if (flags ==HTE_RISING_EDGE_TS ) { + value &= ~TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_SINGLE_EDGE ; + value &= ~TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_LEVEL ; + }else if (flags ==HTE_FALLING_EDGE_TS ) { + value &= ~TEGRA186_GPIO_ENABLE_CONFIG_TRIGGER_TYPE_SINGLE_EDGE ; + } +writel (value, base +TEGRA186_GPIO_ENABLE_CONFIG ); + +return 0 ; +} +static int tegra186_gpio_get (struct gpio_chip *chip,unsigned int offset) {struct tegra_gpio *gpio =gpiochip_get_data (chip);
@@ -726,6 +800,10 @@ static int tegra186_gpio_probe(struct platform_device *pdev) gpio->gpio.set = tegra186_gpio_set; gpio->gpio.set_config = tegra186_gpio_set_config; gpio->gpio.add_pin_ranges = tegra186_gpio_add_pin_ranges; +if (gpio->soc->has_gte) { + gpio->gpio.en_hw_timestamp = tegra186_gpio_en_hw_ts; + gpio->gpio.dis_hw_timestamp = tegra186_gpio_dis_hw_ts; + } gpio->gpio.base =-1 ;
@@ -977,6 +1055,7 @@ static const struct tegra_gpio_soc tegra194_aon_soc = { .name = "tegra194-gpio-aon", .instance = 1, .num_irqs_per_bank = 8, + .has_gte = true, };#define TEGRA234_MAIN_GPIO_PORT (_name, _bank, _port, _pins) \
Signature · 1 line
2.17.1
Dipen Patel
maintainerPATCH v5 8/11 gpiolib: cdev: Add hardware timestamp clock type
In reply to Dipen PatelThis patch adds new clock type for the GPIO controller which can timestamp gpio lines in using hardware means. To expose such functionalities to the userspace, code has been added where during line create or set config API calls, it checks for new clock type and if requested, calls HTE API. During line change event, the HTE subsystem pushes timestamp data to userspace through gpiolib-cdev.
---
Changes in v2:
- Added hte_dir and static structure hte_ts_desc.
- Added callbacks which get invoked by HTE when new data is available.
- Better use of hte_dir and seq from hte_ts_desc.
- Modified sw debounce function to accommodate hardware timestamping.
Changes in v4:
- Correced line level and event sequence counter handling.
- Added hte edge setup functionality.
drivers/gpio/gpiolib-cdev.c | 247 +++++++++++++++++++++++++++++++----- include/uapi/linux/gpio.h | 3 + 2 files changed, 217 insertions(+), 33 deletions(-)
drivers/gpio/gpiolib-cdev.c +214 -33
@@ -24,6 +24,7 @@#include <linux/timekeeping.h> #include <linux/uaccess.h> #include <linux/workqueue.h> +#include <linux/hte.h> #include <uapi/linux/gpio.h> #include "gpiolib.h"
@@ -464,6 +465,25 @@ struct line {* stale value. */ unsigned int level; +/* +* -- hte specific fields -- +*/ +struct hte_ts_desc hdesc; +/* +* HTE provider sets line level at the time of event. The valid +* value is 0 or 1 and negative value for an error. +*/ +int raw_level; +/* +* when sw_debounce is set on HTE enabled line, this is running +* counter of the discarded events. +*/ +u32 total_discard_seq; +/* +* when sw_debounce is set on HTE enabled line, this variable records +* last sequence number before debounce period expires. +*/ +u32 last_seqno; };/**
@@ -518,6 +538,7 @@ struct linereq { GPIO_V2_LINE_DRIVE_FLAGS | \ GPIO_V2_LINE_EDGE_FLAGS | \ GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME | \ + GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE | \ GPIO_V2_LINE_BIAS_FLAGS) static void linereq_put_event(struct linereq *lr,
@@ -542,10 +563,98 @@ static u64 line_event_timestamp(struct line *line) {if (test_bit (FLAG_EVENT_CLOCK_REALTIME , &line->desc->flags))return ktime_get_real_ns (); +else if (test_bit (FLAG_EVENT_CLOCK_HTE , &line->desc->flags)) +return line->timestamp_ns;return ktime_get_ns (); } +static hte_return_t process_hw_ts_thread (void *p) +{ +struct line *line; +struct linereq *lr; +struct gpio_v2_line_event le; +int level; +u64 eflags; + +if (!p) +return HTE_CB_HANDLED ; + + line = p; + lr = line->req; + +memset (&le,0 ,sizeof (le)); + + le.timestamp_ns = line->timestamp_ns; + eflags =READ_ONCE (line->eflags); + +if (eflags ==GPIO_V2_LINE_FLAG_EDGE_BOTH ) { +if (line->raw_level >=0 ) { +if (test_bit (FLAG_ACTIVE_LOW , &line->desc->flags)) + level = !line->raw_level; +else + level = line->raw_level; + }else { + level =gpiod_get_value_cansleep (line->desc); + } + +if (level) + le.id =GPIO_V2_LINE_EVENT_RISING_EDGE ; +else + le.id =GPIO_V2_LINE_EVENT_FALLING_EDGE ; + }else if (eflags ==GPIO_V2_LINE_FLAG_EDGE_RISING ) { +/* Emit low-to-high event */ + le.id =GPIO_V2_LINE_EVENT_RISING_EDGE ; + }else if (eflags ==GPIO_V2_LINE_FLAG_EDGE_FALLING ) { +/* Emit high-to-low event */ + le.id =GPIO_V2_LINE_EVENT_FALLING_EDGE ; + }else { +return HTE_CB_HANDLED ; + } + le.line_seqno = line->line_seqno; + le.seqno = (lr->num_lines ==1 ) ? le.line_seqno : line->req_seqno; + le.offset =gpio_chip_hwgpio (line->desc); + +linereq_put_event (lr, &le); + +return HTE_CB_HANDLED ; +} + +static hte_return_t process_hw_ts (struct hte_ts_data *ts,void *p) +{ +struct line *line; +struct linereq *lr; +int diff_seqno =0 ; + +if (!ts || !p) +return HTE_CB_HANDLED ; + + line = p; + line->timestamp_ns = ts->tsc; + line->raw_level = ts->raw_level; + lr = line->req; + +if (READ_ONCE (line->sw_debounced)) { + line->total_discard_seq++; + line->last_seqno = ts->seq; +mod_delayed_work (system_wq, &line->work, +usecs_to_jiffies (READ_ONCE (line->desc->debounce_period_us))); + }else { +if (unlikely (ts->seq < line->line_seqno)) +return HTE_CB_HANDLED ; + + diff_seqno = ts->seq - line->line_seqno; + line->line_seqno = ts->seq; +if (lr->num_lines !=1 ) + line->req_seqno =atomic_add_return (diff_seqno, + &lr->seqno); + +return HTE_RUN_SECOND_CB ; + } + +return HTE_CB_HANDLED ; +} +static irqreturn_t edge_irq_thread (int irq,void *p) {struct line *line = p;
@@ -651,10 +760,16 @@ static void debounce_work_func(struct work_struct *work)struct gpio_v2_line_event le; struct line *line = container_of(work, struct line, work.work);struct linereq *lr; -int level; +int level, diff_seqno;u64 eflags; - level =gpiod_get_raw_value_cansleep (line->desc); +if (test_bit (FLAG_EVENT_CLOCK_HTE , &line->desc->flags)) { + level = line->raw_level; +if (level <0 ) + level =gpiod_get_raw_value_cansleep (line->desc); + }else { + level =gpiod_get_raw_value_cansleep (line->desc); + }if (level <0 ) {pr_debug_ratelimited ("debouncer failed to read line value\n" );return ;
@@ -685,10 +800,21 @@ static void debounce_work_func(struct work_struct *work) lr = line->req; le.timestamp_ns =line_event_timestamp (line); le.offset =gpio_chip_hwgpio (line->desc); - line->line_seqno++; - le.line_seqno = line->line_seqno; - le.seqno = (lr->num_lines ==1 ) ? - le.line_seqno :atomic_inc_return (&lr->seqno); +if (test_bit (FLAG_EVENT_CLOCK_HTE , &line->desc->flags)) { +/* discard events except the last one */ + line->total_discard_seq -=1 ; + diff_seqno = line->last_seqno - line->total_discard_seq - + line->line_seqno; + line->line_seqno = line->last_seqno - line->total_discard_seq; + le.line_seqno = line->line_seqno; + le.seqno = (lr->num_lines ==1 ) ? + le.line_seqno :atomic_add_return (diff_seqno, &lr->seqno); + }else { + line->line_seqno++; + le.line_seqno = line->line_seqno; + le.seqno = (lr->num_lines ==1 ) ? + le.line_seqno :atomic_inc_return (&lr->seqno); + }if (level)/* Emit low-to-high event */
@@ -700,8 +826,29 @@ static void debounce_work_func(struct work_struct *work)linereq_put_event (lr, &le); } +static int hte_edge_setup (struct line *line,u64 eflags) +{ +unsigned long flags =0 ; +struct hte_ts_desc *hdesc = &line->hdesc; + +if (eflags &GPIO_V2_LINE_FLAG_EDGE_RISING ) + flags |=test_bit (FLAG_ACTIVE_LOW , &line->desc->flags) ? +HTE_FALLING_EDGE_TS :HTE_RISING_EDGE_TS ; +if (eflags &GPIO_V2_LINE_FLAG_EDGE_FALLING ) + flags |=test_bit (FLAG_ACTIVE_LOW , &line->desc->flags) ? +HTE_RISING_EDGE_TS :HTE_FALLING_EDGE_TS ; + + hdesc->attr.edge_flags = flags; + hdesc->attr.line_data = line->desc; + hdesc->attr.line_id =desc_to_gpio (line->desc); + line->total_discard_seq =0 ; + +return hte_req_ts_by_linedata_ns (hdesc, process_hw_ts, + process_hw_ts_thread, line); +} +static int debounce_setup (struct line *line, -unsigned int debounce_period_us) +unsigned int debounce_period_us,bool hte_req) {unsigned long irqflags;int ret, level, irq;
@@ -721,19 +868,27 @@ static int debounce_setup(struct line *line,if (level <0 )return level; - irq =gpiod_to_irq (line->desc); -if (irq <0 ) -return -ENXIO ; +if (!hte_req) { + irq =gpiod_to_irq (line->desc); +if (irq <0 ) +return -ENXIO ; -WRITE_ONCE (line->level, level); - irqflags =IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING ; - ret =request_irq (irq, debounce_irq_handler, irqflags, - line->req->label, line); -if (ret) -return ret; + irqflags =IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING ; + ret =request_irq (irq, debounce_irq_handler, irqflags, + line->req->label, line); +if (ret) +return ret; + line->irq = irq; + }else { + ret =hte_edge_setup (line, +GPIO_V2_LINE_FLAG_EDGE_RISING | +GPIO_V2_LINE_FLAG_EDGE_FALLING ); +if (ret) +return ret; + } +WRITE_ONCE (line->level, level);WRITE_ONCE (line->sw_debounced,1 ); - line->irq = irq; }return 0 ; }
@@ -766,13 +921,16 @@ static u32 gpio_v2_line_config_debounce_period(struct gpio_v2_line_config *lc,return 0 ; } -static void edge_detector_stop (struct line *line) +static void edge_detector_stop (struct line *line,bool hte_en) { -if (line->irq) { +if (line->irq && !hte_en) {free_irq (line->irq, line); line->irq =0 ; } +if (hte_en) +hte_release_ts (&line->hdesc); +cancel_delayed_work_sync (&line->work);WRITE_ONCE (line->sw_debounced,0 );WRITE_ONCE (line->eflags,0 );
@@ -784,7 +942,7 @@ static void edge_detector_stop(struct line *line)static int edge_detector_setup (struct line *line,struct gpio_v2_line_config *lc,unsigned int line_idx, -u64 eflags) +u64 eflags,bool hte_req) {u32 debounce_period_us;unsigned long irqflags =0 ;
@@ -799,7 +957,7 @@ static int edge_detector_setup(struct line *line,WRITE_ONCE (line->eflags, eflags);if (gpio_v2_line_config_debounced (lc, line_idx)) { debounce_period_us =gpio_v2_line_config_debounce_period (lc, line_idx); - ret =debounce_setup (line, debounce_period_us); + ret =debounce_setup (line, debounce_period_us, hte_req);if (ret)return ret;WRITE_ONCE (line->desc->debounce_period_us, debounce_period_us);
@@ -809,6 +967,9 @@ static int edge_detector_setup(struct line *line,if (!eflags ||READ_ONCE (line->sw_debounced))return 0 ; +if (hte_req) +return hte_edge_setup (line, eflags); + irq =gpiod_to_irq (line->desc);if (irq <0 )return -ENXIO ;
@@ -834,13 +995,18 @@ static int edge_detector_setup(struct line *line,static int edge_detector_update (struct line *line,struct gpio_v2_line_config *lc,unsigned int line_idx, -u64 eflags,bool polarity_change) +u64 flags,bool polarity_change, +bool prev_hte_flag) { +u64 eflags = flags &GPIO_V2_LINE_EDGE_FLAGS ;unsigned int debounce_period_us = -gpio_v2_line_config_debounce_period (lc, line_idx); +gpio_v2_line_config_debounce_period (lc, line_idx); +bool hte_change = (prev_hte_flag != + ((flags &GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE ) !=0 ));if ((READ_ONCE (line->eflags) == eflags) && !polarity_change && - (READ_ONCE (line->desc->debounce_period_us) == debounce_period_us)) + (READ_ONCE (line->desc->debounce_period_us) == debounce_period_us) + && !hte_change)return 0 ;/* sw debounced and still will be...*/
@@ -851,11 +1017,12 @@ static int edge_detector_update(struct line *line, }/* reconfiguring edge detection or sw debounce being disabled */ -if ((line->irq && !READ_ONCE (line->sw_debounced)) || +if ((line->irq && !READ_ONCE (line->sw_debounced)) || prev_hte_flag || (!debounce_period_us &&READ_ONCE (line->sw_debounced))) -edge_detector_stop (line); +edge_detector_stop (line, prev_hte_flag); -return edge_detector_setup (line, lc, line_idx, eflags); +return edge_detector_setup (line, lc, line_idx, eflags, + flags &GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE ); } static u64 gpio_v2_line_config_flags(struct gpio_v2_line_config *lc,
@@ -891,7 +1058,6 @@ static int gpio_v2_line_flags_validate(u64 flags)/* Return an error if an unknown flag is set */ if (flags & ~GPIO_V2_LINE_VALID_FLAGS )return -EINVAL ; -/* * Do not allow both INPUT and OUTPUT flags to be set as they are * contradictory.
@@ -900,6 +1066,11 @@ static int gpio_v2_line_flags_validate(u64 flags) (flags & GPIO_V2_LINE_FLAG_OUTPUT))return -EINVAL ; +/* Only allow one event clock source */ +if ((flags &GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME ) && + (flags &GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE )) +return -EINVAL ; +/* Edge detection requires explicit input. */ if ((flags &GPIO_V2_LINE_EDGE_FLAGS ) && !(flags &GPIO_V2_LINE_FLAG_INPUT ))
@@ -992,6 +1163,8 @@ static void gpio_v2_line_config_flags_to_desc_flags(u64 flags,assign_bit (FLAG_EVENT_CLOCK_REALTIME , flagsp, flags &GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME ); +assign_bit (FLAG_EVENT_CLOCK_HTE , flagsp, + flags &GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE ); }static long linereq_get_values (struct linereq *lr,void __user *ip)
@@ -1121,6 +1294,7 @@ static long linereq_set_config_unlocked(struct linereq *lr,unsigned int i;u64 flags;bool polarity_change; +bool prev_hte_flag;int ret;for (i =0 ; i < lr->num_lines; i++) {
@@ -1130,6 +1304,8 @@ static long linereq_set_config_unlocked(struct linereq *lr, (!!test_bit (FLAG_ACTIVE_LOW , &desc->flags) != ((flags &GPIO_V2_LINE_FLAG_ACTIVE_LOW ) !=0 )); + prev_hte_flag = !!test_bit (FLAG_EVENT_CLOCK_HTE , &desc->flags); +gpio_v2_line_config_flags_to_desc_flags (flags, &desc->flags);/* * Lines have to be requested explicitly for input
@@ -1138,7 +1314,7 @@ static long linereq_set_config_unlocked(struct linereq *lr,if (flags &GPIO_V2_LINE_FLAG_OUTPUT ) {int val =gpio_v2_line_config_output_value (lc, i); -edge_detector_stop (&lr->lines[i]); +edge_detector_stop (&lr->lines[i], prev_hte_flag); ret =gpiod_direction_output (desc, val);if (ret)return ret;
@@ -1148,8 +1324,7 @@ static long linereq_set_config_unlocked(struct linereq *lr,return ret; ret =edge_detector_update (&lr->lines[i], lc, i, - flags &GPIO_V2_LINE_EDGE_FLAGS , - polarity_change); + flags, polarity_change, prev_hte_flag);if (ret)return ret; }
@@ -1278,9 +1453,12 @@ static ssize_t linereq_read(struct file *file,static void linereq_free (struct linereq *lr) {unsigned int i; +bool hte;for (i =0 ; i < lr->num_lines; i++) { -edge_detector_stop (&lr->lines[i]); + hte = !!test_bit (FLAG_EVENT_CLOCK_HTE , + &lr->lines[i].desc->flags); +edge_detector_stop (&lr->lines[i], hte);if (lr->lines[i].desc)gpiod_free (lr->lines[i].desc); }
@@ -1406,7 +1584,8 @@ static int linereq_create(struct gpio_device *gdev, void __user *ip) goto out_free_linereq; ret =edge_detector_setup (&lr->lines[i], lc, i, - flags &GPIO_V2_LINE_EDGE_FLAGS ); + flags &GPIO_V2_LINE_EDGE_FLAGS , + flags &GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE );if (ret) goto out_free_linereq; }
@@ -1959,6 +2138,8 @@ static void gpio_desc_to_lineinfo(struct gpio_desc *desc,if (test_bit (FLAG_EVENT_CLOCK_REALTIME , &desc->flags)) info->flags |=GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME ; +else if (test_bit (FLAG_EVENT_CLOCK_HTE , &desc->flags)) + info->flags |=GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE ; debounce_period_us =READ_ONCE (desc->debounce_period_us);if (debounce_period_us) {
include/uapi/linux/gpio.h +3 -0
@@ -66,6 +66,8 @@ struct gpiochip_info {* @GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN: line has pull-down bias enabled * @GPIO_V2_LINE_FLAG_BIAS_DISABLED: line has bias disabled * @GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME: line events contain REALTIME timestamps +* @GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE: line events contain timestamps from +* hardware timestamp engine */ enum gpio_v2_line_flag {GPIO_V2_LINE_FLAG_USED =_BITULL (0 ),
@@ -80,6 +82,7 @@ enum gpio_v2_line_flag {GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN =_BITULL (9 ),GPIO_V2_LINE_FLAG_BIAS_DISABLED =_BITULL (10 ),GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME =_BITULL (11 ), + GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE = _BITULL(12), };/**
Signature · 1 line
2.17.1
Dipen Patel
maintainerPATCH v5 9/11 tools: gpio: Add new hardware clock type
In reply to Dipen Patelgpiolib-cdev is extended to support hardware clock type, this patch reflects that fact.
--- tools/gpio/gpio-event-mon.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/gpio/gpio-event-mon.c +5 -1
@@ -149,6 +149,7 @@ void print_usage(void)" -r Listen for rising edges\n" " -f Listen for falling edges\n" " -w Report the wall-clock time for events\n" +" -t Report the hardware timestamp for events\n" " -b <n> Debounce the line with period n microseconds\n" " [-c <n>] Do <n> loops (optional, infinite loop if not stated)\n" " -? This helptext\n"
@@ -174,7 +175,7 @@ int main(int argc, char **argv)memset (&config,0 ,sizeof (config)); config.flags =GPIO_V2_LINE_FLAG_INPUT ; -while ((c =getopt (argc, argv,"c:n:o:b:dsrfw?" )) !=-1 ) { +while ((c =getopt (argc, argv,"c:n:o:b:dsrfwt?" )) !=-1 ) {switch (c) {case 'c' : loops =strtoul (optarg,NULL ,10 );
@@ -208,6 +209,9 @@ int main(int argc, char **argv)case 'w' : config.flags |=GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME ;break ; +case 't' : + config.flags |=GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE ; +break ;case '?' :print_usage ();return -1 ;
Signature · 1 line
2.17.1
Dipen Patel
maintainerPATCH v5 10/11 hte: Add tegra GPIO HTE test driver
In reply to Dipen PatelTegra194 AON GPIO controller supports hardware timestamping through its HTE known as Generic timestamping Engine(GTE). This kernel space gpio consumer test driver demonstrates HTE functionality. During probe it registers sysfs interface /sys/kernel/tegra_hte_gpio_test/gpio_en_dis. The value 1 enables gpio line for the HTE functionality while the value 0 disables that.
The test driver can be compiled as a module and takes optional parameters gpio_out and gpio_in of type uint that specifies logical GPIO numbers.
This patch also adds compilation support in Kconfig and Makefile.
---
Changes in v3:
- Addressed grammatical errors.
Changes in v4:
- Reflected HTE and GPIOLIB subsytem API changes.
drivers/hte/Kconfig | 9 + drivers/hte/Makefile | 1 + drivers/hte/hte-tegra194-gpio-test.c | 273 +++++++++++++++++++++++++++ 3 files changed, 283 insertions(+) create mode 100644 drivers/hte/hte-tegra194-gpio-test.c
drivers/hte/Kconfig +9 -0
@@ -38,4 +38,13 @@ config HTE_TEGRA194_IRQ_TEST The NVIDIA Tegra194 GTE IRQ test driver demonstrates HTE subsystem usage for the LIC IRQ hardware timestamp. +config HTE_TEGRA194_GPIO_TEST + tristate "NVIDIA Tegra194 HTE GPIO Test" + depends on HTE_TEGRA194 + help + The NVIDIA Tegra194 GTE GPIO test driver demonstrates how to use the HTE + subsystem indirectly through gpiolib API calls for GPIO lines for the + hardware-assisted timestamping. + endif +
drivers/hte/Makefile +1 -0
@@ -1,4 +1,5 @@ obj-$(CONFIG_HTE) += hte.o obj-$(CONFIG_HTE_TEGRA194) += hte-tegra194.o obj-$(CONFIG_HTE_TEGRA194_IRQ_TEST) += hte-tegra194-irq-test.o +obj-$(CONFIG_HTE_TEGRA194_GPIO_TEST) += hte-tegra194-gpio-test.o
drivers/hte/hte-tegra194-gpio-test.c new file +273 -0
273 lines not on this page · raw message
Signature · 1 line
2.17.1
Dipen Patel
maintainerPATCH v5 11/11 MAINTAINERS: Added HTE Subsystem
In reply to Dipen PatelAdded myself as a maintainer for this new Hardware Timestamping Engine (HTE) subsystem.
---
Changes in v3:
- Followed guidelines for the "M" field.
- Removed "*" in "F" field.
MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -8987,6 +8987,14 @@ L: [email protected] S: Maintained F: drivers/input/touchscreen/htcpen.c +HTE SUBSYSTEM +M: Dipen Patel <[email protected]> +S: Maintained +F: drivers/hte/ +F: include/linux/hte.h +F: Documentation/hte/ +F: Documentation/devicetree/bindings/hte/ + HTS221 TEMPERATURE-HUMIDITY IIO DRIVER M: Lorenzo Bianconi <[email protected]> L: [email protected]
Signature · 1 line
2.17.1
Quoted 9 lines · Dipen Patel
This patch series introduces new subsystem called hardware timestamping engine (HTE). It offers functionality such as timestamping through hardware means in realtime. The HTE subsystem centralizes HTE provider and consumers where providers can register themselves and the consumers can request interested entity which could be lines, GPIO, signals or buses. The HTE subsystem provides timestamp in nano seconds, having said that the provider need to convert the timestamp if its not in that unit. There was upstream discussion about the HTE at
https://lore.kernel.org/lkml/[email protected]/
I like this.
Can you put it in a public git and make it eligible for Stephen Rothwell to pull into linux-next and ask him to do so, as we intend to merge this for v5.19?
Yours,
Linus Walleij
Quoted 12 lines · Linus Walleij
Quoted 9 lines · Dipen Patel
This patch series introduces new subsystem called hardware timestamping engine (HTE). It offers functionality such as timestamping through hardware means in realtime. The HTE subsystem centralizes HTE provider and consumers where providers can register themselves and the consumers can request interested entity which could be lines, GPIO, signals or buses. The HTE subsystem provides timestamp in nano seconds, having said that the provider need to convert the timestamp if its not in that unit. There was upstream discussion about the HTE at
https://lore.kernel.org/lkml/[email protected]/
Quoted 5 lines
I like this.
Can you put it in a public git and make it eligible for Stephen Rothwell to pull into linux-next and ask him to do so, as we intend to merge this for v5.19?
Do you intend to maintain this as part of the pinctrl or GPIO trees with Dipen as a sub-maintainer? Or would you prefer for this to be a separate tree?
Thierry
Quoted 15 lines · Thierry Reding
Quoted 14 lines · Linus Walleij
Quoted 9 lines · Dipen Patel
This patch series introduces new subsystem called hardware timestamping engine (HTE). It offers functionality such as timestamping through hardware means in realtime. The HTE subsystem centralizes HTE provider and consumers where providers can register themselves and the consumers can request interested entity which could be lines, GPIO, signals or buses. The HTE subsystem provides timestamp in nano seconds, having said that the provider need to convert the timestamp if its not in that unit. There was upstream discussion about the HTE at
https://lore.kernel.org/lkml/[email protected]/I like this.
Quoted 7 lines
Quoted 3 lines
Can you put it in a public git and make it eligible for Stephen Rothwell to pull into linux-next and ask him to do so, as we intend to merge this for v5.19?
Do you intend to maintain this as part of the pinctrl or GPIO trees with Dipen as a sub-maintainer? Or would you prefer for this to be a separate tree?
It has nothing to do with pin control but a bit to do with GPIO and IIO. I think it needs to be its own tree just like regulators or clocks.
Yours,
Linus Walleij
Dipen Patel
maintainerHi Linus,
Thanks for the feedback. I have just sent v6 version reflecting review comments in dt binding.
I have also added some init APIs in hte core and moved few codes around. It does not change
much from the consumer point of view.
Quoted 19 lines · Linus Walleij
Quoted 9 lines · Dipen Patel
This patch series introduces new subsystem called hardware timestamping engine (HTE). It offers functionality such as timestamping through hardware means in realtime. The HTE subsystem centralizes HTE provider and consumers where providers can register themselves and the consumers can request interested entity which could be lines, GPIO, signals or buses. The HTE subsystem provides timestamp in nano seconds, having said that the provider need to convert the timestamp if its not in that unit. There was upstream discussion about the HTE at
https://lore.kernel.org/lkml/[email protected]/I like this.
Can you put it in a public git and make it eligible for Stephen Rothwell to pull into linux-next and ask him to do so, as we intend to merge this for v5.19?
Yours,
Linus Walleij