Skip to contentSkip to conversation

ibm_newemac: Add support for GPCS, SGMII and M88E1112 PHY

PATCH In review Victor Gallardo 2 participants 5 messages Sep 5, 2008 – Sep 15, 2008

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

PATCH 1/1 ibm_newemac: Add support for GPCS, SGMII and M88E1112 PHY

From: Victor Gallardo <[email protected]>

This patch adds GPCS, SGMII and M88E1112 PHY support for the AMCC PPC460GT/EX processors.

---
 drivers/net/ibm_newemac/core.c |   40 +++++++++++++++----
 drivers/net/ibm_newemac/core.h |    3 +
 drivers/net/ibm_newemac/phy.c  |   84 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/ibm_newemac/phy.h  |    2 +
 4 files changed, 120 insertions(+), 9 deletions(-)
drivers/net/ibm_newemac/core.c +31 -9
index 2e720f2..cef76fe 100644
@@ -201,13 +201,15 @@ static inline int emac_phy_supports_gige(int phy_mode)
 {
 	return  phy_mode == PHY_MODE_GMII ||
 		phy_mode == PHY_MODE_RGMII ||
+		phy_mode == PHY_MODE_SGMII ||
 		phy_mode == PHY_MODE_TBI ||
 		phy_mode == PHY_MODE_RTBI;
 }
 
 static inline int emac_phy_gpcs(int phy_mode)
 {
-	return  phy_mode == PHY_MODE_TBI ||
+	return  phy_mode == PHY_MODE_SGMII ||
+		phy_mode == PHY_MODE_TBI ||
 		phy_mode == PHY_MODE_RTBI;
 }
 
