Commit c1e3299a authored by Alessandro Rubini's avatar Alessandro Rubini

white rabbit: fix generation of pps out

This centralizes a "software" enable timing output, that calls the
"hardware" one (previous code) while keeping track of the status.

With non-wr the pps output is always enabled if the offset from
master is less than 1s.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent c2930876
......@@ -91,7 +91,7 @@ int wr_locking_disable(struct pp_instance *ppi)
int wr_enable_ptracker(struct pp_instance *ppi)
__attribute__((alias("wrpc_spll_enable_ptracker")));
int wr_enable_timing_output(struct pp_instance *ppi, int enable)
int __wr_enable_timing_output(struct pp_instance *ppi, int enable)
__attribute__((alias("wrpc_enable_timing_output")));
int wr_adjust_in_progress()
......
......@@ -15,6 +15,7 @@ static int wr_init(struct pp_instance *ppi, unsigned char *pkt, int plen)
wp->parentWrConfig = NON_WR;
wp->parentWrModeOn = 0;
wp->calibrated = !WR_DEFAULT_PHY_CALIBRATION_REQUIRED;
wr_enable_timing_output(ppi, 0);
return 0;
}
......@@ -120,22 +121,20 @@ static int wr_handle_resp(struct pp_instance *ppi)
* we'll have the Unix time instead, marked by "correct"
*/
if (!WR_DSPOR(ppi)->wrModeOn) {
Boolean pps_out;
if (!ppi->t2.correct || !ppi->t3.correct) {
pp_diag(ppi, servo, 1,
"T2 or T3 incorrect, discarding tuple\n");
return 0;
}
pp_servo_got_resp(ppi);
/* pps always on; until we have a configurable threshold */
if (ofm /* ->seconds || ... */)
pps_out = 1;
/* Only act on changes, so hackers can force it on manually */
if (pps_out != WR_DSPOR(ppi)->ppsOutputOn)
wr_enable_timing_output(ppi, pps_out);
WR_DSPOR(ppi)->ppsOutputOn = pps_out;
/*
* pps always on if offset less than 1 second,
* until ve have a configurable threshold */
if (ofm->seconds)
wr_enable_timing_output(ppi, 0);
else
wr_enable_timing_output(ppi, 1);
}
wr_servo_got_delay(ppi, hdr->correctionfield.lsb);
wr_servo_update(ppi);
......
......@@ -106,7 +106,9 @@ int wr_read_calibration_data(struct pp_instance *ppi,
int wr_enable_ptracker(struct pp_instance *ppi);
/* The former is called by ppsi, the latter is the internal hw detail */
int wr_enable_timing_output(struct pp_instance *ppi, int enable);
int __wr_enable_timing_output(struct pp_instance *ppi, int enable);
int wr_adjust_in_progress(void);
int wr_adjust_counters(int64_t adjust_sec, int32_t adjust_nsec);
......
......@@ -32,6 +32,15 @@ void wr_servo_enable_tracking(int enable)
tracking_enabled = enable;
}
int wr_enable_timing_output(struct pp_instance *ppi, int enable)
{
/* Only act on changes, so hackers can force it on manually */
if (enable != WR_DSPOR(ppi)->ppsOutputOn)
__wr_enable_timing_output(ppi, enable);
WR_DSPOR(ppi)->ppsOutputOn = enable;
return 0;
}
/* my own timestamp arithmetic functions */
static void dump_timestamp(struct pp_instance *ppi, char *what, TimeInternal ts)
......@@ -141,11 +150,8 @@ static int got_sync = 0;
void wr_servo_reset()
{
// shw_pps_gen_enable_output(0); /* fixme: unportable */
cur_servo_state.valid = 0;
servo_state_valid = 0;
// ptpd_netif_enable_timing_output(0);
}
int wr_servo_init(struct pp_instance *ppi)
......
......@@ -151,7 +151,7 @@ int wr_locking_disable(struct pp_instance *ppi)
int wr_enable_ptracker(struct pp_instance *ppi)
__attribute__((alias("wrs_enable_ptracker")));
int wr_enable_timing_output(struct pp_instance *ppi, int enable)
int __wr_enable_timing_output(struct pp_instance *ppi, int enable)
__attribute__((alias("wrs_enable_timing_output")));
int wr_adjust_in_progress()
......
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