[PATCH] phylib: Add support for the LXT973 phy.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Richard Cochran
Date: Monday, May 31, 2010 - 6:09 am

This patch implements a work around for Erratum 5, "3.3 V Fiber Speed
Selection." If the hardware wiring does not respect this erratum, then
fiber optic mode will not work properly.

Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
---
 drivers/net/phy/lxt.c |   51 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 50 insertions(+), 1 deletions(-)

diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c
index 057ecaa..c3de582 100644
--- a/drivers/net/phy/lxt.c
+++ b/drivers/net/phy/lxt.c
@@ -53,6 +53,9 @@
 
 #define MII_LXT971_ISR		19  /* Interrupt Status Register */
 
+/* register definitions for the 973 */
+#define MII_LXT973_PCR 16 /* Port Configuration Register */
+#define PCR_FIBER_SELECT 1
 
 MODULE_DESCRIPTION("Intel LXT PHY driver");
 MODULE_AUTHOR("Andy Fleming");
@@ -119,6 +122,33 @@ static int lxt971_config_intr(struct phy_device *phydev)
 	return err;
 }
 
+static int lxt973_probe(struct phy_device *phydev)
+{
+	int val = phy_read(phydev, MII_LXT973_PCR);
+
+	if (val & PCR_FIBER_SELECT) {
+		/*
+		 * If fiber is selected, then the only correct setting
+		 * is 100Mbps, full duplex, and auto negotiation off.
+		 */
+		val = phy_read(phydev, MII_BMCR);
+		val |= (BMCR_SPEED100 | BMCR_FULLDPLX);
+		val &= ~BMCR_ANENABLE;
+		phy_write(phydev, MII_BMCR, val);
+		/* Remember that the port is in fiber mode. */
+		phydev->priv = lxt973_probe;
+	} else {
+		phydev->priv = NULL;
+	}
+	return 0;
+}
+
+static int lxt973_config_aneg(struct phy_device *phydev)
+{
+	/* Do nothing if port is in fiber mode. */
+	return phydev->priv ? 0 : genphy_config_aneg(phydev);
+}
+
 static struct phy_driver lxt970_driver = {
 	.phy_id		= 0x78100000,
 	.name		= "LXT970",
@@ -146,6 +176,18 @@ static struct phy_driver lxt971_driver = {
 	.driver 	= { .owner = THIS_MODULE,},
 };
 
+static struct phy_driver lxt973_driver = {
+	.phy_id		= 0x00137a10,
+	.name		= "LXT973",
+	.phy_id_mask	= 0xfffffff0,
+	.features	= PHY_BASIC_FEATURES,
+	.flags		= 0,
+	.probe		= lxt973_probe,
+	.config_aneg	= lxt973_config_aneg,
+	.read_status	= genphy_read_status,
+	.driver 	= { .owner = THIS_MODULE,},
+};
+
 static int __init lxt_init(void)
 {
 	int ret;
@@ -157,9 +199,15 @@ static int __init lxt_init(void)
 	ret = phy_driver_register(&lxt971_driver);
 	if (ret)
 		goto err2;
+
+	ret = phy_driver_register(&lxt973_driver);
+	if (ret)
+		goto err3;
 	return 0;
 
- err2:	
+ err3:
+	phy_driver_unregister(&lxt971_driver);
+ err2:
 	phy_driver_unregister(&lxt970_driver);
  err1:
 	return ret;
@@ -169,6 +217,7 @@ static void __exit lxt_exit(void)
 {
 	phy_driver_unregister(&lxt970_driver);
 	phy_driver_unregister(&lxt971_driver);
+	phy_driver_unregister(&lxt973_driver);
 }
 
 module_init(lxt_init);
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] phylib: Add support for the LXT973 phy., Richard Cochran, (Mon May 31, 6:09 am)
Re: [PATCH] phylib: Add support for the LXT973 phy., Andy Fleming, (Tue Jun 1, 3:39 pm)
Re: [PATCH] phylib: Add support for the LXT973 phy., Richard Cochran, (Wed Jun 2, 5:55 am)
Re: [PATCH] phylib: Add support for the LXT973 phy., Richard Cochran, (Wed Jun 2, 6:07 am)
Re: [PATCH] phylib: Add support for the LXT973 phy., David Miller, (Wed Jun 2, 6:50 am)
Re: [PATCH] phylib: Add support for the LXT973 phy., Richard Cochran, (Wed Jun 2, 8:08 am)
Re: [PATCH] phylib: Add support for the LXT973 phy., David Miller, (Wed Jun 2, 8:15 am)
Re: [PATCH] phylib: Add support for the LXT973 phy., Andy Fleming, (Wed Jun 2, 12:32 pm)
Re: [PATCH] phylib: Add support for the LXT973 phy., Richard Cochran, (Thu Jun 3, 4:28 am)
Re: [PATCH] phylib: Add support for the LXT973 phy., Richard Cochran, (Sat Jun 5, 7:00 am)
Re: [PATCH] phylib: Add support for the LXT973 phy., David Miller, (Mon Jun 7, 1:18 am)
Re: [PATCH] phylib: Add support for the LXT973 phy., Andy Fleming, (Mon Jun 7, 8:39 am)
Re: [PATCH] phylib: Add support for the LXT973 phy., Richard Cochran, (Mon Jun 7, 8:39 am)
Re: [PATCH] phylib: Add support for the LXT973 phy., David Miller, (Wed Jun 9, 4:17 pm)
[PATCH] phylib: Add autoload support for the LXT973 phy., David Woodhouse, (Tue Jun 22, 5:38 am)
Re: [PATCH] phylib: Add autoload support for the LXT973 phy., Richard Cochran, (Tue Jun 22, 10:37 pm)
Re: [PATCH] phylib: Add autoload support for the LXT973 phy., David Woodhouse, (Wed Jun 23, 2:00 am)