Commit 6bc8b47d authored by li hongming's avatar li hongming

support new cute-wr-a7 board

parent e3a99db4
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "wrpc.h" #include "wrpc.h"
#include <errno.h> #include <errno.h>
#include "shell.h" #include "shell.h"
#include "syscon.h" #include "dev/syscon.h"
extern struct pp_instance ppi_static[wr_num_ports]; extern struct pp_instance ppi_static[wr_num_ports];
extern int frame_rx_delay_us; extern int frame_rx_delay_us;
......
This diff is collapsed.
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Released to the public domain * Released to the public domain
*/ */
#include <endpoint.h> #include <dev/endpoint.h>
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include <softpll_ng.h> #include <softpll_ng.h>
#include <hal_exports.h> #include <hal_exports.h>
...@@ -18,10 +18,10 @@ int wrpc_read_calibration_data(struct pp_instance *ppi, ...@@ -18,10 +18,10 @@ int wrpc_read_calibration_data(struct pp_instance *ppi,
uint32_t *deltaTx, uint32_t *deltaRx, int32_t *fix_alpha, uint32_t *deltaTx, uint32_t *deltaRx, int32_t *fix_alpha,
int32_t *clock_period) int32_t *clock_period)
{ {
int port = atoi(ppi->iface_name[2]); int port = atoi(&(ppi->iface_name[2]));
struct hal_port_state state; struct hal_port_state state;
wrpc_get_port_state(&state, ppi->iface_name); wrpc_get_port_state(&state, port);
/* check if the data is available */ /* check if the data is available */
if (fix_alpha) if (fix_alpha)
...@@ -87,12 +87,14 @@ int wrpc_calibration_pattern_enable(struct pp_instance *ppi, ...@@ -87,12 +87,14 @@ int wrpc_calibration_pattern_enable(struct pp_instance *ppi,
unsigned int calibrationPattern, unsigned int calibrationPattern,
unsigned int calibrationPatternLen) unsigned int calibrationPatternLen)
{ {
ep_cal_pattern_enable(atoi(&ppi->iface_name[2])); int port = atoi(&(ppi->iface_name[2]));
ep_cal_pattern_enable(port);
return WR_HW_CALIB_OK; return WR_HW_CALIB_OK;
} }
int wrpc_calibration_pattern_disable(struct pp_instance *ppi) int wrpc_calibration_pattern_disable(struct pp_instance *ppi)
{ {
ep_cal_pattern_disable(atoi(&ppi->iface_name[2])); int port = atoi(&(ppi->iface_name[2]));
ep_cal_pattern_disable(port);
return WR_HW_CALIB_OK; return WR_HW_CALIB_OK;
} }
...@@ -7,19 +7,19 @@ ...@@ -7,19 +7,19 @@
#include <stdint.h> #include <stdint.h>
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include <pps_gen.h> #include <dev/pps_gen.h>
#include <softpll_ng.h> #include <softpll_ng.h>
#include "../proto-ext-whiterabbit/wr-constants.h" #include "../proto-ext-whiterabbit/wr-constants.h"
#include <rxts_calibrator.h> #include <dev/rxts_calibrator.h>
#include "wrpc.h" #include "wrpc.h"
extern uint32_t cal_phase_transition[]; extern uint32_t cal_phase_transition[];
int wrpc_spll_locking_enable(struct pp_instance *ppi) int wrpc_spll_locking_enable(struct pp_instance *ppi)
{ {
int port = atoi(&ppi->iface_name[2]); int port = atoi(&(ppi->iface_name[2]));
spll_init(SPLL_MODE_SLAVE, port, 1); spll_init(SPLL_MODE_SLAVE, 2*port, 1);
spll_enable_ptracker(port, 1); spll_enable_ptracker(2*port, 1);
rxts_calibration_start(port); rxts_calibration_start(port);
return WR_SPLL_OK; return WR_SPLL_OK;
} }
...@@ -29,7 +29,7 @@ int wrpc_spll_locking_poll(struct pp_instance *ppi, int grandmaster) ...@@ -29,7 +29,7 @@ int wrpc_spll_locking_poll(struct pp_instance *ppi, int grandmaster)
int locked; int locked;
int i; int i;
static int t24p_calibrated[wr_num_ports]={0,0}; static int t24p_calibrated[wr_num_ports]={0,0};
int port = atoi(&ppi->iface_name[2]); int port = atoi(&(ppi->iface_name[2]));
locked = spll_check_lock(0); /* both slave and gm mode */ locked = spll_check_lock(0); /* both slave and gm mode */
...@@ -58,18 +58,25 @@ int wrpc_spll_locking_disable(struct pp_instance *ppi) ...@@ -58,18 +58,25 @@ int wrpc_spll_locking_disable(struct pp_instance *ppi)
int wrpc_spll_enable_ptracker(struct pp_instance *ppi) int wrpc_spll_enable_ptracker(struct pp_instance *ppi)
{ {
spll_enable_ptracker(atoi(&ppi->iface_name[2]), 1); int port = atoi(&(ppi->iface_name[2]));
// for rx clock
spll_enable_ptracker(2*port, 1);
// for tx clock
spll_enable_ptracker(2*port+1, 1);
return WR_SPLL_OK; return WR_SPLL_OK;
} }
int wrpc_enable_timing_output(struct pp_instance *ppi, int enable) int wrpc_enable_timing_output(struct pp_instance *ppi, int enable)
{ {
int port = atoi(&(ppi->iface_name[2]));
if (enable == WR_DSPOR(ppi)->ppsOutputOn) if (enable == WR_DSPOR(ppi)->ppsOutputOn)
return WR_SPLL_OK; return WR_SPLL_OK;
WR_DSPOR(ppi)->ppsOutputOn = enable; WR_DSPOR(ppi)->ppsOutputOn = enable;
if(port==0)
shw_pps_gen_enable_output(enable); shw_pps_gen_enable_output(enable); // For LED of SFP0.
shw_pps_gen_time_valid(enable); else
shw_pps_gen_time_valid(enable); // For LED of SFP1.
// shw_pps_gen_unmask_output(enable); // For generation of timing signals.
return WR_SPLL_OK; return WR_SPLL_OK;
} }
...@@ -83,7 +90,7 @@ int wrpc_adjust_counters(int64_t adjust_sec, int32_t adjust_nsec) ...@@ -83,7 +90,7 @@ int wrpc_adjust_counters(int64_t adjust_sec, int32_t adjust_nsec)
if (adjust_sec) if (adjust_sec)
shw_pps_gen_adjust(PPSG_ADJUST_SEC, adjust_sec); shw_pps_gen_adjust(PPSG_ADJUST_SEC, adjust_sec);
if (adjust_nsec) if (adjust_nsec)
shw_pps_gen_adjust(PPSG_ADJUST_NSEC, adjust_nsec); shw_pps_gen_adjust(PPSG_ADJUST_NSEC,adjust_nsec);
return 0; return 0;
} }
......
...@@ -20,8 +20,9 @@ ...@@ -20,8 +20,9 @@
#define WRC_MODE_SLAVE 3 #define WRC_MODE_SLAVE 3
#define WRC_MODE_ABSCAL 4 #define WRC_MODE_ABSCAL 4
#define WRC_MODE_CASCADED 5 #define WRC_MODE_CASCADED 5
#define WRC_MODE_CASCADED_MASTER_ONLY 6
extern int ptp_mode[2]; extern int ptp_mode[wr_num_ports];
int wrc_ptp_init(void); int wrc_ptp_init(void);
int wrc_ptp_set_mode(int mode, int port); int wrc_ptp_set_mode(int mode, int port);
...@@ -66,6 +67,6 @@ int wrpc_calibration_pattern_enable(struct pp_instance *ppi, ...@@ -66,6 +67,6 @@ int wrpc_calibration_pattern_enable(struct pp_instance *ppi,
unsigned int calibrationPattern, unsigned int calibrationPattern,
unsigned int calibrationPatternLen); unsigned int calibrationPatternLen);
int wrpc_calibration_pattern_disable(struct pp_instance *ppi); int wrpc_calibration_pattern_disable(struct pp_instance *ppi);
int wrpc_get_port_state(struct hal_port_state *port, const char *port_name); int wrpc_get_port_state(struct hal_port_state *ps, int port);
#endif /* __WRPC_H */ #endif /* __WRPC_H */
...@@ -85,9 +85,11 @@ struct hal_port_state { ...@@ -85,9 +85,11 @@ struct hal_port_state {
/* calibration data */ /* calibration data */
hal_port_calibration_t calib; hal_port_calibration_t calib;
/* current DMTD loopback phase (ps) and whether is it valid or not */ /* current DMTD loopback phase and whether is it valid or not */
uint32_t phase_val; uint32_t phase_rx_val;
int phase_val_valid; int phase_rx_val_valid;
uint32_t phase_tx_val;
int phase_tx_val_valid;
int tx_cal_pending, rx_cal_pending; int tx_cal_pending, rx_cal_pending;
/* locking FSM state */ /* locking FSM state */
int lock_state; int lock_state;
......
...@@ -92,7 +92,7 @@ static int leave_current_state(struct pp_instance *ppi) ...@@ -92,7 +92,7 @@ static int leave_current_state(struct pp_instance *ppi)
ppi->flags &= ~PPI_FLAGS_WAITING; ppi->flags &= ~PPI_FLAGS_WAITING;
pp_diag_fsm(ppi, ppi->current_state_item->name, STATE_LEAVE, 0); pp_diag_fsm(ppi, ppi->current_state_item->name, STATE_LEAVE, 0);
/* next_delay unused: go to new state now */ /* next_delay unused: go to new state now */
return 100; return 0;
} }
/* /*
......
...@@ -26,6 +26,7 @@ static int next_pps_ms(struct pp_instance *ppi, struct pp_time *t) ...@@ -26,6 +26,7 @@ static int next_pps_ms(struct pp_instance *ppi, struct pp_time *t)
int wr_abscal(struct pp_instance *ppi, uint8_t *pkt, int plen) int wr_abscal(struct pp_instance *ppi, uint8_t *pkt, int plen)
{ {
struct pp_time t; struct pp_time t;
struct wr_dsport *wrp = WR_DSPOR(ppi);
int len, i; int len, i;
if (ppi->is_new_state) { if (ppi->is_new_state) {
...@@ -38,6 +39,8 @@ int wr_abscal(struct pp_instance *ppi, uint8_t *pkt, int plen) ...@@ -38,6 +39,8 @@ int wr_abscal(struct pp_instance *ppi, uint8_t *pkt, int plen)
if (pp_timeout(ppi, PP_TO_EXT_0)) { if (pp_timeout(ppi, PP_TO_EXT_0)) {
uint64_t secs = t.secs; uint64_t secs = t.secs;
// wrp->ops->enable_timing_output(ppi, 1);
/* Wait for the second to tick */ /* Wait for the second to tick */
while( ppi->t_ops->get(ppi, &t), t.secs == secs) while( ppi->t_ops->get(ppi, &t), t.secs == secs)
; ;
......
...@@ -184,7 +184,7 @@ int wr_servo_init(struct pp_instance *ppi) ...@@ -184,7 +184,7 @@ int wr_servo_init(struct pp_instance *ppi)
&s->fiber_fix_alpha, &s->clock_period_ps) != WR_HW_CALIB_OK) &s->fiber_fix_alpha, &s->clock_period_ps) != WR_HW_CALIB_OK)
return -1; return -1;
wrp->ops->enable_timing_output(ppi, 0); // wrp->ops->enable_timing_output(ppi, 0);
strncpy(s->if_name, ppi->cfg.iface_name, sizeof(s->if_name)); strncpy(s->if_name, ppi->cfg.iface_name, sizeof(s->if_name));
/* /*
...@@ -455,6 +455,7 @@ int wr_servo_update(struct pp_instance *ppi) ...@@ -455,6 +455,7 @@ int wr_servo_update(struct pp_instance *ppi)
&& locking_poll_ret != WR_SPLL_CALIB_NOT_READY) { && locking_poll_ret != WR_SPLL_CALIB_NOT_READY) {
pp_diag(ppi, servo, 1, "PLL OutOfLock, should restart sync\n"); pp_diag(ppi, servo, 1, "PLL OutOfLock, should restart sync\n");
wrp->ops->enable_timing_output(ppi, 0); wrp->ops->enable_timing_output(ppi, 0);
shw_pps_gen_unmask_output(0);
/* TODO check /* TODO check
* DSPOR(ppi)->doRestart = TRUE; */ * DSPOR(ppi)->doRestart = TRUE; */
} }
...@@ -495,6 +496,8 @@ int wr_servo_update(struct pp_instance *ppi) ...@@ -495,6 +496,8 @@ int wr_servo_update(struct pp_instance *ppi)
* Else, we must ensure we leave this status towards * Else, we must ensure we leave this status towards
* fine tuning * fine tuning
*/ */
wrp->ops->enable_timing_output(ppi, 0);
shw_pps_gen_unmask_output(0);
s->state = WR_SYNC_PHASE; s->state = WR_SYNC_PHASE;
break; break;
...@@ -502,13 +505,15 @@ int wr_servo_update(struct pp_instance *ppi) ...@@ -502,13 +505,15 @@ int wr_servo_update(struct pp_instance *ppi)
wrp->ops->adjust_counters(0, ts_offset_ticks); wrp->ops->adjust_counters(0, ts_offset_ticks);
s->flags |= WR_FLAG_WAIT_HW; s->flags |= WR_FLAG_WAIT_HW;
s->state = WR_SYNC_PHASE; s->state = WR_SYNC_PHASE;
wrp->ops->enable_timing_output(ppi, 0);
shw_pps_gen_unmask_output(0);
break; break;
case WR_SYNC_PHASE: case WR_SYNC_PHASE:
pp_diag(ppi, servo, 2, "oldsetp %i, offset %i:%04i\n", pp_diag(ppi, servo, 2, "oldsetp %i, offset %i:%04i\n",
s->cur_setpoint, ts_offset_ticks, s->cur_setpoint, ts_offset_ticks,
ts_offset_picos); ts_offset_picos);
s->cur_setpoint += ts_offset_picos; s->cur_setpoint += (ts_offset_picos*7/8);
wrp->ops->adjust_phase(s->cur_setpoint); wrp->ops->adjust_phase(s->cur_setpoint);
s->flags |= WR_FLAG_WAIT_HW; s->flags |= WR_FLAG_WAIT_HW;
...@@ -526,6 +531,8 @@ int wr_servo_update(struct pp_instance *ppi) ...@@ -526,6 +531,8 @@ int wr_servo_update(struct pp_instance *ppi)
pp_diag(ppi, time, 1, "system time set to %li TAI\n", pp_diag(ppi, time, 1, "system time set to %li TAI\n",
(long)ppi->t4.secs); (long)ppi->t4.secs);
} }
wrp->ops->enable_timing_output(ppi, 0);
shw_pps_gen_unmask_output(0);
break; break;
case WR_WAIT_OFFSET_STABLE: case WR_WAIT_OFFSET_STABLE:
...@@ -534,8 +541,13 @@ int wr_servo_update(struct pp_instance *ppi) ...@@ -534,8 +541,13 @@ int wr_servo_update(struct pp_instance *ppi)
remaining_offset = abs(ts_offset_picos); remaining_offset = abs(ts_offset_picos);
if(remaining_offset < WR_SERVO_OFFSET_STABILITY_THRESHOLD) { if(remaining_offset < WR_SERVO_OFFSET_STABILITY_THRESHOLD) {
wrp->ops->enable_timing_output(ppi, 1); wrp->ops->enable_timing_output(ppi, 1);
shw_pps_gen_unmask_output(1);
s->delta_ms_prev = s->delta_ms; s->delta_ms_prev = s->delta_ms;
s->state = WR_TRACK_PHASE; s->state = WR_TRACK_PHASE;
} else if (remaining_offset>5*WR_SERVO_OFFSET_STABILITY_THRESHOLD)
{
s->missed_iters = 0;
s->state = WR_SYNC_PHASE;
} else { } else {
s->missed_iters++; s->missed_iters++;
} }
......
...@@ -42,7 +42,7 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -42,7 +42,7 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
struct DSPort *dsport = DSPOR(ppi); struct DSPort *dsport = DSPOR(ppi);
struct pp_runtime_opts *opt = OPTS(ppi); struct pp_runtime_opts *opt = OPTS(ppi);
int ret = 0; int ret = 0;
int port = atoi(&ppi->iface_name[2]); int port = atoi(&(ppi->iface_name[2]));
if (ppi->n_ops->init(ppi) < 0) /* it must handle being called twice */ if (ppi->n_ops->init(ppi) < 0) /* it must handle being called twice */
goto failure; goto failure;
...@@ -56,6 +56,9 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -56,6 +56,9 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
id[1] = mac[1]; id[1] = mac[1];
id[2] = mac[2]; id[2] = mac[2];
id[3] = 0xff; id[3] = 0xff;
if (ppi->role != PPSI_ROLE_MASTER)
id[4] = 0xff;
else
id[4] = 0xfe; id[4] = 0xfe;
id[5] = mac[3]; id[5] = mac[3];
id[6] = mac[4]; id[6] = mac[4];
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include "ptpdump.h" #include "ptpdump.h"
#include "../arch-wrpc/wrpc.h" #include "../arch-wrpc/wrpc.h"
#include <syscon.h> /* wrpc-sw */ #include <dev/syscon.h> /* wrpc-sw */
#include <endpoint.h> /* wrpc-sw */ #include <dev/endpoint.h> /* wrpc-sw */
#include <ptpd_netif.h> /* wrpc-sw */ #include <ptpd_netif.h> /* wrpc-sw */
int frame_rx_delay_us; /* set by faults.c */ int frame_rx_delay_us; /* set by faults.c */
...@@ -40,7 +40,7 @@ static int wrpc_open_ch(struct pp_instance *ppi) ...@@ -40,7 +40,7 @@ static int wrpc_open_ch(struct pp_instance *ppi)
mac_addr_t mac; mac_addr_t mac;
struct wr_sockaddr addr; struct wr_sockaddr addr;
char *macaddr = PP_MCAST_MACADDRESS; char *macaddr = PP_MCAST_MACADDRESS;
int port = atoi(&ppi->iface_name[2]); int port = atoi(&(ppi->iface_name[2]));
if (CONFIG_HAS_P2P && ppi->mech == PP_P2P_MECH) if (CONFIG_HAS_P2P && ppi->mech == PP_P2P_MECH)
macaddr = PP_PDELAY_MACADDRESS; macaddr = PP_PDELAY_MACADDRESS;
...@@ -69,7 +69,7 @@ static int wrpc_net_recv(struct pp_instance *ppi, void *pkt, int len, ...@@ -69,7 +69,7 @@ static int wrpc_net_recv(struct pp_instance *ppi, void *pkt, int len,
struct wr_timestamp wr_ts; struct wr_timestamp wr_ts;
struct wr_sockaddr addr; struct wr_sockaddr addr;
sock = ppi->ch[PP_NP_EVT].custom; sock = ppi->ch[PP_NP_EVT].custom;
int port = atoi(&ppi->iface_name[2]); int port = atoi(&(ppi->iface_name[2]));
got = ptpd_netif_recvfrom(sock, &addr, pkt, len, &wr_ts, port); got = ptpd_netif_recvfrom(sock, &addr, pkt, len, &wr_ts, port);
if (got <= 0) if (got <= 0)
return got; return got;
...@@ -128,7 +128,7 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len, ...@@ -128,7 +128,7 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len,
struct wr_sockaddr addr; struct wr_sockaddr addr;
struct pp_time *t = &ppi->last_snt_time; struct pp_time *t = &ppi->last_snt_time;
int is_pdelay = pp_msgtype_info[msgtype].is_pdelay; int is_pdelay = pp_msgtype_info[msgtype].is_pdelay;
int port = atoi(&ppi->iface_name[2]); int port = atoi(&(ppi->iface_name[2]));
static const uint8_t macaddr[2][ETH_ALEN] = { static const uint8_t macaddr[2][ETH_ALEN] = {
[PP_E2E_MECH] = PP_MCAST_MACADDRESS, [PP_E2E_MECH] = PP_MCAST_MACADDRESS,
[PP_P2P_MECH] = PP_PDELAY_MACADDRESS, [PP_P2P_MECH] = PP_PDELAY_MACADDRESS,
...@@ -159,6 +159,7 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len, ...@@ -159,6 +159,7 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len,
if (t) { if (t) {
t->secs = wr_ts.sec; t->secs = wr_ts.sec;
t->scaled_nsecs = (int64_t)wr_ts.nsec << 16; t->scaled_nsecs = (int64_t)wr_ts.nsec << 16;
t->scaled_nsecs += wr_ts.phase * (1 << 16) / 1000;
if (!wr_ts.correct) if (!wr_ts.correct)
mark_incorrect(t); mark_incorrect(t);
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
* Released according to the GNU LGPL, version 2.1 or any later version. * Released according to the GNU LGPL, version 2.1 or any later version.
*/ */
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include "pps_gen.h" /* in wrpc-sw */ #include "dev/pps_gen.h" /* in wrpc-sw */
#include "syscon.h" /* in wrpc-sw */ #include "dev/syscon.h" /* in wrpc-sw */
static int wrpc_time_get(struct pp_instance *ppi, struct pp_time *t) static int wrpc_time_get(struct pp_instance *ppi, struct pp_time *t)
{ {
......
...@@ -58,9 +58,12 @@ typedef struct ...@@ -58,9 +58,12 @@ typedef struct
struct wrs_socket { struct wrs_socket {
/* parameters for linearization of RX timestamps */ /* parameters for linearization of RX timestamps */
uint32_t clock_period; uint32_t clock_period;
uint32_t phase_transition; uint32_t phase_transition_rx;
uint32_t dmtd_phase; uint32_t dmtd_phase_rx;
int dmtd_phase_valid; uint32_t phase_transition_tx;
uint32_t dmtd_phase_tx;
int dmtd_phase_rx_valid;
int dmtd_phase_tx_valid;
timeout_t dmtd_update_tmo; timeout_t dmtd_update_tmo;
}; };
...@@ -118,8 +121,8 @@ static void update_dmtd(struct wrs_socket *s, struct pp_instance *ppi) ...@@ -118,8 +121,8 @@ static void update_dmtd(struct wrs_socket *s, struct pp_instance *ppi)
p = pp_wrs_lookup_port(ppi->iface_name); p = pp_wrs_lookup_port(ppi->iface_name);
if (!p) if (!p)
return; return;
s->dmtd_phase = p->phase_val; s->dmtd_phase_rx = p->phase_rx_val;
s->dmtd_phase_valid = p->phase_val_valid; s->dmtd_phase_rx_valid = p->phase_rx_val_valid;
tmo_restart(&s->dmtd_update_tmo); tmo_restart(&s->dmtd_update_tmo);
} }
...@@ -131,18 +134,18 @@ static void update_dmtd(struct wrs_socket *s, struct pp_instance *ppi) ...@@ -131,18 +134,18 @@ static void update_dmtd(struct wrs_socket *s, struct pp_instance *ppi)
* -- ARub 2016-10 * -- ARub 2016-10
*/ */
static void wrs_linearize_rx_timestamp(struct pp_time *ts, static void wrs_linearize_rx_timestamp(struct pp_time *ts,
int32_t dmtd_phase, int cntr_ahead, int transition_point, int32_t dmtd_phase_rx, int cntr_ahead, int transition_point,
int clock_period) int clock_period)
{ {
int trip_lo, trip_hi; int trip_lo, trip_hi;
int phase; int phase;
pp_diag(NULL, ext, 3, "linearize ts %s and phase %i\n", pp_diag(NULL, ext, 3, "linearize ts %s and phase %i\n",
fmt_time(ts), dmtd_phase); fmt_time(ts), dmtd_phase_rx);
pp_diag(NULL, ext, 3, " (ahead %i tpoint %i, period %i\n", pp_diag(NULL, ext, 3, " (ahead %i tpoint %i, period %i\n",
cntr_ahead, transition_point, clock_period); cntr_ahead, transition_point, clock_period);
phase = clock_period - 1 - dmtd_phase; phase = clock_period - 1 - dmtd_phase_rx;
/* calculate the range within which falling edge timestamp is stable /* calculate the range within which falling edge timestamp is stable
* (no possible transitions) */ * (no possible transitions) */
...@@ -167,7 +170,7 @@ static void wrs_linearize_rx_timestamp(struct pp_time *ts, ...@@ -167,7 +170,7 @@ static void wrs_linearize_rx_timestamp(struct pp_time *ts,
/* check if the phase is before the counter transition value /* check if the phase is before the counter transition value
* and eventually increase the counter by 1 to simulate a * and eventually increase the counter by 1 to simulate a
* timestamp transition exactly at s->phase_transition * timestamp transition exactly at s->phase_transition_rx
* DMTD phase value */ * DMTD phase value */
if(inside_range(trip_lo, transition_point, phase)) if(inside_range(trip_lo, transition_point, phase))
ts->scaled_nsecs += (clock_period / 1000LL) << 16; ts->scaled_nsecs += (clock_period / 1000LL) << 16;
...@@ -250,9 +253,9 @@ static int wrs_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len, ...@@ -250,9 +253,9 @@ static int wrs_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
if (!WR_DSPOR(ppi)->wrModeOn) { if (!WR_DSPOR(ppi)->wrModeOn) {
goto drop; goto drop;
} }
if (s->dmtd_phase_valid) { if (s->dmtd_phase_rx_valid) {
wrs_linearize_rx_timestamp(t, s->dmtd_phase, wrs_linearize_rx_timestamp(t, s->dmtd_phase_rx,
cntr_ahead, s->phase_transition, s->clock_period); cntr_ahead, s->phase_transition_rx, s->clock_period);
} else { } else {
mark_incorrect(t); mark_incorrect(t);
} }
...@@ -656,10 +659,10 @@ static int wrs_net_init(struct pp_instance *ppi) ...@@ -656,10 +659,10 @@ static int wrs_net_init(struct pp_instance *ppi)
* constant here (ARub) * constant here (ARub)
*/ */
s->clock_period = 16000; /* REF_CLOCK_PERIOD_PS */ s->clock_period = 16000; /* REF_CLOCK_PERIOD_PS */
s->phase_transition = 0; /* DEFAULT_T2_PHASE_TRANS */ s->phase_transition_rx = DEFAULT_T2_PHASE_TRANS; /* DEFAULT_T2_PHASE_TRANS */
s->dmtd_phase = p->phase_val; s->dmtd_phase_rx = p->phase_rx_val;
s->dmtd_phase_valid = 0; s->dmtd_phase_rx_valid = 0;
ppi->ch[PP_NP_GEN].arch_data = s; ppi->ch[PP_NP_GEN].arch_data = s;
ppi->ch[PP_NP_EVT].arch_data = s; ppi->ch[PP_NP_EVT].arch_data = s;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment