RE: [RFC PATCH] net: macb: Add gmii2rgmii converter support
Hi Florian, Thanks for the quick response... > > On June 19, 2016 10:27:17 PM MST, Kedareswara rao Appana >wrote: > >This patch adds support for gmii2rgmii converter in the macb driver. > > > >The GMII to RGMII IP core provides the > >Reduced Gigabit Media Independent Interface > >(RGMII) between Ethernet physical media devices And the Gigabit > >Ethernet controller. > >This core can switch dynamically between the Three different speed > >modes of operation (10/100/1000 Mb/s). > >MDIO interface is used to set operating speed of Ethernet MAC. > > > >Signed-off-by: Kedareswara rao Appana > >--- > >--> Tried to include this Coverter support in the > >PHY layer but it won't fit into the PHY framework as the coverter won't > >have vaild vendor/Device id registers. > >--> The Converter has only one register (16) that need's > >to be programmed with the external phy negotiated speed. > >--> The converter won't follow the Standard MII(ieee 802.3 clause 22). > >--> Will appreciate if someone can help on adding this coverter support > > With the fixed PHY emulated PHY and registering a link_update callback (see > drivers/net/dsa/bcm_sf2.c for an example), you could read specific registers > which indicates link parameters and update the PHY device with these. Thanks will check and get back... > > How exactly is this converter working? This converter does GMII to RGMII conversion. It provides only one register for programing the desired speed and MDIO is Interface to program this register. It sits between the mac and external phy. So, once the phy negotiation completes and link is up, The negotiated speed should be programmed in the converter. Converter data sheet: http://www.xilinx.com/support/documentation/ip_documentation/gmii_to_rgmii/v3_0/pg160-gmii-to-rgmii.pdf Regards, Kedar. > > -- > Florian
Re: [RFC PATCH] net: macb: Add gmii2rgmii converter support
On Mon, 2016-06-20 at 10:57 +0530, Kedareswara rao Appana wrote: > This patch adds support for gmii2rgmii converter > in the macb driver. [] > diff --git a/drivers/net/ethernet/cadence/macb.c > b/drivers/net/ethernet/cadence/macb.c [] > @@ -376,6 +389,20 @@ static int macb_mii_probe(struct net_device *dev) > int phy_irq; > int ret; > > + if (bp->gmii2rgmii_phy_node) { > + phydev = of_phy_attach(bp->dev, > + bp->gmii2rgmii_phy_node, > + 0, 0); > + if (!phydev) { > + dev_err(>pdev->dev, "%s: no gmii_to_rgmii found\n", > + dev->name); why use dev_err(>pdev->dev, ...) and not netdev_err(dev, ...) ?
[RFC PATCH] net: macb: Add gmii2rgmii converter support
This patch adds support for gmii2rgmii converter in the macb driver. The GMII to RGMII IP core provides the Reduced Gigabit Media Independent Interface (RGMII) between Ethernet physical media devices And the Gigabit Ethernet controller. This core can switch dynamically between the Three different speed modes of operation (10/100/1000 Mb/s). MDIO interface is used to set operating speed of Ethernet MAC. Signed-off-by: Kedareswara rao Appana--- --> Tried to include this Coverter support in the PHY layer but it won't fit into the PHY framework as the coverter won't have vaild vendor/Device id registers. --> The Converter has only one register (16) that need's to be programmed with the external phy negotiated speed. --> The converter won't follow the Standard MII(ieee 802.3 clause 22). --> Will appreciate if someone can help on adding this coverter support drivers/net/ethernet/cadence/macb.c | 37 -- drivers/net/ethernet/cadence/macb.h |7 ++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index cb07d95..2b6412a 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c @@ -305,8 +305,10 @@ static void macb_handle_link_change(struct net_device *dev) { struct macb *bp = netdev_priv(dev); struct phy_device *phydev = bp->phy_dev; + struct phy_device *gmii2rgmii_phydev = bp->gmii2rgmii_phy_dev; unsigned long flags; int status_change = 0; + u16 gmii2rgmii_reg = 0; spin_lock_irqsave(>lock, flags); @@ -320,15 +322,26 @@ static void macb_handle_link_change(struct net_device *dev) if (macb_is_gem(bp)) reg &= ~GEM_BIT(GBE); - if (phydev->duplex) + if (phydev->duplex) { reg |= MACB_BIT(FD); - if (phydev->speed == SPEED_100) + gmii2rgmii_reg |= MACB_GMII2RGMII_FULLDPLX; + } + if (phydev->speed == SPEED_100) { reg |= MACB_BIT(SPD); + gmii2rgmii_reg |= MACB_GMII2RGMII_SPEED100; + } if (phydev->speed == SPEED_1000 && - bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE) + bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE) { reg |= GEM_BIT(GBE); + gmii2rgmii_reg |= MACB_GMII2RGMII_SPEED1000; + } macb_or_gem_writel(bp, NCFGR, reg); + if (!gmii2rgmii_phydev) { + phy_write(gmii2rgmii_phydev, + MACB_GMII2RGMII_REG_NUM, + gmii2rgmii_reg); + } bp->speed = phydev->speed; bp->duplex = phydev->duplex; @@ -376,6 +389,20 @@ static int macb_mii_probe(struct net_device *dev) int phy_irq; int ret; + if (bp->gmii2rgmii_phy_node) { + phydev = of_phy_attach(bp->dev, + bp->gmii2rgmii_phy_node, + 0, 0); + if (!phydev) { + dev_err(>pdev->dev, "%s: no gmii_to_rgmii found\n", + dev->name); + return -1; + } + bp->gmii2rgmii_phy_dev = phydev; + } else { + bp->gmii2rgmii_phy_dev = NULL; + } + phydev = phy_find_first(bp->mii_bus); if (!phydev) { netdev_err(dev, "no PHY found\n"); @@ -3001,6 +3028,8 @@ static int macb_probe(struct platform_device *pdev) bp->phy_interface = err; } + bp->gmii2rgmii_phy_node = of_parse_phandle(bp->pdev->dev.of_node, + "gmii2rgmii-phy-handle", 0); /* IP specific init */ err = init(pdev); if (err) @@ -3059,6 +3088,8 @@ static int macb_remove(struct platform_device *pdev) bp = netdev_priv(dev); if (bp->phy_dev) phy_disconnect(bp->phy_dev); + if (bp->gmii2rgmii_phy_dev) + phy_disconnect(bp->gmii2rgmii_phy_dev); mdiobus_unregister(bp->mii_bus); mdiobus_free(bp->mii_bus); diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h index 8a13824..625aaf3 100644 --- a/drivers/net/ethernet/cadence/macb.h +++ b/drivers/net/ethernet/cadence/macb.h @@ -559,6 +559,11 @@ struct macb_dma_desc { /* limit RX checksum offload to TCP and UDP packets */ #define
Re: [RFC PATCH] net: macb: Add gmii2rgmii converter support
On June 19, 2016 10:27:17 PM MST, Kedareswara rao Appanawrote: >This patch adds support for gmii2rgmii converter >in the macb driver. > >The GMII to RGMII IP core provides the >Reduced Gigabit Media Independent Interface >(RGMII) between Ethernet physical media devices >And the Gigabit Ethernet controller. >This core can switch dynamically between the >Three different speed modes of operation (10/100/1000 Mb/s). >MDIO interface is used to set operating speed of Ethernet MAC. > >Signed-off-by: Kedareswara rao Appana >--- >--> Tried to include this Coverter support in the >PHY layer but it won't fit into the PHY framework as the >coverter won't have vaild vendor/Device id registers. >--> The Converter has only one register (16) that need's >to be programmed with the external phy negotiated speed. >--> The converter won't follow the Standard MII(ieee 802.3 clause 22). >--> Will appreciate if someone can help on adding this coverter support With the fixed PHY emulated PHY and registering a link_update callback (see drivers/net/dsa/bcm_sf2.c for an example), you could read specific registers which indicates link parameters and update the PHY device with these. How exactly is this converter working? -- Florian