drivers/timers/ptp: support ptp clock driver model

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>
This commit is contained in:
dongjiuzhu1
2025-03-22 15:09:48 +08:00
committed by Alan C. Assis
parent 7298977894
commit 31eb339356
10 changed files with 1019 additions and 1 deletions
+35
View File
@@ -2366,6 +2366,41 @@ config DEBUG_PCI_INFO
endif # DEBUG_PCI
config DEBUG_PTP
bool "PTP Debug Features"
default n
depends on PTP_CLOCK
---help---
Enable PTP driver debug features.
Support for this debug option is architecture-specific and may not
be available for some MCUs.
if DEBUG_PTP
config DEBUG_PTP_ERROR
bool "PTP Error Output"
default n
depends on DEBUG_ERROR
---help---
Enable PTP driver error output to SYSLOG.
config DEBUG_PTP_WARN
bool "PTP Warnings Output"
default n
depends on DEBUG_WARN
---help---
Enable PTP driver warning output to SYSLOG.
config DEBUG_PTP_INFO
bool "PTP Informational Output"
default n
depends on DEBUG_INFO
---help---
Enable PTP driver informational output to SYSLOG.
endif # DEBUG_PTP
config DEBUG_RPMSG
bool "RPMSG Debug Features"
default n