Skip to content

Commit 184ecc9

Browse files
vincentc-renesasdavem330
authored andcommitted
ptp: Add adjphase function to support phase offset control.
Adds adjust phase function to take advantage of a PHC clock's hardware filtering capability that uses phase offset control word instead of frequency offset control word. Signed-off-by: Vincent Cheng <[email protected]> Reviewed-by: Richard Cochran <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 115506f commit 184ecc9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

drivers/ptp/ptp_clock.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx)
146146
else
147147
err = ops->adjfreq(ops, ppb);
148148
ptp->dialed_frequency = tx->freq;
149+
} else if (tx->modes & ADJ_OFFSET) {
150+
if (ops->adjphase)
151+
err = ops->adjphase(ops, tx->offset);
149152
} else if (tx->modes == 0) {
150153
tx->freq = ptp->dialed_frequency;
151154
err = 0;

include/linux/ptp_clock_kernel.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct ptp_system_timestamp {
3636
};
3737

3838
/**
39-
* struct ptp_clock_info - decribes a PTP hardware clock
39+
* struct ptp_clock_info - describes a PTP hardware clock
4040
*
4141
* @owner: The clock driver should set to THIS_MODULE.
4242
* @name: A short "friendly name" to identify the clock and to
@@ -65,6 +65,9 @@ struct ptp_system_timestamp {
6565
* parameter delta: Desired frequency offset from nominal frequency
6666
* in parts per billion
6767
*
68+
* @adjphase: Adjusts the phase offset of the hardware clock.
69+
* parameter delta: Desired change in nanoseconds.
70+
*
6871
* @adjtime: Shifts the time of the hardware clock.
6972
* parameter delta: Desired change in nanoseconds.
7073
*
@@ -128,6 +131,7 @@ struct ptp_clock_info {
128131
struct ptp_pin_desc *pin_config;
129132
int (*adjfine)(struct ptp_clock_info *ptp, long scaled_ppm);
130133
int (*adjfreq)(struct ptp_clock_info *ptp, s32 delta);
134+
int (*adjphase)(struct ptp_clock_info *ptp, s32 phase);
131135
int (*adjtime)(struct ptp_clock_info *ptp, s64 delta);
132136
int (*gettime64)(struct ptp_clock_info *ptp, struct timespec64 *ts);
133137
int (*gettimex64)(struct ptp_clock_info *ptp, struct timespec64 *ts,

0 commit comments

Comments
 (0)