From patchwork Sun Feb 28 21:24:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sjoerd Simons X-Patchwork-Id: 63184 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1098199lbc; Mon, 29 Feb 2016 00:06:48 -0800 (PST) X-Received: by 10.28.229.132 with SMTP id c126mr9581637wmh.72.1456733208914; Mon, 29 Feb 2016 00:06:48 -0800 (PST) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id h84si19076444wmf.124.2016.02.29.00.06.48; Mon, 29 Feb 2016 00:06:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 34EA5A7660; Mon, 29 Feb 2016 09:06:10 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tj3zZJavJ819; Mon, 29 Feb 2016 09:06:10 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 89483A765D; Mon, 29 Feb 2016 09:05:34 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6C02DA75BC for ; Mon, 29 Feb 2016 09:05:14 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LKgrvBOtl6JO for ; Mon, 29 Feb 2016 09:05:14 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by theia.denx.de (Postfix) with ESMTPS id B9B0FA75E5 for ; Mon, 29 Feb 2016 09:05:13 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sjoerd) with ESMTPSA id 56632266EB6 Received: by dusk.luon.net (Postfix, from userid 1000) id 3623A22253; Sun, 28 Feb 2016 22:25:06 +0100 (CET) From: Sjoerd Simons To: Simon Glass Date: Sun, 28 Feb 2016 22:24:57 +0100 Message-Id: <1456694706-911-4-git-send-email-sjoerd.simons@collabora.co.uk> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1456694706-911-1-git-send-email-sjoerd.simons@collabora.co.uk> References: <1456694706-911-1-git-send-email-sjoerd.simons@collabora.co.uk> Cc: Joe Hershberger , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 03/12] net: designware: Add a fix_mac_speed hook X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- 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(-) -- 2.7.0 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot 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