aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Romieu <romieu@fr.zoreil.com>2005-07-30 07:14:38 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-07-30 18:21:00 -0400
commit9ede109bbe93d5bbe4271e346106847fbfea95a1 (patch)
treed3ab06379a0303bddfef4643a9a4f3cf5f417c24
parent3cec93c7124c3037dbff826d6c08e9758a301cd7 (diff)
[PATCH] sis190: allow a non-hardcoded ID for the PHY.
Allow a non-hardcoded ID for the PHY This is the first step before the driver probes for the PHY address. Signed-off-by: Francois Romieu <romieu@fr.zoreil.com> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
-rw-r--r--drivers/net/sis190.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index 2387d4844037..f78799c4235e 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -354,21 +354,17 @@ static void __mdio_cmd(void __iomem *ioaddr, u32 ctl)
354 printk(KERN_ERR PFX "PHY command failed !\n"); 354 printk(KERN_ERR PFX "PHY command failed !\n");
355} 355}
356 356
357static void mdio_write(void __iomem *ioaddr, int reg, int val) 357static void mdio_write(void __iomem *ioaddr, int phy_id, int reg, int val)
358{ 358{
359 u32 pmd = 1;
360
361 __mdio_cmd(ioaddr, EhnMIIreq | EhnMIIwrite | 359 __mdio_cmd(ioaddr, EhnMIIreq | EhnMIIwrite |
362 (((u32) reg) << EhnMIIregShift) | (pmd << EhnMIIpmdShift) | 360 (((u32) reg) << EhnMIIregShift) | (phy_id << EhnMIIpmdShift) |
363 (((u32) val) << EhnMIIdataShift)); 361 (((u32) val) << EhnMIIdataShift));
364} 362}
365 363
366static int mdio_read(void __iomem *ioaddr, int reg) 364static int mdio_read(void __iomem *ioaddr, int phy_id, int reg)
367{ 365{
368 u32 pmd = 1;
369
370 __mdio_cmd(ioaddr, EhnMIIreq | EhnMIIread | 366 __mdio_cmd(ioaddr, EhnMIIreq | EhnMIIread |
371 (((u32) reg) << EhnMIIregShift) | (pmd << EhnMIIpmdShift)); 367 (((u32) reg) << EhnMIIregShift) | (phy_id << EhnMIIpmdShift));
372 368
373 return (u16) (SIS_R32(GMIIControl) >> EhnMIIdataShift); 369 return (u16) (SIS_R32(GMIIControl) >> EhnMIIdataShift);
374} 370}
@@ -377,14 +373,14 @@ static void __mdio_write(struct net_device *dev, int phy_id, int reg, int val)
377{ 373{
378 struct sis190_private *tp = netdev_priv(dev); 374 struct sis190_private *tp = netdev_priv(dev);
379 375
380 mdio_write(tp->mmio_addr, reg, val); 376 mdio_write(tp->mmio_addr, phy_id, reg, val);
381} 377}
382 378
383static int __mdio_read(struct net_device *dev, int phy_id, int reg) 379static int __mdio_read(struct net_device *dev, int phy_id, int reg)
384{ 380{
385 struct sis190_private *tp = netdev_priv(dev); 381 struct sis190_private *tp = netdev_priv(dev);
386 382
387 return mdio_read(tp->mmio_addr, reg); 383 return mdio_read(tp->mmio_addr, phy_id, reg);
388} 384}
389 385
390static u16 __devinit sis190_read_eeprom(void __iomem *ioaddr, u32 reg) 386static u16 __devinit sis190_read_eeprom(void __iomem *ioaddr, u32 reg)
@@ -876,18 +872,19 @@ static void sis190_phy_task(void * data)
876 struct net_device *dev = data; 872 struct net_device *dev = data;
877 struct sis190_private *tp = netdev_priv(dev); 873 struct sis190_private *tp = netdev_priv(dev);
878 void __iomem *ioaddr = tp->mmio_addr; 874 void __iomem *ioaddr = tp->mmio_addr;
875 int phy_id = tp->mii_if.phy_id;
879 u16 val; 876 u16 val;
880 877
881 rtnl_lock(); 878 rtnl_lock();
882 879
883 val = mdio_read(ioaddr, MII_BMCR); 880 val = mdio_read(ioaddr, phy_id, MII_BMCR);
884 if (val & BMCR_RESET) { 881 if (val & BMCR_RESET) {
885 // FIXME: needlessly high ? -- FR 02/07/2005 882 // FIXME: needlessly high ? -- FR 02/07/2005
886 mod_timer(&tp->timer, jiffies + HZ/10); 883 mod_timer(&tp->timer, jiffies + HZ/10);
887 } else if (!(mdio_read(ioaddr, MII_BMSR) & BMSR_ANEGCOMPLETE)) { 884 } else if (!(mdio_read(ioaddr, phy_id, MII_BMSR) & BMSR_ANEGCOMPLETE)) {
888 net_link(tp, KERN_WARNING "%s: PHY reset until link up.\n", 885 net_link(tp, KERN_WARNING "%s: PHY reset until link up.\n",
889 dev->name); 886 dev->name);
890 mdio_write(ioaddr, MII_BMCR, val | BMCR_RESET); 887 mdio_write(ioaddr, phy_id, MII_BMCR, val | BMCR_RESET);
891 mod_timer(&tp->timer, jiffies + SIS190_PHY_TIMEOUT); 888 mod_timer(&tp->timer, jiffies + SIS190_PHY_TIMEOUT);
892 } else { 889 } else {
893 /* Rejoice ! */ 890 /* Rejoice ! */
@@ -917,10 +914,10 @@ static void sis190_phy_task(void * data)
917 { 0, "unknown", 0x0000 } 914 { 0, "unknown", 0x0000 }
918 }, *p; 915 }, *p;
919 916
920 val = mdio_read(ioaddr, 0x1f); 917 val = mdio_read(ioaddr, phy_id, 0x1f);
921 net_link(tp, KERN_INFO "%s: mii ext = %04x.\n", dev->name, val); 918 net_link(tp, KERN_INFO "%s: mii ext = %04x.\n", dev->name, val);
922 919
923 val = mdio_read(ioaddr, MII_LPA); 920 val = mdio_read(ioaddr, phy_id, MII_LPA);
924 net_link(tp, KERN_INFO "%s: mii lpa = %04x.\n", dev->name, val); 921 net_link(tp, KERN_INFO "%s: mii lpa = %04x.\n", dev->name, val);
925 922
926 for (p = reg31; p->ctl; p++) { 923 for (p = reg31; p->ctl; p++) {
@@ -1250,7 +1247,7 @@ static struct net_device * __devinit sis190_init_board(struct pci_dev *pdev)
1250 tp->mii_if.dev = dev; 1247 tp->mii_if.dev = dev;
1251 tp->mii_if.mdio_read = __mdio_read; 1248 tp->mii_if.mdio_read = __mdio_read;
1252 tp->mii_if.mdio_write = __mdio_write; 1249 tp->mii_if.mdio_write = __mdio_write;
1253 // tp->mii_if.phy_id = XXX; 1250 tp->mii_if.phy_id = 1;
1254 tp->mii_if.phy_id_mask = 0x1f; 1251 tp->mii_if.phy_id_mask = 0x1f;
1255 tp->mii_if.reg_num_mask = 0x1f; 1252 tp->mii_if.reg_num_mask = 0x1f;
1256 1253
@@ -1423,23 +1420,24 @@ static void sis190_set_speed_auto(struct net_device *dev)
1423{ 1420{
1424 struct sis190_private *tp = netdev_priv(dev); 1421 struct sis190_private *tp = netdev_priv(dev);
1425 void __iomem *ioaddr = tp->mmio_addr; 1422 void __iomem *ioaddr = tp->mmio_addr;
1423 int phy_id = tp->mii_if.phy_id;
1426 int val; 1424 int val;
1427 1425
1428 net_link(tp, KERN_INFO "%s: Enabling Auto-negotiation.\n", dev->name); 1426 net_link(tp, KERN_INFO "%s: Enabling Auto-negotiation.\n", dev->name);
1429 1427
1430 val = mdio_read(ioaddr, MII_ADVERTISE); 1428 val = mdio_read(ioaddr, phy_id, MII_ADVERTISE);
1431 1429
1432 // Enable 10/100 Full/Half Mode, leave MII_ADVERTISE bit4:0 1430 // Enable 10/100 Full/Half Mode, leave MII_ADVERTISE bit4:0
1433 // unchanged. 1431 // unchanged.
1434 mdio_write(ioaddr, MII_ADVERTISE, (val & ADVERTISE_SLCT) | 1432 mdio_write(ioaddr, phy_id, MII_ADVERTISE, (val & ADVERTISE_SLCT) |
1435 ADVERTISE_100FULL | ADVERTISE_10FULL | 1433 ADVERTISE_100FULL | ADVERTISE_10FULL |
1436 ADVERTISE_100HALF | ADVERTISE_10HALF); 1434 ADVERTISE_100HALF | ADVERTISE_10HALF);
1437 1435
1438 // Enable 1000 Full Mode. 1436 // Enable 1000 Full Mode.
1439 mdio_write(ioaddr, MII_CTRL1000, ADVERTISE_1000FULL); 1437 mdio_write(ioaddr, phy_id, MII_CTRL1000, ADVERTISE_1000FULL);
1440 1438
1441 // Enable auto-negotiation and restart auto-negotiation. 1439 // Enable auto-negotiation and restart auto-negotiation.
1442 mdio_write(ioaddr, MII_BMCR, 1440 mdio_write(ioaddr, phy_id, MII_BMCR,
1443 BMCR_ANENABLE | BMCR_ANRESTART | BMCR_RESET); 1441 BMCR_ANENABLE | BMCR_ANRESTART | BMCR_RESET);
1444} 1442}
1445 1443