diff options
| author | Rajesh Hosakote <rhosakote@nvidia.com> | 2016-10-17 10:48:39 -0400 |
|---|---|---|
| committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2016-11-16 14:04:23 -0500 |
| commit | ddbed75fbebb66fe5ae534c9284986197f96c247 (patch) | |
| tree | 13f858545129eb7176e70fd409f68cabfe20f82e /include/linux/platform/tegra | |
| parent | 0697a2d2826a66c86dae9ce0b280dad63e48f681 (diff) | |
PTP update notification framework
Bug 1823033
Change-Id: I345e707455e5e64ad316143e3cea085b20588110
Signed-off-by: Rajesh Hosakote <rhosakote@nvidia.com>
Reviewed-on: http://git-master/r/1237704
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Dmitry Pervushin <dpervushin@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sumeet Gupta <sumeetg@nvidia.com>
Diffstat (limited to 'include/linux/platform/tegra')
| -rw-r--r-- | include/linux/platform/tegra/ptp-notifier.h | 81 |
1 files changed, 81 insertions, 0 deletions
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 @@ | |||
| 1 | /* | ||
| 2 | * include/linux/platform/tegra/ptp-notifier.h | ||
| 3 | * | ||
| 4 | * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify it | ||
| 7 | * under the terms and conditions of the GNU General Public License, | ||
| 8 | * version 2, as published by the Free Software Foundation. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 13 | * more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #ifndef __PTP_NOTIFIER_H | ||
| 20 | #define __PTP_NOTIFIER_H | ||
| 21 | |||
| 22 | #ifdef CONFIG_TEGRA_PTP_NOTIFIER | ||
| 23 | /* register / unregister HW time source */ | ||
| 24 | void tegra_register_hwtime_source(u64 (*func)(void)); | ||
| 25 | void tegra_unregister_hwtime_source(void); | ||
| 26 | |||
| 27 | /* clients registering / unregistering for time update events */ | ||
| 28 | int tegra_register_hwtime_notifier(struct notifier_block *nb); | ||
| 29 | int tegra_unregister_hwtime_notifier(struct notifier_block *nb); | ||
| 30 | |||
| 31 | /* Notify time updates to registered clients */ | ||
| 32 | int tegra_hwtime_notifier_call_chain(unsigned int val, void *v); | ||
| 33 | |||
| 34 | /* | ||
| 35 | * Get HW time counter. | ||
| 36 | * Clients may call the API every anytime PTP time is needed. | ||
| 37 | * If HW time source is not registered, returns ktime_get_real instead | ||
| 38 | */ | ||
| 39 | u64 get_ptp_hwtime(void); | ||
| 40 | |||
| 41 | #else /* CONFIG_TEGRA_PTP_NOTIFIER */ | ||
| 42 | |||
| 43 | /* register / unregister HW time source */ | ||
| 44 | static inline void tegra_register_hwtime_source(u64 (*func)(void)) | ||
| 45 | { | ||
| 46 | } | ||
| 47 | |||
| 48 | static inline void tegra_unregister_hwtime_source(void) | ||
| 49 | { | ||
| 50 | } | ||
| 51 | |||
| 52 | /* clients registering / unregistering for time update events */ | ||
| 53 | static inline int tegra_register_hwtime_notifier(struct notifier_block *nb) | ||
| 54 | { | ||
| 55 | return 0; | ||
| 56 | } | ||
| 57 | |||
| 58 | static inline int tegra_unregister_hwtime_notifier(struct notifier_block *nb) | ||
| 59 | { | ||
| 60 | return -ENOENT; | ||
| 61 | } | ||
| 62 | |||
| 63 | /* Notify time updates to registered clients */ | ||
| 64 | static inline int tegra_hwtime_notifier_call_chain(unsigned int val, void *v) | ||
| 65 | { | ||
| 66 | return notifier_to_errno(NOTIFY_DONE); | ||
| 67 | } | ||
| 68 | |||
| 69 | /* | ||
| 70 | * Get HW time counter. | ||
| 71 | * Clients may call the API every anytime PTP time is needed. | ||
| 72 | * If HW time source is not registered, returns ktime_get_real instead | ||
| 73 | */ | ||
| 74 | static inline u64 get_ptp_hwtime(void) | ||
| 75 | { | ||
| 76 | return ktime_to_ns(ktime_get_real()); | ||
| 77 | } | ||
| 78 | |||
| 79 | #endif /* CONFIG_TEGRA_PTP_NOTIFIER */ | ||
| 80 | |||
| 81 | #endif /* __PTP_NOTIFIER_H */ | ||
