[U-Boot] [PATCH] net: Add fixed phy driver

Christian Gmeiner christian.gmeiner at gmail.com
Mon Sep 2 14:28:11 CEST 2013


This patch is needed if the MAC is directly connected to a ethernet switch.
In my case the FEC MAC is connected to a Micrel KSZ8895. All I need to to
is configure my fixed phy/link like:

Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
---
 drivers/net/phy/Makefile |    1 +
 drivers/net/phy/fixed.c  |   34 ++++++++++++++++++++++++++++++++++
 drivers/net/phy/phy.c    |    3 +++
 3 files changed, 38 insertions(+)
 create mode 100644 drivers/net/phy/fixed.c

diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index fe762e9..17e486f 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -19,6 +19,7 @@ COBJS-$(CONFIG_PHY_ATHEROS) += atheros.o
 COBJS-$(CONFIG_PHY_BROADCOM) += broadcom.o
 COBJS-$(CONFIG_PHY_DAVICOM) += davicom.o
 COBJS-$(CONFIG_PHY_ET1011C) += et1011c.o
+COBJS-$(CONFIG_PHY_FIXED) += fixed.o
 COBJS-$(CONFIG_PHY_ICPLUS) += icplus.o
 COBJS-$(CONFIG_PHY_LXT) += lxt.o
 COBJS-$(CONFIG_PHY_MARVELL) += marvell.o
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
new file mode 100644
index 0000000..70ff7bb
--- /dev/null
+++ b/drivers/net/phy/fixed.c
@@ -0,0 +1,34 @@
+/*
+ * Fixed PHY driver
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ * Copyright 2013 Bachmann electronic GmbH
+ * author Gmeiner Christian
+  */
+#include <config.h>
+#include <common.h>
+#include <phy.h>
+
+int fixed_config(struct phy_device *phydev)
+{
+	phydev->link = 1;
+	phydev->duplex = CONFIG_PHY_FIXED_SPEED;
+	phydev->speed = CONFIG_PHY_FIXED_DUPLEX;
+
+	return 0;
+}
+
+static struct phy_driver fixed_driver = {
+	.uid  = 0xffffffff,
+	.mask = 0x00000000,
+	.name = "Fixed PHY",
+	.features = 0,
+	.config   = &fixed_config,
+};
+
+int phy_fixed_init(void)
+{
+	phy_register(&fixed_driver);
+	return 0;
+}
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 62925bb..f2bccaf 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -479,6 +479,9 @@ int phy_init(void)
 #ifdef CONFIG_PHY_VITESSE
 	phy_vitesse_init();
 #endif
+#ifdef CONFIG_PHY_FIXED
+	phy_fixed_init();
+#endif
 
 	return 0;
 }
-- 
1.7.10.4



More information about the U-Boot mailing list