@@ -547,8 +549,9 @@ static int emac_configure(struct emac_instance *dev)
 	switch (dev->phy.speed) {
 	case SPEED_1000:
 		if (emac_phy_gpcs(dev->phy.mode)) {
-			mr1 |= EMAC_MR1_MF_1000GPCS |
-				EMAC_MR1_MF_IPPA(dev->phy.address);
+			mr1 |= EMAC_MR1_MF_1000GPCS | EMAC_MR1_MF_IPPA(
+				(dev->phy.gpcs_address != 0xffffffff) ?
+				 dev->phy.gpcs_address : dev->phy.address);
 
 			/* Put some arbitrary OUI, Manuf & Rev IDs so we can
 			 * identify this GPCS PHY later.
@@ -660,8 +663,12 @@ static int emac_configure(struct emac_instance *dev)
 	out_be32(&p->iser,  r);
 
 	/* We need to take GPCS PHY out of isolate mode after EMAC reset */
-	if (emac_phy_gpcs(dev->phy.mode))
-		emac_mii_reset_phy(&dev->phy);
+	if (emac_phy_gpcs(dev->phy.mode)) {
+		if (dev->phy.gpcs_address != 0xffffffff)
+			emac_mii_reset_gpcs(&dev->phy);
+		else
+			emac_mii_reset_phy(&dev->phy);
+	}
 
 	/* Required for Pause packet support in EMAC */
 	dev_mc_add(ndev, default_mcast_addr, sizeof(default_mcast_addr), 1);
@@ -869,7 +876,9 @@ static int emac_mdio_read(struct net_device *ndev, int id, int reg)
 	struct emac_instance *dev = netdev_priv(ndev);
 	int res;
 
-	res = __emac_mdio_read(dev->mdio_instance ? dev->mdio_instance : dev,
+	res = __emac_mdio_read((dev->mdio_instance &&
+				dev->phy.gpcs_address != id) ?
+				dev->mdio_instance : dev,
 			       (u8) id, (u8) reg);
 	return res;
 }
@@ -878,7 +887,9 @@ static void emac_mdio_write(struct net_device *ndev, int id, int reg, int val)
 {
 	struct emac_instance *dev = netdev_priv(ndev);
 
-	__emac_mdio_write(dev->mdio_instance ? dev->mdio_instance : dev,
+	__emac_mdio_write((dev->mdio_instance &&
+			   dev->phy.gpcs_address != id) ?
+			   dev->mdio_instance : dev,
 			  (u8) id, (u8) reg, (u16) val);
 }
 
@@ -2367,7 +2378,11 @@ static int __devinit emac_init_phy(struct emac_instance *dev)
 		 * XXX I probably should move these settings to the dev tree
 		 */
 		dev->phy.address = -1;
-		dev->phy.features = SUPPORTED_100baseT_Full | SUPPORTED_MII;
+		dev->phy.features = SUPPORTED_MII;
+		if (emac_phy_supports_gige(dev->phy_mode))
+			dev->phy.features |= SUPPORTED_1000baseT_Full;
+		else
+			dev->phy.features |= SUPPORTED_100baseT_Full;
 		dev->phy.pause = 1;
 
 		return 0;
@@ -2406,7 +2421,9 @@ static int __devinit emac_init_phy(struct emac_instance *dev)
 		 * Note that the busy_phy_map is currently global
 		 * while it should probably be per-ASIC...
 		 */
-		dev->phy.address = dev->cell_index;
+		dev->phy.gpcs_address = dev->gpcs_address;
+		if (dev->phy.gpcs_address == 0xffffffff)
+			dev->phy.address = dev->cell_index;
 	}
 
 	emac_configure(dev);
@@ -2516,6 +2533,8 @@ static int __devinit emac_init_config(struct emac_instance *dev)
 		dev->phy_address = 0xffffffff;
 	if (emac_read_uint_prop(np, "phy-map", &dev->phy_map, 0))
 		dev->phy_map = 0xffffffff;
+	if (emac_read_uint_prop(np, "gpcs-address", &dev->gpcs_address, 0))
+		dev->gpcs_address = 0xffffffff;
 	if (emac_read_uint_prop(np->parent, "clock-frequency", &dev->opb_bus_freq, 1))
 		return -ENXIO;
 	if (emac_read_uint_prop(np, "tah-device", &dev->tah_ph, 0))
@@ -2824,6 +2843,9 @@ static int __devinit emac_probe(struct of_device *ofdev,
 	       ndev->dev_addr[0], ndev->dev_addr[1], ndev->dev_addr[2],
 	       ndev->dev_addr[3], ndev->dev_addr[4], ndev->dev_addr[5]);
 
+	if (dev->phy_mode == PHY_MODE_SGMII)
+		printk(KERN_NOTICE "%s: in SGMII mode\n", ndev->name);
+
 	if (dev->phy.address >= 0)
 		printk("%s: found %s PHY (0x%02x)\n", ndev->name,
 		       dev->phy.def->name, dev->phy.address);
drivers/net/ibm_newemac/core.h +3 -0
index 6545e69..7312eac 100644
@@ -190,6 +190,9 @@ struct emac_instance {
 	struct delayed_work		link_work;
 	int				link_polling;
 
+	/* GPCS PHY infos */
+	u32				gpcs_address;
+
 	/* Shared MDIO if any */
 	u32				mdio_ph;
 	struct of_device		*mdio_dev;
drivers/net/ibm_newemac/phy.c +84 -0

113 lines not on this page · raw message

drivers/net/ibm_newemac/phy.h +2 -0
index 1b65c81..5d2bf4c 100644
@@ -57,6 +57,7 @@ struct mii_phy {
 				   or determined automaticaly */
 	int address;		/* PHY address */
 	int mode;		/* PHY mode */
+	int gpcs_address;	/* GPCS PHY address */
 
 	/* 1: autoneg enabled, 0: disabled */
 	int autoneg;
@@ -81,5 +82,6 @@ struct mii_phy {
  */
 int emac_mii_phy_probe(struct mii_phy *phy, int address);
 int emac_mii_reset_phy(struct mii_phy *phy);
+int emac_mii_reset_gpcs(struct mii_phy *phy);
 
 #endif /* __IBM_NEWEMAC_PHY_H */
Signature · 1 line
1.5.5
#1 lore raw
Quoted 4 lines · Victor Gallardo

From: Victor Gallardo <[email protected]>

This patch adds GPCS, SGMII and M88E1112 PHY support for the AMCC PPC460GT/EX processors.

So if I understand the patch correctly, either there is an *MII PHY in which case phy_address is used, or there's a GPCS one and phy_address is -1 and gpcs_address is used right ?

Why not instead always use phy_address, and have a flag indicating whether it's an MII or GPCS PHY ? This would avoid the added gpcs_read/write functions, among other things, and I believe would look cleaner... Or am I missing something ?

Cheers,
Ben.

#2 lore raw

RE: [PATCH] ibm_newemac: Add support for GPCS, SGMII and M88E1112PHY

Hello Benjamin,

On the 460EX/GT in SGMII mode, GPCS access is needed for communication with the internal SGMII SerDes. It is possible that there is still a PHY. So we need a way to access both addresses.

For Example on the AMCC Arches Board.

EMAC 0 has only a GPCS PHY (address 0xA)
EMAC 1 has M88E1112 PHY (address 0x0) and GPCS PHY (address 0xB) EMAC 2 has M88E1112 PHY (address 0x1) and GPCS PHY (address 0xC)

Regards,

Victor Gallardo

________________________________

From: Benjamin Herrenschmidt [mailto:[email protected]]
Sent: Sun 9/7/2008 5:29 PM
To: Victor Gallardo
Cc: [email protected]; Feng Kan
Subject: Re: [PATCH] ibm_newemac: Add support for GPCS, SGMII and M88E1112PHY

Quoted 4 lines · Victor Gallardo

From: Victor Gallardo <[email protected]>

This patch adds GPCS, SGMII and M88E1112 PHY support for the AMCC PPC460GT/EX processors.

So if I understand the patch correctly, either there is an *MII PHY in which case phy_address is used, or there's a GPCS one and phy_address is -1 and gpcs_address is used right ?

Why not instead always use phy_address, and have a flag indicating whether it's an MII or GPCS PHY ? This would avoid the added gpcs_read/write functions, among other things, and I believe would look cleaner... Or am I missing something ?

Cheers,
Ben.

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

#3 lore raw

RE: [PATCH] ibm_newemac: Add support for GPCS, SGMII and M88E1112PHY

Quoted 9 lines · Victor Gallardo

Hello Benjamin,

On the 460EX/GT in SGMII mode, GPCS access is needed for communication with the internal SGMII SerDes. It is possible that there is still a PHY. So we need a way to access both addresses.

For Example on the AMCC Arches Board.

EMAC 0 has only a GPCS PHY (address 0xA)
EMAC 1 has M88E1112 PHY (address 0x0) and GPCS PHY (address 0xB) EMAC 2 has M88E1112 PHY (address 0x1) and GPCS PHY (address 0xC)

Ok. Thanks. I need to review your patch a bit better, hopefully later this week. I'll let you know. Ping me if you get no news by next monday.

Cheers,
Ben.

Quoted 35 lines

Regards,

Victor Gallardo

________________________________

From: Benjamin Herrenschmidt [mailto:[email protected]]
Sent: Sun 9/7/2008 5:29 PM
To: Victor Gallardo
Cc: [email protected]; Feng Kan
Subject: Re: [PATCH] ibm_newemac: Add support for GPCS, SGMII and M88E1112PHY

Quoted 4 lines · Victor Gallardo

From: Victor Gallardo <[email protected]>

This patch adds GPCS, SGMII and M88E1112 PHY support for the AMCC PPC460GT/EX processors.

So if I understand the patch correctly, either there is an *MII PHY in which case phy_address is used, or there's a GPCS one and phy_address is -1 and gpcs_address is used right ?

Why not instead always use phy_address, and have a flag indicating whether it's an MII or GPCS PHY ? This would avoid the added gpcs_read/write functions, among other things, and I believe would look cleaner... Or am I missing something ?

Cheers,
Ben.

#4 lore raw

RE: [PATCH] ibm_newemac: Add support for GPCS, SGMII andM88E1112PHY

Hi Ben,

Quoted 5 lines

Ok. Thanks. I need to review your patch a bit better, hopefully later this week. I'll let you know. Ping me if you get no news by next monday.

Cheers,
Ben.

Have you had a change to look at this patch.

Thanks,

Victor Gallardo