static int et131x_xcvr_init(struct et131x_adapter *adapter) { int status = 0; MI_IMR_t imr; MI_ISR_t isr; MI_LCR2_t lcr2; adapter->Bmsr.value = 0; MiRead(adapter, (uint8_t) offsetof(MI_REGS_t, isr), &isr.value); MiRead(adapter, (uint8_t) offsetof(MI_REGS_t, imr), &imr.value); imr.bits.int_en = 0x1; imr.bits.link_status = 0x1; imr.bits.autoneg_status = 0x1; MiWrite(adapter, (uint8_t) offsetof(MI_REGS_t, imr), imr.value); if ((adapter->eepromData[1] & 0x4) == 0) { MiRead(adapter, (uint8_t) offsetof(MI_REGS_t, lcr2), &lcr2.value); if ((adapter->eepromData[1] & 0x8) == 0) lcr2.bits.led_tx_rx = 0x3; else lcr2.bits.led_tx_rx = 0x4; lcr2.bits.led_link = 0xa; MiWrite(adapter, (uint8_t) offsetof(MI_REGS_t, lcr2), lcr2.value); } if (adapter->AiForceSpeed == 0 && adapter->AiForceDpx == 0) { if ((adapter->RegistryFlowControl == TxOnly) || (adapter->RegistryFlowControl == Both)) { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_SET, 4, 11, NULL); } else { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_CLEAR, 4, 11, NULL); } if (adapter->RegistryFlowControl == Both) { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_SET, 4, 10, NULL); } else { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_CLEAR, 4, 10, NULL); } ET1310_PhyAutoNeg(adapter, true); ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_SET, 0, 9, NULL); return status; } else { ET1310_PhyAutoNeg(adapter, false); if (adapter->AiForceDpx != 1) { if ((adapter->RegistryFlowControl == TxOnly) || (adapter->RegistryFlowControl == Both)) { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_SET, 4, 11, NULL); } else { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_CLEAR, 4, 11, NULL); } if (adapter->RegistryFlowControl == Both) { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_SET, 4, 10, NULL); } else { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_CLEAR, 4, 10, NULL); } } else { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_CLEAR, 4, 10, NULL); ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_CLEAR, 4, 11, NULL); } switch (adapter->AiForceSpeed) { case 10: if (adapter->AiForceDpx == 1) TPAL_SetPhy10HalfDuplex(adapter); else if (adapter->AiForceDpx == 2) TPAL_SetPhy10FullDuplex(adapter); else TPAL_SetPhy10Force(adapter); break; case 100: if (adapter->AiForceDpx == 1) TPAL_SetPhy100HalfDuplex(adapter); else if (adapter->AiForceDpx == 2) TPAL_SetPhy100FullDuplex(adapter); else TPAL_SetPhy100Force(adapter); break; case 1000: TPAL_SetPhy1000FullDuplex(adapter); break; } return status; } }
/** * et131x_xcvr_init - Init the phy if we are setting it into force mode * @adapter: pointer to our private adapter structure * * Returns 0 on success, errno on failure (as defined in errno.h) */ static int et131x_xcvr_init(struct et131x_adapter *adapter) { int status = 0; MI_IMR_t imr; MI_ISR_t isr; MI_LCR2_t lcr2; /* Zero out the adapter structure variable representing BMSR */ adapter->Bmsr.value = 0; MiRead(adapter, (uint8_t) offsetof(MI_REGS_t, isr), &isr.value); MiRead(adapter, (uint8_t) offsetof(MI_REGS_t, imr), &imr.value); /* Set the link status interrupt only. Bad behavior when link status * and auto neg are set, we run into a nested interrupt problem */ imr.bits.int_en = 0x1; imr.bits.link_status = 0x1; imr.bits.autoneg_status = 0x1; MiWrite(adapter, (uint8_t) offsetof(MI_REGS_t, imr), imr.value); /* Set the LED behavior such that LED 1 indicates speed (off = * 10Mbits, blink = 100Mbits, on = 1000Mbits) and LED 2 indicates * link and activity (on for link, blink off for activity). * * NOTE: Some customizations have been added here for specific * vendors; The LED behavior is now determined by vendor data in the * EEPROM. However, the above description is the default. */ if ((adapter->eepromData[1] & 0x4) == 0) { MiRead(adapter, (uint8_t) offsetof(MI_REGS_t, lcr2), &lcr2.value); if ((adapter->eepromData[1] & 0x8) == 0) lcr2.bits.led_tx_rx = 0x3; else lcr2.bits.led_tx_rx = 0x4; lcr2.bits.led_link = 0xa; MiWrite(adapter, (uint8_t) offsetof(MI_REGS_t, lcr2), lcr2.value); } /* Determine if we need to go into a force mode and set it */ if (adapter->AiForceSpeed == 0 && adapter->AiForceDpx == 0) { if ((adapter->RegistryFlowControl == TxOnly) || (adapter->RegistryFlowControl == Both)) { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_SET, 4, 11, NULL); } else { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_CLEAR, 4, 11, NULL); } if (adapter->RegistryFlowControl == Both) { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_SET, 4, 10, NULL); } else { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_CLEAR, 4, 10, NULL); } /* Set the phy to autonegotiation */ ET1310_PhyAutoNeg(adapter, true); /* NOTE - Do we need this? */ ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_SET, 0, 9, NULL); return status; } else { ET1310_PhyAutoNeg(adapter, false); /* Set to the correct force mode. */ if (adapter->AiForceDpx != 1) { if ((adapter->RegistryFlowControl == TxOnly) || (adapter->RegistryFlowControl == Both)) { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_SET, 4, 11, NULL); } else { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_CLEAR, 4, 11, NULL); } if (adapter->RegistryFlowControl == Both) { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_SET, 4, 10, NULL); } else { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_CLEAR, 4, 10, NULL); } } else { ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_CLEAR, 4, 10, NULL); ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_CLEAR, 4, 11, NULL); } switch (adapter->AiForceSpeed) { case 10: if (adapter->AiForceDpx == 1) TPAL_SetPhy10HalfDuplex(adapter); else if (adapter->AiForceDpx == 2) TPAL_SetPhy10FullDuplex(adapter); else TPAL_SetPhy10Force(adapter); break; case 100: if (adapter->AiForceDpx == 1) TPAL_SetPhy100HalfDuplex(adapter); else if (adapter->AiForceDpx == 2) TPAL_SetPhy100FullDuplex(adapter); else TPAL_SetPhy100Force(adapter); break; case 1000: TPAL_SetPhy1000FullDuplex(adapter); break; } return status; } }