diff options
Diffstat (limited to 'drivers/staging/et131x/et1310_phy.c')
-rw-r--r-- | drivers/staging/et131x/et1310_phy.c | 770 |
1 files changed, 345 insertions, 425 deletions
diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 9dd6dfd9a033..dd199bdb9eff 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -2,7 +2,7 @@ * Agere Systems Inc. * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs * - * Copyright © 2005 Agere Systems Inc. + * Copyright * 2005 Agere Systems Inc. * All rights reserved. * http://www.agere.com * @@ -19,7 +19,7 @@ * software indicates your acceptance of these terms and conditions. If you do * not agree with these terms and conditions, do not use the software. * - * Copyright © 2005 Agere Systems Inc. + * Copyright * 2005 Agere Systems Inc. * All rights reserved. * * Redistribution and use in source or binary forms, with or without @@ -40,7 +40,7 @@ * * Disclaimer * - * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN @@ -56,7 +56,6 @@ */ #include "et131x_version.h" -#include "et131x_debug.h" #include "et131x_defs.h" #include <linux/pci.h> @@ -74,9 +73,9 @@ #include <linux/interrupt.h> #include <linux/in.h> #include <linux/delay.h> -#include <asm/io.h> +#include <linux/io.h> +#include <linux/bitops.h> #include <asm/system.h> -#include <asm/bitops.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> @@ -98,11 +97,6 @@ #include "et1310_rx.h" #include "et1310_mac.h" -/* Data for debugging facilities */ -#ifdef CONFIG_ET131X_DEBUG -extern dbg_info_t *et131x_dbginfo; -#endif /* CONFIG_ET131X_DEBUG */ - /* Prototypes for functions with local scope */ static int et131x_xcvr_init(struct et131x_adapter *adapter); @@ -118,7 +112,7 @@ static int et131x_xcvr_init(struct et131x_adapter *adapter); int PhyMiRead(struct et131x_adapter *adapter, uint8_t xcvrAddr, uint8_t xcvrReg, uint16_t *value) { - struct _MAC_t __iomem *mac = &adapter->CSRAddress->mac; + struct _MAC_t __iomem *mac = &adapter->regs->mac; int status = 0; uint32_t delay; MII_MGMT_ADDR_t miiAddr; @@ -157,9 +151,9 @@ int PhyMiRead(struct et131x_adapter *adapter, uint8_t xcvrAddr, /* If we hit the max delay, we could not read the register */ if (delay >= 50) { - DBG_WARNING(et131x_dbginfo, + dev_warn(&adapter->pdev->dev, "xcvrReg 0x%08x could not be read\n", xcvrReg); - DBG_WARNING(et131x_dbginfo, "status is 0x%08x\n", + dev_warn(&adapter->pdev->dev, "status is 0x%08x\n", miiIndicator.value); status = -EIO; @@ -179,10 +173,6 @@ int PhyMiRead(struct et131x_adapter *adapter, uint8_t xcvrAddr, /* Stop the read operation */ writel(0, &mac->mii_mgmt_cmd.value); - DBG_VERBOSE(et131x_dbginfo, " xcvr_addr = 0x%02x, " - "xcvr_reg = 0x%02x, " - "value = 0x%04x.\n", xcvrAddr, xcvrReg, *value); - /* set the registers we touched back to the state at which we entered * this function */ @@ -202,7 +192,7 @@ int PhyMiRead(struct et131x_adapter *adapter, uint8_t xcvrAddr, */ int MiWrite(struct et131x_adapter *adapter, uint8_t xcvrReg, uint16_t value) { - struct _MAC_t __iomem *mac = &adapter->CSRAddress->mac; + struct _MAC_t __iomem *mac = &adapter->regs->mac; int status = 0; uint8_t xcvrAddr = adapter->Stats.xcvr_addr; uint32_t delay; @@ -242,11 +232,11 @@ int MiWrite(struct et131x_adapter *adapter, uint8_t xcvrReg, uint16_t value) if (delay == 100) { uint16_t TempValue; - DBG_WARNING(et131x_dbginfo, - "xcvrReg 0x%08x could not be written", xcvrReg); - DBG_WARNING(et131x_dbginfo, "status is 0x%08x\n", + dev_warn(&adapter->pdev->dev, + "xcvrReg 0x%08x could not be written", xcvrReg); + dev_warn(&adapter->pdev->dev, "status is 0x%08x\n", miiIndicator.value); - DBG_WARNING(et131x_dbginfo, "command is 0x%08x\n", + dev_warn(&adapter->pdev->dev, "command is 0x%08x\n", readl(&mac->mii_mgmt_cmd.value)); MiRead(adapter, xcvrReg, &TempValue); @@ -258,15 +248,11 @@ int MiWrite(struct et131x_adapter *adapter, uint8_t xcvrReg, uint16_t value) writel(0, &mac->mii_mgmt_cmd.value); /* set the registers we touched back to the state at which we entered - * this function - */ + * this function + */ writel(miiAddr.value, &mac->mii_mgmt_addr.value); writel(miiCmd.value, &mac->mii_mgmt_cmd.value); - DBG_VERBOSE(et131x_dbginfo, " xcvr_addr = 0x%02x, " - "xcvr_reg = 0x%02x, " - "value = 0x%04x.\n", xcvrAddr, xcvrReg, value); - return status; } @@ -284,8 +270,6 @@ int et131x_xcvr_find(struct et131x_adapter *adapter) MI_IDR2_t idr2; uint32_t xcvr_id; - DBG_ENTER(et131x_dbginfo); - /* We need to get xcvr id and address we just get the first one */ for (xcvr_addr = 0; xcvr_addr < 32; xcvr_addr++) { /* Read the ID from the PHY */ @@ -299,10 +283,6 @@ int et131x_xcvr_find(struct et131x_adapter *adapter) xcvr_id = (uint32_t) ((idr1.value << 16) | idr2.value); if ((idr1.value != 0) && (idr1.value != 0xffff)) { - DBG_TRACE(et131x_dbginfo, - "Xcvr addr: 0x%02x\tXcvr_id: 0x%08x\n", - xcvr_addr, xcvr_id); - adapter->Stats.xcvr_id = xcvr_id; adapter->Stats.xcvr_addr = xcvr_addr; @@ -310,8 +290,6 @@ int et131x_xcvr_find(struct et131x_adapter *adapter) break; } } - - DBG_LEAVE(et131x_dbginfo); return status; } @@ -327,13 +305,9 @@ int et131x_setphy_normal(struct et131x_adapter *adapter) { int status; - DBG_ENTER(et131x_dbginfo); - /* Make sure the PHY is powered up */ ET1310_PhyPowerDown(adapter, 0); status = et131x_xcvr_init(adapter); - - DBG_LEAVE(et131x_dbginfo); return status; } @@ -350,8 +324,6 @@ static int et131x_xcvr_init(struct et131x_adapter *adapter) MI_ISR_t isr; MI_LCR2_t lcr2; - DBG_ENTER(et131x_dbginfo); - /* Zero out the adapter structure variable representing BMSR */ adapter->Bmsr.value = 0; @@ -412,8 +384,6 @@ static int et131x_xcvr_init(struct et131x_adapter *adapter) /* NOTE - Do we need this? */ ET1310_PhyAccessMiBit(adapter, TRUEPHY_BIT_SET, 0, 9, NULL); - - DBG_LEAVE(et131x_dbginfo); return status; } else { ET1310_PhyAutoNeg(adapter, false); @@ -449,79 +419,75 @@ static int et131x_xcvr_init(struct et131x_adapter *adapter) switch (adapter->AiForceSpeed) { case 10: - if (adapter->AiForceDpx == 1) { + if (adapter->AiForceDpx == 1) TPAL_SetPhy10HalfDuplex(adapter); - } else if (adapter->AiForceDpx == 2) { + else if (adapter->AiForceDpx == 2) TPAL_SetPhy10FullDuplex(adapter); - } else { + else TPAL_SetPhy10Force(adapter); - } break; case 100: - if (adapter->AiForceDpx == 1) { + if (adapter->AiForceDpx == 1) TPAL_SetPhy100HalfDuplex(adapter); - } else if (adapter->AiForceDpx == 2) { + else if (adapter->AiForceDpx == 2) TPAL_SetPhy100FullDuplex(adapter); - } else { + else TPAL_SetPhy100Force(adapter); - } break; case 1000: TPAL_SetPhy1000FullDuplex(adapter); break; } - DBG_LEAVE(et131x_dbginfo); return status; } } -void et131x_Mii_check(struct et131x_adapter *pAdapter, +void et131x_Mii_check(struct et131x_adapter *etdev, MI_BMSR_t bmsr, MI_BMSR_t bmsr_ints) { - uint8_t ucLinkStatus; - uint32_t uiAutoNegStatus; - uint32_t uiSpeed; - uint32_t uiDuplex; - uint32_t uiMdiMdix; - uint32_t uiMasterSlave; - uint32_t uiPolarity; - unsigned long lockflags; - - DBG_ENTER(et131x_dbginfo); + uint8_t link_status; + uint32_t autoneg_status; + uint32_t speed; + uint32_t duplex; + uint32_t mdi_mdix; + uint32_t masterslave; + uint32_t polarity; + unsigned long flags; if (bmsr_ints.bits.link_status) { if (bmsr.bits.link_status) { - pAdapter->PoMgmt.TransPhyComaModeOnBoot = 20; + etdev->PoMgmt.TransPhyComaModeOnBoot = 20; /* Update our state variables and indicate the * connected state */ - spin_lock_irqsave(&pAdapter->Lock, lockflags); + spin_lock_irqsave(&etdev->Lock, flags); - pAdapter->MediaState = NETIF_STATUS_MEDIA_CONNECT; - MP_CLEAR_FLAG(pAdapter, fMP_ADAPTER_LINK_DETECTION); + etdev->MediaState = NETIF_STATUS_MEDIA_CONNECT; + etdev->Flags &= ~fMP_ADAPTER_LINK_DETECTION; - spin_unlock_irqrestore(&pAdapter->Lock, lockflags); + spin_unlock_irqrestore(&etdev->Lock, flags); /* Don't indicate state if we're in loopback mode */ - if (pAdapter->RegistryPhyLoopbk == false) { - netif_carrier_on(pAdapter->netdev); - } + if (etdev->RegistryPhyLoopbk == false) + netif_carrier_on(etdev->netdev); } else { - DBG_WARNING(et131x_dbginfo, - "Link down cable problem\n"); + dev_warn(&etdev->pdev->dev, + "Link down - cable problem ?\n"); - if (pAdapter->uiLinkSpeed == TRUEPHY_SPEED_10MBPS) { - // NOTE - Is there a way to query this without TruePHY? - // && TRU_QueryCoreType(pAdapter->hTruePhy, 0) == EMI_TRUEPHY_A13O) { + if (etdev->linkspeed == TRUEPHY_SPEED_10MBPS) { + /* NOTE - Is there a way to query this without + * TruePHY? + * && TRU_QueryCoreType(etdev->hTruePhy, 0) == EMI_TRUEPHY_A13O) { + */ uint16_t Register18; - MiRead(pAdapter, 0x12, &Register18); - MiWrite(pAdapter, 0x12, Register18 | 0x4); - MiWrite(pAdapter, 0x10, Register18 | 0x8402); - MiWrite(pAdapter, 0x11, Register18 | 511); - MiWrite(pAdapter, 0x12, Register18); + MiRead(etdev, 0x12, &Register18); + MiWrite(etdev, 0x12, Register18 | 0x4); + MiWrite(etdev, 0x10, Register18 | 0x8402); + MiWrite(etdev, 0x11, Register18 | 511); + MiWrite(etdev, 0x12, Register18); } /* For the first N seconds of life, we are in "link @@ -530,35 +496,32 @@ void et131x_Mii_check(struct et131x_adapter *pAdapter, * Timer expires, we can report disconnected (handled * in the LinkDetectionDPC). */ - if ((MP_IS_FLAG_CLEAR - (pAdapter, fMP_ADAPTER_LINK_DETECTION)) - || (pAdapter->MediaState == - NETIF_STATUS_MEDIA_DISCONNECT)) { - spin_lock_irqsave(&pAdapter->Lock, lockflags); - pAdapter->MediaState = + if (!(etdev->Flags & fMP_ADAPTER_LINK_DETECTION) || + (etdev->MediaState == NETIF_STATUS_MEDIA_DISCONNECT)) { + spin_lock_irqsave(&etdev->Lock, flags); + etdev->MediaState = NETIF_STATUS_MEDIA_DISCONNECT; - spin_unlock_irqrestore(&pAdapter->Lock, - lockflags); + spin_unlock_irqrestore(&etdev->Lock, + flags); /* Only indicate state if we're in loopback * mode */ - if (pAdapter->RegistryPhyLoopbk == false) { - netif_carrier_off(pAdapter->netdev); - } + if (etdev->RegistryPhyLoopbk == false) + netif_carrier_off(etdev->netdev); } - pAdapter->uiLinkSpeed = 0; - pAdapter->uiDuplexMode = 0; + etdev->linkspeed = 0; + etdev->duplex_mode = 0; /* Free the packets being actively sent & stopped */ - et131x_free_busy_send_packets(pAdapter); + et131x_free_busy_send_packets(etdev); /* Re-initialize the send structures */ - et131x_init_send(pAdapter); + et131x_init_send(etdev); /* Reset the RFD list and re-start RU */ - et131x_reset_recv(pAdapter); + et131x_reset_recv(etdev); /* * Bring the device back to the state it was during @@ -566,296 +529,256 @@ void et131x_Mii_check(struct et131x_adapter *pAdapter, * way, when we get the auto-neg complete interrupt, * we can complete init by calling ConfigMacREGS2. */ - et131x_soft_reset(pAdapter); + et131x_soft_reset(etdev); /* Setup ET1310 as per the documentation */ - et131x_adapter_setup(pAdapter); + et131x_adapter_setup(etdev); /* Setup the PHY into coma mode until the cable is * plugged back in */ - if (pAdapter->RegistryPhyComa == 1) { - EnablePhyComa(pAdapter); - } + if (etdev->RegistryPhyComa == 1) + EnablePhyComa(etdev); } } if (bmsr_ints.bits.auto_neg_complete || - ((pAdapter->AiForceDpx == 3) && (bmsr_ints.bits.link_status))) { - if (bmsr.bits.auto_neg_complete || (pAdapter->AiForceDpx == 3)) { - ET1310_PhyLinkStatus(pAdapter, - &ucLinkStatus, &uiAutoNegStatus, - &uiSpeed, &uiDuplex, &uiMdiMdix, - &uiMasterSlave, &uiPolarity); - - pAdapter->uiLinkSpeed = uiSpeed; - pAdapter->uiDuplexMode = uiDuplex; - - DBG_TRACE(et131x_dbginfo, - "pAdapter->uiLinkSpeed 0x%04x, pAdapter->uiDuplex 0x%08x\n", - pAdapter->uiLinkSpeed, - pAdapter->uiDuplexMode); - - pAdapter->PoMgmt.TransPhyComaModeOnBoot = 20; - - if (pAdapter->uiLinkSpeed == TRUEPHY_SPEED_10MBPS) { - // NOTE - Is there a way to query this without TruePHY? - // && TRU_QueryCoreType(pAdapter->hTruePhy, 0) == EMI_TRUEPHY_A13O) { + (etdev->AiForceDpx == 3 && bmsr_ints.bits.link_status)) { + if (bmsr.bits.auto_neg_complete || etdev->AiForceDpx == 3) { + ET1310_PhyLinkStatus(etdev, + &link_status, &autoneg_status, + &speed, &duplex, &mdi_mdix, + &masterslave, &polarity); + + etdev->linkspeed = speed; + etdev->duplex_mode = duplex; + + etdev->PoMgmt.TransPhyComaModeOnBoot = 20; + + if (etdev->linkspeed == TRUEPHY_SPEED_10MBPS) { + /* + * NOTE - Is there a way to query this without + * TruePHY? + * && TRU_QueryCoreType(etdev->hTruePhy, 0)== EMI_TRUEPHY_A13O) { + */ uint16_t Register18; - MiRead(pAdapter, 0x12, &Register18); - MiWrite(pAdapter, 0x12, Register18 | 0x4); - MiWrite(pAdapter, 0x10, Register18 | 0x8402); - MiWrite(pAdapter, 0x11, Register18 | 511); - MiWrite(pAdapter, 0x12, Register18); + MiRead(etdev, 0x12, &Register18); + MiWrite(etdev, 0x12, Register18 | 0x4); + MiWrite(etdev, 0x10, Register18 | 0x8402); + MiWrite(etdev, 0x11, Register18 | 511); + MiWrite(etdev, 0x12, Register18); } - ConfigFlowControl(pAdapter); + ConfigFlowControl(etdev); - if ((pAdapter->uiLinkSpeed == TRUEPHY_SPEED_1000MBPS) && - (pAdapter->RegistryJumboPacket > 2048)) - { - ET1310_PhyAndOrReg(pAdapter, 0x16, 0xcfff, - 0x2000); - } + if (etdev->linkspeed == TRUEPHY_SPEED_1000MBPS && + etdev->RegistryJumboPacket > 2048) + ET1310_PhyAndOrReg(etdev, 0x16, 0xcfff, + 0x2000); - SetRxDmaTimer(pAdapter); - ConfigMACRegs2(pAdapter); + SetRxDmaTimer(etdev); + ConfigMACRegs2(etdev); } } - - DBG_LEAVE(et131x_dbginfo); } /** * TPAL_SetPhy10HalfDuplex - Force the phy into 10 Base T Half Duplex mode. - * @pAdapter: pointer to the adapter structure + * @etdev: pointer to the adapter structure * * Also sets the MAC so it is syncd up properly */ -void TPAL_SetPhy10HalfDuplex(struct et131x_adapter *pAdapter) +void TPAL_SetPhy10HalfDuplex(struct et131x_adapter *etdev) { - DBG_ENTER(et131x_dbginfo); - /* Power down PHY */ - ET1310_PhyPowerDown(pAdapter, 1); + ET1310_PhyPowerDown(etdev, 1); /* First we need to turn off all other advertisement */ - ET1310_PhyAdvertise1000BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - ET1310_PhyAdvertise100BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); /* Set our advertise values accordingly */ - ET1310_PhyAdvertise10BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_HALF); + ET1310_PhyAdvertise10BaseT(etdev, TRUEPHY_ADV_DUPLEX_HALF); /* Power up PHY */ - ET1310_PhyPowerDown(pAdapter, 0); - - DBG_LEAVE(et131x_dbginfo); + ET1310_PhyPowerDown(etdev, 0); } /** * TPAL_SetPhy10FullDuplex - Force the phy into 10 Base T Full Duplex mode. - * @pAdapter: pointer to the adapter structure + * @etdev: pointer to the adapter structure * * Also sets the MAC so it is syncd up properly */ -void TPAL_SetPhy10FullDuplex(struct et131x_adapter *pAdapter) +void TPAL_SetPhy10FullDuplex(struct et131x_adapter *etdev) { - DBG_ENTER(et131x_dbginfo); - /* Power down PHY */ - ET1310_PhyPowerDown(pAdapter, 1); + ET1310_PhyPowerDown(etdev, 1); /* First we need to turn off all other advertisement */ - ET1310_PhyAdvertise1000BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - ET1310_PhyAdvertise100BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); /* Set our advertise values accordingly */ - ET1310_PhyAdvertise10BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_FULL); + ET1310_PhyAdvertise10BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); /* Power up PHY */ - ET1310_PhyPowerDown(pAdapter, 0); - - DBG_LEAVE(et131x_dbginfo); + ET1310_PhyPowerDown(etdev, 0); } /** * TPAL_SetPhy10Force - Force Base-T FD mode WITHOUT using autonegotiation - * @pAdapter: pointer to the adapter structure + * @etdev: pointer to the adapter structure */ -void TPAL_SetPhy10Force(struct et131x_adapter *pAdapter) +void TPAL_SetPhy10Force(struct et131x_adapter *etdev) { - DBG_ENTER(et131x_dbginfo); - /* Power down PHY */ - ET1310_PhyPowerDown(pAdapter, 1); + ET1310_PhyPowerDown(etdev, 1); /* Disable autoneg */ - ET1310_PhyAutoNeg(pAdapter, false); + ET1310_PhyAutoNeg(etdev, false); /* Disable all advertisement */ - ET1310_PhyAdvertise1000BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); - ET1310_PhyAdvertise10BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); - ET1310_PhyAdvertise100BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); /* Force 10 Mbps */ - ET1310_PhySpeedSelect(pAdapter, TRUEPHY_SPEED_10MBPS); + ET1310_PhySpeedSelect(etdev, TRUEPHY_SPEED_10MBPS); /* Force Full duplex */ - ET1310_PhyDuplexMode(pAdapter, TRUEPHY_DUPLEX_FULL); + ET1310_PhyDuplexMode(etdev, TRUEPHY_DUPLEX_FULL); /* Power up PHY */ - ET1310_PhyPowerDown(pAdapter, 0); - - DBG_LEAVE(et131x_dbginfo); + ET1310_PhyPowerDown(etdev, 0); } /** * TPAL_SetPhy100HalfDuplex - Force 100 Base T Half Duplex mode. - * @pAdapter: pointer to the adapter structure + * @etdev: pointer to the adapter structure * * Also sets the MAC so it is syncd up properly. */ -void TPAL_SetPhy100HalfDuplex(struct et131x_adapter *pAdapter) +void TPAL_SetPhy100HalfDuplex(struct et131x_adapter *etdev) { - DBG_ENTER(et131x_dbginfo); - /* Power down PHY */ - ET1310_PhyPowerDown(pAdapter, 1); + ET1310_PhyPowerDown(etdev, 1); /* first we need to turn off all other advertisement */ - ET1310_PhyAdvertise1000BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - ET1310_PhyAdvertise10BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); /* Set our advertise values accordingly */ - ET1310_PhyAdvertise100BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_HALF); + ET1310_PhyAdvertise100BaseT(etdev, TRUEPHY_ADV_DUPLEX_HALF); /* Set speed */ - ET1310_PhySpeedSelect(pAdapter, TRUEPHY_SPEED_100MBPS); + ET1310_PhySpeedSelect(etdev, TRUEPHY_SPEED_100MBPS); /* Power up PHY */ - ET1310_PhyPowerDown(pAdapter, 0); - - DBG_LEAVE(et131x_dbginfo); + ET1310_PhyPowerDown(etdev, 0); } /** * TPAL_SetPhy100FullDuplex - Force 100 Base T Full Duplex mode. - * @pAdapter: pointer to the adapter structure + * @etdev: pointer to the adapter structure * * Also sets the MAC so it is syncd up properly */ -void TPAL_SetPhy100FullDuplex(struct et131x_adapter *pAdapter) +void TPAL_SetPhy100FullDuplex(struct et131x_adapter *etdev) { - DBG_ENTER(et131x_dbginfo); - /* Power down PHY */ - ET1310_PhyPowerDown(pAdapter, 1); + ET1310_PhyPowerDown(etdev, 1); /* First we need to turn off all other advertisement */ - ET1310_PhyAdvertise1000BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - ET1310_PhyAdvertise10BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); /* Set our advertise values accordingly */ - ET1310_PhyAdvertise100BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_FULL); + ET1310_PhyAdvertise100BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); /* Power up PHY */ - ET1310_PhyPowerDown(pAdapter, 0); - - DBG_LEAVE(et131x_dbginfo); + ET1310_PhyPowerDown(etdev, 0); } /** * TPAL_SetPhy100Force - Force 100 BaseT FD mode WITHOUT using autonegotiation - * @pAdapter: pointer to the adapter structure + * @etdev: pointer to the adapter structure */ -void TPAL_SetPhy100Force(struct et131x_adapter *pAdapter) +void TPAL_SetPhy100Force(struct et131x_adapter *etdev) { - DBG_ENTER(et131x_dbginfo); - /* Power down PHY */ - ET1310_PhyPowerDown(pAdapter, 1); + ET1310_PhyPowerDown(etdev, 1); /* Disable autoneg */ - ET1310_PhyAutoNeg(pAdapter, false); + ET1310_PhyAutoNeg(etdev, false); /* Disable all advertisement */ - ET1310_PhyAdvertise1000BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); - ET1310_PhyAdvertise10BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); - ET1310_PhyAdvertise100BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); /* Force 100 Mbps */ - ET1310_PhySpeedSelect(pAdapter, TRUEPHY_SPEED_100MBPS); + ET1310_PhySpeedSelect(etdev, TRUEPHY_SPEED_100MBPS); /* Force Full duplex */ - ET1310_PhyDuplexMode(pAdapter, TRUEPHY_DUPLEX_FULL); + ET1310_PhyDuplexMode(etdev, TRUEPHY_DUPLEX_FULL); /* Power up PHY */ - ET1310_PhyPowerDown(pAdapter, 0); - - DBG_LEAVE(et131x_dbginfo); + ET1310_PhyPowerDown(etdev, 0); } /** * TPAL_SetPhy1000FullDuplex - Force 1000 Base T Full Duplex mode - * @pAdapter: pointer to the adapter structure + * @etdev: pointer to the adapter structure * * Also sets the MAC so it is syncd up properly. */ -void TPAL_SetPhy1000FullDuplex(struct et131x_adapter *pAdapter) +void TPAL_SetPhy1000FullDuplex(struct et131x_adapter *etdev) { - DBG_ENTER(et131x_dbginfo); - /* Power down PHY */ - ET1310_PhyPowerDown(pAdapter, 1); + ET1310_PhyPowerDown(etdev, 1); /* first we need to turn off all other advertisement */ - ET1310_PhyAdvertise100BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); - ET1310_PhyAdvertise10BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); + ET1310_PhyAdvertise10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); /* set our advertise values accordingly */ - ET1310_PhyAdvertise1000BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_FULL); + ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); /* power up PHY */ - ET1310_PhyPowerDown(pAdapter, 0); - - DBG_LEAVE(et131x_dbginfo); + ET1310_PhyPowerDown(etdev, 0); } /** * TPAL_SetPhyAutoNeg - Set phy to autonegotiation mode. - * @pAdapter: pointer to the adapter structure + * @etdev: pointer to the adapter structure */ -void TPAL_SetPhyAutoNeg(struct et131x_adapter *pAdapter) +void TPAL_SetPhyAutoNeg(struct et131x_adapter *etdev) { - DBG_ENTER(et131x_dbginfo); - /* Power down PHY */ - ET1310_PhyPowerDown(pAdapter, 1); + ET1310_PhyPowerDown(etdev, 1); /* Turn on advertisement of all capabilities */ - ET1310_PhyAdvertise10BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_BOTH); + ET1310_PhyAdvertise10BaseT(etdev, TRUEPHY_ADV_DUPLEX_BOTH); - ET1310_PhyAdvertise100BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_BOTH); + ET1310_PhyAdvertise100BaseT(etdev, TRUEPHY_ADV_DUPLEX_BOTH); - if (pAdapter->DeviceID != ET131X_PCI_DEVICE_ID_FAST) { - ET1310_PhyAdvertise1000BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_FULL); - } else { - ET1310_PhyAdvertise1000BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE); - } + if (etdev->pdev->device != ET131X_PCI_DEVICE_ID_FAST) + ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); + else + ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); /* Make sure auto-neg is ON (it is disabled in FORCE modes) */ - ET1310_PhyAutoNeg(pAdapter, true); + ET1310_PhyAutoNeg(etdev, true); /* Power up PHY */ - ET1310_PhyPowerDown(pAdapter, 0); - - DBG_LEAVE(et131x_dbginfo); + ET1310_PhyPowerDown(etdev, 0); } @@ -906,371 +829,368 @@ static const uint16_t ConfigPhy[25][2] = { }; /* condensed version of the phy initialization routine */ -void ET1310_PhyInit(struct et131x_adapter *pAdapter) +void ET1310_PhyInit(struct et131x_adapter *etdev) { - uint16_t usData, usIndex; + uint16_t data, index; - if (pAdapter == NULL) { + if (etdev == NULL) return; - } - // get the identity (again ?) - MiRead(pAdapter, PHY_ID_1, &usData); - MiRead(pAdapter, PHY_ID_2, &usData); + /* get the identity (again ?) */ + MiRead(etdev, PHY_ID_1, &data); + MiRead(etdev, PHY_ID_2, &data); - // what does this do/achieve ? - MiRead(pAdapter, PHY_MPHY_CONTROL_REG, &usData); // should read 0002 - MiWrite(pAdapter, PHY_MPHY_CONTROL_REG, 0x0006); + /* what does this do/achieve ? */ + MiRead(etdev, PHY_MPHY_CONTROL_REG, &data); /* should read 0002 */ + MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0006); - // read modem register 0402, should I do something with the return data ? - MiWrite(pAdapter, PHY_INDEX_REG, 0x0402); - MiRead(pAdapter, PHY_DATA_REG, &usData); + /* read modem register 0402, should I do something with the return + data ? */ + MiWrite(etdev, PHY_INDEX_REG, 0x0402); + MiRead(etdev, PHY_DATA_REG, &data); - // what does this do/achieve ? - MiWrite(pAdapter, PHY_MPHY_CONTROL_REG, 0x0002); + /* what does this do/achieve ? */ + MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0002); - // get the identity (again ?) - MiRead(pAdapter, PHY_ID_1, &usData); - MiRead(pAdapter, PHY_ID_2, &usData); + /* get the identity (again ?) */ + MiRead(etdev, PHY_ID_1, &data); + MiRead(etdev, PHY_ID_2, &data); - // what does this achieve ? - MiRead(pAdapter, PHY_MPHY_CONTROL_REG, &usData); // should read 0002 - MiWrite(pAdapter, PHY_MPHY_CONTROL_REG, 0x0006); + /* what does this achieve ? */ + MiRead(etdev, PHY_MPHY_CONTROL_REG, &data); /* should read 0002 */ + MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0006); - // read modem register 0402, should I do something with the return data? - MiWrite(pAdapter, PHY_INDEX_REG, 0x0402); - MiRead(pAdapter, PHY_DATA_REG, &usData); + /* read modem register 0402, should I do something with + the return data? */ + MiWrite(etdev, PHY_INDEX_REG, 0x0402); + MiRead(etdev, PHY_DATA_REG, &data); - MiWrite(pAdapter, PHY_MPHY_CONTROL_REG, 0x0002); + MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0002); - // what does this achieve (should return 0x1040) - MiRead(pAdapter, PHY_CONTROL, &usData); - MiRead(pAdapter, PHY_MPHY_CONTROL_REG, &usData); // should read 0002 - MiWrite(pAdapter, PHY_CONTROL, 0x1840); + /* what does this achieve (should return 0x1040) */ + MiRead(etdev, PHY_CONTROL, &data); + MiRead(etdev, PHY_MPHY_CONTROL_REG, &data); /* should read 0002 */ + MiWrite(etdev, PHY_CONTROL, 0x1840); - MiWrite(pAdapter, PHY_MPHY_CONTROL_REG, 0x0007); + MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0007); - // here the writing of the array starts.... - usIndex = 0; - while (ConfigPhy[usIndex][0] != 0x0000) { - // write value - MiWrite(pAdapter, PHY_INDEX_REG, ConfigPhy[usIndex][0]); - MiWrite(pAdapter, PHY_DATA_REG, ConfigPhy[usIndex][1]); + /* here the writing of the array starts.... */ + index = 0; + while (ConfigPhy[index][0] != 0x0000) { + /* write value */ + MiWrite(etdev, PHY_INDEX_REG, ConfigPhy[index][0]); + MiWrite(etdev, PHY_DATA_REG, ConfigPhy[index][1]); - // read it back - MiWrite(pAdapter, PHY_INDEX_REG, ConfigPhy[usIndex][0]); - MiRead(pAdapter, PHY_DATA_REG, &usData); + /* read it back */ + MiWrite(etdev, PHY_INDEX_REG, ConfigPhy[index][0]); + MiRead(etdev, PHY_DATA_REG, &data); - // do a check on the value read back ? - usIndex++; + /* do a check on the value read back ? */ + index++; } - // here the writing of the array ends... + /* here the writing of the array ends... */ - MiRead(pAdapter, PHY_CONTROL, &usData); // 0x1840 - MiRead(pAdapter, PHY_MPHY_CONTROL_REG, &usData); // should read 0007 - MiWrite(pAdapter, PHY_CONTROL, 0x1040); - MiWrite(pAdapter, PHY_MPHY_CONTROL_REG, 0x0002); + MiRead(etdev, PHY_CONTROL, &data); /* 0x1840 */ + MiRead(etdev, PHY_MPHY_CONTROL_REG, &data);/* should read 0007 */ + MiWrite(etdev, PHY_CONTROL, 0x1040); + MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0002); } -void ET1310_PhyReset(struct et131x_adapter *pAdapter) +void ET1310_PhyReset(struct et131x_adapter *etdev) { - MiWrite(pAdapter, PHY_CONTROL, 0x8000); + MiWrite(etdev, PHY_CONTROL, 0x8000); } -void ET1310_PhyPowerDown(struct et131x_adapter *pAdapter, bool down) +void ET1310_PhyPowerDown(struct et131x_adapter *etdev, bool down) { - uint16_t usData; + uint16_t data; - MiRead(pAdapter, PHY_CONTROL, &usData); + MiRead(etdev, PHY_CONTROL, &data); if (down == false) { - // Power UP - usData &= ~0x0800; - MiWrite(pAdapter, PHY_CONTROL, usData); + /* Power UP */ + data &= ~0x0800; + MiWrite(etdev, PHY_CONTROL, data); } else { - // Power DOWN - usData |= 0x0800; - MiWrite(pAdapter, PHY_CONTROL, usData); + /* Power DOWN */ + data |= 0x0800; + MiWrite(etdev, PHY_CONTROL, data); } } -void ET1310_PhyAutoNeg(struct et131x_adapter *pAdapter, bool enable) +void ET1310_PhyAutoNeg(struct et131x_adapter *etdev, bool enable) { - uint16_t usData; + uint16_t data; - MiRead(pAdapter, PHY_CONTROL, &usData); + MiRead(etdev, PHY_CONTROL, &data); if (enable == true) { - // Autonegotiation ON - usData |= 0x1000; - MiWrite(pAdapter, PHY_CONTROL, usData); + /* Autonegotiation ON */ + data |= 0x1000; + MiWrite(etdev, PHY_CONTROL, data); } else { - // Autonegotiation OFF - usData &= ~0x1000; - MiWrite(pAdapter, PHY_CONTROL, usData); + /* Autonegotiation OFF */ + data &= ~0x1000; + MiWrite(etdev, PHY_CONTROL, data); } } -void ET1310_PhyDuplexMode(struct et131x_adapter *pAdapter, uint16_t duplex) +void ET1310_PhyDuplexMode(struct et131x_adapter *etdev, uint16_t duplex) { - uint16_t usData; + uint16_t data; - MiRead(pAdapter, PHY_CONTROL, &usData); + MiRead(etdev, PHY_CONTROL, &data); if (duplex == TRUEPHY_DUPLEX_FULL) { - // Set Full Duplex - usData |= 0x100; - MiWrite(pAdapter, PHY_CONTROL, usData); + /* Set Full Duplex */ + data |= 0x100; + MiWrite(etdev, PHY_CONTROL, data); } else { - // Set Half Duplex - usData &= ~0x100; - MiWrite(pAdapter, PHY_CONTROL, usData); + /* Set Half Duplex */ + data &= ~0x100; + MiWrite(etdev, PHY_CONTROL, data); } } -void ET1310_PhySpeedSelect(struct et131x_adapter *pAdapter, uint16_t speed) +void ET1310_PhySpeedSelect(struct et131x_adapter *etdev, uint16_t speed) { - uint16_t usData; + uint16_t data; - // Read the PHY control register - MiRead(pAdapter, PHY_CONTROL, &usData); + /* Read the PHY control register */ + MiRead(etdev, PHY_CONTROL, &data); - // Clear all Speed settings (Bits 6, 13) - usData &= ~0x2040; + /* Clear all Speed settings (Bits 6, 13) */ + data &= ~0x2040; - // Reset the speed bits based on user selection + /* Reset the speed bits based on user selection */ switch (speed) { case TRUEPHY_SPEED_10MBPS: - // Bits already cleared above, do nothing + /* Bits already cleared above, do nothing */ break; case TRUEPHY_SPEED_100MBPS: - // 100M == Set bit 13 - usData |= 0x2000; + /* 100M == Set bit 13 */ + data |= 0x2000; break; case TRUEPHY_SPEED_1000MBPS: default: - usData |= 0x0040; + data |= 0x0040; break; } - // Write back the new speed - MiWrite(pAdapter, PHY_CONTROL, usData); + /* Write back the new speed */ + MiWrite(etdev, PHY_CONTROL, data); } -void ET1310_PhyAdvertise1000BaseT(struct et131x_adapter *pAdapter, +void ET1310_PhyAdvertise1000BaseT(struct et131x_adapter *etdev, uint16_t duplex) { - uint16_t usData; + uint16_t data; - // Read the PHY 1000 Base-T Control Register - MiRead(pAdapter, PHY_1000_CONTROL, &usData); + /* Read the PHY 1000 Base-T Control Register */ + MiRead(etdev, PHY_1000_CONTROL, &data); - // Clear Bits 8,9 - usData &= ~0x0300; + /* Clear Bits 8,9 */ + data &= ~0x0300; switch (duplex) { case TRUEPHY_ADV_DUPLEX_NONE: - // Duplex already cleared, do nothing + /* Duplex already cleared, do nothing */ break; case TRUEPHY_ADV_DUPLEX_FULL: - // Set Bit 9 - usData |= 0x0200; + /* Set Bit 9 */ + data |= 0x0200; break; case TRUEPHY_ADV_DUPLEX_HALF: - // Set Bit 8 - usData |= 0x0100; + /* Set Bit 8 */ + data |= 0x0100; break; case TRUEPHY_ADV_DUPLEX_BOTH: default: - usData |= 0x0300; + data |= 0x0300; break; } - // Write back advertisement - MiWrite(pAdapter, PHY_1000_CONTROL, usData); + /* Write back advertisement */ + MiWrite(etdev, PHY_1000_CONTROL, data); } -void ET1310_PhyAdvertise100BaseT(struct et131x_adapter *pAdapter, +void ET1310_PhyAdvertise100BaseT(struct et131x_adapter *etdev, uint16_t duplex) { - uint16_t usData; + uint16_t data; - // Read the Autonegotiation Register (10/100) - MiRead(pAdapter, PHY_AUTO_ADVERTISEMENT, &usData); + /* Read the Autonegotiation Register (10/100) */ + MiRead(etdev, PHY_AUTO_ADVERTISEMENT, &data); - // Clear bits 7,8 - usData &= ~0x0180; + /* Clear bits 7,8 */ + data &= ~0x0180; switch (duplex) { case TRUEPHY_ADV_DUPLEX_NONE: - // Duplex already cleared, do nothing + /* Duplex already cleared, do nothing */ break; case TRUEPHY_ADV_DUPLEX_FULL: - // Set Bit 8 - usData |= 0x0100; + /* Set Bit 8 */ + data |= 0x0100; break; case TRUEPHY_ADV_DUPLEX_HALF: - // Set Bit 7 - usData |= 0x0080; + /* Set Bit 7 */ + data |= 0x0080; break; case TRUEPHY_ADV_DUPLEX_BOTH: default: - // Set Bits 7,8 - usData |= 0x0180; + /* Set Bits 7,8 */ + data |= 0x0180; break; } - // Write back advertisement - MiWrite(pAdapter, PHY_AUTO_ADVERTISEMENT, usData); + /* Write back advertisement */ + MiWrite(etdev, PHY_AUTO_ADVERTISEMENT, data); } -void ET1310_PhyAdvertise10BaseT(struct et131x_adapter *pAdapter, +void ET1310_PhyAdvertise10BaseT(struct et131x_adapter *etdev, uint16_t duplex) { - uint16_t usData; + uint16_t data; - // Read the Autonegotiation Register (10/100) - MiRead(pAdapter, PHY_AUTO_ADVERTISEMENT, &usData); + /* Read the Autonegotiation Register (10/100) */ + MiRead(etdev, PHY_AUTO_ADVERTISEMENT, &data); - // Clear bits 5,6 - usData &= ~0x0060; + /* Clear bits 5,6 */ + data &= ~0x0060; switch (duplex) { case TRUEPHY_ADV_DUPLEX_NONE: - // Duplex already cleared, do nothing + /* Duplex already cleared, do nothing */ break; case TRUEPHY_ADV_DUPLEX_FULL: - // Set Bit 6 - usData |= 0x0040; + /* Set Bit 6 */ + data |= 0x0040; break; case TRUEPHY_ADV_DUPLEX_HALF: - // Set Bit 5 - usData |= 0x0020; + /* Set Bit 5 */ + data |= 0x0020; break; case TRUEPHY_ADV_DUPLEX_BOTH: default: - // Set Bits 5,6 - usData |= 0x0060; + /* Set Bits 5,6 */ + data |= 0x0060; break; } - // Write back advertisement - MiWrite(pAdapter, PHY_AUTO_ADVERTISEMENT, usData); + /* Write back advertisement */ + MiWrite(etdev, PHY_AUTO_ADVERTISEMENT, data); } -void ET1310_PhyLinkStatus(struct et131x_adapter *pAdapter, - uint8_t *ucLinkStatus, - uint32_t *uiAutoNeg, - uint32_t *uiLinkSpeed, - uint32_t *uiDuplexMode, - uint32_t *uiMdiMdix, - uint32_t *uiMasterSlave, uint32_t *uiPolarity) +void ET1310_PhyLinkStatus(struct et131x_adapter *etdev, + uint8_t *link_status, + uint32_t *autoneg, + uint32_t *linkspeed, + uint32_t *duplex_mode, + uint32_t *mdi_mdix, + uint32_t *masterslave, uint32_t *polarity) { - uint16_t usMiStatus = 0; - uint16_t us1000BaseT = 0; - uint16_t usVmiPhyStatus = 0; - uint16_t usControl = 0; - - MiRead(pAdapter, PHY_STATUS, &usMiStatus); - MiRead(pAdapter, PHY_1000_STATUS, &us1000BaseT); - MiRead(pAdapter, PHY_PHY_STATUS, &usVmiPhyStatus); - MiRead(pAdapter, PHY_CONTROL, &usControl); - - if (ucLinkStatus) { - *ucLinkStatus = - (unsigned char)((usVmiPhyStatus & 0x0040) ? 1 : 0); + uint16_t mistatus = 0; + uint16_t is1000BaseT = 0; + uint16_t vmi_phystatus = 0; + uint16_t control = 0; + + MiRead(etdev, PHY_STATUS, &mistatus); + MiRead(etdev, PHY_1000_STATUS, &is1000BaseT); + MiRead(etdev, PHY_PHY_STATUS, &vmi_phystatus); + MiRead(etdev, PHY_CONTROL, &control); + + if (link_status) { + *link_status = + (unsigned char)((vmi_phystatus & 0x0040) ? 1 : 0); } - if (uiAutoNeg) { - *uiAutoNeg = - (usControl & 0x1000) ? ((usVmiPhyStatus & 0x0020) ? + if (autoneg) { + *autoneg = + (control & 0x1000) ? ((vmi_phystatus & 0x0020) ? TRUEPHY_ANEG_COMPLETE : TRUEPHY_ANEG_NOT_COMPLETE) : TRUEPHY_ANEG_DISABLED; } - if (uiLinkSpeed) { - *uiLinkSpeed = (usVmiPhyStatus & 0x0300) >> 8; - } + if (linkspeed) + *linkspeed = (vmi_phystatus & 0x0300) >> 8; - if (uiDuplexMode) { - *uiDuplexMode = (usVmiPhyStatus & 0x0080) >> 7; - } + if (duplex_mode) + *duplex_mode = (vmi_phystatus & 0x0080) >> 7; - if (uiMdiMdix) { + if (mdi_mdix) /* NOTE: Need to complete this */ - *uiMdiMdix = 0; - } + *mdi_mdix = 0; - if (uiMasterSlave) { - *uiMasterSlave = - (us1000BaseT & 0x4000) ? TRUEPHY_CFG_MASTER : + if (masterslave) { + *masterslave = + (is1000BaseT & 0x4000) ? TRUEPHY_CFG_MASTER : TRUEPHY_CFG_SLAVE; } - if (uiPolarity) { - *uiPolarity = - (usVmiPhyStatus & 0x0400) ? TRUEPHY_POLARITY_INVERTED : + if (polarity) { + *polarity = + (vmi_phystatus & 0x0400) ? TRUEPHY_POLARITY_INVERTED : TRUEPHY_POLARITY_NORMAL; } } -void ET1310_PhyAndOrReg(struct et131x_adapter *pAdapter, +void ET1310_PhyAndOrReg(struct et131x_adapter *etdev, uint16_t regnum, uint16_t andMask, uint16_t orMask) { uint16_t reg; - // Read the requested register - MiRead(pAdapter, regnum, ®); + /* Read the requested register */ + MiRead(etdev, regnum, ®); - // Apply the AND mask + /* Apply the AND mask */ reg &= andMask; - // Apply the OR mask + /* Apply the OR mask */ reg |= orMask; - // Write the value back to the register - MiWrite(pAdapter, regnum, reg); + /* Write the value back to the register */ + MiWrite(etdev, regnum, reg); } -void ET1310_PhyAccessMiBit(struct et131x_adapter *pAdapter, uint16_t action, +void ET1310_PhyAccessMiBit(struct et131x_adapter *etdev, uint16_t action, uint16_t regnum, uint16_t bitnum, uint8_t *value) { uint16_t reg; uint16_t mask = 0; - // Create a mask to isolate the requested bit + /* Create a mask to isolate the requested bit */ mask = 0x0001 << bitnum; - // Read the requested register - MiRead(pAdapter, regnum, ®); + /* Read the requested register */ + MiRead(etdev, regnum, ®); switch (action) { case TRUEPHY_BIT_READ: - if (value != NULL) { + if (value != NULL) *value = (reg & mask) >> bitnum; - } break; case TRUEPHY_BIT_SET: reg |= mask; - MiWrite(pAdapter, regnum, reg); + MiWrite(etdev, regnum, reg); break; case TRUEPHY_BIT_CLEAR: reg &= ~mask; - MiWrite(pAdapter, regnum, reg); + MiWrite(etdev, regnum, reg); break; default: |