Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ptp_clock.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_DRIVERS_PTP_CLOCK_H_
14#define ZEPHYR_INCLUDE_DRIVERS_PTP_CLOCK_H_
15
22
23#include <zephyr/kernel.h>
24#include <stdint.h>
25#include <zephyr/device.h>
26#include <zephyr/sys/util.h>
27#include <zephyr/net/ptp_time.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/* Name of the PTP clock driver */
34#if !defined(PTP_CLOCK_NAME)
35#define PTP_CLOCK_NAME "PTP_CLOCK"
36#endif
37
38__subsystem struct ptp_clock_driver_api {
39 int (*set)(const struct device *dev, struct net_ptp_time *tm);
40 int (*get)(const struct device *dev, struct net_ptp_time *tm);
41 int (*adjust)(const struct device *dev, int increment);
42 int (*rate_adjust)(const struct device *dev, double ratio);
43};
44
53static inline int ptp_clock_set(const struct device *dev,
54 struct net_ptp_time *tm)
55{
56 return DEVICE_API_GET(ptp_clock, dev)->set(dev, tm);
57}
58
67__syscall int ptp_clock_get(const struct device *dev, struct net_ptp_time *tm);
68
69static inline int z_impl_ptp_clock_get(const struct device *dev,
70 struct net_ptp_time *tm)
71{
72 return DEVICE_API_GET(ptp_clock, dev)->get(dev, tm);
73}
74
83static inline int ptp_clock_adjust(const struct device *dev, int increment)
84{
85 return DEVICE_API_GET(ptp_clock, dev)->adjust(dev, increment);
86}
87
96static inline int ptp_clock_rate_adjust(const struct device *dev, double rate)
97{
98 return DEVICE_API_GET(ptp_clock, dev)->rate_adjust(dev, rate);
99}
100
101#ifdef __cplusplus
102}
103#endif
104
105#include <zephyr/syscalls/ptp_clock.h>
106
110
111#endif /* ZEPHYR_INCLUDE_DRIVERS_PTP_CLOCK_H_ */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1375
static int ptp_clock_rate_adjust(const struct device *dev, double rate)
Adjust the PTP clock rate ratio based on its nominal frequency.
Definition ptp_clock.h:96
static int ptp_clock_set(const struct device *dev, struct net_ptp_time *tm)
Set the time of the PTP clock.
Definition ptp_clock.h:53
int ptp_clock_get(const struct device *dev, struct net_ptp_time *tm)
Get the time of the PTP clock.
static int ptp_clock_adjust(const struct device *dev, int increment)
Adjust the PTP clock time.
Definition ptp_clock.h:83
Public kernel APIs.
Public functions for the Precision Time Protocol time specification.
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
(Generalized) Precision Time Protocol Timestamp format.
Definition ptp_time.h:111
Definition ptp_clock.h:38
int(* get)(const struct device *dev, struct net_ptp_time *tm)
Definition ptp_clock.h:40
int(* adjust)(const struct device *dev, int increment)
Definition ptp_clock.h:41
int(* rate_adjust)(const struct device *dev, double ratio)
Definition ptp_clock.h:42
int(* set)(const struct device *dev, struct net_ptp_time *tm)
Definition ptp_clock.h:39
Definition time.h:24
Misc utilities.