Skip to contentSkip to conversation

powerpc: 83xx: support for the SMSC LAN8700 PHY

PATCH Superseded Heiko Schocher 2 participants 2 messages Nov 19, 2008 – Nov 20, 2008

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/5 powerpc: 83xx: support for the SMSC LAN8700 PHY

---

changes since v1:

- rebased against current HEAD
commit e0b0ec843085f96f4fe0738424835ee90e58bc00

 drivers/qe/uec_phy.c |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)
drivers/qe/uec_phy.c +59 -0
index 829f082..13f3d1a 100644
@@ -603,6 +603,55 @@ static int fixed_phy_read_status (struct uec_mii_info *mii_info)
 	return 0;
 }
 
+static int smsc_config_aneg (struct uec_mii_info *mii_info)
+{
+	return 0;
+}
+
+static int smsc_read_status (struct uec_mii_info *mii_info)
+{
+	u16 status;
+	int err;
+
+	/* Update the link, but return if there
+	 * was an error */
+	err = genmii_update_link (mii_info);
+	if (err)
+		return err;
+
+	/* If the link is up, read the speed and duplex */
+	/* If we aren't autonegotiating, assume speeds
+	 * are as set */
+	if (mii_info->autoneg && mii_info->link) {
+		int	val;
+
+		status = phy_read (mii_info, 0x1f);
+		val = (status & 0x1c) >> 2;
+		
+		switch (val) {
+			case 1:
+				mii_info->duplex = DUPLEX_HALF;
+				mii_info->speed = SPEED_10;
+				break;
+			case 5:
+				mii_info->duplex = DUPLEX_FULL;
+				mii_info->speed = SPEED_10;
+				break;
+			case 2:
+				mii_info->duplex = DUPLEX_HALF;
+				mii_info->speed = SPEED_100;
+				break;
+			case 6:
+				mii_info->duplex = DUPLEX_FULL;
+				mii_info->speed = SPEED_100;
+				break;
+		}
+		mii_info->pause = 0;
+	}
+
+	return 0;
+}
+
 static struct phy_info phy_info_dm9161 = {
 	.phy_id = 0x0181b880,
 	.phy_id_mask = 0x0ffffff0,
@@ -655,6 +704,15 @@ static struct phy_info phy_info_fixedphy = {
 	.read_status = fixed_phy_read_status,
 };
 
+static struct phy_info phy_info_smsclan8700 = {
+	.phy_id = 0x0007c0c0,
+	.phy_id_mask = 0xfffffff0,
+	.name = "SMSC LAN",
+	.features = MII_BASIC_FEATURES,
+	.config_aneg = smsc_config_aneg,
+	.read_status = smsc_read_status,
+};
+
 static struct phy_info phy_info_genmii = {
 	.phy_id = 0x00000000,
 	.phy_id_mask = 0x00000000,
@@ -670,6 +728,7 @@ static struct phy_info *phy_info[] = {
 	&phy_info_marvell,
 	&phy_info_bcm5481,
 	&phy_info_fixedphy,
+	&phy_info_smsclan8700,
 	&phy_info_genmii,
 	NULL
 };
Signature · 5 lines
1.5.6.1

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#1 lore raw

PATCH v2 1/5 powerpc: 83xx: support for the SMSC LAN8700 PHY

On Wed, 19 Nov 2008 10:09:38 +0100
Heiko Schocher <[email protected]> wrote:

Hello Heiko,

Quoted 5 lines

- rebased against current HEAD
commit e0b0ec843085f96f4fe0738424835ee90e58bc00

 drivers/qe/uec_phy.c |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)

sorry for the late reply, this looks like it's subject prefix should be "net:" and this patch go through Ben Warren (net maintainer), since there's really nothing 83xx specific in here.

it looks all good except for the two comments I have below.

drivers/qe/uec_phy.c static struct phy_info phy_info_fixedphy = { · line 710

Quoted 4 lines
drivers/qe/uec_phy.c +4 -0
+static struct phy_info phy_info_smsclan8700 = {
+	.phy_id = 0x0007c0c0,
+	.phy_id_mask = 0xfffffff0,
+	.name = "SMSC LAN",

"SMSC LAN8700" (because there are other SMSC LAN PHYs with different phy_id's for that mask).

drivers/qe/uec_phy.c static struct phy_info *phy_info[] = { · line 733

Quoted 7 lines
drivers/qe/uec_phy.c +1 -0
@@ -670,6 +728,7 @@ static struct phy_info *phy_info[] = {
 	&phy_info_marvell,
 	&phy_info_bcm5481,
 	&phy_info_fixedphy,
+	&phy_info_smsclan8700,
 	&phy_info_genmii,
 	NULL

if I'm not mistaken, I believe the smsclan8700 entries here should precede the fixedphy implementation (both in the phy_info list here, and for each of the chunks above, to maintain a consistent intra-file order). The reason is that if you have a board with both a smsclan8700 phy and a fixedphy (or with a use for fixedphy), uec_get_phy_info will fail to match on the smsclan8700, since the phy_info list is processed in order and will stop before the smsclan8700 because it matched the fixedphy entry first. I believe that's the case, although I could be wrong - I've never set up and run a fixed phy.

Kim