* [U-Boot] [PATCH v3 0/2] net: macb: Add remove callback and align the compatibles
@ 2017-04-14 6:36 Wenyou Yang
2017-04-14 6:36 ` [U-Boot] [PATCH v3 1/2] net: macb: Add remove callback Wenyou Yang
2017-04-14 6:36 ` [U-Boot] [PATCH v3 2/2] net: macb: Align the compatibles with kernel Wenyou Yang
0 siblings, 2 replies; 5+ messages in thread
From: Wenyou Yang @ 2017-04-14 6:36 UTC (permalink / raw)
To: u-boot
Add the remove callback to avoid the failure of mdio_register(),
and add the compatibles to align with the kernel.
Changes in v3:
- Incorporate [PATCH] net: macb: align the compatibles with kernel.
- Rebase on the latest commit (db40c1aa1c10) of master branch of u-boot-net.
- Add Acked-by tag.
Changes in v2:
- Rebase on v2017.03.
Wenyou Yang (2):
net: macb: Add remove callback
net: macb: Align the compatibles with kernel
drivers/net/macb.c | 49 +++++++++++++++++++++++++++++++++----------------
1 file changed, 33 insertions(+), 16 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v3 1/2] net: macb: Add remove callback
2017-04-14 6:36 [U-Boot] [PATCH v3 0/2] net: macb: Add remove callback and align the compatibles Wenyou Yang
@ 2017-04-14 6:36 ` Wenyou Yang
2017-04-22 3:07 ` sjg at google.com
2017-04-14 6:36 ` [U-Boot] [PATCH v3 2/2] net: macb: Align the compatibles with kernel Wenyou Yang
1 sibling, 1 reply; 5+ messages in thread
From: Wenyou Yang @ 2017-04-14 6:36 UTC (permalink / raw)
To: u-boot
To avoid the failure of mdio_register(), add the remove callback
to unregister the mii_dev when removing the ethernet device.
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
---
Changes in v3: None
Changes in v2:
- Rebase on v2017.03.
drivers/net/macb.c | 45 +++++++++++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 16 deletions(-)
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 402e866817..a4c6bd0ee6 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -111,6 +111,9 @@ struct macb_device {
#endif
unsigned short phy_addr;
struct mii_dev *bus;
+#ifdef CONFIG_PHYLIB
+ struct phy_device *phydev;
+#endif
#ifdef CONFIG_DM_ETH
#ifdef CONFIG_CLK
@@ -479,9 +482,6 @@ static int macb_phy_init(struct macb_device *macb, const char *name)
#ifdef CONFIG_DM_ETH
struct macb_device *macb = dev_get_priv(dev);
#endif
-#ifdef CONFIG_PHYLIB
- struct phy_device *phydev;
-#endif
u32 ncfgr;
u16 phy_id, status, adv, lpa;
int media, speed, duplex;
@@ -503,19 +503,19 @@ static int macb_phy_init(struct macb_device *macb, const char *name)
#ifdef CONFIG_PHYLIB
#ifdef CONFIG_DM_ETH
- phydev = phy_connect(macb->bus, macb->phy_addr, dev,
+ macb->phydev = phy_connect(macb->bus, macb->phy_addr, dev,
macb->phy_interface);
#else
/* need to consider other phy interface mode */
- phydev = phy_connect(macb->bus, macb->phy_addr, &macb->netdev,
+ macb->phydev = phy_connect(macb->bus, macb->phy_addr, &macb->netdev,
PHY_INTERFACE_MODE_RGMII);
#endif
- if (!phydev) {
+ if (!macb->phydev) {
printf("phy_connect failed\n");
return -ENODEV;
}
- phy_config(phydev);
+ phy_config(macb->phydev);
#endif
status = macb_mdio_read(macb, MII_BMSR);
@@ -1056,23 +1056,35 @@ static int macb_eth_probe(struct udevice *dev)
_macb_eth_initialize(macb);
#if defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB)
- int retval;
- struct mii_dev *mdiodev = mdio_alloc();
- if (!mdiodev)
+ macb->bus = mdio_alloc();
+ if (!macb->bus)
return -ENOMEM;
- strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
- mdiodev->read = macb_miiphy_read;
- mdiodev->write = macb_miiphy_write;
+ strncpy(macb->bus->name, dev->name, MDIO_NAME_LEN);
+ macb->bus->read = macb_miiphy_read;
+ macb->bus->write = macb_miiphy_write;
- retval = mdio_register(mdiodev);
- if (retval < 0)
- return retval;
+ ret = mdio_register(macb->bus);
+ if (ret < 0)
+ return ret;
macb->bus = miiphy_get_dev_by_name(dev->name);
#endif
return 0;
}
+static int macb_eth_remove(struct udevice *dev)
+{
+ struct macb_device *macb = dev_get_priv(dev);
+
+#ifdef CONFIG_PHYLIB
+ free(macb->phydev);
+#endif
+ mdio_unregister(macb->bus);
+ mdio_free(macb->bus);
+
+ return 0;
+}
+
static int macb_eth_ofdata_to_platdata(struct udevice *dev)
{
struct eth_pdata *pdata = dev_get_platdata(dev);
@@ -1092,6 +1104,7 @@ U_BOOT_DRIVER(eth_macb) = {
.of_match = macb_eth_ids,
.ofdata_to_platdata = macb_eth_ofdata_to_platdata,
.probe = macb_eth_probe,
+ .remove = macb_eth_remove,
.ops = &macb_eth_ops,
.priv_auto_alloc_size = sizeof(struct macb_device),
.platdata_auto_alloc_size = sizeof(struct eth_pdata),
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v3 2/2] net: macb: Align the compatibles with kernel
2017-04-14 6:36 [U-Boot] [PATCH v3 0/2] net: macb: Add remove callback and align the compatibles Wenyou Yang
2017-04-14 6:36 ` [U-Boot] [PATCH v3 1/2] net: macb: Add remove callback Wenyou Yang
@ 2017-04-14 6:36 ` Wenyou Yang
2017-04-22 3:07 ` sjg at google.com
1 sibling, 1 reply; 5+ messages in thread
From: Wenyou Yang @ 2017-04-14 6:36 UTC (permalink / raw)
To: u-boot
Add the compatibles to align with the kernel.
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
---
Changes in v3:
- Incorporate [PATCH] net: macb: align the compatibles with kernel.
- Rebase on the latest commit (db40c1aa1c10) of master branch of u-boot-net.
- Add Acked-by tag.
Changes in v2: None
drivers/net/macb.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index a4c6bd0ee6..7d045c90c5 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -1095,6 +1095,10 @@ static int macb_eth_ofdata_to_platdata(struct udevice *dev)
static const struct udevice_id macb_eth_ids[] = {
{ .compatible = "cdns,macb" },
+ { .compatible = "cdns,at91sam9260-macb" },
+ { .compatible = "atmel,sama5d2-gem" },
+ { .compatible = "atmel,sama5d3-gem" },
+ { .compatible = "atmel,sama5d4-gem" },
{ }
};
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v3 2/2] net: macb: Align the compatibles with kernel
2017-04-14 6:36 ` [U-Boot] [PATCH v3 2/2] net: macb: Align the compatibles with kernel Wenyou Yang
@ 2017-04-22 3:07 ` sjg at google.com
0 siblings, 0 replies; 5+ messages in thread
From: sjg at google.com @ 2017-04-22 3:07 UTC (permalink / raw)
To: u-boot
Add the compatibles to align with the kernel.
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
---
Changes in v3:
- Incorporate [PATCH] net: macb: align the compatibles with kernel.
- Rebase on the latest commit (db40c1aa1c10) of master branch of u-boot-net.
- Add Acked-by tag.
Changes in v2: None
drivers/net/macb.c | 4 ++++
1 file changed, 4 insertions(+)
Applied to u-boot-dm/next, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v3 1/2] net: macb: Add remove callback
2017-04-14 6:36 ` [U-Boot] [PATCH v3 1/2] net: macb: Add remove callback Wenyou Yang
@ 2017-04-22 3:07 ` sjg at google.com
0 siblings, 0 replies; 5+ messages in thread
From: sjg at google.com @ 2017-04-22 3:07 UTC (permalink / raw)
To: u-boot
To avoid the failure of mdio_register(), add the remove callback
to unregister the mii_dev when removing the ethernet device.
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
---
Changes in v3: None
Changes in v2:
- Rebase on v2017.03.
drivers/net/macb.c | 45 +++++++++++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 16 deletions(-)
Applied to u-boot-dm/next, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-04-22 3:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-14 6:36 [U-Boot] [PATCH v3 0/2] net: macb: Add remove callback and align the compatibles Wenyou Yang
2017-04-14 6:36 ` [U-Boot] [PATCH v3 1/2] net: macb: Add remove callback Wenyou Yang
2017-04-22 3:07 ` sjg at google.com
2017-04-14 6:36 ` [U-Boot] [PATCH v3 2/2] net: macb: Align the compatibles with kernel Wenyou Yang
2017-04-22 3:07 ` sjg at google.com
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.