Commit 3a274df6 authored by Maciej Lipinski's avatar Maciej Lipinski Committed by Jean-Claude BAU

[HAL] remove HAL_PORT_RX_SETUP_STATE_CALIB_NO_LPDC from hal_port_fsm_rx and move…

[HAL] remove HAL_PORT_RX_SETUP_STATE_CALIB_NO_LPDC from hal_port_fsm_rx and move bitslide measurement

Rational: when LPDC is done, we need to wait for link_up (the
early_link_up is already set). There can be potentially time
when we are in the HAL_PORT_RX_SETUP_STATE_DONE done state and
the early_link_up=1 while link_up=0. This forces a bit different
behavior for the LPDC and non-LPDC behavior. The new approarch:
- if no LPDC, go directly to HAL_PORT_RX_SETUP_STATE_DONE and
  wait there for link_up
- if LPDC, do the all the necessary stuff and then wait for
  link_up in HAL_PORT_RX_SETUP_STATE_DONE
The bitslide measurement could be done only for non-LPDC, yet
there is no harm in reading the bitslide register in all cases,
it is hardcoded to zero when LPDC is supported. Doing it
outside the hal_port_fsm_rx is more similar to what was in the
original HAL, furthermore, bitslide measurement was there before
LPDC, so it can be considered somehow independent
parent 1a2c7074
......@@ -189,8 +189,6 @@ static int _hal_port_state_link_down(void *vpfg, int eventMsk, int isNewState) {
led_set_wrmode(ps->hw_index,SFP_LED_WRMODE_OFF);
led_set_synched(ps->hw_index, 0);
/* bitslide is measured, if appropriate, in hal_port_rx_setup_state_fsm()*/
ps->calib.bitslide_ps = 0;
}
/* if final state reached for tx setup state machine then
......@@ -198,17 +196,28 @@ static int _hal_port_state_link_down(void *vpfg, int eventMsk, int isNewState) {
*/
if (hal_port_rx_setup_state_fsm(ps)==1 ) {
/* any calibration, if any, has been done*/
ps->calib.tx_calibrated = 1;
ps->calib.rx_calibrated = 1;
ps->calib.delta_rx_phy = ps->calib.phy_rx_min;
ps->calib.delta_tx_phy = ps->calib.phy_tx_min;
ps->tx_cal_pending = 0;
ps->rx_cal_pending = 0;
/* bitslide was obtained in hal_port_rx_setup_state_fsm() */
pr_info("%s:%s: bitslide= %u [ps]\n",__func__,ps->name,ps->calib.bitslide_ps);
_fireState(vpfg,HAL_PORT_STATE_LINK_UP);
/* measure bitslide regardless of LPDC support,
(if not supported, the value of the register will be zero) */
uint32_t bit_slide_steps;
if ( pcs_readl(ps, 16,&bit_slide_steps) >=0 ) {
bit_slide_steps= (bit_slide_steps>> 4) & 0x1f;
/* FIXME: use proper register names */
ps->calib.bitslide_ps=bit_slide_steps*(uint32_t)800; /* 1 step = 800ps */
/* any calibration, if any, has been done*/
ps->calib.tx_calibrated = 1;
ps->calib.rx_calibrated = 1;
ps->calib.delta_rx_phy = ps->calib.phy_rx_min;
ps->calib.delta_tx_phy = ps->calib.phy_tx_min;
ps->tx_cal_pending = 0;
ps->rx_cal_pending = 0;
pr_info("%s:%s: bitslide= %u [ps]\n",__func__,
ps->name,ps->calib.bitslide_ps);
_fireState(vpfg,HAL_PORT_STATE_LINK_UP);
}
else
pr_warning("Cannot read bitslide, retrying...\n");
return 0;
}
return 0;
......
......@@ -29,8 +29,6 @@
* States :
* - HAL_PORT_RX_SETUP_STATE_START:
* Inital state
* - HAL_PORT_RX_SETUP_STATE_CALIB_NO_LPDC :
* Calibration when LPDC is not supported
* - .....
* - HAL_PORT_RX_SETUP_STATE_DONE:
* RX setup terminated
......@@ -44,7 +42,6 @@
/* external prototypes */
static int _buildEvents(void * vpfg);
static int _hal_port_rx_setup_state_start(void *vpfg, int eventMsk, int isNewState);
static int _hal_port_rx_setup_state_calib_no_lpdc(void *vpfg, int ventMsk, int isNewState);
static int _hal_port_rx_setup_state_reset_pcs(void *vpfg, int ventMsk, int isNewState);
static int _hal_port_rx_setup_state_wait_lock(void *vpfg, int ventMsk, int isNewState);
static int _hal_port_rx_setup_state_validate(void *vpfg, int ventMsk, int isNewState);
......@@ -57,10 +54,6 @@ static halPortStateTable_t _fsmStateTable[] =
.stateName="START",
FSM_SET_FCT_NAME(_hal_port_rx_setup_state_start)
},
{ .state=HAL_PORT_RX_SETUP_STATE_CALIB_NO_LPDC,
.stateName="CALIB_NO_LPDC",
FSM_SET_FCT_NAME(_hal_port_rx_setup_state_calib_no_lpdc)
},
{ .state=HAL_PORT_RX_SETUP_STATE_RESET_PCS,
.stateName="RESET_PCS",
FSM_SET_FCT_NAME(_hal_port_rx_setup_state_reset_pcs)
......@@ -123,9 +116,10 @@ static __inline__ void updatePllState(struct hal_port_state * ps) {
/* START state
* (Hypothesis: LPDC support has already been determined before )
*
* if link up event then
* if LPDC is not supported then state = CALIB_NO_LPDC
* else state = DONE
* if if LPDC
* start the LPDC process
* else
* nothing to do, go to DONE and wait for link up
* fi
*/
static int _hal_port_rx_setup_state_start(void *vpfg, int eventMsk, int isNewState) {
......@@ -145,43 +139,12 @@ static int _hal_port_rx_setup_state_start(void *vpfg, int eventMsk, int isNewSta
_fireState(vpfg,HAL_PORT_RX_SETUP_STATE_RESET_PCS);
}
} else {
if ( _isHalRxSetupEventLinkUp(eventMsk) ) {
_fireState(vpfg,HAL_PORT_RX_SETUP_STATE_CALIB_NO_LPDC);
}
/* nothing to do, go waiting for link_up*/
_fireState(vpfg,HAL_PORT_RX_SETUP_STATE_DONE);
}
return 0;
}
/* CALIB_NO_LPDC state
*
* if link down event then state = START
* if link up state then
* Calculate the bit slide.
* if bit slide successfully calculated then state=DONE
* fi
*/
static int _hal_port_rx_setup_state_calib_no_lpdc(void *vpfg, int eventMsk, int isNewState) {
struct hal_port_state * ps=((halPortFsmGen_t *)vpfg)->ps;
if ( _isHalRxSetupEventLinkDown(eventMsk) ) {
_fireState(vpfg,HAL_PORT_RX_SETUP_STATE_START);
return 0;
}
if ( _isHalRxSetupEventLinkUp(eventMsk) ) {
uint32_t bit_slide_steps;
if ( pcs_readl(ps, 16,&bit_slide_steps) >=0 ) {
bit_slide_steps= (bit_slide_steps>> 4) & 0x1f;
/* FIXME: use proper register names */
ps->calib.bitslide_ps=bit_slide_steps*(uint32_t)800; /* 1 step = 800ps */
_fireState(vpfg,HAL_PORT_RX_SETUP_STATE_DONE);
}
else
pr_warning("Cannot read bitslide in NO-LPDC mode, retrying...\n");
}
return 0;
}
/*
* RESET_PCS state
......@@ -269,10 +232,11 @@ static int _hal_port_rx_setup_state_validate(void *vpfg, int eventMsk, int isNew
}
/*
* DONE state
* DONE state - wait for link_up
*
* if link down event then state=START
* if link up event then return final state machine reached
* if LPDC supported
* if early_link_down event then state=START
* if link up event then return final state machine reached
*
*/
static int _hal_port_rx_setup_state_done(void *vpfg, int eventMsk, int isNewState) {
......@@ -288,10 +252,6 @@ static int _hal_port_rx_setup_state_done(void *vpfg, int eventMsk, int isNewStat
return 0;
}
}
if ( _isHalRxSetupEventLinkDown(eventMsk) ) {
_fireState(vpfg,HAL_PORT_RX_SETUP_STATE_START);
return 0;
}
if ( _isHalRxSetupEventLinkUp(eventMsk) ) {
return 1; /* Final state reached */;
}
......
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