Re: [U-Boot] [PATCH 2/2] net: phy: Add gmiitorgmii converter support

2019-01-25 Thread Michal Simek
On 24. 01. 19 18:24, Joe Hershberger wrote:
> On Thu, Jan 24, 2019 at 2:07 AM Michal Simek  wrote:
>>
>> On 23. 01. 19 19:20, Joe Hershberger wrote:
>>> On Tue, Nov 27, 2018 at 12:20 AM Siva Durga Prasad Paladugu
>>>  wrote:

 This patch adds support for gmiitorgmii converter.
 This converter sits between the MAC and the external phy
 MAC <==> GMII2RGMII <==> RGMII_PHY.
 The ethernet driver probes this bridge and this bridge driver
 probes real phy driver and invokes the real phy functionalities
 as requested. This bridge just needs to be configured based on
 real phy negotiated speed and duplex.

 Signed-off-by: Siva Durga Prasad Paladugu 
 Signed-off-by: Michal Simek 
 ---
>>>
>>> FYI, NI doesn't use the Xilinx adapter, we have several internal
>>> adapters... GMII to RGMII, RMII, and I believe GMII (passing through
>>> EMIO).
>>
>> ok. How do you manage them?
> 
> They are managed by 2 digital lines on EMIO

ok.

>>
>>>
  drivers/net/phy/Kconfig |   7 +++
  drivers/net/phy/Makefile|   1 +
  drivers/net/phy/phy.c   |  41 ++
  drivers/net/phy/xilinx_gmii2rgmii.c | 103 
 
  include/phy.h   |   6 +++
  5 files changed, 158 insertions(+)
  create mode 100644 drivers/net/phy/xilinx_gmii2rgmii.c

 diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
 index 3dc0822..a68e167 100644
 --- a/drivers/net/phy/Kconfig
 +++ b/drivers/net/phy/Kconfig
 @@ -217,6 +217,13 @@ config PHY_VITESSE
  config PHY_XILINX
 bool "Xilinx Ethernet PHYs support"

 +config PHY_XILINX_GMII2RGMII
 +   bool "Xilinx GMII to RGMII Ethernet PHYs support"
 +   help
 + This adds support for Xilinx GMII to RGMII IP core. This IP acts
 + as bridge between MAC connected over GMII and external phy that
 + is connected over RGMII interface.
 +
  config PHY_FIXED
 bool "Fixed-Link PHY"
 depends on DM_ETH
 diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
 index 555da83..76b6197 100644
 --- a/drivers/net/phy/Makefile
 +++ b/drivers/net/phy/Makefile
 @@ -27,6 +27,7 @@ obj-$(CONFIG_PHY_SMSC) += smsc.o
  obj-$(CONFIG_PHY_TERANETICS) += teranetics.o
  obj-$(CONFIG_PHY_TI) += ti.o
  obj-$(CONFIG_PHY_XILINX) += xilinx_phy.o
 +obj-$(CONFIG_PHY_XILINX_GMII2RGMII) += xilinx_gmii2rgmii.o
  obj-$(CONFIG_PHY_VITESSE) += vitesse.o
  obj-$(CONFIG_PHY_MSCC) += mscc.o
  obj-$(CONFIG_PHY_FIXED) += fixed.o
 diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
 index 3cb2785..d02c4d8 100644
 --- a/drivers/net/phy/phy.c
 +++ b/drivers/net/phy/phy.c
 @@ -528,6 +528,9 @@ int phy_init(void)
  #ifdef CONFIG_PHY_FIXED
 phy_fixed_init();
  #endif
 +#ifdef CONFIG_PHY_XILINX_GMII2RGMII
 +   phy_xilinx_gmii2rgmii_init();
 +#endif
