mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 13:27:01 +08:00
drivers/timers/ptp: support ptp clock dummy driver
This patch adds a dummy PTP clock driver implementation that provides a software-based PTP clock for testing and development purposes. Key changes include: 1. Dummy PTP clock driver implementation: - Added drivers/timers/ptp_clock_dummy.c - Provides software-based PTP clock using system monotonic clock - Implements all required lower-half driver operations 2. Lower-half driver operations: - adjfine: Frequency adjustment (stores adjustment value) - adjtime: Time offset adjustment (applies delta to base time) - gettime: Returns current PTP clock time - settime: Sets PTP clock time - getcaps: Reports clock capabilities (1 billion PPB max adjustment) - getcrosststamp: Provides system/device cross-timestamp 3. Driver initialization: - Added ptp_clock_dummy_init() in drivers/drivers_initialize.c - Auto-registration under CONFIG_PTP_CLOCK_DUMMY configuration - Creates /dev/ptp0 character device node 4. Build system integration: - Added CONFIG_PTP_CLOCK_DUMMY Kconfig option (depends on PTP_CLOCK) - Updated CMakeLists.txt and Make.defs - Added include/nuttx/timers/ptp_clock_dummy.h header 5. Implementation details: - Uses clock_gettime(CLOCK_MONOTONIC) as time base - Tracks time offset and frequency adjustment internally - Suitable for testing PTP clock applications without hardware This dummy driver enables development and testing of PTP clock applications on platforms without dedicated PTP hardware support. Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
committed by
Alan C. Assis
parent
31eb339356
commit
314cccf166
@@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/timers/ptp_clock_dummy.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_TIMERS_PTP_CLOCK_DUMMY_H
|
||||
#define __INCLUDE_NUTTX_TIMERS_PTP_CLOCK_DUMMY_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ptp_clock_dummy_initialize
|
||||
*
|
||||
* Description:
|
||||
* This function will initialize dummy ptp device driver for test.
|
||||
*
|
||||
* Input Parameters:
|
||||
* devno - The user specifies number of device. ex: /dev/ptpX.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK if the driver was successfully initialize; A negated errno value is
|
||||
* returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ptp_clock_dummy_initialize(int devno);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif /* __INCLUDE_NUTTX_TIMERS_PTP_CLOCK_DUMMY_H */
|
||||
Reference in New Issue
Block a user