[U-Boot] [PATCH v2 03/12] net: designware: Add a fix_mac_speed hook

Sjoerd Simons sjoerd.simons at collabora.co.uk
Sun Feb 28 22:24:57 CET 2016


Add the ability for e.g. drivers subclassing to register a function to
be called after phy link negotiation. This is useful if e.g. the driver
needs to change the mac configuration based on the negotiated speed.

Signed-off-by: Sjoerd Simons <sjoerd.simons at collabora.co.uk>

---

Changes in v2:
- Move the hook into the dw_adjust_link function
- Rename the hook to fix_mac_speed, similar to Linux

 drivers/net/designware.c | 8 ++++++--
 drivers/net/designware.h | 4 ++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 8834506..5eaa1de 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -231,7 +231,8 @@ static int _dw_write_hwaddr(struct dw_eth_dev *priv, u8 *mac_id)
 	return 0;
 }
 
-static void dw_adjust_link(struct eth_mac_regs *mac_p,
+static void dw_adjust_link(struct dw_eth_dev *priv,
+			   struct eth_mac_regs *mac_p,
 			   struct phy_device *phydev)
 {
 	u32 conf = readl(&mac_p->conf) | FRAMEBURSTENABLE | DISABLERXOWN;
@@ -257,6 +258,9 @@ static void dw_adjust_link(struct eth_mac_regs *mac_p,
 	printf("Speed: %d, %s duplex%s\n", phydev->speed,
 	       (phydev->duplex) ? "full" : "half",
 	       (phydev->port == PORT_FIBRE) ? ", fiber mode" : "");
+
+	if (priv->fix_mac_speed)
+		priv->fix_mac_speed(priv);
 }
 
 static void _dw_eth_halt(struct dw_eth_dev *priv)
@@ -322,7 +326,7 @@ static int _dw_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
 		return ret;
 	}
 
-	dw_adjust_link(mac_p, priv->phydev);
+	dw_adjust_link(priv, mac_p, priv->phydev);
 
 	if (!priv->phydev->link)
 		return -EIO;
diff --git a/drivers/net/designware.h b/drivers/net/designware.h
index 6b4bfd7..792af7c 100644
--- a/drivers/net/designware.h
+++ b/drivers/net/designware.h
@@ -237,6 +237,10 @@ struct dw_eth_dev {
 	struct gpio_desc reset_gpio;
 	struct phy_device *phydev;
 	struct mii_dev *bus;
+
+#ifdef CONFIG_DM_ETH
+	int (*fix_mac_speed)(struct dw_eth_dev *priv);
+#endif
 };
 
 #ifdef CONFIG_DM_ETH
-- 
2.7.0



More information about the U-Boot mailing list