/* Configure the XAUI driver that is an output from Falcon */ static void falcon_setup_xaui(struct efx_nic *efx) { efx_oword_t sdctl, txdrv; /* Move the XAUI into low power, unless there is no PHY, in * which case the XAUI will have to drive a cable. */ if (efx->phy_type == PHY_TYPE_NONE) return; falcon_read(efx, &sdctl, XX_SD_CTL_REG); EFX_SET_OWORD_FIELD(sdctl, XX_HIDRVD, XX_SD_CTL_DRV_DEFAULT); EFX_SET_OWORD_FIELD(sdctl, XX_LODRVD, XX_SD_CTL_DRV_DEFAULT); EFX_SET_OWORD_FIELD(sdctl, XX_HIDRVC, XX_SD_CTL_DRV_DEFAULT); EFX_SET_OWORD_FIELD(sdctl, XX_LODRVC, XX_SD_CTL_DRV_DEFAULT); EFX_SET_OWORD_FIELD(sdctl, XX_HIDRVB, XX_SD_CTL_DRV_DEFAULT); EFX_SET_OWORD_FIELD(sdctl, XX_LODRVB, XX_SD_CTL_DRV_DEFAULT); EFX_SET_OWORD_FIELD(sdctl, XX_HIDRVA, XX_SD_CTL_DRV_DEFAULT); EFX_SET_OWORD_FIELD(sdctl, XX_LODRVA, XX_SD_CTL_DRV_DEFAULT); falcon_write(efx, &sdctl, XX_SD_CTL_REG); EFX_POPULATE_OWORD_8(txdrv, XX_DEQD, XX_TXDRV_DEQ_DEFAULT, XX_DEQC, XX_TXDRV_DEQ_DEFAULT, XX_DEQB, XX_TXDRV_DEQ_DEFAULT, XX_DEQA, XX_TXDRV_DEQ_DEFAULT, XX_DTXD, XX_TXDRV_DTX_DEFAULT, XX_DTXC, XX_TXDRV_DTX_DEFAULT, XX_DTXB, XX_TXDRV_DTX_DEFAULT, XX_DTXA, XX_TXDRV_DTX_DEFAULT); falcon_write(efx, &txdrv, XX_TXDRV_CTL_REG); }
bool falcon_xaui_link_ok(struct efx_nic *efx) { efx_oword_t reg; bool align_done, link_ok = false; int sync_status; if (LOOPBACK_INTERNAL(efx)) return true; falcon_read(efx, ®, XX_CORE_STAT_REG); align_done = EFX_OWORD_FIELD(reg, XX_ALIGN_DONE); sync_status = EFX_OWORD_FIELD(reg, XX_SYNC_STAT); if (align_done && (sync_status == XX_SYNC_STAT_DECODE_SYNCED)) link_ok = true; EFX_SET_OWORD_FIELD(reg, XX_COMMA_DET, XX_COMMA_DET_RESET); EFX_SET_OWORD_FIELD(reg, XX_CHARERR, XX_CHARERR_RESET); EFX_SET_OWORD_FIELD(reg, XX_DISPERR, XX_DISPERR_RESET); falcon_write(efx, ®, XX_CORE_STAT_REG); if (efx->link_up && link_ok) if (efx->phy_op->mmds & (1 << MDIO_MMD_PHYXS)) link_ok = efx_mdio_phyxgxs_lane_sync(efx); return link_ok; }
static void falcon_setup_xaui(struct efx_nic *efx) { efx_oword_t sdctl, txdrv; if (efx->phy_type == PHY_TYPE_NONE) return; falcon_read(efx, &sdctl, XX_SD_CTL_REG); EFX_SET_OWORD_FIELD(sdctl, XX_HIDRVD, XX_SD_CTL_DRV_DEFAULT); EFX_SET_OWORD_FIELD(sdctl, XX_LODRVD, XX_SD_CTL_DRV_DEFAULT); EFX_SET_OWORD_FIELD(sdctl, XX_HIDRVC, XX_SD_CTL_DRV_DEFAULT); EFX_SET_OWORD_FIELD(sdctl, XX_LODRVC, XX_SD_CTL_DRV_DEFAULT); EFX_SET_OWORD_FIELD(sdctl, XX_HIDRVB, XX_SD_CTL_DRV_DEFAULT); EFX_SET_OWORD_FIELD(sdctl, XX_LODRVB, XX_SD_CTL_DRV_DEFAULT); EFX_SET_OWORD_FIELD(sdctl, XX_HIDRVA, XX_SD_CTL_DRV_DEFAULT); EFX_SET_OWORD_FIELD(sdctl, XX_LODRVA, XX_SD_CTL_DRV_DEFAULT); falcon_write(efx, &sdctl, XX_SD_CTL_REG); EFX_POPULATE_OWORD_8(txdrv, XX_DEQD, XX_TXDRV_DEQ_DEFAULT, XX_DEQC, XX_TXDRV_DEQ_DEFAULT, XX_DEQB, XX_TXDRV_DEQ_DEFAULT, XX_DEQA, XX_TXDRV_DEQ_DEFAULT, XX_DTXD, XX_TXDRV_DTX_DEFAULT, XX_DTXC, XX_TXDRV_DTX_DEFAULT, XX_DTXB, XX_TXDRV_DTX_DEFAULT, XX_DTXA, XX_TXDRV_DTX_DEFAULT); falcon_write(efx, &txdrv, XX_TXDRV_CTL_REG); }
static void falcon_mask_status_intr(struct efx_nic *efx, bool enable) { efx_oword_t reg; if ((falcon_rev(efx) != FALCON_REV_B0) || LOOPBACK_INTERNAL(efx)) return; /* We expect xgmii faults if the wireside link is up */ if (!EFX_WORKAROUND_5147(efx) || !efx->link_up) return; /* We can only use this interrupt to signal the negative edge of * xaui_align [we have to poll the positive edge]. */ if (!efx->mac_up) return; /* Flush the ISR */ if (enable) falcon_read(efx, ®, XM_MGT_INT_REG_B0); EFX_POPULATE_OWORD_2(reg, XM_MSK_RMTFLT, !enable, XM_MSK_LCLFLT, !enable); falcon_write(efx, ®, XM_MGT_INT_MSK_REG_B0); }
static void falcon_reconfigure_xgxs_core(struct efx_nic *efx) { efx_oword_t reg; bool xgxs_loopback = (efx->loopback_mode == LOOPBACK_XGXS); bool xaui_loopback = (efx->loopback_mode == LOOPBACK_XAUI); bool xgmii_loopback = (efx->loopback_mode == LOOPBACK_XGMII); /* XGXS block is flaky and will need to be reset if moving * into our out of XGMII, XGXS or XAUI loopbacks. */ if (EFX_WORKAROUND_5147(efx)) { bool old_xgmii_loopback, old_xgxs_loopback, old_xaui_loopback; bool reset_xgxs; falcon_read(efx, ®, XX_CORE_STAT_REG); old_xgxs_loopback = EFX_OWORD_FIELD(reg, XX_XGXS_LB_EN); old_xgmii_loopback = EFX_OWORD_FIELD(reg, XX_XGMII_LB_EN); falcon_read(efx, ®, XX_SD_CTL_REG); old_xaui_loopback = EFX_OWORD_FIELD(reg, XX_LPBKA); /* The PHY driver may have turned XAUI off */ reset_xgxs = ((xgxs_loopback != old_xgxs_loopback) || (xaui_loopback != old_xaui_loopback) || (xgmii_loopback != old_xgmii_loopback)); if (reset_xgxs) falcon_reset_xaui(efx); } falcon_read(efx, ®, XX_CORE_STAT_REG); EFX_SET_OWORD_FIELD(reg, XX_FORCE_SIG, (xgxs_loopback || xaui_loopback) ? XX_FORCE_SIG_DECODE_FORCED : 0); EFX_SET_OWORD_FIELD(reg, XX_XGXS_LB_EN, xgxs_loopback); EFX_SET_OWORD_FIELD(reg, XX_XGMII_LB_EN, xgmii_loopback); falcon_write(efx, ®, XX_CORE_STAT_REG); falcon_read(efx, ®, XX_SD_CTL_REG); EFX_SET_OWORD_FIELD(reg, XX_LPBKD, xaui_loopback); EFX_SET_OWORD_FIELD(reg, XX_LPBKC, xaui_loopback); EFX_SET_OWORD_FIELD(reg, XX_LPBKB, xaui_loopback); EFX_SET_OWORD_FIELD(reg, XX_LPBKA, xaui_loopback); falcon_write(efx, ®, XX_SD_CTL_REG); }
static void falcon_reconfigure_xgxs_core(struct efx_nic *efx) { efx_oword_t reg; bool xgxs_loopback = (efx->loopback_mode == LOOPBACK_XGXS); bool xaui_loopback = (efx->loopback_mode == LOOPBACK_XAUI); bool xgmii_loopback = (efx->loopback_mode == LOOPBACK_XGMII); if (EFX_WORKAROUND_5147(efx)) { bool old_xgmii_loopback, old_xgxs_loopback, old_xaui_loopback; bool reset_xgxs; falcon_read(efx, ®, XX_CORE_STAT_REG); old_xgxs_loopback = EFX_OWORD_FIELD(reg, XX_XGXS_LB_EN); old_xgmii_loopback = EFX_OWORD_FIELD(reg, XX_XGMII_LB_EN); falcon_read(efx, ®, XX_SD_CTL_REG); old_xaui_loopback = EFX_OWORD_FIELD(reg, XX_LPBKA); reset_xgxs = ((xgxs_loopback != old_xgxs_loopback) || (xaui_loopback != old_xaui_loopback) || (xgmii_loopback != old_xgmii_loopback)); if (reset_xgxs) falcon_reset_xaui(efx); } falcon_read(efx, ®, XX_CORE_STAT_REG); EFX_SET_OWORD_FIELD(reg, XX_FORCE_SIG, (xgxs_loopback || xaui_loopback) ? XX_FORCE_SIG_DECODE_FORCED : 0); EFX_SET_OWORD_FIELD(reg, XX_XGXS_LB_EN, xgxs_loopback); EFX_SET_OWORD_FIELD(reg, XX_XGMII_LB_EN, xgmii_loopback); falcon_write(efx, ®, XX_CORE_STAT_REG); falcon_read(efx, ®, XX_SD_CTL_REG); EFX_SET_OWORD_FIELD(reg, XX_LPBKD, xaui_loopback); EFX_SET_OWORD_FIELD(reg, XX_LPBKC, xaui_loopback); EFX_SET_OWORD_FIELD(reg, XX_LPBKB, xaui_loopback); EFX_SET_OWORD_FIELD(reg, XX_LPBKA, xaui_loopback); falcon_write(efx, ®, XX_SD_CTL_REG); }
static bool falcon_xgmii_status(struct efx_nic *efx) { efx_oword_t reg; if (falcon_rev(efx) < FALCON_REV_B0) return true; /* The ISR latches, so clear it and re-read */ falcon_read(efx, ®, XM_MGT_INT_REG_B0); falcon_read(efx, ®, XM_MGT_INT_REG_B0); if (EFX_OWORD_FIELD(reg, XM_LCLFLT) || EFX_OWORD_FIELD(reg, XM_RMTFLT)) { EFX_INFO(efx, "MGT_INT: "EFX_DWORD_FMT"\n", EFX_DWORD_VAL(reg)); return false; } return true; }
static void falcon_mask_status_intr(struct efx_nic *efx, bool enable) { efx_oword_t reg; if ((falcon_rev(efx) < FALCON_REV_B0) || LOOPBACK_INTERNAL(efx)) return; /* Flush the ISR */ if (enable) falcon_read(efx, ®, XM_MGT_INT_REG_B0); EFX_POPULATE_OWORD_2(reg, XM_MSK_RMTFLT, !enable, XM_MSK_LCLFLT, !enable); falcon_write(efx, ®, XM_MGT_INT_MSK_REG_B0); }
/************************************************************************** * * MAC operations * *************************************************************************/ static int falcon_reset_xmac(struct efx_nic *efx) { efx_oword_t reg; int count; EFX_POPULATE_OWORD_1(reg, XM_CORE_RST, 1); falcon_write(efx, ®, XM_GLB_CFG_REG); for (count = 0; count < 10000; count++) { /* wait upto 100ms */ falcon_read(efx, ®, XM_GLB_CFG_REG); if (EFX_OWORD_FIELD(reg, XM_CORE_RST) == 0) return 0; udelay(10); } EFX_ERR(efx, "timed out waiting for XMAC core reset\n"); return -ETIMEDOUT; }
int falcon_reset_xaui(struct efx_nic *efx) { efx_oword_t reg; int count; EFX_POPULATE_DWORD_1(reg, XX_RST_XX_EN, 1); falcon_write(efx, ®, XX_PWR_RST_REG); /* Give some time for the link to establish */ for (count = 0; count < 1000; count++) { /* wait upto 10ms */ falcon_read(efx, ®, XX_PWR_RST_REG); if (EFX_OWORD_FIELD(reg, XX_RST_XX_EN) == 0) { falcon_setup_xaui(efx); return 0; } udelay(10); } EFX_ERR(efx, "timed out waiting for XAUI/XGXS reset\n"); return -ETIMEDOUT; }
int falcon_reset_xaui(struct efx_nic *efx) { efx_oword_t reg; int count; EFX_POPULATE_DWORD_1(reg, XX_RST_XX_EN, 1); falcon_write(efx, ®, XX_PWR_RST_REG); for (count = 0; count < 1000; count++) { falcon_read(efx, ®, XX_PWR_RST_REG); if (EFX_OWORD_FIELD(reg, XX_RST_XX_EN) == 0 && EFX_OWORD_FIELD(reg, XX_SD_RST_ACT) == 0) { falcon_setup_xaui(efx); return 0; } udelay(10); } EFX_ERR(efx, "timed out waiting for XAUI/XGXS reset\n"); return -ETIMEDOUT; }
int falcon_reset_xaui(struct efx_nic *efx) { efx_oword_t reg; int count; /* Start reset sequence */ EFX_POPULATE_DWORD_1(reg, XX_RST_XX_EN, 1); falcon_write(efx, ®, XX_PWR_RST_REG); /* Wait up to 10 ms for completion, then reinitialise */ for (count = 0; count < 1000; count++) { falcon_read(efx, ®, XX_PWR_RST_REG); if (EFX_OWORD_FIELD(reg, XX_RST_XX_EN) == 0 && EFX_OWORD_FIELD(reg, XX_SD_RST_ACT) == 0) { falcon_setup_xaui(efx); return 0; } udelay(10); } EFX_ERR(efx, "timed out waiting for XAUI/XGXS reset\n"); return -ETIMEDOUT; }
bool falcon_xaui_link_ok(struct efx_nic *efx) { efx_oword_t reg; bool align_done, link_ok = false; int sync_status; if (LOOPBACK_INTERNAL(efx)) return true; /* Read link status */ falcon_read(efx, ®, XX_CORE_STAT_REG); align_done = EFX_OWORD_FIELD(reg, XX_ALIGN_DONE); sync_status = EFX_OWORD_FIELD(reg, XX_SYNC_STAT); if (align_done && (sync_status == XX_SYNC_STAT_DECODE_SYNCED)) link_ok = true; /* Clear link status ready for next read */ EFX_SET_OWORD_FIELD(reg, XX_COMMA_DET, XX_COMMA_DET_RESET); EFX_SET_OWORD_FIELD(reg, XX_CHARERR, XX_CHARERR_RESET); EFX_SET_OWORD_FIELD(reg, XX_DISPERR, XX_DISPERR_RESET); falcon_write(efx, ®, XX_CORE_STAT_REG); /* If the link is up, then check the phy side of the xaui link * (error conditions from the wire side propoagate back through * the phy to the xaui side). */ if (efx->link_up && link_ok) { if (efx->phy_op->mmds & (1 << MDIO_MMD_PHYXS)) link_ok = mdio_clause45_phyxgxs_lane_sync(efx); } /* If the PHY and XAUI links are up, then check the mac's xgmii * fault state */ if (efx->link_up && link_ok) link_ok = falcon_xgmii_status(efx); return link_ok; }
static void falcon_mask_status_intr(struct efx_nic *efx, bool enable) { efx_oword_t reg; if ((falcon_rev(efx) != FALCON_REV_B0) || LOOPBACK_INTERNAL(efx)) return; if (!EFX_WORKAROUND_5147(efx) || !efx->link_up) return; if (!efx->mac_up) return; if (enable) falcon_read(efx, ®, XM_MGT_INT_REG_B0); EFX_POPULATE_OWORD_2(reg, XM_MSK_RMTFLT, !enable, XM_MSK_LCLFLT, !enable); falcon_write(efx, ®, XM_MGT_INT_MSK_REG_B0); }
static void falcon_reconfigure_gmac(struct efx_nic *efx) { bool loopback, tx_fc, rx_fc, bytemode; int if_mode; unsigned int max_frame_len; efx_oword_t reg; /* Configuration register 1 */ tx_fc = (efx->link_fc & EFX_FC_TX) || !efx->link_fd; rx_fc = !!(efx->link_fc & EFX_FC_RX); loopback = (efx->loopback_mode == LOOPBACK_GMAC); bytemode = (efx->link_speed == 1000); EFX_POPULATE_OWORD_5(reg, GM_LOOP, loopback, GM_TX_EN, 1, GM_TX_FC_EN, tx_fc, GM_RX_EN, 1, GM_RX_FC_EN, rx_fc); falcon_write(efx, ®, GM_CFG1_REG); udelay(10); /* Configuration register 2 */ if_mode = (bytemode) ? 2 : 1; EFX_POPULATE_OWORD_5(reg, GM_IF_MODE, if_mode, GM_PAD_CRC_EN, 1, GM_LEN_CHK, 1, GM_FD, efx->link_fd, GM_PAMBL_LEN, 0x7/*datasheet recommended */); falcon_write(efx, ®, GM_CFG2_REG); udelay(10); /* Max frame len register */ max_frame_len = EFX_MAX_FRAME_LEN(efx->net_dev->mtu); EFX_POPULATE_OWORD_1(reg, GM_MAX_FLEN, max_frame_len); falcon_write(efx, ®, GM_MAX_FLEN_REG); udelay(10); /* FIFO configuration register 0 */ EFX_POPULATE_OWORD_5(reg, GMF_FTFENREQ, 1, GMF_STFENREQ, 1, GMF_FRFENREQ, 1, GMF_SRFENREQ, 1, GMF_WTMENREQ, 1); falcon_write(efx, ®, GMF_CFG0_REG); udelay(10); /* FIFO configuration register 1 */ EFX_POPULATE_OWORD_2(reg, GMF_CFGFRTH, 0x12, GMF_CFGXOFFRTX, 0xffff); falcon_write(efx, ®, GMF_CFG1_REG); udelay(10); /* FIFO configuration register 2 */ EFX_POPULATE_OWORD_2(reg, GMF_CFGHWM, 0x3f, GMF_CFGLWM, 0xa); falcon_write(efx, ®, GMF_CFG2_REG); udelay(10); /* FIFO configuration register 3 */ EFX_POPULATE_OWORD_2(reg, GMF_CFGHWMFT, 0x1c, GMF_CFGFTTH, 0x08); falcon_write(efx, ®, GMF_CFG3_REG); udelay(10); /* FIFO configuration register 4 */ EFX_POPULATE_OWORD_1(reg, GMF_HSTFLTRFRM_PAUSE, 1); falcon_write(efx, ®, GMF_CFG4_REG); udelay(10); /* FIFO configuration register 5 */ falcon_read(efx, ®, GMF_CFG5_REG); EFX_SET_OWORD_FIELD(reg, GMF_CFGBYTMODE, bytemode); EFX_SET_OWORD_FIELD(reg, GMF_CFGHDPLX, !efx->link_fd); EFX_SET_OWORD_FIELD(reg, GMF_HSTDRPLT64, !efx->link_fd); EFX_SET_OWORD_FIELD(reg, GMF_HSTFLTRFRMDC_PAUSE, 0); falcon_write(efx, ®, GMF_CFG5_REG); udelay(10); /* MAC address */ EFX_POPULATE_OWORD_4(reg, GM_HWADDR_5, efx->net_dev->dev_addr[5], GM_HWADDR_4, efx->net_dev->dev_addr[4], GM_HWADDR_3, efx->net_dev->dev_addr[3], GM_HWADDR_2, efx->net_dev->dev_addr[2]); falcon_write(efx, ®, GM_ADR1_REG); udelay(10); EFX_POPULATE_OWORD_2(reg, GM_HWADDR_1, efx->net_dev->dev_addr[1], GM_HWADDR_0, efx->net_dev->dev_addr[0]); falcon_write(efx, ®, GM_ADR2_REG); udelay(10); falcon_reconfigure_mac_wrapper(efx); }