[U-Boot] [RFC PATCH 3/3] phylib: add generic phy driver

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Wed Aug 26 22:13:03 CEST 2009


this driver must be the last one registered to be the last one probed

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/phy/Makefile  |    1 +
 drivers/net/phy/generic.c |   35 +++++++++++++++++++++++++++++++++++
 drivers/net/phy/phylib.c  |    8 ++++++++
 include/phydev.h          |    5 +++++
 4 files changed, 49 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/phy/generic.c

diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index c8abc21..987504f 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	:= $(obj)libphy.a
 
+COBJS-$(CONFIG_PHY_GENERIC) += generic.o
 COBJS-$(CONFIG_BITBANGMII) += miiphybb.o
 COBJS-$(CONFIG_MV88E61XX_SWITCH) += mv88e61xx.o
 COBJS-$(CONFIG_MII) += miidev.o
diff --git a/drivers/net/phy/generic.c b/drivers/net/phy/generic.c
new file mode 100644
index 0000000..0d8f69c
--- /dev/null
+++ b/drivers/net/phy/generic.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+#include <common.h>
+#include <phydev.h>
+
+void generic_phy_register(void)
+{
+	struct phy_driver generic_phy = {
+		.name = "Generic PHY",
+		.phy_id = 0xffffffff,
+		.phy_id_mask = 0xffffffff,
+		.features = 0,
+		.config_init = generic_phy_init,
+	};
+
+	phy_driver_register(&generic_phy);
+}
diff --git a/drivers/net/phy/phylib.c b/drivers/net/phy/phylib.c
index 100c6c5..e6d1b8c 100644
--- a/drivers/net/phy/phylib.c
+++ b/drivers/net/phy/phylib.c
@@ -52,6 +52,14 @@ int phy_init(void)
 	/* Initialize the list */
 	INIT_LIST_HEAD(&phy_drvs.list);
 
+	/*
+	 * this generic phy driver must be the last one registered to be
+	 * the last one probed
+	 */
+#ifdef CONFIG_PHY_GENERIC
+	generic_phy_register();
+#endif
+
 	return 0;
 }
 
diff --git a/include/phydev.h b/include/phydev.h
index b15e138..fb06142 100644
--- a/include/phydev.h
+++ b/include/phydev.h
@@ -116,4 +116,9 @@ int genphy_restart_aneg(struct phy_device *phydev);
 int genphy_setup_forced(struct phy_device *phydev);
 int genphy_update_link(struct phy_device *phydev);
 
+/*
+ * Phy register functions
+ */
+void generic_phy_register(void);
+
 #endif /* __PHYDEV_H__ */
-- 
1.6.3.1



More information about the U-Boot mailing list