Skip to contentSkip to conversation

phylib: add the ICPlus IP175C PHY driver

PATCH In review Kim Phillips 2 participants 2 messages May 8, 2007 – May 9, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 2/6 phylib: add the ICPlus IP175C PHY driver

The ICPlus IP175C sports a 100Mbit/s 4-port switch in addition to a dedicated 100Mbit/s WAN port.

---
 drivers/net/phy/Kconfig  |    6 ++
 drivers/net/phy/Makefile |    1 +
 drivers/net/phy/icplus.c |  128 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 135 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/phy/icplus.c
drivers/net/phy/Kconfig +6 -0
index f994f12..91cf33e 100644
@@ -62,6 +62,12 @@ config BROADCOM_PHY
 	---help---
 	  Currently supports the BCM5411, BCM5421 and BCM5461 PHYs.
 
+config ICPLUS_PHY
+	tristate "Drivers for ICPlus PHYs"
+	depends on PHYLIB
+	---help---
+	  Currently supports the IP175C PHY.
+
 config FIXED_PHY
 	tristate "Drivers for PHY emulation on fixed speed/link"
 	depends on PHYLIB
drivers/net/phy/Makefile +1 -0
index bcd1efb..8885650 100644
@@ -11,4 +11,5 @@ obj-$(CONFIG_QSEMI_PHY)		+= qsemi.o
 obj-$(CONFIG_SMSC_PHY)		+= smsc.o
 obj-$(CONFIG_VITESSE_PHY)	+= vitesse.o
 obj-$(CONFIG_BROADCOM_PHY)	+= broadcom.o
+obj-$(CONFIG_ICPLUS_PHY)	+= icplus.o
 obj-$(CONFIG_FIXED_PHY)		+= fixed.o
drivers/net/phy/icplus.c new file +128 -0

128 lines not on this page · raw message

Signature · 1 line
1.5.0.3
#1 lore raw

drivers/net/phy/icplus.c line 56

Quoted 12 lines · Kim Phillips
drivers/net/phy/icplus.c new file +12 -0
+		/* master reset */
+		err = phydev->bus->write(phydev->bus, 30, 0, 0x175c);
+		if (err < 0)
+			return err;
+
+		/* data sheet specifies reset period is 2 msec */
+		udelay(3000);
+
+		/* enable IP175C mode */
+		err = phydev->bus->write(phydev->bus, 29, 31, 0x175c);
+		if (err < 0)
+			return err;

1) use mdelay()

2) write-followed-by-delay does not guarantee the delay, because you have not factored in PCI posting (or other bus delays)

drivers/net/phy/icplus.c line 66

Quoted 9 lines
drivers/net/phy/icplus.c new file +9 -0
+		/* Set MII0 speed and duplex (in PHY mode) */
+		err = phydev->bus->write(phydev->bus, 29, 22, 0x420);
+		if (err < 0)
+			return err;
+
+		for (i=0; i<5; i++) {
+			err = phydev->bus->write(phydev->bus, i, MII_BMCR, BMCR_RESET);
+		}
+		udelay(3000);

ditto

Quoted 22 lines
drivers/net/phy/icplus.c new file +22 -0
+		full_reset_performed = 1;
+	}
+
+	if (phydev->addr != 4) {
+		phydev->state = PHY_RUNNING;
+		phydev->speed = SPEED_100;
+		phydev->duplex = DUPLEX_FULL;
+		phydev->link = 1;
+		netif_carrier_on(phydev->attached_dev);
+	}
+
+	return 0;
+}
+
+static int ip175c_read_status(struct phy_device *phydev)
+{
+	if (phydev->addr == 4) { /* if WAN port */
+		genphy_read_status(phydev);
+	} else {
+		/* Don't need to read status for switch ports */
+		phydev->irq = PHY_IGNORE_INTERRUPT;
+	}

drivers/net/phy/icplus.c line 99

Quoted 10 lines
drivers/net/phy/icplus.c new file +10 -0
+
+	return 0;
+}
+
+
+static int ip175c_config_aneg(struct phy_device *phydev)
+{
+	if (phydev->addr == 4) { /* if WAN port */
+		genphy_config_aneg(phydev);
+	}

codingstyle: remove braces around single C statements