forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
include: Move ptp_clock.h to drivers/ptp_clock.h
Move ptp_clock.h out of the top level include/ dir into include/drivers/ptp_clock.h and deprecated the old location. Signed-off-by: Kumar Gala <[email protected]>
- Loading branch information
Showing
12 changed files
with
119 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Copyright (c) 2018 Intel Corporation. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef ZEPHYR_INCLUDE_DRIVERS_PTP_CLOCK_H_ | ||
#define ZEPHYR_INCLUDE_DRIVERS_PTP_CLOCK_H_ | ||
|
||
#include <kernel.h> | ||
#include <stdint.h> | ||
#include <device.h> | ||
#include <sys/util.h> | ||
#include <net/ptp_time.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* Name of the PTP clock driver */ | ||
#if !defined(PTP_CLOCK_NAME) | ||
#define PTP_CLOCK_NAME "PTP_CLOCK" | ||
#endif | ||
|
||
__subsystem struct ptp_clock_driver_api { | ||
int (*set)(const struct device *dev, struct net_ptp_time *tm); | ||
int (*get)(const struct device *dev, struct net_ptp_time *tm); | ||
int (*adjust)(const struct device *dev, int increment); | ||
int (*rate_adjust)(const struct device *dev, float ratio); | ||
}; | ||
|
||
/** | ||
* @brief Set the time of the PTP clock. | ||
* | ||
* @param dev PTP clock device | ||
* @param tm Time to set | ||
* | ||
* @return 0 if ok, <0 if error | ||
*/ | ||
static inline int ptp_clock_set(const struct device *dev, | ||
struct net_ptp_time *tm) | ||
{ | ||
const struct ptp_clock_driver_api *api = | ||
(const struct ptp_clock_driver_api *)dev->api; | ||
|
||
return api->set(dev, tm); | ||
} | ||
|
||
/** | ||
* @brief Get the time of the PTP clock. | ||
* | ||
* @param dev PTP clock device | ||
* @param tm Where to store the current time. | ||
* | ||
* @return 0 if ok, <0 if error | ||
*/ | ||
__syscall int ptp_clock_get(const struct device *dev, struct net_ptp_time *tm); | ||
|
||
static inline int z_impl_ptp_clock_get(const struct device *dev, | ||
struct net_ptp_time *tm) | ||
{ | ||
const struct ptp_clock_driver_api *api = | ||
(const struct ptp_clock_driver_api *)dev->api; | ||
|
||
return api->get(dev, tm); | ||
} | ||
|
||
/** | ||
* @brief Adjust the PTP clock time. | ||
* | ||
* @param dev PTP clock device | ||
* @param increment Increment of the clock in nanoseconds | ||
* | ||
* @return 0 if ok, <0 if error | ||
*/ | ||
static inline int ptp_clock_adjust(const struct device *dev, int increment) | ||
{ | ||
const struct ptp_clock_driver_api *api = | ||
(const struct ptp_clock_driver_api *)dev->api; | ||
|
||
return api->adjust(dev, increment); | ||
} | ||
|
||
/** | ||
* @brief Adjust the PTP clock time change rate when compared to its neighbor. | ||
* | ||
* @param dev PTP clock device | ||
* @param rate Rate of the clock time change | ||
* | ||
* @return 0 if ok, <0 if error | ||
*/ | ||
static inline int ptp_clock_rate_adjust(const struct device *dev, float rate) | ||
{ | ||
const struct ptp_clock_driver_api *api = | ||
(const struct ptp_clock_driver_api *)dev->api; | ||
|
||
return api->rate_adjust(dev, rate); | ||
} | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#include <syscalls/ptp_clock.h> | ||
|
||
#endif /* ZEPHYR_INCLUDE_DRIVERS_PTP_CLOCK_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters