From ddbed75fbebb66fe5ae534c9284986197f96c247 Mon Sep 17 00:00:00 2001 From: Rajesh Hosakote Date: Mon, 17 Oct 2016 20:18:39 +0530 Subject: PTP update notification framework Bug 1823033 Change-Id: I345e707455e5e64ad316143e3cea085b20588110 Signed-off-by: Rajesh Hosakote Reviewed-on: http://git-master/r/1237704 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Dmitry Pervushin GVS: Gerrit_Virtual_Submit Reviewed-by: Sumeet Gupta --- include/linux/platform/tegra/ptp-notifier.h | 81 +++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 include/linux/platform/tegra/ptp-notifier.h (limited to 'include/linux/platform/tegra') diff --git a/include/linux/platform/tegra/ptp-notifier.h b/include/linux/platform/tegra/ptp-notifier.h new file mode 100644 index 000000000..fa9681278 --- /dev/null +++ b/include/linux/platform/tegra/ptp-notifier.h @@ -0,0 +1,81 @@ +/* + * include/linux/platform/tegra/ptp-notifier.h + * + * Copyright (c) 2016, 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __PTP_NOTIFIER_H +#define __PTP_NOTIFIER_H + +#ifdef CONFIG_TEGRA_PTP_NOTIFIER +/* register / unregister HW time source */ +void tegra_register_hwtime_source(u64 (*func)(void)); +void tegra_unregister_hwtime_source(void); + +/* clients registering / unregistering for time update events */ +int tegra_register_hwtime_notifier(struct notifier_block *nb); +int tegra_unregister_hwtime_notifier(struct notifier_block *nb); + +/* Notify time updates to registered clients */ +int tegra_hwtime_notifier_call_chain(unsigned int val, void *v); + +/* + * Get HW time counter. + * Clients may call the API every anytime PTP time is needed. + * If HW time source is not registered, returns ktime_get_real instead + */ +u64 get_ptp_hwtime(void); + +#else /* CONFIG_TEGRA_PTP_NOTIFIER */ + +/* register / unregister HW time source */ +static inline void tegra_register_hwtime_source(u64 (*func)(void)) +{ +} + +static inline void tegra_unregister_hwtime_source(void) +{ +} + +/* clients registering / unregistering for time update events */ +static inline int tegra_register_hwtime_notifier(struct notifier_block *nb) +{ + return 0; +} + +static inline int tegra_unregister_hwtime_notifier(struct notifier_block *nb) +{ + return -ENOENT; +} + +/* Notify time updates to registered clients */ +static inline int tegra_hwtime_notifier_call_chain(unsigned int val, void *v) +{ + return notifier_to_errno(NOTIFY_DONE); +} + +/* + * Get HW time counter. + * Clients may call the API every anytime PTP time is needed. + * If HW time source is not registered, returns ktime_get_real instead + */ +static inline u64 get_ptp_hwtime(void) +{ + return ktime_to_ns(ktime_get_real()); +} + +#endif /* CONFIG_TEGRA_PTP_NOTIFIER */ + +#endif /* __PTP_NOTIFIER_H */ -- cgit v1.2.2