phc2sys: Read maximum frequency adjustment.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>master
parent
1f2c9de982
commit
e3f57d1579
5
makefile
5
makefile
|
@ -52,8 +52,9 @@ ptp4l: $(OBJ)
|
|||
pmc: msg.o pmc.o pmc_common.o print.o raw.o sk.o tlv.o transport.o udp.o \
|
||||
udp6.o uds.o util.o version.o
|
||||
|
||||
phc2sys: clockadj.o msg.o phc2sys.o pmc_common.o print.o pi.o servo.o raw.o \
|
||||
sk.o stats.o sysoff.o tlv.o transport.o udp.o udp6.o uds.o util.o version.o
|
||||
phc2sys: clockadj.o msg.o phc.o phc2sys.o pi.o pmc_common.o print.o servo.o \
|
||||
raw.o sk.o stats.o sysoff.o tlv.o transport.o udp.o udp6.o uds.o util.o \
|
||||
version.o
|
||||
|
||||
hwstamp_ctl: hwstamp_ctl.o version.o
|
||||
|
||||
|
|
14
phc2sys.c
14
phc2sys.c
|
@ -37,6 +37,7 @@
|
|||
#include "ds.h"
|
||||
#include "fsm.h"
|
||||
#include "missing.h"
|
||||
#include "phc.h"
|
||||
#include "pi.h"
|
||||
#include "pmc_common.h"
|
||||
#include "print.h"
|
||||
|
@ -52,8 +53,6 @@
|
|||
#define KI 0.3
|
||||
#define NS_PER_SEC 1000000000LL
|
||||
|
||||
#define max_ppb 512000
|
||||
|
||||
#define PHC_PPS_OFFSET_LIMIT 10000000
|
||||
#define PMC_UPDATE_INTERVAL (60 * NS_PER_SEC)
|
||||
|
||||
|
@ -543,7 +542,7 @@ int main(int argc, char *argv[])
|
|||
char *progname, *ethdev = NULL;
|
||||
clockid_t src = CLOCK_INVALID;
|
||||
int c, phc_readings = 5, phc_rate = 1, pps_fd = -1;
|
||||
int r, wait_sync = 0, forced_sync_offset = 0;
|
||||
int max_ppb, r, wait_sync = 0, forced_sync_offset = 0;
|
||||
int print_level = LOG_INFO, use_syslog = 1, verbose = 0;
|
||||
double ppb;
|
||||
struct clock dst_clock = {
|
||||
|
@ -701,6 +700,15 @@ int main(int argc, char *argv[])
|
|||
make sure ppb is the actual frequency of the clock. */
|
||||
clockadj_set_freq(dst_clock.clkid, ppb);
|
||||
clockadj_set_leap(dst_clock.clkid, 0);
|
||||
if (dst_clock.clkid == CLOCK_REALTIME) {
|
||||
max_ppb = sysclk_max_freq();
|
||||
} else {
|
||||
max_ppb = phc_max_adj(dst_clock.clkid);
|
||||
if (!max_ppb) {
|
||||
pr_err("clock is not adjustable");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
dst_clock.servo = servo_create(CLOCK_SERVO_PI, -ppb, max_ppb, 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue