staging: et131x: Following mvoe to use phydev, remove detritus
cover staging: et131x: Following mvoe to use phydev, remove detritus
These changes make a big cleanup of the PHY driver code, and removing stuff that isn't (hopefully) relevant anymore.
Mark Einon (12):
staging: et131x: Remove private adapter->linkspeed and
staging: et131x: Remove private adapter->duplex_mode
staging: et131x: Remove redundant struct adapter
staging: et131x: Remove PHY interrupt handling code
staging: et131x: remove calls to
staging: et131x: Remove registry_rx_mem_end from
staging: et131x: Remove cached_mask_value from
staging: et131x: Remove duplicated register defines
staging: et131x: Replace magic numbers in et1310_phy.c
staging: et131x: Remove struct mi_regs from
staging: et131x: Remove ai_force_[duplex|speed] from
staging: et131x: Update README file
drivers/staging/et131x/README | 2 - drivers/staging/et131x/et1310_mac.c | 15 ++- drivers/staging/et131x/et1310_phy.c | 105 ++++++++++------------- drivers/staging/et131x/et1310_phy.h | 143 +++++++++++++++---------------- drivers/staging/et131x/et1310_rx.c | 9 ++- drivers/staging/et131x/et1310_tx.c | 6 +- drivers/staging/et131x/et131x_adapter.h | 13 --- drivers/staging/et131x/et131x_initpci.c | 16 ++-- drivers/staging/et131x/et131x_isr.c | 40 --------- 9 files changed, 143 insertions(+), 206 deletions(-)
PATCH 1/12 staging: et131x: Remove private adapter->linkspeed and use phydev->speed instead
The phy device keeps a note of the link speed, so use that value instead of the driver private one.
Also use the phydev defines for link speeds, and remove the driver private ones.
adapter->hw_errs was never used, even in the vendor driver, so remove that too.
--- drivers/staging/et131x/et1310_mac.c | 7 +++++-- drivers/staging/et131x/et1310_phy.c | 9 ++++----- drivers/staging/et131x/et1310_phy.h | 5 ----- drivers/staging/et131x/et1310_rx.c | 9 +++++++-- drivers/staging/et131x/et1310_tx.c | 6 ++++-- drivers/staging/et131x/et131x_adapter.h | 2 -- drivers/staging/et131x/et131x_initpci.c | 12 ++++++------ 7 files changed, 26 insertions(+), 24 deletions(-)
drivers/staging/et131x/et1310_mac.c +5 -2
@@ -82,6 +82,7 @@#include <linux/if_arp.h> #include <linux/ioport.h> #include <linux/crc32.h> +#include <linux/phy.h> #include "et1310_phy.h" #include "et131x_adapter.h"
@@ -166,6 +167,7 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter) {int32_t delay =0 ;struct mac_regs __iomem *mac = &adapter->regs->mac; +struct phy_device *phydev = adapter->phydev;u32 cfg1;u32 cfg2;u32 ifctrl;
@@ -178,7 +180,7 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter)/* Set up the if mode bits */ cfg2 &= ~0x300 ; -if (adapter->linkspeed ==TRUEPHY_SPEED_1000MBPS ) { +if (phydev && phydev->speed ==SPEED_1000 ) { cfg2 |=0x200 ;/* Phy mode bit */ ifctrl &= ~(1 <<24 );
@@ -239,6 +241,7 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter)void et1310_config_rxmac_regs (struct et131x_adapter *adapter) {struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; +struct phy_device *phydev = adapter->phydev;u32 sa_lo;u32 sa_hi =0 ;u32 pf_ctrl =0 ;
@@ -351,7 +354,7 @@ void et1310_config_rxmac_regs(struct et131x_adapter *adapter)* bit 16: Receive frame truncated. * bit 17: Drop packet enable */ -if (adapter->linkspeed ==TRUEPHY_SPEED_100MBPS ) +if (phydev && phydev->speed ==SPEED_100 )writel (0x30038 , &rxmac->mif_ctrl);else writel (0x30030 , &rxmac->mif_ctrl);
drivers/staging/et131x/et1310_phy.c +4 -5
@@ -440,6 +440,7 @@ void et131x_xcvr_init(struct et131x_adapter *adapter)void et131x_mii_check (struct et131x_adapter *adapter,u16 bmsr,u16 bmsr_ints) { +struct phy_device *phydev = adapter->phydev;u8 link_status;u32 autoneg_status;u32 speed;
@@ -456,7 +457,7 @@ void et131x_mii_check(struct et131x_adapter *adapter,dev_warn (&adapter->pdev->dev,"Link down - cable problem ?\n" ); -if (adapter->linkspeed ==TRUEPHY_SPEED_10MBPS ) { +if (phydev && phydev->speed ==SPEED_10 ) {/* NOTE - Is there a way to query this without * TruePHY? * && TRU_QueryCoreType(adapter->hTruePhy, 0) ==
@@ -476,7 +477,6 @@ void et131x_mii_check(struct et131x_adapter *adapter,netif_carrier_off (adapter->netdev); - adapter->linkspeed =0 ; adapter->duplex_mode =0 ;/* Free the packets being actively sent & stopped */
@@ -516,12 +516,11 @@ void et131x_mii_check(struct et131x_adapter *adapter, &speed, &duplex, &mdi_mdix, &masterslave, &polarity); - adapter->linkspeed = speed; adapter->duplex_mode = duplex; adapter->boot_coma =20 ; -if (adapter->linkspeed ==TRUEPHY_SPEED_10MBPS ) { +if (phydev && phydev->speed ==SPEED_10 ) {/* * NOTE - Is there a way to query this without * TruePHY?
@@ -542,7 +541,7 @@ void et131x_mii_check(struct et131x_adapter *adapter,et1310_config_flow_control (adapter); -if (adapter->linkspeed ==TRUEPHY_SPEED_1000MBPS && +if (phydev && phydev->speed ==SPEED_1000 && adapter->registry_jumbo_packet >2048 )et1310_phy_and_or_reg (adapter,0x16 ,0xcfff ,0x2000 );
drivers/staging/et131x/et1310_phy.h +0 -5
@@ -242,11 +242,6 @@ struct mi_regs {#define TRUEPHY_MASK 2#endif -/* Define speeds */ -#define TRUEPHY_SPEED_10MBPS 0 -#define TRUEPHY_SPEED_100MBPS 1 -#define TRUEPHY_SPEED_1000MBPS 2 -/* Define duplex modes */ #define TRUEPHY_DUPLEX_HALF 0#define TRUEPHY_DUPLEX_FULL 1
drivers/staging/et131x/et1310_rx.c +7 -2
@@ -82,6 +82,7 @@#include <linux/skbuff.h> #include <linux/if_arp.h> #include <linux/ioport.h> +#include <linux/phy.h> #include "et1310_phy.h" #include "et131x_adapter.h"
@@ -724,11 +725,15 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter)*/ void et131x_set_rx_dma_timer (struct et131x_adapter *adapter) { +struct phy_device *phydev = adapter->phydev; + +if (!phydev) +return ; +/* For version B silicon, we do not use the RxDMA timer for 10 and 100 * Mbits/s line rates. We do not enable and RxDMA interrupt coalescing. */ -if ((adapter->linkspeed ==TRUEPHY_SPEED_100MBPS ) || - (adapter->linkspeed ==TRUEPHY_SPEED_10MBPS )) { +if ((phydev->speed ==SPEED_100 ) || (phydev->speed ==SPEED_10 )) {writel (0 , &adapter->regs->rxdma.max_pkt_time);writel (1 , &adapter->regs->rxdma.num_pkt_done); }
drivers/staging/et131x/et1310_tx.c +4 -2
@@ -82,6 +82,7 @@#include <linux/skbuff.h> #include <linux/if_arp.h> #include <linux/ioport.h> +#include <linux/phy.h> #include "et1310_phy.h" #include "et131x_adapter.h"
@@ -287,6 +288,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)u32 nr_frags =skb_shinfo (skb)->nr_frags +1 ;struct skb_frag_struct *frags = &skb_shinfo (skb)->frags[0 ];unsigned long flags; +struct phy_device *phydev = adapter->phydev;/* Part of the optimizations of this send routine restrict us to * sending 24 fragments at a pass. In practice we should never see
@@ -400,7 +402,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)if (frag ==0 )return -EIO ; -if (adapter->linkspeed ==TRUEPHY_SPEED_1000MBPS ) { +if (phydev && phydev->speed ==SPEED_1000 ) {if (++adapter->tx_ring.since_irq ==PARM_TX_NUM_BUFS_DEF ) {/* Last element & Interrupt flag */ desc[frag -1 ].flags =0x5 ;
@@ -478,7 +480,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)/* For Gig only, we use Tx Interrupt coalescing. Enable the software * timer to wake us up if this packet isn't followed by N more. */ -if (adapter->linkspeed ==TRUEPHY_SPEED_1000MBPS ) { +if (phydev && phydev->speed ==SPEED_1000 ) {writel (PARM_TX_TIME_INT_DEF *NANO_IN_A_MICRO , &adapter->regs->global.watchdog_timer); }
drivers/staging/et131x/et131x_adapter.h +0 -2
@@ -147,7 +147,6 @@ struct et131x_adapter {/* Flags that indicate current state of the adapter */ u32 flags; -u32 hw_errs;/* Configuration */ u8 rom_addr[ETH_ALEN ];
@@ -170,7 +169,6 @@ struct et131x_adapter {/* Packet Filter and look ahead size */ u32 packet_filter; -u32 linkspeed;u32 duplex_mode;/* multicast list */
drivers/staging/et131x/et131x_initpci.c +6 -6
@@ -678,12 +678,6 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,/* Copy address into the net_device struct */ memcpy (netdev->dev_addr, adapter->addr,ETH_ALEN ); -/* Setup et1310 as per the documentation */ -et131x_adapter_setup (adapter); - -/* Create a timer to count errors received by the NIC */ -init_timer (&adapter->error_timer); - adapter->error_timer.expires = jiffies +TX_ERROR_PERIOD *HZ /1000 ; adapter->error_timer.function = et131x_error_timer_handler; adapter->error_timer.data = (unsigned long )adapter;
@@ -726,6 +720,12 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, goto err_mdio_unregister; } +/* Setup et1310 as per the documentation */ +et131x_adapter_setup (adapter); + +/* Create a timer to count errors received by the NIC */ +init_timer (&adapter->error_timer); +/* We can enable interrupts now * * NOTE - Because registration of interrupt handler is done in the
Signature · 1 line
1.7.6
PATCH 2/12 staging: et131x: Remove private adapter->duplex_mode and use phydev->duplex instead
In reply to Mark EinonThe phy device keeps a note of the duplex mode, so use that value instead of duplex mode.
Also use the phydev defines for duplex modes, and remove the driver private ones.
--- drivers/staging/et131x/et1310_mac.c | 8 +++++--- drivers/staging/et131x/et1310_phy.c | 4 ---- drivers/staging/et131x/et1310_phy.h | 4 ---- drivers/staging/et131x/et131x_adapter.h | 1 - 4 files changed, 5 insertions(+), 12 deletions(-)
drivers/staging/et131x/et1310_mac.c +5 -3
@@ -205,11 +205,11 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter) cfg2 &= ~0x0021 ;/* Turn on duplex if needed */ -if (adapter->duplex_mode) +if (phydev && phydev->duplex ==DUPLEX_FULL ) cfg2 |=0x01 ; ifctrl &= ~(1 <<26 ); -if (!adapter->duplex_mode) +if (phydev && phydev->duplex ==DUPLEX_HALF ) ifctrl |= (1 <<26 );/* Enable ghd */ writel (ifctrl, &mac->if_ctrl);
@@ -450,7 +450,9 @@ void et1310_config_macstat_regs(struct et131x_adapter *adapter)void et1310_config_flow_control (struct et131x_adapter *adapter) { -if (adapter->duplex_mode ==0 ) { +struct phy_device *phydev = adapter->phydev; + +if (phydev->duplex ==DUPLEX_HALF ) { adapter->flowcontrol =FLOW_NONE ; }else {char remote_pause, remote_async_pause;
drivers/staging/et131x/et1310_phy.c +0 -4
@@ -477,8 +477,6 @@ void et131x_mii_check(struct et131x_adapter *adapter,netif_carrier_off (adapter->netdev); - adapter->duplex_mode =0 ; -/* Free the packets being actively sent & stopped */ et131x_free_busy_send_packets (adapter);
@@ -516,8 +514,6 @@ void et131x_mii_check(struct et131x_adapter *adapter, &speed, &duplex, &mdi_mdix, &masterslave, &polarity); - adapter->duplex_mode = duplex; - adapter->boot_coma =20 ;if (phydev && phydev->speed ==SPEED_10 ) {
drivers/staging/et131x/et1310_phy.h +0 -4
@@ -242,10 +242,6 @@ struct mi_regs {#define TRUEPHY_MASK 2#endif -/* Define duplex modes */ -#define TRUEPHY_DUPLEX_HALF 0 -#define TRUEPHY_DUPLEX_FULL 1 -/* Define master/slave configuration values */ #define TRUEPHY_CFG_SLAVE 0#define TRUEPHY_CFG_MASTER 1
drivers/staging/et131x/et131x_adapter.h +0 -1
@@ -169,7 +169,6 @@ struct et131x_adapter {/* Packet Filter and look ahead size */ u32 packet_filter; -u32 duplex_mode;/* multicast list */ u32 multicast_addr_count;
Signature · 1 line
1.7.6
PATCH 3/12 staging: et131x: Remove redundant struct adapter members
In reply to Mark Einonadapter->speed_duplex was never referenced. adapter->registry_phy_coma was always set to zero, even in the vendor driver.
Removing all member references and associated dead code.
--- drivers/staging/et131x/et1310_phy.c | 6 ------ drivers/staging/et131x/et131x_adapter.h | 2 -- drivers/staging/et131x/et131x_initpci.c | 4 +--- 3 files changed, 1 insertions(+), 11 deletions(-)
drivers/staging/et131x/et1310_phy.c +0 -6
@@ -496,12 +496,6 @@ void et131x_mii_check(struct et131x_adapter *adapter,/* Setup ET1310 as per the documentation */ et131x_adapter_setup (adapter); - -/* Setup the PHY into coma mode until the cable is -* plugged back in -*/ -if (adapter->registry_phy_coma ==1 ) -et1310_enable_phy_coma (adapter); } }
drivers/staging/et131x/et131x_adapter.h +0 -2
@@ -178,9 +178,7 @@ struct et131x_adapter {struct address_map __iomem *regs;/* Registry parameters */ -u8 speed_duplex;/* speed/duplex */ u8 wanted_flow;/* Flow we want for 802.3x flow control */ -u8 registry_phy_coma;/* Phy Coma mode enable/disable */ u32 registry_rx_mem_end;/* Size of internal rx memory */ u32 registry_jumbo_packet;/* Max supported ethernet packet size */
drivers/staging/et131x/et131x_initpci.c +1 -3
@@ -250,14 +250,12 @@ void et131x_error_timer_handler(unsigned long data) "No interrupts, in PHY coma, pm_csr = 0x%x\n", pm_csr);if (!(adapter->bmsr &BMSR_LSTATUS ) && - adapter->registry_phy_coma && adapter->boot_coma <11 ) { adapter->boot_coma++; }if (adapter->boot_coma ==10 ) { -if (!(adapter->bmsr &BMSR_LSTATUS ) - && adapter->registry_phy_coma) { +if (!(adapter->bmsr &BMSR_LSTATUS )) {if ((pm_csr &ET_PM_PHY_SW_COMA ) ==0 ) {/* NOTE - This was originally a 'sync with * interrupt'. How to do that under Linux?
Signature · 1 line
1.7.6
PATCH 4/12 staging: et131x: Remove PHY interrupt handling code from driver isr handler
In reply to Mark EinonThe PHY interrupt is now handled by the phy_device, and the equivalent code is present in et131x_adjust_link, called from the phy_device when needed.
--- drivers/staging/et131x/et131x_isr.c | 38 ----------------------------------- 1 files changed, 0 insertions(+), 38 deletions(-)
drivers/staging/et131x/et131x_isr.c +0 -38
@@ -364,44 +364,6 @@ void et131x_isr_handler(struct work_struct *work)dev_err (&adapter->pdev->dev,"WAKE_ON_LAN interrupt\n" ); } -/* Handle the PHY interrupt */ -if (status &ET_INTR_PHY ) { -u32 pm_csr; -u16 bmsr_ints; -u16 bmsr_data; -u16 myisr; - -/* If we are in coma mode when we get this interrupt, -* we need to disable it. -*/ - pm_csr =readl (&iomem->global.pm_csr); -if (pm_csr &ET_PM_PHY_SW_COMA ) { -/* -* Check to see if we are in coma mode and if -* so, disable it because we will not be able -* to read PHY values until we are out. -*/ -et1310_disable_phy_coma (adapter); - } - -/* Read the PHY ISR to clear the reason for the -* interrupt. -*/ -et131x_mii_read (adapter, - (uint8_t ) offsetof(struct mi_regs , isr), - &myisr); - -et131x_mii_read (adapter, - (uint8_t ) offsetof(struct mi_regs , bmsr), - &bmsr_data); - - bmsr_ints = adapter->bmsr ^ bmsr_data; - adapter->bmsr = bmsr_data; - -/* Do all the cable in / cable out stuff */ -et131x_mii_check (adapter, bmsr_data, bmsr_ints); - } -/* Let's move on to the TxMac */ if (status &ET_INTR_TXMAC ) {u32 err =readl (&iomem->txmac.err);
Signature · 1 line
1.7.6
PATCH 5/12 staging: et131x: remove calls to netif_carrier_[on|off] from et131x_mii_check
In reply to Mark EinonAs et131x_adjust_link is called from the phydev in response to a netif_carrier_[on|off], and is the only caller of et131x_mii_check, we don't need to call netif_carrier_[on|off] again.
--- drivers/staging/et131x/et1310_phy.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/staging/et131x/et1310_phy.c +0 -3
@@ -452,7 +452,6 @@ void et131x_mii_check(struct et131x_adapter *adapter,if (bmsr_ints &BMSR_LSTATUS ) {if (bmsr &BMSR_LSTATUS ) { adapter->boot_coma =20 ; -netif_carrier_on (adapter->netdev); }else {dev_warn (&adapter->pdev->dev,"Link down - cable problem ?\n" );
@@ -475,8 +474,6 @@ void et131x_mii_check(struct et131x_adapter *adapter,et131x_mii_write (adapter,0x12 , register18); } -netif_carrier_off (adapter->netdev); -/* Free the packets being actively sent & stopped */ et131x_free_busy_send_packets (adapter);
Signature · 1 line
1.7.6
PATCH 6/12 staging: et131x: Remove registry_rx_mem_end from struct et131x_adapter
In reply to Mark Einonregistry_rx_mem_end is not referenced anywhere in the driver.
--- drivers/staging/et131x/et131x_adapter.h | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/staging/et131x/et131x_adapter.h +0 -4
@@ -136,7 +136,6 @@ struct ce_stats {u32 interrupt_status; }; -/* The private adapter structure */ struct et131x_adapter {struct net_device *netdev;
@@ -179,11 +178,8 @@ struct et131x_adapter {/* Registry parameters */ u8 wanted_flow;/* Flow we want for 802.3x flow control */ - -u32 registry_rx_mem_end;/* Size of internal rx memory */ u32 registry_jumbo_packet;/* Max supported ethernet packet size */ -/* Derived from the registry: */ u8 ai_force_duplex;/* duplex setting */ u16 ai_force_speed;/* 'Speed', user over-ride of line speed */
Signature · 1 line
1.7.6
PATCH 7/12 staging: et131x: Remove cached_mask_value from et131x_adapter
In reply to Mark Einoncached_mask_value is only ever assigned, never read. Remove it.
--- drivers/staging/et131x/et131x_adapter.h | 2 -- drivers/staging/et131x/et131x_isr.c | 2 -- 2 files changed, 0 insertions(+), 4 deletions(-)
drivers/staging/et131x/et131x_adapter.h +0 -2
@@ -200,8 +200,6 @@ struct et131x_adapter {u16 pdown_speed;u8 pdown_duplex; -u32 cached_mask_value; -/* Xcvr status at last poll */ u16 bmsr;
drivers/staging/et131x/et131x_isr.c +0 -2
@@ -125,7 +125,6 @@ void et131x_enable_interrupts(struct et131x_adapter *adapter)else mask =INT_MASK_ENABLE_NO_FLOW ; - adapter->cached_mask_value = mask;writel (mask, &adapter->regs->global.int_mask); }
@@ -139,7 +138,6 @@ void et131x_enable_interrupts(struct et131x_adapter *adapter)void et131x_disable_interrupts (struct et131x_adapter *adapter) {/* Disable all global interrupts */ - adapter->cached_mask_value =INT_MASK_DISABLE ;writel (INT_MASK_DISABLE , &adapter->regs->global.int_mask); }
Signature · 1 line
1.7.6
PATCH 8/12 staging: et131x: Remove duplicated register defines from et1310_phy.h
In reply to Mark EinonThe VMI_* set of register defines are not used, and duplicate the set of PHY_* registers from the same file, which are used - hence removing.
--- drivers/staging/et131x/et1310_phy.h | 18 ------------------ 1 files changed, 0 insertions(+), 18 deletions(-)
drivers/staging/et131x/et1310_phy.h +0 -18
@@ -61,24 +61,6 @@#include "et1310_address_map.h" -/* VMI Register Addresses */ -#define VMI_RESERVED16_REG 16 -#define VMI_RESERVED17_REG 17 -#define VMI_RESERVED18_REG 18 -#define VMI_LOOPBACK_CONTROL_REG 19 -#define VMI_RESERVED20_REG 20 -#define VMI_MI_CONTROL_REG 21 -#define VMI_PHY_CONFIGURATION_REG 22 -#define VMI_PHY_CONTROL_REG 23 -#define VMI_INTERRUPT_MASK_REG 24 -#define VMI_INTERRUPT_STATUS_REG 25 -#define VMI_PHY_STATUS_REG 26 -#define VMI_LED_CONTROL_1_REG 27 -#define VMI_LED_CONTROL_2_REG 28 -#define VMI_RESERVED29_REG 29 -#define VMI_RESERVED30_REG 30 -#define VMI_RESERVED31_REG 31 -/* PHY Register Mapping(MI) Management Interface Regs */ struct mi_regs {u8 bmcr;/* Basic mode control reg(Reg 0x00) */
Signature · 1 line
1.7.6
PATCH 9/12 staging: et131x: Replace magic numbers in et1310_phy.c with defines
In reply to Mark EinonReplaced et131x_phy.c magic numbers specifying registers and their values with defines, defined in et131x_phy.h
--- drivers/staging/et131x/et1310_phy.c | 77 +++++++++++++++++--------------- drivers/staging/et131x/et1310_phy.h | 84 ++++++++++++++++++++++++++-------- 2 files changed, 105 insertions(+), 56 deletions(-)
drivers/staging/et131x/et1310_phy.c +41 -36
@@ -122,12 +122,11 @@ int et131x_mdio_reset(struct mii_bus *bus)struct net_device *netdev = bus->priv;struct et131x_adapter *adapter =netdev_priv (netdev); -et131x_mii_write (adapter,MII_BMCR ,0x8000 ); +et131x_mii_write (adapter,MII_BMCR ,BMCR_RESET );return 0 ; } -int et131x_mii_read (struct et131x_adapter *adapter,u8 reg,u16 *value) {struct phy_device *phydev = adapter->phydev;
@@ -293,9 +292,9 @@ void et1310_phy_power_down(struct et131x_adapter *adapter, bool down)u16 data;et131x_mii_read (adapter,MII_BMCR , &data); - data &= ~0x0800 ;/* Power UP */ -if (down)/* Power DOWN */ - data |=0x0800 ; + data &= ~BMCR_PDOWN ; +if (down) + data |=BMCR_PDOWN ;et131x_mii_write (adapter,MII_BMCR , data); }
@@ -333,19 +332,20 @@ static void et1310_phy_link_status(struct et131x_adapter *adapter,et131x_mii_read (adapter,PHY_PHY_STATUS , &vmi_phystatus);et131x_mii_read (adapter,MII_BMCR , &control); - *link_status = (vmi_phystatus &0x0040 ) ?1 :0 ; - *autoneg = (control &0x1000 ) ? ((vmi_phystatus &0x0020 ) ? + *link_status = (vmi_phystatus &ET_PHY_LSTATUS ) ?1 :0 ; + *autoneg = (control &ET_PHY_AUTONEG_STATUS ) ? + ((vmi_phystatus &ET_PHY_AUTONEG_ENABLE ) ?TRUEPHY_ANEG_COMPLETE :TRUEPHY_ANEG_NOT_COMPLETE ) : -TRUEPHY_ANEG_DISABLED ; - *linkspeed = (vmi_phystatus &0x0300 ) >>8 ; - *duplex_mode = (vmi_phystatus &0x0080 ) >>7 ; +TRUEPHY_ANEG_DISABLED ; + *linkspeed = (vmi_phystatus &ET_PHY_SPEED_STATUS ) >>8 ; + *duplex_mode = (vmi_phystatus &ET_PHY_DUPLEX_STATUS ) >>7 ;/* NOTE: Need to complete this */ *mdi_mdix =0 ; - *masterslave = (is1000BaseT &0x4000 ) ? + *masterslave = (is1000BaseT &ET_1000BT_MSTR_SLV ) ?TRUEPHY_CFG_MASTER :TRUEPHY_CFG_SLAVE ; - *polarity = (vmi_phystatus &0x0400 ) ? + *polarity = (vmi_phystatus &ET_PHY_POLARITY_STATUS ) ?TRUEPHY_POLARITY_INVERTED :TRUEPHY_POLARITY_NORMAL ; }
@@ -402,15 +402,17 @@ void et131x_xcvr_init(struct et131x_adapter *adapter)/* Zero out the adapter structure variable representing BMSR */ adapter->bmsr =0 ; -et131x_mii_read (adapter, (u8 ) offsetof(struct mi_regs , isr), &isr); -et131x_mii_read (adapter, (u8 ) offsetof(struct mi_regs , imr), &imr); +et131x_mii_read (adapter,PHY_INTERRUPT_STATUS , &isr); +et131x_mii_read (adapter,PHY_INTERRUPT_MASK , &imr);/* Set the link status interrupt only. Bad behavior when link status * and auto neg are set, we run into a nested interrupt problem */ - imr |=0x0105 ; + imr |= (ET_PHY_INT_MASK_AUTONEGSTAT & +ET_PHY_INT_MASK_LINKSTAT & +ET_PHY_INT_MASK_ENABLE ); -et131x_mii_write (adapter, (u8 ) offsetof(struct mi_regs , imr), imr); +et131x_mii_write (adapter,PHY_INTERRUPT_MASK , imr);/* Set the LED behavior such that LED 1 indicates speed (off = * 10Mbits, blink = 100Mbits, on = 1000Mbits) and LED 2 indicates
@@ -421,19 +423,17 @@ void et131x_xcvr_init(struct et131x_adapter *adapter)* EEPROM. However, the above description is the default. */ if ((adapter->eeprom_data[1 ] &0x4 ) ==0 ) { -et131x_mii_read (adapter, (u8 ) offsetof(struct mi_regs , lcr2), - &lcr2); +et131x_mii_read (adapter,PHY_LED_2 , &lcr2); - lcr2 &=0x00FF ; - lcr2 |=0xA000 ;/* led link */ + lcr2 &= (ET_LED2_LED_100TX &ET_LED2_LED_1000T ); + lcr2 |= (LED_VAL_LINKON_ACTIVE <<LED_LINK_SHIFT );if ((adapter->eeprom_data[1 ] &0x8 ) ==0 ) - lcr2 |=0x0300 ; + lcr2 |= (LED_VAL_1000BT_100BTX <<LED_TXRX_SHIFT );else - lcr2 |=0x0400 ; + lcr2 |= (LED_VAL_LINKON <<LED_TXRX_SHIFT ); -et131x_mii_write (adapter, (u8 ) offsetof(struct mi_regs , lcr2), - lcr2); +et131x_mii_write (adapter,PHY_LED_2 , lcr2); } }
@@ -464,14 +464,16 @@ void et131x_mii_check(struct et131x_adapter *adapter,*/ u16 register18; -et131x_mii_read (adapter,0x12 , ®ister18); -et131x_mii_write (adapter,0x12 , +et131x_mii_read (adapter,PHY_MPHY_CONTROL_REG , + ®ister18); +et131x_mii_write (adapter,PHY_MPHY_CONTROL_REG , register18 |0x4 ); -et131x_mii_write (adapter,0x10 , +et131x_mii_write (adapter,PHY_INDEX_REG , register18 |0x8402 ); -et131x_mii_write (adapter,0x11 , +et131x_mii_write (adapter,PHY_DATA_REG , register18 |511 ); -et131x_mii_write (adapter,0x12 , register18); +et131x_mii_write (adapter,PHY_MPHY_CONTROL_REG , + register18); }/* Free the packets being actively sent & stopped */
@@ -516,22 +518,25 @@ void et131x_mii_check(struct et131x_adapter *adapter,*/ u16 register18; -et131x_mii_read (adapter,0x12 , ®ister18); -et131x_mii_write (adapter,0x12 , +et131x_mii_read (adapter,PHY_MPHY_CONTROL_REG , + ®ister18); +et131x_mii_write (adapter,PHY_MPHY_CONTROL_REG , register18 |0x4 ); -et131x_mii_write (adapter,0x10 , +et131x_mii_write (adapter,PHY_INDEX_REG , register18 |0x8402 ); -et131x_mii_write (adapter,0x11 , +et131x_mii_write (adapter,PHY_DATA_REG , register18 |511 ); -et131x_mii_write (adapter,0x12 , register18); +et131x_mii_write (adapter,PHY_MPHY_CONTROL_REG , + register18); }et1310_config_flow_control (adapter);if (phydev && phydev->speed ==SPEED_1000 && adapter->registry_jumbo_packet >2048 ) -et1310_phy_and_or_reg (adapter,0x16 ,0xcfff , -0x2000 ); +et1310_phy_and_or_reg (adapter,PHY_CONFIG , + ~ET_PHY_CONFIG_TX_FIFO_DEPTH , +ET_PHY_CONFIG_FIFO_DEPTH_32 );et131x_set_rx_dma_timer (adapter);et1310_config_mac_regs2 (adapter);
drivers/staging/et131x/et1310_phy.h +64 -20
127 lines not on this page · raw message
Signature · 1 line
1.7.6
PATCH 10/12 staging: et131x: Remove struct mi_regs from et1310_phy.h
In reply to Mark EinonThis structure is no longer used, and references registers defined in mii.h and other parts of et1310_phy.h
--- drivers/staging/et131x/et1310_phy.h | 34 +++++----------------------------- 1 files changed, 5 insertions(+), 29 deletions(-)
drivers/staging/et131x/et1310_phy.h +5 -29
@@ -61,6 +61,11 @@#include "et1310_address_map.h" +/* +* Defines for generic MII registers 0x00 -> 0x0F can be found in +* include/linux/mii.h +*/ +/* some defines for modem registers that seem to be 'reserved' */ #define PHY_INDEX_REG 0x10#define PHY_DATA_REG 0x11
@@ -80,35 +85,6 @@/* TRU_VMI_LINK_CONTROL_REG 29 */ /* TRU_VMI_TIMING_CONTROL_REG */ -/* PHY Register Mapping(MI) Management Interface Regs */ -struct mi_regs { -u8 bmcr;/* Basic mode control reg(Reg 0x00) */ -u8 bmsr;/* Basic mode status reg(Reg 0x01) */ -u8 idr1;/* Phy identifier reg 1(Reg 0x02) */ -u8 idr2;/* Phy identifier reg 2(Reg 0x03) */ -u8 anar;/* Auto-Negotiation advertisement(Reg 0x04) */ -u8 anlpar;/* Auto-Negotiation link Partner Ability(Reg 0x05) */ -u8 aner;/* Auto-Negotiation expansion reg(Reg 0x06) */ -u8 annptr;/* Auto-Negotiation next page transmit reg(Reg 0x07) */ -u8 lpnpr;/* link partner next page reg(Reg 0x08) */ -u8 gcr;/* Gigabit basic mode control reg(Reg 0x09) */ -u8 gsr;/* Gigabit basic mode status reg(Reg 0x0A) */ -u8 mi_res1[4 ];/* Future use by MI working group(Reg 0x0B - 0x0E) */ -u8 esr;/* Extended status reg(Reg 0x0F) */ -u8 mi_res2[3 ];/* Future use by MI working group(Reg 0x10 - 0x12) */ -u8 loop_ctl;/* Loopback Control Reg(Reg 0x13) */ -u8 mi_res3;/* Future use by MI working group(Reg 0x14) */ -u8 mcr;/* MI Control Reg(Reg 0x15) */ -u8 pcr;/* Configuration Reg(Reg 0x16) */ -u8 phy_ctl;/* PHY Control Reg(Reg 0x17) */ -u8 imr;/* Interrupt Mask Reg(Reg 0x18) */ -u8 isr;/* Interrupt Status Reg(Reg 0x19) */ -u8 psr;/* PHY Status Reg(Reg 0x1A) */ -u8 lcr1;/* LED Control 1 Reg(Reg 0x1B) */ -u8 lcr2;/* LED Control 2 Reg(Reg 0x1C) */ -u8 mi_res4[3 ];/* Future use by MI working group(Reg 0x1D - 0x1F) */ -}; -/* MI Register 10: Gigabit basic mode status reg(Reg 0x0A) */ #define ET_1000BT_MSTR_SLV 0x4000
Signature · 1 line
1.7.6
PATCH 11/12 staging: et131x: Remove ai_force_[duplex|speed] from et131x_adapter
In reply to Mark EinonThe ai_force settings were used to set the ethernet speed and duplex manually. This is now being done by the phy_device, so remove.
--- drivers/staging/et131x/et1310_phy.c | 6 ++---- drivers/staging/et131x/et131x_adapter.h | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/staging/et131x/et1310_phy.c +2 -4
@@ -498,10 +498,8 @@ void et131x_mii_check(struct et131x_adapter *adapter, } } -if ((bmsr_ints &BMSR_ANEGCOMPLETE ) || - (adapter->ai_force_duplex ==3 && (bmsr_ints &BMSR_LSTATUS ))) { -if ((bmsr &BMSR_ANEGCOMPLETE ) || - adapter->ai_force_duplex ==3 ) { +if (bmsr_ints &BMSR_ANEGCOMPLETE ) { +if (bmsr &BMSR_ANEGCOMPLETE ) { et1310_phy_link_status(adapter, &link_status, &autoneg_status, &speed, &duplex, &mdi_mdix,
drivers/staging/et131x/et131x_adapter.h +0 -2
@@ -181,8 +181,6 @@ struct et131x_adapter {u32 registry_jumbo_packet;/* Max supported ethernet packet size */ /* Derived from the registry: */ -u8 ai_force_duplex;/* duplex setting */ -u16 ai_force_speed;/* 'Speed', user over-ride of line speed */ u8 flowcontrol;/* flow control validated by the far-end */ /* Minimize init-time */
Signature · 1 line
1.7.6
PATCH 12/12 staging: et131x: Update README file
In reply to Mark EinonI believe that the driver is up to date with the latest network driver changes, so removing this line from the TODO to see if anyone else disagrees.
Also all useless typecasts are now dead.
--- drivers/staging/et131x/README | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/staging/et131x/README +0 -2
@@ -9,8 +9,6 @@ Note, the powermanagement options were removed from the vendor provided driver as they did not build properly at the time. TODO: - - forward port for latest network driver changes - - kill useless typecasts (e.g. in et1310_phy.c) - alloc_etherdev is initializing memory with zero?!? - add_timer call in et131x_netdev.c is correct? - Add power saving functionality (suspend, sleep, resume)
Signature · 1 line
1.7.6