Commit adc08e73 authored by Jean-Claude BAU's avatar Jean-Claude BAU

Improve diagnostics getting PLL state

parent d4930dda
......@@ -28,9 +28,10 @@
#define HEXP_LOCK_CMD_ENABLE_TRACKING 3
#define HEXP_LOCK_CMD_RESET 4
#define HEXP_LOCK_STATUS_LOCKED 0
#define HEXP_LOCK_STATUS_BUSY 1
#define HEXP_LOCK_STATUS_NONE 2
#define HEXP_LOCK_STATUS_UNLOCKED 0
#define HEXP_LOCK_STATUS_LOCKED 1
#define HEXP_LOCK_STATUS_RELOCK_ERROR 2
#define HEXP_LOCK_STATUS_ERROR 3
#define HEXP_PPSG_CMD_GET 0
#define HEXP_PPSG_CMD_ADJUST_PHASE 1
......@@ -117,9 +118,6 @@ extern struct minipc_pd __rpcdef_pps_cmd;
extern struct minipc_pd __rpcdef_port_update_cmd;
/* Prototypes of functions that call on rpc */
extern int halexp_check_running(void);
extern int halexp_reset_port(const char *port_name);
extern int halexp_calibration_cmd(const char *port_name, int command, int on_off);
extern int halexp_lock_cmd(const char *port_name, int command, int priority);
extern int halexp_pps_cmd(int cmd, hexp_pps_params_t *params);
......
......@@ -14,13 +14,15 @@
#include <ppsi/lib.h>
/* Please increment WRS_PPSI_SHMEM_VERSION if you change any exported data structure */
#define WRS_PPSI_SHMEM_VERSION 32 /* added HAL_PORT_STATE_RESET to hal */
#define WRS_PPSI_SHMEM_VERSION 33
/* White Rabbit softpll status values */
#define WRH_SPLL_OK 0
#define WRH_SPLL_READY 1
#define WRH_SPLL_CALIB_NOT_READY 2
#define WRH_SPLL_ERROR -1
#define WRH_SPLL_OK 0
#define WRH_SPLL_LOCKED 1
#define WRH_SPLL_UNLOCKED 2
#define WRH_SPLL_RELOCK_ERROR 3
#define WRH_SPLL_UNKWOWN_ERROR 4
/* White Rabbit calibration defines */
#define WRH_HW_CALIB_TX 1
......
......@@ -241,10 +241,8 @@ static int __wrh_servo_update(struct pp_instance *ppi)
return 1; /* We have to wait before to start the synchronization */
locking_poll_ret = WRH_OPER()->locking_poll(ppi);
if (locking_poll_ret != WRH_SPLL_READY
&& locking_poll_ret != WRH_SPLL_CALIB_NOT_READY) {
pp_error("%s: PLL out of lock (Err=%d)\n",__func__,locking_poll_ret);
if (locking_poll_ret != WRH_SPLL_LOCKED ){
pp_error("%s: PLL error detected (Err=%d). Force restart.\n",__func__,locking_poll_ret);
s->doRestart = TRUE;
return 0;
}
......
......@@ -146,7 +146,7 @@ static Boolean le1_evt_STATE_OK(struct pp_instance *ppi) {
case PPS_UNCALIBRATED :
pll_state= WRH_OPER()->locking_poll(ppi); /* Get the PPL state */
basicDS->isCongruent =
basicDS->isRxCoherent= pll_state == WRH_SPLL_READY ? 1 : 0;
basicDS->isRxCoherent= pll_state == WRH_SPLL_LOCKED ? 1 : 0;
break;
case PPS_MASTER :
basicDS->isRxCoherent=
......@@ -162,7 +162,7 @@ static Boolean le1_evt_STATE_OK(struct pp_instance *ppi) {
* might remain locked. We want to detect this case.
*
* Thus, the condition should be:
* basicDS->isCongruent= pll_state == !WRH_SPLL_READY ? 1 : 0;
* basicDS->isCongruent= pll_state == !WRH_SPLL_LOCKED ? 1 : 0;
*/
basicDS->isCongruent = 1;
break;
......
......@@ -295,7 +295,7 @@ int wrs_locking_reset(struct pp_instance *ppi)
if ( ppi->glbs->defaultDS->clockQuality.clockClass != PP_PTP_CLASS_GM_LOCKED )
if ( wrs_set_timing_mode(GLBS(ppi),WRH_TM_FREE_MASTER)<0 ) {
return -1;
return WRH_SPLL_ERROR;
}
WRS_ARCH_I(ppi)->timingModeLockingState=WRH_TM_LOCKING_STATE_LOCKING;
......@@ -305,20 +305,39 @@ int wrs_locking_reset(struct pp_instance *ppi)
int wrs_locking_poll(struct pp_instance *ppi)
{
int ret, rval;
char *pp_diag_msg;
char text[128];
ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_lock_cmd,
&rval, ppi->iface_name, HEXP_LOCK_CMD_CHECK, 0);
if ( ret<0 ) {
pp_diag(ppi, time, 2, "PLL is not ready: minirpc communication error %s\n",strerror(errno));
return WRH_SPLL_ERROR; /* FIXME should be WRH_SPLL_NOT_READY */
if (PP_HAS_DIAG) {
pp_sprintf(text,"not ready: minirpc communication error %s",strerror(errno));
pp_diag_set_msg(pp_diag_msg,text);
}
if (rval != HEXP_LOCK_STATUS_LOCKED) {
pp_diag(ppi, time, 2, "PLL not locked(%d)\n",rval);
return WRH_SPLL_ERROR; /* FIXME should be WRH_SPLL_NOT_READY */
ret=WRH_SPLL_ERROR;
} else {
switch (rval) {
case HEXP_LOCK_STATUS_LOCKED :
pp_diag_set_msg(pp_diag_msg,"locked");
ret=WRH_SPLL_LOCKED;
break;
case HEXP_LOCK_STATUS_UNLOCKED :
pp_diag_set_msg(pp_diag_msg,"unlocked");
ret=WRH_SPLL_UNLOCKED;
break;
case HEXP_LOCK_STATUS_RELOCK_ERROR:
pp_diag_set_msg(pp_diag_msg,"in fault. Re-locking error.");
ret=WRH_SPLL_RELOCK_ERROR;
break;
default:
pp_diag_set_msg(pp_diag_msg,"in an unknown state");
ret=WRH_SPLL_UNKWOWN_ERROR;
break;
}
pp_diag(ppi, time, 2, "PLL is locked\n");
return WRH_SPLL_READY;
}
pp_diag(ppi, time, 2, "PLL is %s\n",pp_diag_get_msg(pp_diag_msg));
return ret;
}
/* This is a hack, but at least the year is 640bit clean */
......
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