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>
#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"
{
int32_t delay = 0;
struct mac_regs __iomem *mac = &adapter->regs->mac;
+ struct phy_device *phydev = adapter->phydev;
u32 cfg1;
u32 cfg2;
u32 ifctrl;
/* 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);
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;
* 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);
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;
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) ==
netif_carrier_off(adapter->netdev);
- adapter->linkspeed = 0;
adapter->duplex_mode = 0;
/* Free the packets being actively sent & stopped */
&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?
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);
#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
#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"
*/
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);
}
#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"
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
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;
/* 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);
}
/* Flags that indicate current state of the adapter */
u32 flags;
- u32 hw_errs;
/* Configuration */
u8 rom_addr[ETH_ALEN];
/* Packet Filter and look ahead size */
u32 packet_filter;
- u32 linkspeed;
u32 duplex_mode;
/* multicast list */
/* 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;
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