Zephyr Project API 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
24
25#include <zephyr/kernel.h>
26#include <stdint.h>
27#include <zephyr/device.h>
28#include <zephyr/sys/util.h>
29#include <zephyr/net/ptp_time.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/* Name of the PTP clock driver */
36#if !defined(PTP_CLOCK_NAME)
37#define PTP_CLOCK_NAME "PTP_CLOCK"
38#endif
39
44
49typedef int (*ptp_clock_api_set_t)(const struct device *dev, struct net_ptp_time *tm);
50
55typedef int (*ptp_clock_api_get_t)(const struct device *dev, struct net_ptp_time *tm);
56
61typedef int (*ptp_clock_api_adjust_t)(const struct device *dev, int increment);
62
67typedef int (*ptp_clock_api_rate_adjust_t)(const struct device *dev, double ratio);
68
90
92
101static inline int ptp_clock_set(const struct device *dev,
102 struct net_ptp_time *tm)
103{
104 return DEVICE_API_GET(ptp_clock, dev)->set(dev, tm);
105}
106
115__syscall int ptp_clock_get(const struct device *dev, struct net_ptp_time *tm);
116
117static inline int z_impl_ptp_clock_get(const struct device *dev,
118 struct net_ptp_time *tm)
119{
120 return DEVICE_API_GET(ptp_clock, dev)->get(dev, tm);
121}
122
131static inline int ptp_clock_adjust(const struct device *dev, int increment)
132{
133 return DEVICE_API_GET(ptp_clock, dev)->adjust(dev, increment);
134}
135
144static inline int ptp_clock_rate_adjust(const struct device *dev, double rate)
145{
146 return DEVICE_API_GET(ptp_clock, dev)->rate_adjust(dev, rate);
147}
148
149#ifdef __cplusplus
150}
151#endif
152
153#include <zephyr/syscalls/ptp_clock.h>
154
158
159#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:1449
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:144
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:101
int ptp_clock_get(const struct device *dev, struct net_ptp_time *tm)
Get the time of the PTP clock.
int(* ptp_clock_api_get_t)(const struct device *dev, struct net_ptp_time *tm)
Get the time of the PTP clock.
Definition ptp_clock.h:55
static int ptp_clock_adjust(const struct device *dev, int increment)
Adjust the PTP clock time.
Definition ptp_clock.h:131
int(* ptp_clock_api_adjust_t)(const struct device *dev, int increment)
Adjust the PTP clock time.
Definition ptp_clock.h:61
int(* ptp_clock_api_rate_adjust_t)(const struct device *dev, double ratio)
Adjust the PTP clock rate ratio based on its nominal frequency.
Definition ptp_clock.h:67
int(* ptp_clock_api_set_t)(const struct device *dev, struct net_ptp_time *tm)
@def_driverbackendgroup{PTP Clock,ptp_clock_interface}
Definition ptp_clock.h:49
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
@driver_ops{PTP Clock}
Definition ptp_clock.h:72
ptp_clock_api_set_t set
@driver_ops_mandatory Set the time of the PTP clock.
Definition ptp_clock.h:76
ptp_clock_api_get_t get
@driver_ops_mandatory Get the time of the PTP clock.
Definition ptp_clock.h:80
ptp_clock_api_rate_adjust_t rate_adjust
@driver_ops_mandatory Adjust the PTP clock rate ratio based on its nominal frequency.
Definition ptp_clock.h:88
ptp_clock_api_adjust_t adjust
@driver_ops_mandatory Adjust the PTP clock time.
Definition ptp_clock.h:84
Definition time.h:24
Misc utilities.