>>>
>>> I'm a bit surprised this needs to act as a unique type of device and
>>> not a normal phy driver? When the phy_id is read, what is returned?
>>> The real phy? Nothing? You change the speed by accessing MDIO?
>>
>> It is connected on mdio bus but unfortunately there is no phy_id to read
>> to be able to use that.
>>
>> https://www.xilinx.com/support/documentation/ip_documentation/gmii_to_rgmii/v4_0/pg160-gmii-to-rgmii.pdf
>> page 21
> 
> That's very unfortunate. Is it not something you can have added to the IP?

This is official IP in IP catalog and there is no way to update current
version.


>>>
 return 0;
  }

 @@ -875,6 +878,41 @@ void phy_connect_dev(struct phy_device *phydev, 
 struct eth_device *dev)
 debug("%s connected to %s\n", dev->name, phydev->drv->name);
  }

 +#ifdef CONFIG_PHY_XILINX_GMII2RGMII
 +#ifdef CONFIG_DM_ETH
 +static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
 +struct udevice *dev,
 +phy_interface_t interface)
 +#else
 +static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
 +struct eth_device *dev,
 +phy_interface_t interface)
 +#endif
 +{
 +   struct phy_device *phydev = NULL;
 +   int sn = dev_of_offset(dev);
 +   int off;
 +
 +   while (sn > 0) {
 +   off = fdt_node_offset_by_compatible(gd->fdt_blob, sn,
 +   
 "xlnx,gmii-to-rgmii-1.0");
>>>
>>> This seems to be searching under the eth dev, but at least in the
>>> "linux/Documentation/devicetree/bindings/net/xilinx_gmii2rgmii.txt"
>>> docs, this is found under the mdio node. How is this supposed to
>>> 

Re: [U-Boot] [PATCH 2/2] net: phy: Add gmiitorgmii converter support

2019-01-24 Thread Joe Hershberger
On Thu, Jan 24, 2019 at 2:07 AM Michal Simek  wrote:
>
> On 23. 01. 19 19:20, Joe Hershberger wrote:
> > On Tue, Nov 27, 2018 at 12:20 AM Siva Durga Prasad Paladugu
> >  wrote:
> >>
> >> This patch adds support for gmiitorgmii converter.
> >> This converter sits between the MAC and the external phy
> >> MAC <==> GMII2RGMII <==> RGMII_PHY.
> >> The ethernet driver probes this bridge and this bridge driver
> >> probes real phy driver and invokes the real phy functionalities
> >> as requested. This bridge just needs to be configured based on
> >> real phy negotiated speed and duplex.
> >>
> >> Signed-off-by: Siva Durga Prasad Paladugu 
> >> Signed-off-by: Michal Simek 
> >> ---
> >
> > FYI, NI doesn't use the Xilinx adapter, we have several internal
> > adapters... GMII to RGMII, RMII, and I believe GMII (passing through
> > EMIO).
>
> ok. How do you manage them?

They are managed by 2 digital lines on EMIO
>
> >
> >>  drivers/net/phy/Kconfig |   7 +++
> >>  drivers/net/phy/Makefile|   1 +
> >>  drivers/net/phy/phy.c   |  41 ++
> >>  drivers/net/phy/xilinx_gmii2rgmii.c | 103 
> >> 
> >>  include/phy.h   |   6 +++
> >>  5 files changed, 158 insertions(+)
> >>  create mode 100644 drivers/net/phy/xilinx_gmii2rgmii.c
> >>
> >> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
> >> index 3dc0822..a68e167 100644
> >> --- a/drivers/net/phy/Kconfig
> >> +++ b/drivers/net/phy/Kconfig
> >> @@ -217,6 +217,13 @@ config PHY_VITESSE
> >>  config PHY_XILINX
> >> bool "Xilinx Ethernet PHYs support"
> >>
> >> +config PHY_XILINX_GMII2RGMII
> >> +   bool "Xilinx GMII to RGMII Ethernet PHYs support"
> >> +   help
> >> + This adds support for Xilinx GMII to RGMII IP core. This IP acts
> >> + as bridge between MAC connected over GMII and external phy that
> >> + is connected over RGMII interface.
> >> +
> >>  config PHY_FIXED
> >> bool "Fixed-Link PHY"
> >> depends on DM_ETH
> >> diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
> >> index 555da83..76b6197 100644
> >> --- a/drivers/net/phy/Makefile
> >> +++ b/drivers/net/phy/Makefile
> >> @@ -27,6 +27,7 @@ obj-$(CONFIG_PHY_SMSC) += smsc.o
> >>  obj-$(CONFIG_PHY_TERANETICS) += teranetics.o
> >>  obj-$(CONFIG_PHY_TI) += ti.o
> >>  obj-$(CONFIG_PHY_XILINX) += xilinx_phy.o
> >> +obj-$(CONFIG_PHY_XILINX_GMII2RGMII) += xilinx_gmii2rgmii.o
> >>  obj-$(CONFIG_PHY_VITESSE) += vitesse.o
> >>  obj-$(CONFIG_PHY_MSCC) += mscc.o
> >>  obj-$(CONFIG_PHY_FIXED) += fixed.o
> >> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> >> index 3cb2785..d02c4d8 100644
> >> --- a/drivers/net/phy/phy.c
> >> +++ b/drivers/net/phy/phy.c
> >> @@ -528,6 +528,9 @@ int phy_init(void)
> >>  #ifdef CONFIG_PHY_FIXED
> >> phy_fixed_init();
> >>  #endif
> >> +#ifdef CONFIG_PHY_XILINX_GMII2RGMII
> >> +   phy_xilinx_gmii2rgmii_init();
> >> +#endif
> >
> > I'm a bit surprised this needs to act as a unique type of device and
> > not a normal phy driver? When the phy_id is read, what is returned?
> > The real phy? Nothing? You change the speed by accessing MDIO?
>
> It is connected on mdio bus but unfortunately there is no phy_id to read
> to be able to use that.
>
> https://www.xilinx.com/support/documentation/ip_documentation/gmii_to_rgmii/v4_0/pg160-gmii-to-rgmii.pdf
> page 21

That's very unfortunate. Is it not something you can have added to the IP?

> >
> >> return 0;
> >>  }
> >>
> >> @@ -875,6 +878,41 @@ void phy_connect_dev(struct phy_device *phydev, 
> >> struct eth_device *dev)
> >> debug("%s connected to %s\n", dev->name, phydev->drv->name);
> >>  }
> >>
> >> +#ifdef CONFIG_PHY_XILINX_GMII2RGMII
> >> +#ifdef CONFIG_DM_ETH
> >> +static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
> >> +struct udevice *dev,
> >> +phy_interface_t interface)
> >> +#else
> >> +static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
> >> +struct eth_device *dev,
> >> +phy_interface_t interface)
> >> +#endif
> >> +{
> >> +   struct phy_device *phydev = NULL;
> >> +   int sn = dev_of_offset(dev);
> >> +   int off;
> >> +
> >> +   while (sn > 0) {
> >> +   off = fdt_node_offset_by_compatible(gd->fdt_blob, sn,
> >> +   
> >> "xlnx,gmii-to-rgmii-1.0");
> >
> > This seems to be searching under the eth dev, but at least in the
> > "linux/Documentation/devicetree/bindings/net/xilinx_gmii2rgmii.txt"
> > docs, this is found under the mdio node. How is this supposed to
> > handle more than one bridge?
>
> I haven't seen design with more than one bridge. It is really just one
> brigde which goes to regular phy.

A number of our 

Re: [U-Boot] [PATCH 2/2] net: phy: Add gmiitorgmii converter support

2019-01-24 Thread Michal Simek
On 23. 01. 19 19:20, Joe Hershberger wrote:
> On Tue, Nov 27, 2018 at 12:20 AM Siva Durga Prasad Paladugu
>  wrote:
>>
>> This patch adds support for gmiitorgmii converter.
>> This converter sits between the MAC and the external phy
>> MAC <==> GMII2RGMII <==> RGMII_PHY.
>> The ethernet driver probes this bridge and this bridge driver
>> probes real phy driver and invokes the real phy functionalities
>> as requested. This bridge just needs to be configured based on
>> real phy negotiated speed and duplex.
>>
>> Signed-off-by: Siva Durga Prasad Paladugu 
>> Signed-off-by: Michal Simek 
>> ---
> 
> FYI, NI doesn't use the Xilinx adapter, we have several internal
> adapters... GMII to RGMII, RMII, and I believe GMII (passing through
> EMIO).

ok. How do you manage them?


> 
>>  drivers/net/phy/Kconfig |   7 +++
>>  drivers/net/phy/Makefile|   1 +
>>  drivers/net/phy/phy.c   |  41 ++
>>  drivers/net/phy/xilinx_gmii2rgmii.c | 103 
>> 
>>  include/phy.h   |   6 +++
>>  5 files changed, 158 insertions(+)
>>  create mode 100644 drivers/net/phy/xilinx_gmii2rgmii.c
>>
>> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
>> index 3dc0822..a68e167 100644
>> --- a/drivers/net/phy/Kconfig
>> +++ b/drivers/net/phy/Kconfig
>> @@ -217,6 +217,13 @@ config PHY_VITESSE
>>  config PHY_XILINX
>> bool "Xilinx Ethernet PHYs support"
>>
>> +config PHY_XILINX_GMII2RGMII
>> +   bool "Xilinx GMII to RGMII Ethernet PHYs support"
>> +   help
>> + This adds support for Xilinx GMII to RGMII IP core. This IP acts
>> + as bridge between MAC connected over GMII and external phy that
>> + is connected over RGMII interface.
>> +
>>  config PHY_FIXED
>> bool "Fixed-Link PHY"
>> depends on DM_ETH
>> diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
>> index 555da83..76b6197 100644
>> --- a/drivers/net/phy/Makefile
>> +++ b/drivers/net/phy/Makefile
>> @@ -27,6 +27,7 @@ obj-$(CONFIG_PHY_SMSC) += smsc.o
>>  obj-$(CONFIG_PHY_TERANETICS) += teranetics.o
>>  obj-$(CONFIG_PHY_TI) += ti.o
>>  obj-$(CONFIG_PHY_XILINX) += xilinx_phy.o
>> +obj-$(CONFIG_PHY_XILINX_GMII2RGMII) += xilinx_gmii2rgmii.o
>>  obj-$(CONFIG_PHY_VITESSE) += vitesse.o
>>  obj-$(CONFIG_PHY_MSCC) += mscc.o
>>  obj-$(CONFIG_PHY_FIXED) += fixed.o
>> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
>> index 3cb2785..d02c4d8 100644
>> --- a/drivers/net/phy/phy.c
>> +++ b/drivers/net/phy/phy.c
>> @@ -528,6 +528,9 @@ int phy_init(void)
>>  #ifdef CONFIG_PHY_FIXED
>> phy_fixed_init();
>>  #endif
>> +#ifdef CONFIG_PHY_XILINX_GMII2RGMII
>> +   phy_xilinx_gmii2rgmii_init();
>> +#endif
> 
> I'm a bit surprised this needs to act as a unique type of device and
> not a normal phy driver? When the phy_id is read, what is returned?
> The real phy? Nothing? You change the speed by accessing MDIO?

It is connected on mdio bus but unfortunately there is no phy_id to read
to be able to use that.

https://www.xilinx.com/support/documentation/ip_documentation/gmii_to_rgmii/v4_0/pg160-gmii-to-rgmii.pdf
page 21


> 
>> return 0;
>>  }
>>
>> @@ -875,6 +878,41 @@ void phy_connect_dev(struct phy_device *phydev, struct 
>> eth_device *dev)
>> debug("%s connected to %s\n", dev->name, phydev->drv->name);
>>  }
>>
>> +#ifdef CONFIG_PHY_XILINX_GMII2RGMII
>> +#ifdef CONFIG_DM_ETH
>> +static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
>> +struct udevice *dev,
>> +phy_interface_t interface)
>> +#else
>> +static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
>> +struct eth_device *dev,
>> +phy_interface_t interface)
>> +#endif
>> +{
>> +   struct phy_device *phydev = NULL;
>> +   int sn = dev_of_offset(dev);
>> +   int off;
>> +
>> +   while (sn > 0) {
>> +   off = fdt_node_offset_by_compatible(gd->fdt_blob, sn,
>> +   
>> "xlnx,gmii-to-rgmii-1.0");
> 
> This seems to be searching under the eth dev, but at least in the
> "linux/Documentation/devicetree/bindings/net/xilinx_gmii2rgmii.txt"
> docs, this is found under the mdio node. How is this supposed to
> handle more than one bridge?

I haven't seen design with more than one bridge. It is really just one
brigde which goes to regular phy.

Regarding mdio and DT binding. I haven't seen anywhere written if phys
should be inside mdio node or they should be just child in controller node.

I see some examples where mdio node needs to contain compatibility
string and there is separate driver for that.

In dt spec nothing is written about it and also I haven't seen yaml
checking from Rob.

The key point for example is to show how bridge needs description for

Re: [U-Boot] [PATCH 2/2] net: phy: Add gmiitorgmii converter support

2019-01-23 Thread Joe Hershberger
On Tue, Nov 27, 2018 at 12:20 AM Siva Durga Prasad Paladugu
 wrote:
>
> This patch adds support for gmiitorgmii converter.
> This converter sits between the MAC and the external phy
> MAC <==> GMII2RGMII <==> RGMII_PHY.
> The ethernet driver probes this bridge and this bridge driver
> probes real phy driver and invokes the real phy functionalities
> as requested. This bridge just needs to be configured based on
> real phy negotiated speed and duplex.
>
> Signed-off-by: Siva Durga Prasad Paladugu 
> Signed-off-by: Michal Simek 
> ---

FYI, NI doesn't use the Xilinx adapter, we have several internal
adapters... GMII to RGMII, RMII, and I believe GMII (passing through
EMIO).

>  drivers/net/phy/Kconfig |   7 +++
>  drivers/net/phy/Makefile|   1 +
>  drivers/net/phy/phy.c   |  41 ++
>  drivers/net/phy/xilinx_gmii2rgmii.c | 103 
> 
>  include/phy.h   |   6 +++
>  5 files changed, 158 insertions(+)
>  create mode 100644 drivers/net/phy/xilinx_gmii2rgmii.c
>
> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
> index 3dc0822..a68e167 100644
> --- a/drivers/net/phy/Kconfig
> +++ b/drivers/net/phy/Kconfig
> @@ -217,6 +217,13 @@ config PHY_VITESSE
>  config PHY_XILINX
> bool "Xilinx Ethernet PHYs support"
>
> +config PHY_XILINX_GMII2RGMII
> +   bool "Xilinx GMII to RGMII Ethernet PHYs support"
> +   help
> + This adds support for Xilinx GMII to RGMII IP core. This IP acts
> + as bridge between MAC connected over GMII and external phy that
> + is connected over RGMII interface.
> +
>  config PHY_FIXED
> bool "Fixed-Link PHY"
> depends on DM_ETH
> diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
> index 555da83..76b6197 100644
> --- a/drivers/net/phy/Makefile
> +++ b/drivers/net/phy/Makefile
> @@ -27,6 +27,7 @@ obj-$(CONFIG_PHY_SMSC) += smsc.o
>  obj-$(CONFIG_PHY_TERANETICS) += teranetics.o
>  obj-$(CONFIG_PHY_TI) += ti.o
>  obj-$(CONFIG_PHY_XILINX) += xilinx_phy.o
> +obj-$(CONFIG_PHY_XILINX_GMII2RGMII) += xilinx_gmii2rgmii.o
>  obj-$(CONFIG_PHY_VITESSE) += vitesse.o
>  obj-$(CONFIG_PHY_MSCC) += mscc.o
>  obj-$(CONFIG_PHY_FIXED) += fixed.o
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 3cb2785..d02c4d8 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -528,6 +528,9 @@ int phy_init(void)
>  #ifdef CONFIG_PHY_FIXED
> phy_fixed_init();
>  #endif
> +#ifdef CONFIG_PHY_XILINX_GMII2RGMII
> +   phy_xilinx_gmii2rgmii_init();
> +#endif

I'm a bit surprised this needs to act as a unique type of device and
not a normal phy driver? When the phy_id is read, what is returned?
The real phy? Nothing? You change the speed by accessing MDIO?

> return 0;
>  }
>
> @@ -875,6 +878,41 @@ void phy_connect_dev(struct phy_device *phydev, struct 
> eth_device *dev)
> debug("%s connected to %s\n", dev->name, phydev->drv->name);
>  }
>
> +#ifdef CONFIG_PHY_XILINX_GMII2RGMII
> +#ifdef CONFIG_DM_ETH
> +static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
> +struct udevice *dev,
> +phy_interface_t interface)
> +#else
> +static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
> +struct eth_device *dev,
> +phy_interface_t interface)
> +#endif
> +{
> +   struct phy_device *phydev = NULL;
> +   int sn = dev_of_offset(dev);
> +   int off;
> +
> +   while (sn > 0) {
> +   off = fdt_node_offset_by_compatible(gd->fdt_blob, sn,
> +   "xlnx,gmii-to-rgmii-1.0");

This seems to be searching under the eth dev, but at least in the
"linux/Documentation/devicetree/bindings/net/xilinx_gmii2rgmii.txt"
docs, this is found under the mdio node. How is this supposed to
handle more than one bridge?

> +   if (off > 0) {
> +   phydev = phy_device_create(bus,
> +  off, PHY_GMII2RGMII_ID,
> +  interface);
> +   break;
> +   }
> +   if (off == -FDT_ERR_NOTFOUND)
> +   sn = fdt_first_subnode(gd->fdt_blob, sn);
> +   else
> +   printf("%s: Error finding compat string:%d\n",
> +  __func__, off);
> +   }
> +
> +   return phydev;
> +}
> +#endif
> +
>  #ifdef CONFIG_PHY_FIXED
>  #ifdef CONFIG_DM_ETH
>  static struct phy_device *phy_connect_fixed(struct mii_dev *bus,
> @@ -920,6 +958,9 @@ struct phy_device *phy_connect(struct mii_dev *bus, int 
> addr,
>  #ifdef CONFIG_PHY_FIXED
> phydev = phy_connect_fixed(bus, dev, interface);
>  #endif
> +#ifdef 

Re: [U-Boot] [PATCH 2/2] net: phy: Add gmiitorgmii converter support

2018-12-20 Thread Michal Simek
On 27. 11. 18 7:19, Siva Durga Prasad Paladugu wrote:
> This patch adds support for gmiitorgmii converter.
> This converter sits between the MAC and the external phy
> MAC <==> GMII2RGMII <==> RGMII_PHY.
> The ethernet driver probes this bridge and this bridge driver
> probes real phy driver and invokes the real phy functionalities
> as requested. This bridge just needs to be configured based on
> real phy negotiated speed and duplex.
> 
> Signed-off-by: Siva Durga Prasad Paladugu 
> Signed-off-by: Michal Simek 
> ---
>  drivers/net/phy/Kconfig |   7 +++
>  drivers/net/phy/Makefile|   1 +
>  drivers/net/phy/phy.c   |  41 ++
>  drivers/net/phy/xilinx_gmii2rgmii.c | 103 
> 
>  include/phy.h   |   6 +++
>  5 files changed, 158 insertions(+)
>  create mode 100644 drivers/net/phy/xilinx_gmii2rgmii.c
> 
> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
> index 3dc0822..a68e167 100644
> --- a/drivers/net/phy/Kconfig
> +++ b/drivers/net/phy/Kconfig
> @@ -217,6 +217,13 @@ config PHY_VITESSE
>  config PHY_XILINX
>   bool "Xilinx Ethernet PHYs support"
>  
> +config PHY_XILINX_GMII2RGMII
> + bool "Xilinx GMII to RGMII Ethernet PHYs support"
> + help
> +   This adds support for Xilinx GMII to RGMII IP core. This IP acts
> +   as bridge between MAC connected over GMII and external phy that
> +   is connected over RGMII interface.
> +
>  config PHY_FIXED
>   bool "Fixed-Link PHY"
>   depends on DM_ETH
> diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
> index 555da83..76b6197 100644
> --- a/drivers/net/phy/Makefile
> +++ b/drivers/net/phy/Makefile
> @@ -27,6 +27,7 @@ obj-$(CONFIG_PHY_SMSC) += smsc.o
>  obj-$(CONFIG_PHY_TERANETICS) += teranetics.o
>  obj-$(CONFIG_PHY_TI) += ti.o
>  obj-$(CONFIG_PHY_XILINX) += xilinx_phy.o
> +obj-$(CONFIG_PHY_XILINX_GMII2RGMII) += xilinx_gmii2rgmii.o
>  obj-$(CONFIG_PHY_VITESSE) += vitesse.o
>  obj-$(CONFIG_PHY_MSCC) += mscc.o
>  obj-$(CONFIG_PHY_FIXED) += fixed.o
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 3cb2785..d02c4d8 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -528,6 +528,9 @@ int phy_init(void)
>  #ifdef CONFIG_PHY_FIXED
>   phy_fixed_init();
>  #endif
> +#ifdef CONFIG_PHY_XILINX_GMII2RGMII
> + phy_xilinx_gmii2rgmii_init();
> +#endif
>   return 0;
>  }
>  
> @@ -875,6 +878,41 @@ void phy_connect_dev(struct phy_device *phydev, struct 
> eth_device *dev)
>   debug("%s connected to %s\n", dev->name, phydev->drv->name);
>  }
>  
> +#ifdef CONFIG_PHY_XILINX_GMII2RGMII
> +#ifdef CONFIG_DM_ETH
> +static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
> +  struct udevice *dev,
> +  phy_interface_t interface)
> +#else
> +static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
> +  struct eth_device *dev,
> +  phy_interface_t interface)
> +#endif
> +{
> + struct phy_device *phydev = NULL;
> + int sn = dev_of_offset(dev);
> + int off;
> +
> + while (sn > 0) {
> + off = fdt_node_offset_by_compatible(gd->fdt_blob, sn,
> + "xlnx,gmii-to-rgmii-1.0");
> + if (off > 0) {
> + phydev = phy_device_create(bus,
> +off, PHY_GMII2RGMII_ID,
> +interface);
> + break;
> + }
> + if (off == -FDT_ERR_NOTFOUND)
> + sn = fdt_first_subnode(gd->fdt_blob, sn);
> + else
> + printf("%s: Error finding compat string:%d\n",
> +__func__, off);
> + }
> +
> + return phydev;
> +}
> +#endif
> +
>  #ifdef CONFIG_PHY_FIXED
>  #ifdef CONFIG_DM_ETH
>  static struct phy_device *phy_connect_fixed(struct mii_dev *bus,
> @@ -920,6 +958,9 @@ struct phy_device *phy_connect(struct mii_dev *bus, int 
> addr,
>  #ifdef CONFIG_PHY_FIXED
>   phydev = phy_connect_fixed(bus, dev, interface);
>  #endif
> +#ifdef CONFIG_PHY_XILINX_GMII2RGMII
> + phydev = phy_connect_gmii2rgmii(bus, dev, interface);
> +#endif

I was debugging one issue in connection to fixed-link phy and I think we
should try to connect gmii2rgmii if phydev is NULL.

It means this should be

#ifdef CONFIG_PHY_XILINX_GMII2RGMII
if (!phydev)
phydev = phy_connect_gmii2rgmii(bus, dev, interface);
#endif

Thanks,
Michal
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot