Patchwork [U-Boot,v2] net: Add fixed phy driver

login
register
mail settings
Submitter Christian Gmeiner
Date Sept. 2, 2013, 12:30 p.m.
Message ID <1378125001-27222-1-git-send-email-christian.gmeiner@gmail.com>
Download mbox | patch
Permalink /patch/271920/
State Changes Requested
Delegated to: Joe Hershberger
Headers show

Comments

Christian Gmeiner - Sept. 2, 2013, 12:30 p.m.
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:

#define IMX_FEC_BASE                    ENET_BASE_ADDR
#define CONFIG_FEC_XCV_TYPE             MII100
#define CONFIG_ETHPRIME                 "FEC"
#define CONFIG_FEC_MXC_PHYADDR          0x5
#define CONFIG_PHYLIB
#define CONFIG_PHY_FIXED
#define CONFIG_PHY_FIXED_SPEED		SPEED_100
#define CONFIG_PHY_FIXED_DUPLEX		DUPLEX_FULL

Signed-off-by: Christian Gmeiner <christian.gmeiner@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
Andy Fleming - Sept. 3, 2013, 1:16 a.m.
On Mon, Sep 2, 2013 at 7:30 AM, Christian Gmeiner <
christian.gmeiner@gmail.com> wrote:

> 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:
>
> #define IMX_FEC_BASE                    ENET_BASE_ADDR
> #define CONFIG_FEC_XCV_TYPE             MII100
> #define CONFIG_ETHPRIME                 "FEC"
> #define CONFIG_FEC_MXC_PHYADDR          0x5
> #define CONFIG_PHYLIB
> #define CONFIG_PHY_FIXED
> #define CONFIG_PHY_FIXED_SPEED          SPEED_100
> #define CONFIG_PHY_FIXED_DUPLEX         DUPLEX_FULL
>
> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
>

This doesn't work very well if you ever have more than one switch, or need
more than one fixed link for some other reason. It needs to be possible to
instantiate the fixed PHY interface(s) at runtime, IMO.

Andy
Joe Hershberger - Nov. 21, 2013, 7:02 p.m.
Hi Christian / Andy,

On Mon, Sep 2, 2013 at 8:16 PM, Andy Fleming <afleming@gmail.com> wrote:
> On Mon, Sep 2, 2013 at 7:30 AM, Christian Gmeiner <
> christian.gmeiner@gmail.com> wrote:
>
>> 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:
>>
>> #define IMX_FEC_BASE                    ENET_BASE_ADDR
>> #define CONFIG_FEC_XCV_TYPE             MII100
>> #define CONFIG_ETHPRIME                 "FEC"
>> #define CONFIG_FEC_MXC_PHYADDR          0x5
>> #define CONFIG_PHYLIB
>> #define CONFIG_PHY_FIXED
>> #define CONFIG_PHY_FIXED_SPEED          SPEED_100
>> #define CONFIG_PHY_FIXED_DUPLEX         DUPLEX_FULL
>>
>> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
>>
>
> This doesn't work very well if you ever have more than one switch, or need
> more than one fixed link for some other reason. It needs to be possible to
> instantiate the fixed PHY interface(s) at runtime, IMO.

Do you plan to implement this in a more flexible way?

Thanks,
-Joe
Christian Gmeiner - Dec. 10, 2013, 10:21 a.m.
Hi Joe

> On Mon, Sep 2, 2013 at 8:16 PM, Andy Fleming <afleming@gmail.com> wrote:
>> On Mon, Sep 2, 2013 at 7:30 AM, Christian Gmeiner <
>> christian.gmeiner@gmail.com> wrote:
>>
>>> 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:
>>>
>>> #define IMX_FEC_BASE                    ENET_BASE_ADDR
>>> #define CONFIG_FEC_XCV_TYPE             MII100
>>> #define CONFIG_ETHPRIME                 "FEC"
>>> #define CONFIG_FEC_MXC_PHYADDR          0x5
>>> #define CONFIG_PHYLIB
>>> #define CONFIG_PHY_FIXED
>>> #define CONFIG_PHY_FIXED_SPEED          SPEED_100
>>> #define CONFIG_PHY_FIXED_DUPLEX         DUPLEX_FULL
>>>
>>> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
>>>
>>
>> This doesn't work very well if you ever have more than one switch, or need
>> more than one fixed link for some other reason. It needs to be possible to
>> instantiate the fixed PHY interface(s) at runtime, IMO.
>
> Do you plan to implement this in a more flexible way?
>

I am working on the final version of u-boot for two devices. If i
still need it to get networking
running I will send a patch.


greets
--
Christian Gmeiner, MSc

Patch

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;
 }