mirror of
https://github.com/apache/nuttx.git
synced 2026-05-10 07:18:49 +08:00
31eb339356
This patch introduces the foundational PTP (Precision Time Protocol) clock driver framework for NuttX, enabling precise time synchronization support based on IEEE 1588 standard. Key changes include: 1. New PTP clock driver infrastructure: - Added drivers/timers/ptp_clock.c implementing upper-half driver - Created include/nuttx/timers/ptp_clock.h with PTP clock interfaces - Implemented upper/lower half driver architecture for hardware abstraction 2. Core functionality: - Clock time get/set operations (gettime, settime) - Frequency adjustment support (adjtime, adjfine) - Phase adjustment capabilities - System-device cross-timestamping for precise synchronization 3. IOCTL commands: - PTP_CLOCK_SETTIME/GETTIME for time manipulation - PTP_CLOCK_GETRES for resolution queries - PTP_CLOCK_ADJTIME for time adjustment - PTP_CLOCK_GETCAPS for capability queries - PTP_SYS_OFFSET* for system offset measurements 4. Supporting structures: - struct ptp_lowerhalf_s: lower-half driver interface - struct ptp_clock_caps: clock capabilities descriptor - struct ptp_sys_offset: system time offset measurement - Added timex structures in include/sys/timex.h for ADJ_* operations 5. Build system integration: - Added CONFIG_PTP_CLOCK Kconfig option - Updated CMakeLists.txt and Make.defs - Added PTPCLK debug macros in include/debug.h This framework provides the base for PTP clock implementations, allowing hardware-specific drivers to register and provide precise time services through a standardized interface. Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>