From 6ff9cac2cad40cf6fd054410f1f965feb61f5f92 Mon Sep 17 00:00:00 2001 From: Dipen Patel Date: Wed, 29 Jan 2020 22:19:27 -0800 Subject: drivers: staging: Add Generic timestamping support Adds generic hardware timestamping (GTE) support for the T194 SoC. There are certain applications like robotics which may require more accurate recording of the occurance of the certain events. GTE driver will help monitor AON GPIOs and LIC interrupts. GTE driver also implements char driver for userspace to monitor GPIO through IOCTL. Other kernel APIs are exported and defined in the tegra-gte.h file for kernel client drivers to use. APIs are not stable and subject to change in the future. It is for this reason GTE driver is provided in the staging directory. Since its APIs are not stable, it should not break existing nvpps driver code from the stage-main which also uses GTE but in limited way. It is for this reason this driver will not be selected if nvpps is enabled. Bug 2757864 Change-Id: I0947f2b90232eb6c2a31163e33ec5ad45b7bd415 Signed-off-by: Dipen Patel Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2287452 Reviewed-by: Bibek Basu Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- include/linux/tegra-gte.h | 105 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 include/linux/tegra-gte.h (limited to 'include/linux') diff --git a/include/linux/tegra-gte.h b/include/linux/tegra-gte.h new file mode 100644 index 000000000..4862db05d --- /dev/null +++ b/include/linux/tegra-gte.h @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#ifndef _LINUX_TEGRA_GTE_ENGINE_H +#define _LINUX_TEGRA_GTE_ENGINE_H + +#include + +struct tegra_gte_ev_desc { + int id; + int gid; + u32 ev_bit; + u32 slice; +}; + +/* GTE hardware timestamping event details */ +struct tegra_gte_ev_detail { + u64 ts_raw; /* raw counter value */ + u64 ts_ns; /* counter value converted into nano seconds */ + int dir; /* direction of the event */ +}; + +#ifdef CONFIG_TEGRA_HTS_GTE +/* + * GTE event registration function + * + * Parameters: + * + * Input: + * @np: device node of the interested GTE device + * @ev_id: event id + * + * Returns: + * Returns ERR_PTR in case of failure or valid + * struct tegra_gte_ev_desc for success. + * + * Note: API is not stable and subject to change. + */ +struct tegra_gte_ev_desc *tegra_gte_register_event(struct device_node *np, + u32 ev_id); + +/* + * GTE event un-registration function + * + * Parameters: + * + * Input: + * @desc: This parameter should be the same as returned from register + * + * Returns: + * Returns 0 for success and any other value for the failure + * + * Note: API is not stable and subject to change. + */ +int tegra_gte_unregister_event(struct tegra_gte_ev_desc *desc); + +/* + * GTE event retrieval function + * + * Parameters: + * + * Input: + * @desc: This parameter should be the same as returned from register + * + * Output: + * @hts: hts event details + * + * Returns: + * Returns 0 for success and any other value for the failure + * + * Note: API is not stable and subject to change. + */ +int tegra_gte_retrieve_event(const struct tegra_gte_ev_desc *desc, + struct tegra_gte_ev_detail *hts); + +#else /* ! CONFIG_TEGRA_HTS_GTE */ +static inline struct tegra_gte_ev_desc *tegra_gte_register_event( + struct device_node *np, u32 ev_id) +{ + return ERR_PTR(-ENOSYS); +} + +static inline int tegra_gte_unregister_event(struct tegra_gte_ev_desc *desc) +{ + return -ENOSYS; +} + +static inline int tegra_gte_retrieve_event(const struct tegra_gte_ev_desc *desc, + struct tegra_gte_ev_detail *hts) +{ + return -ENOSYS; +} + +#endif /* ! CONFIG_TEGRA_HTS_GTE */ +#endif -- cgit v1.2.2