Commit 5eefc005 authored by Maciej Lipinski's avatar Maciej Lipinski

added comments

parent 9b2d9103
ppsi @ bda685cb
Subproject commit 6958c7129b29c33456538ee5f1651bbef71592bb Subproject commit bda685cb87f752a865c7690b382021e6c486ea3f
...@@ -126,6 +126,9 @@ int any_port_locked() ...@@ -126,6 +126,9 @@ int any_port_locked()
return rts_state.current_ref; return rts_state.current_ref;
} }
/*
* return id of the backup channel, if available
*/
int backup_port() int backup_port()
{ {
if(!rts_state_valid) return -1; if(!rts_state_valid) return -1;
...@@ -380,24 +383,26 @@ uint32_t pcs_readl(hal_port_state_t *p, int reg) ...@@ -380,24 +383,26 @@ uint32_t pcs_readl(hal_port_state_t *p, int reg)
static int handle_link_down(hal_port_state_t *p, int link_up) static int handle_link_down(hal_port_state_t *p, int link_up)
{ {
/* If, at any moment, the link goes down, reset the FSM and the port state structure. */ /* If, at any moment, the link goes down, reset the FSM and the port state structure unless
- it is a backup port, in this case don't touch the sPLL
- it has a backup port, in this case switch the timing to backup */
if(!link_up && p->state != HAL_PORT_STATE_LINK_DOWN && p->state != HAL_PORT_STATE_DISABLED) if(!link_up && p->state != HAL_PORT_STATE_LINK_DOWN && p->state != HAL_PORT_STATE_DISABLED)
{ {
if(p->locked) if(p->locked)
{ {
if(hal_get_timing_mode() != HAL_TIMING_MODE_GRAND_MASTER) if(hal_get_timing_mode() != HAL_TIMING_MODE_GRAND_MASTER)
if(backup_port() == REF_NONE) if(backup_port() == REF_NONE) // not a backup & no backup for it
{ {
rts_set_mode(RTS_MODE_GM_FREERUNNING); rts_set_mode(RTS_MODE_GM_FREERUNNING);
TRACE(TRACE_INFO, "switching RTS to use local reference"); TRACE(TRACE_INFO, "switching RTS to use local reference");
} }
else if(backup_port() == p->hw_index) else if(backup_port() == p->hw_index) // it is backup port
{ {
rts_backup_channel(p->hw_index, RTS_BACKUP_CH_DOWN); rts_backup_channel(p->hw_index, RTS_BACKUP_CH_DOWN);
TRACE(TRACE_INFO, "switching off backup reference"); TRACE(TRACE_INFO, "switching off backup reference");
} }
else else //it has a backup port
{ {
rts_backup_channel(p->hw_index, RTS_BACKUP_CH_ACTIVATE); rts_backup_channel(p->hw_index, RTS_BACKUP_CH_ACTIVATE);
TRACE(TRACE_INFO, "switching to backup reference"); TRACE(TRACE_INFO, "switching to backup reference");
...@@ -618,7 +623,7 @@ int hal_port_start_lock(const char *port_name, int priority) ...@@ -618,7 +623,7 @@ int hal_port_start_lock(const char *port_name, int priority)
TRACE(TRACE_INFO, "Locking to port: %s", port_name); TRACE(TRACE_INFO, "Locking to port: %s", port_name);
if(priority == 0) if(priority == 0) // only primary slave port needs that, don't do for backups
rts_set_mode(RTS_MODE_BC); rts_set_mode(RTS_MODE_BC);
return rts_lock_channel(p->hw_index, priority) < 0 ? PORT_ERROR : PORT_OK; return rts_lock_channel(p->hw_index, priority) < 0 ? PORT_ERROR : PORT_OK;
......
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