Commit bac5bbd9 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

looks like we have a fix

parent 9a32a2ff
......@@ -250,6 +250,9 @@ static int port_fsm_state_link_up(fsm_t *fsm, int eventMsk, int isNewState) {
if ( !_isHalEventPortEarlyLinkUp(eventMsk)) {
fsm_fire_state(fsm,HAL_PORT_STATE_LINK_DOWN);
}
if ( !_isHalEventPortRxAligned(eventMsk)) {
fsm_fire_state(fsm,HAL_PORT_STATE_LINK_DOWN);
}
}
if ( !_isHalEventSfpPresent(eventMsk) ) {
......
......@@ -208,6 +208,10 @@ static int _hal_port_rx_setup_state_start(fsm_t *fsm, int eventMsk, int isNewSta
MDIO_LPC_CTRL_DMTD_SOURCE_RXRECCLK |
MDIO_LPC_CTRL_RESET_RX,
MDIO_LPC_CTRL);
shw_udelay(1000);
pcs_writel(ps, MDIO_LPC_CTRL_TX_ENABLE |
MDIO_LPC_CTRL_DMTD_SOURCE_RXRECCLK,
MDIO_LPC_CTRL);
libwr_tmo_restart(&rxSetup->watchdog_timeout);
}
}
......@@ -391,13 +395,14 @@ static int _hal_port_rx_setup_state_done(fsm_t *fsm, int eventMsk, int isNewStat
int early_up = _isHalRxSetupEventEarlyLinkUp(eventMsk);
int link_up = _isHalRxSetupEventLinkUp(eventMsk);
int link_aligned = _isHalRxSetupEventRxAligned(eventMsk);
/* earlyLinkUp detection only if LPDC support */
if ( ps->lpdc.isSupported ) {
if ( isNewState ) {
libwr_tmo_restart(&ps->lpdc.rxSetup->align_to_link_timeout);
}
if ( !early_up) {
if ( !early_up ) {
// Port went done
my_log("rxcal: early link flag lost on port wri%d\n",
ps->hw_index + 1);
......@@ -405,21 +410,44 @@ static int _hal_port_rx_setup_state_done(fsm_t *fsm, int eventMsk, int isNewStat
fsm_fire_state(fsm, HAL_PORT_RX_SETUP_STATE_INIT);
return 0;
}
if ( !link_aligned ) {
// Port went done
my_log("rxcal: aligned flag lost on port wri%d\n",
ps->hw_index + 1);
fsm_fire_state(fsm, HAL_PORT_RX_SETUP_STATE_INIT);
return 0;
}
if( libwr_tmo_expired( &ps->lpdc.rxSetup->align_to_link_timeout ) && !link_up)
{
uint32_t stat;
uint32_t stat, msr;
pcs_readl(ps, MDIO_LPC_STAT,&stat);
pcs_readl(ps, MII_BMSR, &msr);
// we are aligned but no Autoneg link up? restart the autonegotiation...
my_log("rxcal: link is fucked up. Retrying calibration on port %d\n",ps->hw_index + 1);
printf("[port fup %d] LPC_STAT 0x%04x\n", ps->hw_index+1, stat);
dump_rx_pattern(ps);
pcs_writel(ps, BMCR_ANENABLE | BMCR_ANRESTART, MII_BMCR);
dump_rx_pattern(ps);
libwr_tmo_restart(&ps->lpdc.rxSetup->align_to_link_timeout);
if( !(stat & MDIO_LPC_STAT_LINK_ALIGNED ))
{
my_log("rxcal: link is fucked up and UNALIGNED. Retrying calibration on port %d\n", ps->hw_index + 1);
fsm_fire_state(fsm, HAL_PORT_RX_SETUP_STATE_INIT);
} else {
my_log("rxcal: link is fucked up (AUTONEG), retrying it on port %d\n",ps->hw_index + 1);
printf("[port fup %d] LPC_STAT 0x%04x MSR 0x%04x\n", ps->hw_index+1, stat, msr);
dump_rx_pattern(ps);
//pcs_writel(ps, BMCR_PDOWN, MII_BMCR);
shw_udelay(1000000);
my_log("Bring port back up...\n");
dump_rx_pattern(ps);
pcs_writel(ps, BMCR_ANENABLE | BMCR_ANRESTART, MII_BMCR);
dump_rx_pattern(ps);
libwr_tmo_restart(&ps->lpdc.rxSetup->align_to_link_timeout);
}
return 0;
}
......
......@@ -39,7 +39,7 @@
extern struct hal_shmem_header *hal_shmem;
extern struct wrs_shm_head *hal_shmem_hdr;
#define FSM_DEBUG 0
#define FSM_DEBUG 1
hal_ports_t halPorts;
......
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