Commit 414daf01 authored by Jeff Garzik's avatar Jeff Garzik

Update eepro100 net driver's mdio_{read,write} functions

to take 'struct net_device *' not 'long' as their first
argument.  This makes eepro100 compatible with the standard
MII ethtool API, preparing it for that support.

No functional changes should occur with this patch, if anything
changes at all it is a bug.  (and testing shows no changes...)
parent 180df3b2
......@@ -532,8 +532,8 @@ static int eepro100_init_one(struct pci_dev *pdev,
static void eepro100_remove_one (struct pci_dev *pdev);
static int do_eeprom_cmd(long ioaddr, int cmd, int cmd_len);
static int mdio_read(long ioaddr, int phy_id, int location);
static int mdio_write(long ioaddr, int phy_id, int location, int value);
static int mdio_read(struct net_device *dev, int phy_id, int location);
static int mdio_write(struct net_device *dev, int phy_id, int location, int value);
static int speedo_open(struct net_device *dev);
static void speedo_resume(struct net_device *dev);
static void speedo_timer(unsigned long data);
......@@ -730,6 +730,9 @@ static int __devinit speedo_found1(struct pci_dev *pdev,
#endif
printk("IRQ %d.\n", pdev->irq);
/* we must initialize base_addr early, for mdio_{read,write} */
dev->base_addr = ioaddr;
#if 1 || defined(kernel_bloat)
/* OK, this is pure kernel bloat. I don't like it when other drivers
waste non-pageable kernel space to emit similar messages, but I need
......@@ -755,18 +758,18 @@ static int __devinit speedo_found1(struct pci_dev *pdev,
phys[(eeprom[7]>>8)&7]);
if (((eeprom[6]>>8) & 0x3f) == DP83840
|| ((eeprom[6]>>8) & 0x3f) == DP83840A) {
int mdi_reg23 = mdio_read(ioaddr, eeprom[6] & 0x1f, 23) | 0x0422;
int mdi_reg23 = mdio_read(dev, eeprom[6] & 0x1f, 23) | 0x0422;
if (congenb)
mdi_reg23 |= 0x0100;
printk(KERN_INFO" DP83840 specific setup, setting register 23 to %4.4x.\n",
mdi_reg23);
mdio_write(ioaddr, eeprom[6] & 0x1f, 23, mdi_reg23);
mdio_write(dev, eeprom[6] & 0x1f, 23, mdi_reg23);
}
if ((option >= 0) && (option & 0x70)) {
printk(KERN_INFO " Forcing %dMbs %s-duplex operation.\n",
(option & 0x20 ? 100 : 10),
(option & 0x10 ? "full" : "half"));
mdio_write(ioaddr, eeprom[6] & 0x1f, 0,
mdio_write(dev, eeprom[6] & 0x1f, MII_BMCR,
((option & 0x20) ? 0x2000 : 0) | /* 100mbps? */
((option & 0x10) ? 0x0100 : 0)); /* Full duplex? */
}
......@@ -808,7 +811,6 @@ static int __devinit speedo_found1(struct pci_dev *pdev,
pci_set_drvdata (pdev, dev);
dev->base_addr = ioaddr;
dev->irq = pdev->irq;
sp = dev->priv;
......@@ -915,8 +917,9 @@ static int __devinit do_eeprom_cmd(long ioaddr, int cmd, int cmd_len)
return retval;
}
static int mdio_read(long ioaddr, int phy_id, int location)
static int mdio_read(struct net_device *dev, int phy_id, int location)
{
long ioaddr = dev->base_addr;
int val, boguscnt = 64*10; /* <64 usec. to complete, typ 27 ticks */
outl(0x08000000 | (location<<16) | (phy_id<<21), ioaddr + SCBCtrlMDI);
do {
......@@ -929,8 +932,9 @@ static int mdio_read(long ioaddr, int phy_id, int location)
return val & 0xffff;
}
static int mdio_write(long ioaddr, int phy_id, int location, int value)
static int mdio_write(struct net_device *dev, int phy_id, int location, int value)
{
long ioaddr = dev->base_addr;
int val, boguscnt = 64*10; /* <64 usec. to complete, typ 27 ticks */
outl(0x04000000 | (location<<16) | (phy_id<<21) | value,
ioaddr + SCBCtrlMDI);
......@@ -983,9 +987,9 @@ speedo_open(struct net_device *dev)
0x2100 100-FD
*/
#ifdef honor_default_port
mdio_write(ioaddr, phy_addr, 0, mii_ctrl[dev->default_port & 7]);
mdio_write(dev, phy_addr, MII_BMCR, mii_ctrl[dev->default_port & 7]);
#else
mdio_write(ioaddr, phy_addr, 0, 0x3300);
mdio_write(dev, phy_addr, MII_BMCR, 0x3300);
#endif
}
#endif
......@@ -1006,9 +1010,9 @@ speedo_open(struct net_device *dev)
sp->rx_mode = -1; /* Invalid -> always reset the mode. */
set_rx_mode(dev);
if ((sp->phy[0] & 0x8000) == 0)
sp->advertising = mdio_read(ioaddr, sp->phy[0] & 0x1f, 4);
sp->advertising = mdio_read(dev, sp->phy[0] & 0x1f, MII_ADVERTISE);
if (mdio_read(ioaddr, sp->phy[0] & 0x1f, MII_BMSR) & BMSR_LSTATUS)
if (mdio_read(dev, sp->phy[0] & 0x1f, MII_BMSR) & BMSR_LSTATUS)
netif_carrier_on(dev);
else
netif_carrier_off(dev);
......@@ -1030,7 +1034,7 @@ speedo_open(struct net_device *dev)
/* No need to wait for the command unit to accept here. */
if ((sp->phy[0] & 0x8000) == 0)
mdio_read(ioaddr, sp->phy[0] & 0x1f, 0);
mdio_read(dev, sp->phy[0] & 0x1f, MII_BMCR);
return 0;
}
......@@ -1160,7 +1164,7 @@ static void speedo_timer(unsigned long data)
/* We have MII and lost link beat. */
if ((sp->phy[0] & 0x8000) == 0) {
int partner = mdio_read(ioaddr, phy_num, 5);
int partner = mdio_read(dev, phy_num, MII_LPA);
if (partner != sp->partner) {
int flow_ctrl = sp->advertising & partner & 0x0400 ? 1 : 0;
if (speedo_debug > 2) {
......@@ -1174,9 +1178,9 @@ static void speedo_timer(unsigned long data)
sp->rx_mode = -1; /* Trigger a reload. */
}
/* Clear sticky bit. */
mdio_read(ioaddr, phy_num, 1);
mdio_read(dev, phy_num, MII_BMSR);
/* If link beat has returned... */
if (mdio_read(ioaddr, phy_num, MII_BMSR) & BMSR_LSTATUS)
if (mdio_read(dev, phy_num, MII_BMSR) & BMSR_LSTATUS)
netif_carrier_on(dev);
else
netif_carrier_off(dev);
......@@ -1242,7 +1246,7 @@ static void speedo_show_state(struct net_device *dev)
/* FIXME: what does it mean? --SAW */
if (i == 6) i = 21;
printk(KERN_DEBUG "%s: PHY index %d register %d is %4.4x.\n",
dev->name, phy_num, i, mdio_read(ioaddr, phy_num, i));
dev->name, phy_num, i, mdio_read(dev, phy_num, i));
}
}
#endif
......@@ -1334,22 +1338,22 @@ static void speedo_purge_tx(struct net_device *dev)
static void reset_mii(struct net_device *dev)
{
struct speedo_private *sp = (struct speedo_private *)dev->priv;
long ioaddr = dev->base_addr;
/* Reset the MII transceiver, suggested by Fred Young @ scalable.com. */
if ((sp->phy[0] & 0x8000) == 0) {
int phy_addr = sp->phy[0] & 0x1f;
int advertising = mdio_read(ioaddr, phy_addr, 4);
int mii_bmcr = mdio_read(ioaddr, phy_addr, 0);
mdio_write(ioaddr, phy_addr, 0, 0x0400);
mdio_write(ioaddr, phy_addr, 1, 0x0000);
mdio_write(ioaddr, phy_addr, 4, 0x0000);
mdio_write(ioaddr, phy_addr, 0, 0x8000);
int advertising = mdio_read(dev, phy_addr, MII_ADVERTISE);
int mii_bmcr = mdio_read(dev, phy_addr, MII_BMCR);
mdio_write(dev, phy_addr, MII_BMCR, 0x0400);
mdio_write(dev, phy_addr, MII_BMSR, 0x0000);
mdio_write(dev, phy_addr, MII_ADVERTISE, 0x0000);
mdio_write(dev, phy_addr, MII_BMCR, 0x8000);
#ifdef honor_default_port
mdio_write(ioaddr, phy_addr, 0, mii_ctrl[dev->default_port & 7]);
mdio_write(dev, phy_addr, MII_BMCR, mii_ctrl[dev->default_port & 7]);
#else
mdio_read(ioaddr, phy_addr, 0);
mdio_write(ioaddr, phy_addr, 0, mii_bmcr);
mdio_write(ioaddr, phy_addr, 4, advertising);
mdio_read(dev, phy_addr, MII_BMCR);
mdio_write(dev, phy_addr, MII_BMCR, mii_bmcr);
mdio_write(dev, phy_addr, MII_ADVERTISE, advertising);
#endif
}
}
......@@ -1990,7 +1994,6 @@ static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
static int speedo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
struct speedo_private *sp = (struct speedo_private *)dev->priv;
long ioaddr = dev->base_addr;
struct mii_ioctl_data *data = (struct mii_ioctl_data *)&rq->ifr_data;
int phy = sp->phy[0] & 0x1f;
int saved_acpi;
......@@ -2007,7 +2010,7 @@ static int speedo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
timer routine. 2000/05/09 SAW */
saved_acpi = pci_set_power_state(sp->pdev, 0);
t = del_timer_sync(&sp->timer);
data->val_out = mdio_read(ioaddr, data->phy_id & 0x1f, data->reg_num & 0x1f);
data->val_out = mdio_read(dev, data->phy_id & 0x1f, data->reg_num & 0x1f);
if (t)
add_timer(&sp->timer); /* may be set to the past --SAW */
pci_set_power_state(sp->pdev, saved_acpi);
......@@ -2018,7 +2021,7 @@ static int speedo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
return -EPERM;
saved_acpi = pci_set_power_state(sp->pdev, 0);
t = del_timer_sync(&sp->timer);
mdio_write(ioaddr, data->phy_id, data->reg_num, data->val_in);
mdio_write(dev, data->phy_id, data->reg_num, data->val_in);
if (t)
add_timer(&sp->timer); /* may be set to the past --SAW */
pci_set_power_state(sp->pdev, saved_acpi);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment