diff options
author | Mark Einon <mark.einon@gmail.com> | 2011-09-04 06:24:32 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-09-06 19:54:53 -0400 |
commit | 412f8e0c52b126c6f54d0626a9dede9438d76c03 (patch) | |
tree | 6a9f76a432d3d9fba883b8e2dc3cfdea3319eda2 | |
parent | 740b7a2cb18206374aabe38c0ec1f1344214ac97 (diff) |
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.
Signed-off-by: Mark Einon <mark.einon@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/et131x/et1310_mac.c | 7 | ||||
-rw-r--r-- | drivers/staging/et131x/et1310_phy.c | 9 | ||||
-rw-r--r-- | drivers/staging/et131x/et1310_phy.h | 5 | ||||
-rw-r--r-- | drivers/staging/et131x/et1310_rx.c | 9 | ||||
-rw-r--r-- | drivers/staging/et131x/et1310_tx.c | 6 | ||||
-rw-r--r-- | drivers/staging/et131x/et131x_adapter.h | 2 | ||||
-rw-r--r-- | drivers/staging/et131x/et131x_initpci.c | 12 |
7 files changed, 26 insertions, 24 deletions
diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c index 36f21685599..efabc038bb4 100644 --- a/drivers/staging/et131x/et1310_mac.c +++ b/drivers/staging/et131x/et1310_mac.c | |||
@@ -82,6 +82,7 @@ | |||
82 | #include <linux/if_arp.h> | 82 | #include <linux/if_arp.h> |
83 | #include <linux/ioport.h> | 83 | #include <linux/ioport.h> |
84 | #include <linux/crc32.h> | 84 | #include <linux/crc32.h> |
85 | #include <linux/phy.h> | ||
85 | 86 | ||
86 | #include "et1310_phy.h" | 87 | #include "et1310_phy.h" |
87 | #include "et131x_adapter.h" | 88 | #include "et131x_adapter.h" |
@@ -166,6 +167,7 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter) | |||
166 | { | 167 | { |
167 | int32_t delay = 0; | 168 | int32_t delay = 0; |
168 | struct mac_regs __iomem *mac = &adapter->regs->mac; | 169 | struct mac_regs __iomem *mac = &adapter->regs->mac; |
170 | struct phy_device *phydev = adapter->phydev; | ||
169 | u32 cfg1; | 171 | u32 cfg1; |
170 | u32 cfg2; | 172 | u32 cfg2; |
171 | u32 ifctrl; | 173 | u32 ifctrl; |
@@ -178,7 +180,7 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter) | |||
178 | 180 | ||
179 | /* Set up the if mode bits */ | 181 | /* Set up the if mode bits */ |
180 | cfg2 &= ~0x300; | 182 | cfg2 &= ~0x300; |
181 | if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS) { | 183 | if (phydev && phydev->speed == SPEED_1000) { |
182 | cfg2 |= 0x200; | 184 | cfg2 |= 0x200; |
183 | /* Phy mode bit */ | 185 | /* Phy mode bit */ |
184 | ifctrl &= ~(1 << 24); | 186 | ifctrl &= ~(1 << 24); |
@@ -239,6 +241,7 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter) | |||
239 | void et1310_config_rxmac_regs(struct et131x_adapter *adapter) | 241 | void et1310_config_rxmac_regs(struct et131x_adapter *adapter) |
240 | { | 242 | { |
241 | struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; | 243 | struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac; |
244 | struct phy_device *phydev = adapter->phydev; | ||
242 | u32 sa_lo; | 245 | u32 sa_lo; |
243 | u32 sa_hi = 0; | 246 | u32 sa_hi = 0; |
244 | u32 pf_ctrl = 0; | 247 | u32 pf_ctrl = 0; |
@@ -351,7 +354,7 @@ void et1310_config_rxmac_regs(struct et131x_adapter *adapter) | |||
351 | * bit 16: Receive frame truncated. | 354 | * bit 16: Receive frame truncated. |
352 | * bit 17: Drop packet enable | 355 | * bit 17: Drop packet enable |
353 | */ | 356 | */ |
354 | if (adapter->linkspeed == TRUEPHY_SPEED_100MBPS) | 357 | if (phydev && phydev->speed == SPEED_100) |
355 | writel(0x30038, &rxmac->mif_ctrl); | 358 | writel(0x30038, &rxmac->mif_ctrl); |
356 | else | 359 | else |
357 | writel(0x30030, &rxmac->mif_ctrl); | 360 | writel(0x30030, &rxmac->mif_ctrl); |
diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 12345c7d32d..c5d0d02f4ca 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c | |||
@@ -440,6 +440,7 @@ void et131x_xcvr_init(struct et131x_adapter *adapter) | |||
440 | void et131x_mii_check(struct et131x_adapter *adapter, | 440 | void et131x_mii_check(struct et131x_adapter *adapter, |
441 | u16 bmsr, u16 bmsr_ints) | 441 | u16 bmsr, u16 bmsr_ints) |
442 | { | 442 | { |
443 | struct phy_device *phydev = adapter->phydev; | ||
443 | u8 link_status; | 444 | u8 link_status; |
444 | u32 autoneg_status; | 445 | u32 autoneg_status; |
445 | u32 speed; | 446 | u32 speed; |
@@ -456,7 +457,7 @@ void et131x_mii_check(struct et131x_adapter *adapter, | |||
456 | dev_warn(&adapter->pdev->dev, | 457 | dev_warn(&adapter->pdev->dev, |
457 | "Link down - cable problem ?\n"); | 458 | "Link down - cable problem ?\n"); |
458 | 459 | ||
459 | if (adapter->linkspeed == TRUEPHY_SPEED_10MBPS) { | 460 | if (phydev && phydev->speed == SPEED_10) { |
460 | /* NOTE - Is there a way to query this without | 461 | /* NOTE - Is there a way to query this without |
461 | * TruePHY? | 462 | * TruePHY? |
462 | * && TRU_QueryCoreType(adapter->hTruePhy, 0) == | 463 | * && TRU_QueryCoreType(adapter->hTruePhy, 0) == |
@@ -476,7 +477,6 @@ void et131x_mii_check(struct et131x_adapter *adapter, | |||
476 | 477 | ||
477 | netif_carrier_off(adapter->netdev); | 478 | netif_carrier_off(adapter->netdev); |
478 | 479 | ||
479 | adapter->linkspeed = 0; | ||
480 | adapter->duplex_mode = 0; | 480 | adapter->duplex_mode = 0; |
481 | 481 | ||
482 | /* Free the packets being actively sent & stopped */ | 482 | /* Free the packets being actively sent & stopped */ |
@@ -516,12 +516,11 @@ void et131x_mii_check(struct et131x_adapter *adapter, | |||
516 | &speed, &duplex, &mdi_mdix, | 516 | &speed, &duplex, &mdi_mdix, |
517 | &masterslave, &polarity); | 517 | &masterslave, &polarity); |
518 | 518 | ||
519 | adapter->linkspeed = speed; | ||
520 | adapter->duplex_mode = duplex; | 519 | adapter->duplex_mode = duplex; |
521 | 520 | ||
522 | adapter->boot_coma = 20; | 521 | adapter->boot_coma = 20; |
523 | 522 | ||
524 | if (adapter->linkspeed == TRUEPHY_SPEED_10MBPS) { | 523 | if (phydev && phydev->speed == SPEED_10) { |
525 | /* | 524 | /* |
526 | * NOTE - Is there a way to query this without | 525 | * NOTE - Is there a way to query this without |
527 | * TruePHY? | 526 | * TruePHY? |
@@ -542,7 +541,7 @@ void et131x_mii_check(struct et131x_adapter *adapter, | |||
542 | 541 | ||
543 | et1310_config_flow_control(adapter); | 542 | et1310_config_flow_control(adapter); |
544 | 543 | ||
545 | if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS && | 544 | if (phydev && phydev->speed == SPEED_1000 && |
546 | adapter->registry_jumbo_packet > 2048) | 545 | adapter->registry_jumbo_packet > 2048) |
547 | et1310_phy_and_or_reg(adapter, 0x16, 0xcfff, | 546 | et1310_phy_and_or_reg(adapter, 0x16, 0xcfff, |
548 | 0x2000); | 547 | 0x2000); |
diff --git a/drivers/staging/et131x/et1310_phy.h b/drivers/staging/et131x/et1310_phy.h index 88dc8cdb6ef..3e95c66dfde 100644 --- a/drivers/staging/et131x/et1310_phy.h +++ b/drivers/staging/et131x/et1310_phy.h | |||
@@ -242,11 +242,6 @@ struct mi_regs { | |||
242 | #define TRUEPHY_MASK 2 | 242 | #define TRUEPHY_MASK 2 |
243 | #endif | 243 | #endif |
244 | 244 | ||
245 | /* Define speeds */ | ||
246 | #define TRUEPHY_SPEED_10MBPS 0 | ||
247 | #define TRUEPHY_SPEED_100MBPS 1 | ||
248 | #define TRUEPHY_SPEED_1000MBPS 2 | ||
249 | |||
250 | /* Define duplex modes */ | 245 | /* Define duplex modes */ |
251 | #define TRUEPHY_DUPLEX_HALF 0 | 246 | #define TRUEPHY_DUPLEX_HALF 0 |
252 | #define TRUEPHY_DUPLEX_FULL 1 | 247 | #define TRUEPHY_DUPLEX_FULL 1 |
diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c index f50420c582a..c402c5e61e4 100644 --- a/drivers/staging/et131x/et1310_rx.c +++ b/drivers/staging/et131x/et1310_rx.c | |||
@@ -82,6 +82,7 @@ | |||
82 | #include <linux/skbuff.h> | 82 | #include <linux/skbuff.h> |
83 | #include <linux/if_arp.h> | 83 | #include <linux/if_arp.h> |
84 | #include <linux/ioport.h> | 84 | #include <linux/ioport.h> |
85 | #include <linux/phy.h> | ||
85 | 86 | ||
86 | #include "et1310_phy.h" | 87 | #include "et1310_phy.h" |
87 | #include "et131x_adapter.h" | 88 | #include "et131x_adapter.h" |
@@ -724,11 +725,15 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) | |||
724 | */ | 725 | */ |
725 | void et131x_set_rx_dma_timer(struct et131x_adapter *adapter) | 726 | void et131x_set_rx_dma_timer(struct et131x_adapter *adapter) |
726 | { | 727 | { |
728 | struct phy_device *phydev = adapter->phydev; | ||
729 | |||
730 | if (!phydev) | ||
731 | return; | ||
732 | |||
727 | /* For version B silicon, we do not use the RxDMA timer for 10 and 100 | 733 | /* For version B silicon, we do not use the RxDMA timer for 10 and 100 |
728 | * Mbits/s line rates. We do not enable and RxDMA interrupt coalescing. | 734 | * Mbits/s line rates. We do not enable and RxDMA interrupt coalescing. |
729 | */ | 735 | */ |
730 | if ((adapter->linkspeed == TRUEPHY_SPEED_100MBPS) || | 736 | if ((phydev->speed == SPEED_100) || (phydev->speed == SPEED_10)) { |
731 | (adapter->linkspeed == TRUEPHY_SPEED_10MBPS)) { | ||
732 | writel(0, &adapter->regs->rxdma.max_pkt_time); | 737 | writel(0, &adapter->regs->rxdma.max_pkt_time); |
733 | writel(1, &adapter->regs->rxdma.num_pkt_done); | 738 | writel(1, &adapter->regs->rxdma.num_pkt_done); |
734 | } | 739 | } |
diff --git a/drivers/staging/et131x/et1310_tx.c b/drivers/staging/et131x/et1310_tx.c index aa07138069f..1f806511f6c 100644 --- a/drivers/staging/et131x/et1310_tx.c +++ b/drivers/staging/et131x/et1310_tx.c | |||
@@ -82,6 +82,7 @@ | |||
82 | #include <linux/skbuff.h> | 82 | #include <linux/skbuff.h> |
83 | #include <linux/if_arp.h> | 83 | #include <linux/if_arp.h> |
84 | #include <linux/ioport.h> | 84 | #include <linux/ioport.h> |
85 | #include <linux/phy.h> | ||
85 | 86 | ||
86 | #include "et1310_phy.h" | 87 | #include "et1310_phy.h" |
87 | #include "et131x_adapter.h" | 88 | #include "et131x_adapter.h" |
@@ -287,6 +288,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) | |||
287 | u32 nr_frags = skb_shinfo(skb)->nr_frags + 1; | 288 | u32 nr_frags = skb_shinfo(skb)->nr_frags + 1; |
288 | struct skb_frag_struct *frags = &skb_shinfo(skb)->frags[0]; | 289 | struct skb_frag_struct *frags = &skb_shinfo(skb)->frags[0]; |
289 | unsigned long flags; | 290 | unsigned long flags; |
291 | struct phy_device *phydev = adapter->phydev; | ||
290 | 292 | ||
291 | /* Part of the optimizations of this send routine restrict us to | 293 | /* Part of the optimizations of this send routine restrict us to |
292 | * sending 24 fragments at a pass. In practice we should never see | 294 | * 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) | |||
400 | if (frag == 0) | 402 | if (frag == 0) |
401 | return -EIO; | 403 | return -EIO; |
402 | 404 | ||
403 | if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS) { | 405 | if (phydev && phydev->speed == SPEED_1000) { |
404 | if (++adapter->tx_ring.since_irq == PARM_TX_NUM_BUFS_DEF) { | 406 | if (++adapter->tx_ring.since_irq == PARM_TX_NUM_BUFS_DEF) { |
405 | /* Last element & Interrupt flag */ | 407 | /* Last element & Interrupt flag */ |
406 | desc[frag - 1].flags = 0x5; | 408 | desc[frag - 1].flags = 0x5; |
@@ -478,7 +480,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) | |||
478 | /* For Gig only, we use Tx Interrupt coalescing. Enable the software | 480 | /* For Gig only, we use Tx Interrupt coalescing. Enable the software |
479 | * timer to wake us up if this packet isn't followed by N more. | 481 | * timer to wake us up if this packet isn't followed by N more. |
480 | */ | 482 | */ |
481 | if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS) { | 483 | if (phydev && phydev->speed == SPEED_1000) { |
482 | writel(PARM_TX_TIME_INT_DEF * NANO_IN_A_MICRO, | 484 | writel(PARM_TX_TIME_INT_DEF * NANO_IN_A_MICRO, |
483 | &adapter->regs->global.watchdog_timer); | 485 | &adapter->regs->global.watchdog_timer); |
484 | } | 486 | } |
diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h index fbefd2e88d8..1e65e798282 100644 --- a/drivers/staging/et131x/et131x_adapter.h +++ b/drivers/staging/et131x/et131x_adapter.h | |||
@@ -147,7 +147,6 @@ struct et131x_adapter { | |||
147 | 147 | ||
148 | /* Flags that indicate current state of the adapter */ | 148 | /* Flags that indicate current state of the adapter */ |
149 | u32 flags; | 149 | u32 flags; |
150 | u32 hw_errs; | ||
151 | 150 | ||
152 | /* Configuration */ | 151 | /* Configuration */ |
153 | u8 rom_addr[ETH_ALEN]; | 152 | u8 rom_addr[ETH_ALEN]; |
@@ -170,7 +169,6 @@ struct et131x_adapter { | |||
170 | 169 | ||
171 | /* Packet Filter and look ahead size */ | 170 | /* Packet Filter and look ahead size */ |
172 | u32 packet_filter; | 171 | u32 packet_filter; |
173 | u32 linkspeed; | ||
174 | u32 duplex_mode; | 172 | u32 duplex_mode; |
175 | 173 | ||
176 | /* multicast list */ | 174 | /* multicast list */ |
diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 3cfcc2d07b7..eb08889e20b 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c | |||
@@ -678,12 +678,6 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, | |||
678 | /* Copy address into the net_device struct */ | 678 | /* Copy address into the net_device struct */ |
679 | memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN); | 679 | memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN); |
680 | 680 | ||
681 | /* Setup et1310 as per the documentation */ | ||
682 | et131x_adapter_setup(adapter); | ||
683 | |||
684 | /* Create a timer to count errors received by the NIC */ | ||
685 | init_timer(&adapter->error_timer); | ||
686 | |||
687 | adapter->error_timer.expires = jiffies + TX_ERROR_PERIOD * HZ / 1000; | 681 | adapter->error_timer.expires = jiffies + TX_ERROR_PERIOD * HZ / 1000; |
688 | adapter->error_timer.function = et131x_error_timer_handler; | 682 | adapter->error_timer.function = et131x_error_timer_handler; |
689 | adapter->error_timer.data = (unsigned long)adapter; | 683 | adapter->error_timer.data = (unsigned long)adapter; |
@@ -726,6 +720,12 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev, | |||
726 | goto err_mdio_unregister; | 720 | goto err_mdio_unregister; |
727 | } | 721 | } |
728 | 722 | ||
723 | /* Setup et1310 as per the documentation */ | ||
724 | et131x_adapter_setup(adapter); | ||
725 | |||
726 | /* Create a timer to count errors received by the NIC */ | ||
727 | init_timer(&adapter->error_timer); | ||
728 | |||
729 | /* We can enable interrupts now | 729 | /* We can enable interrupts now |
730 | * | 730 | * |
731 | * NOTE - Because registration of interrupt handler is done in the | 731 | * NOTE - Because registration of interrupt handler is done in the |