From patchwork Tue Nov 8 15:54:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olliver Schinagl X-Patchwork-Id: 692376 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3tCw4r1GHLz9t2b for ; Wed, 9 Nov 2016 03:39:24 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=schinagl.nl header.i=@schinagl.nl header.b="BYAQJqX6"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A3D16B38C0; Tue, 8 Nov 2016 17:37:59 +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 WKMsNUJfbw9c; Tue, 8 Nov 2016 17:37:59 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 89FFFB3862; Tue, 8 Nov 2016 17:37:12 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9207AA75E6 for ; Tue, 8 Nov 2016 17:02:19 +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 hURJ88Ul8Gzu for ; Tue, 8 Nov 2016 17:02:19 +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 7of9.schinagl.nl (7of9.schinagl.nl [88.159.158.68]) by theia.denx.de (Postfix) with ESMTPS id 8E713B383C for ; Tue, 8 Nov 2016 17:02:18 +0100 (CET) Received: from localhost.localdomain (static-98-101-100-159.thenetworkfactory.nl [159.100.101.98]) by 7of9.schinagl.nl (Postfix) with ESMTPA id D7A8F5747FF; Tue, 8 Nov 2016 16:54:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=schinagl.nl; s=7of9; t=1478620493; bh=lP4LFLyAg7bP9XpqM2gUfmSLryyfm1VRY5hAwo7Bdwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BYAQJqX62sEdZ2iUVB3AFkxETI9PGYRKy0qreErXCDGOh/NsBSeNwdI+PNXEThL83 X3oVehpmCDxgUpKyvJvR20rHdl/YqiOzbgpAtqfn1U8Ac88QoSNJn9A0XeCmBafsl1 3lYXl4Ll1hwVnEMRlv41fvjPnywdlw+rqH2u0tdA= From: Olliver Schinagl To: Ian Campbell , Hans De Goede , Albert Aribaud , Iain Paton , FUKAUMI Naoki , Joe Hershberger , Olliver Schinagl , Simon Glass , Jeffy Chen , Michal Simek , =?UTF-8?q?Stefan=20Br=C3=BCns?= , Nathan Rossi , =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= , Stefano Babic , Stefan Roese , Maxime Ripard Date: Tue, 8 Nov 2016 16:54:28 +0100 Message-Id: <20161108155437.1085-3-oliver@schinagl.nl> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161108155437.1085-1-oliver@schinagl.nl> References: <[PATCH v2 0/5] Retrieve MAC address from EEPROM> <20161108155437.1085-1-oliver@schinagl.nl> X-Mailman-Approved-At: Tue, 08 Nov 2016 17:36:38 +0100 Cc: dev@linux-sunxi.org, u-boot@lists.denx.de Subject: [U-Boot] [PATCH 02/11] net: sunxi-emac: Write HW address via function 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" Currently the mac address is programmed directly in _sunxi_emac_eth_init making it a one time inflexible operation. By moving it into a separate function, we can now use this more flexibly. Signed-off-by: Olliver Schinagl Acked-by: Joe Hershberger --- drivers/net/sunxi_emac.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c index 11cd0ea..99339db 100644 --- a/drivers/net/sunxi_emac.c +++ b/drivers/net/sunxi_emac.c @@ -327,6 +327,20 @@ static void emac_reset(struct emac_eth_dev *priv) udelay(200); } +static int _sunxi_write_hwaddr(struct emac_eth_dev *priv, u8 *enetaddr) +{ + struct emac_regs *regs = priv->regs; + u32 enetaddr_lo, enetaddr_hi; + + enetaddr_lo = enetaddr[2] | (enetaddr[1] << 8) | (enetaddr[0] << 16); + enetaddr_hi = enetaddr[5] | (enetaddr[4] << 8) | (enetaddr[3] << 16); + + writel(enetaddr_hi, ®s->mac_a1); + writel(enetaddr_lo, ®s->mac_a0); + + return 0; +} + static int _sunxi_emac_eth_init(struct emac_eth_dev *priv, u8 *enetaddr) { struct emac_regs *regs = priv->regs; @@ -350,10 +364,7 @@ static int _sunxi_emac_eth_init(struct emac_eth_dev *priv, u8 *enetaddr) /* Set up EMAC */ emac_setup(priv); - writel(enetaddr[0] << 16 | enetaddr[1] << 8 | enetaddr[2], - ®s->mac_a1); - writel(enetaddr[3] << 16 | enetaddr[4] << 8 | enetaddr[5], - ®s->mac_a0); + _sunxi_write_hwaddr(priv, enetaddr); mdelay(1);