* [PATCH] net: fec: add simple support for fixed-link @ 2016-05-04 7:28 Wjatscheslaw Stoljarski 2016-05-04 13:11 ` Sascha Hauer 0 siblings, 1 reply; 4+ messages in thread From: Wjatscheslaw Stoljarski @ 2016-05-04 7:28 UTC (permalink / raw) To: Barebox List Signed-off-by: Wjatscheslaw Stoljarski <wjatscheslaw.stoljarski@kiwigrid.com> --- drivers/net/fec_imx.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c index 696483f..31802c2 100644 --- a/drivers/net/fec_imx.c +++ b/drivers/net/fec_imx.c @@ -669,6 +669,8 @@ static int fec_probe(struct device_d *dev) enum fec_type type; int phy_reset; u32 msec = 1; + struct device_node *fixed_link_node; + int speed; ret = dev_get_drvdata(dev, (const void **)&type); if (ret) @@ -716,6 +718,16 @@ static int fec_probe(struct device_d *dev) gpio_set_value(phy_reset, 1); } + fixed_link_node = of_get_child_by_name(dev->device_node, "fixed-link"); + if (fixed_link_node) { + if (!of_property_read_u32(fixed_link_node, "speed", &speed)) { + if (speed == 100) + fec->phy_flags |= PHYLIB_FORCE_100; + else if (speed == 10) + fec->phy_flags |= PHYLIB_FORCE_10; + } + } + /* Reset chip. */ writel(FEC_ECNTRL_RESET, fec->regs + FEC_ECNTRL); while(readl(fec->regs + FEC_ECNTRL) & 1) { -- 1.9.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: fec: add simple support for fixed-link 2016-05-04 7:28 [PATCH] net: fec: add simple support for fixed-link Wjatscheslaw Stoljarski @ 2016-05-04 13:11 ` Sascha Hauer 2016-05-04 14:55 ` Wjatscheslaw Stoljarski 0 siblings, 1 reply; 4+ messages in thread From: Sascha Hauer @ 2016-05-04 13:11 UTC (permalink / raw) To: Wjatscheslaw Stoljarski; +Cc: Barebox List Hi Wjatscheslaw, On Wed, May 04, 2016 at 09:28:55AM +0200, Wjatscheslaw Stoljarski wrote: > Signed-off-by: Wjatscheslaw Stoljarski <wjatscheslaw.stoljarski@kiwigrid.com> > --- > drivers/net/fec_imx.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c Instead of introducing a i.MX FEC specific solution for this problem, can you test the following patch? It currently lacks support for the speed/full-duplex properties, but with these added we could apply the patch. Sascha -------------------------------8<------------------------------ From 4a2bfb1400dff8c5d4a14e0faeb653974c3e4acf Mon Sep 17 00:00:00 2001 From: Sascha Hauer <s.hauer@pengutronix.de> Date: Thu, 11 Feb 2016 11:05:11 +0100 Subject: [PATCH] net: phy: Add fixed link support Some network devices, especially when connected to a switch, are connected via a fixed link. This patch adds support for a fixed phy configured through device tree. TODO: Add support for the "speed" and "full-duplex" properties. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- drivers/net/phy/phy.c | 49 +++++++++++++++++++++++++++++++++++++++++-------- include/linux/phy.h | 2 +- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index be2c68b..73176fb 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -52,9 +52,11 @@ int phy_update_status(struct phy_device *phydev) int ret; int oldspeed = phydev->speed, oldduplex = phydev->duplex; - ret = drv->read_status(phydev); - if (ret) - return ret; + if (drv) { + ret = drv->read_status(phydev); + if (ret) + return ret; + } if (phydev->speed == oldspeed && phydev->duplex == oldduplex) return 0; @@ -173,10 +175,15 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id) phydev->bus = bus; phydev->dev.bus = &mdio_bus_type; - sprintf(phydev->dev.name, "mdio%d-phy%02x", + if (bus) { + sprintf(phydev->dev.name, "mdio%d-phy%02x", phydev->bus->dev.id, phydev->addr); - phydev->dev.id = DEVICE_ID_SINGLE; + phydev->dev.id = DEVICE_ID_SINGLE; + } else { + sprintf(phydev->dev.name, "fixed-phy"); + phydev->dev.id = DEVICE_ID_DYNAMIC; + } return phydev; } @@ -245,7 +252,9 @@ static void phy_config_aneg(struct phy_device *phydev) struct phy_driver *drv; drv = to_phy_driver(phydev->dev.driver); - drv->config_aneg(phydev); + + if (drv) + drv->config_aneg(phydev); } int phy_register_device(struct phy_device *phydev) @@ -255,13 +264,15 @@ int phy_register_device(struct phy_device *phydev) if (phydev->registered) return -EBUSY; - phydev->dev.parent = &phydev->bus->dev; + if (!phydev->dev.parent) + phydev->dev.parent = &phydev->bus->dev; ret = register_device(&phydev->dev); if (ret) return ret; - phydev->bus->phy_map[phydev->addr] = phydev; + if (phydev->bus) + phydev->bus->phy_map[phydev->addr] = phydev; phydev->registered = 1; @@ -289,6 +300,22 @@ void phy_unregister_device(struct phy_device *phydev) phydev->registered = 0; } +struct phy_device *of_phy_register_fixed_link(struct device_node *np, struct eth_device *edev) +{ + struct phy_device *phydev; + + phydev = phy_device_create(NULL, 0, 0); + + phydev->dev.parent = &edev->dev; + phydev->registered = 1; + phydev->speed = 1000; + phydev->duplex = 1; + phydev->pause = phydev->asym_pause = 0; + phydev->link = 1; + + return phydev; +} + static struct phy_device *of_mdio_find_phy(struct eth_device *edev) { struct device_d *dev; @@ -305,6 +332,12 @@ static struct phy_device *of_mdio_find_phy(struct eth_device *edev) phy_node = of_parse_phandle(edev->parent->device_node, "phy", 0); if (!phy_node) phy_node = of_parse_phandle(edev->parent->device_node, "phy-device", 0); + if (!phy_node) { + phy_node = of_get_child_by_name(edev->parent->device_node, "fixed-link"); + if (phy_node) + return of_phy_register_fixed_link(phy_node, edev); + } + if (!phy_node) return NULL; diff --git a/include/linux/phy.h b/include/linux/phy.h index 38b0670..d7b10af 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -251,7 +251,7 @@ struct phy_driver { struct driver_d drv; }; -#define to_phy_driver(d) container_of(d, struct phy_driver, drv) +#define to_phy_driver(d) ((d) ? container_of(d, struct phy_driver, drv) : NULL) #define PHY_ANY_ID "MATCH ANY PHY" #define PHY_ANY_UID 0xffffffff -- 2.8.0.rc3 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: fec: add simple support for fixed-link 2016-05-04 13:11 ` Sascha Hauer @ 2016-05-04 14:55 ` Wjatscheslaw Stoljarski 2016-05-09 6:31 ` Sascha Hauer 0 siblings, 1 reply; 4+ messages in thread From: Wjatscheslaw Stoljarski @ 2016-05-04 14:55 UTC (permalink / raw) To: Sascha Hauer; +Cc: Barebox List Hi Sascha, it works for me. Thanks! On Wed, May 04, 2016 at 03:11:21PM +0200, Sascha Hauer wrote: > Hi Wjatscheslaw, > > On Wed, May 04, 2016 at 09:28:55AM +0200, Wjatscheslaw Stoljarski wrote: > > Signed-off-by: Wjatscheslaw Stoljarski <wjatscheslaw.stoljarski@kiwigrid.com> > > --- > > drivers/net/fec_imx.c | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > > > diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c > > Instead of introducing a i.MX FEC specific solution for this problem, > can you test the following patch? It currently lacks support for the > speed/full-duplex properties, but with these added we could apply the > patch. > > Sascha > > -------------------------------8<------------------------------ > > From 4a2bfb1400dff8c5d4a14e0faeb653974c3e4acf Mon Sep 17 00:00:00 2001 > From: Sascha Hauer <s.hauer@pengutronix.de> > Date: Thu, 11 Feb 2016 11:05:11 +0100 > Subject: [PATCH] net: phy: Add fixed link support > > Some network devices, especially when connected to a switch, are > connected via a fixed link. This patch adds support for a fixed phy > configured through device tree. > TODO: Add support for the "speed" and "full-duplex" properties. > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> > --- > drivers/net/phy/phy.c | 49 +++++++++++++++++++++++++++++++++++++++++-------- > include/linux/phy.h | 2 +- > 2 files changed, 42 insertions(+), 9 deletions(-) > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index be2c68b..73176fb 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -52,9 +52,11 @@ int phy_update_status(struct phy_device *phydev) > int ret; > int oldspeed = phydev->speed, oldduplex = phydev->duplex; > > - ret = drv->read_status(phydev); > - if (ret) > - return ret; > + if (drv) { > + ret = drv->read_status(phydev); > + if (ret) > + return ret; > + } > > if (phydev->speed == oldspeed && phydev->duplex == oldduplex) > return 0; > @@ -173,10 +175,15 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id) > phydev->bus = bus; > phydev->dev.bus = &mdio_bus_type; > > - sprintf(phydev->dev.name, "mdio%d-phy%02x", > + if (bus) { > + sprintf(phydev->dev.name, "mdio%d-phy%02x", > phydev->bus->dev.id, > phydev->addr); > - phydev->dev.id = DEVICE_ID_SINGLE; > + phydev->dev.id = DEVICE_ID_SINGLE; > + } else { > + sprintf(phydev->dev.name, "fixed-phy"); > + phydev->dev.id = DEVICE_ID_DYNAMIC; > + } > > return phydev; > } > @@ -245,7 +252,9 @@ static void phy_config_aneg(struct phy_device *phydev) > struct phy_driver *drv; > > drv = to_phy_driver(phydev->dev.driver); > - drv->config_aneg(phydev); > + > + if (drv) > + drv->config_aneg(phydev); > } > > int phy_register_device(struct phy_device *phydev) > @@ -255,13 +264,15 @@ int phy_register_device(struct phy_device *phydev) > if (phydev->registered) > return -EBUSY; > > - phydev->dev.parent = &phydev->bus->dev; > + if (!phydev->dev.parent) > + phydev->dev.parent = &phydev->bus->dev; > > ret = register_device(&phydev->dev); > if (ret) > return ret; > > - phydev->bus->phy_map[phydev->addr] = phydev; > + if (phydev->bus) > + phydev->bus->phy_map[phydev->addr] = phydev; > > phydev->registered = 1; > > @@ -289,6 +300,22 @@ void phy_unregister_device(struct phy_device *phydev) > phydev->registered = 0; > } > > +struct phy_device *of_phy_register_fixed_link(struct device_node *np, struct eth_device *edev) > +{ > + struct phy_device *phydev; > + > + phydev = phy_device_create(NULL, 0, 0); > + > + phydev->dev.parent = &edev->dev; > + phydev->registered = 1; > + phydev->speed = 1000; > + phydev->duplex = 1; > + phydev->pause = phydev->asym_pause = 0; > + phydev->link = 1; > + > + return phydev; > +} > + > static struct phy_device *of_mdio_find_phy(struct eth_device *edev) > { > struct device_d *dev; > @@ -305,6 +332,12 @@ static struct phy_device *of_mdio_find_phy(struct eth_device *edev) > phy_node = of_parse_phandle(edev->parent->device_node, "phy", 0); > if (!phy_node) > phy_node = of_parse_phandle(edev->parent->device_node, "phy-device", 0); > + if (!phy_node) { > + phy_node = of_get_child_by_name(edev->parent->device_node, "fixed-link"); > + if (phy_node) > + return of_phy_register_fixed_link(phy_node, edev); > + } > + > if (!phy_node) > return NULL; > > diff --git a/include/linux/phy.h b/include/linux/phy.h > index 38b0670..d7b10af 100644 > --- a/include/linux/phy.h > +++ b/include/linux/phy.h > @@ -251,7 +251,7 @@ struct phy_driver { > > struct driver_d drv; > }; > -#define to_phy_driver(d) container_of(d, struct phy_driver, drv) > +#define to_phy_driver(d) ((d) ? container_of(d, struct phy_driver, drv) : NULL) > > #define PHY_ANY_ID "MATCH ANY PHY" > #define PHY_ANY_UID 0xffffffff > -- > 2.8.0.rc3 > > -- > Pengutronix e.K. | | > Industrial Linux Solutions | http://www.pengutronix.de/ | > Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: fec: add simple support for fixed-link 2016-05-04 14:55 ` Wjatscheslaw Stoljarski @ 2016-05-09 6:31 ` Sascha Hauer 0 siblings, 0 replies; 4+ messages in thread From: Sascha Hauer @ 2016-05-09 6:31 UTC (permalink / raw) To: Wjatscheslaw Stoljarski; +Cc: Barebox List On Wed, May 04, 2016 at 04:55:14PM +0200, Wjatscheslaw Stoljarski wrote: > Hi Sascha, > > it works for me. Thanks! Thanks for testing. I take this as a Tested-by: Wjatscheslaw Stoljarski <wjatscheslaw.stoljarski@kiwigrid.com> Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-05-09 6:32 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-05-04 7:28 [PATCH] net: fec: add simple support for fixed-link Wjatscheslaw Stoljarski 2016-05-04 13:11 ` Sascha Hauer 2016-05-04 14:55 ` Wjatscheslaw Stoljarski 2016-05-09 6:31 ` Sascha Hauer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox