From patchwork Tue Dec 20 13:53:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 132421 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 1A13AB7036 for ; Wed, 21 Dec 2011 00:54:10 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 675E42815E; Tue, 20 Dec 2011 14:53:59 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 i0eWCGLkkI8L; Tue, 20 Dec 2011 14:53:59 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 56AD628168; Tue, 20 Dec 2011 14:53:51 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D400828157 for ; Tue, 20 Dec 2011 14:53:49 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 BhVp36FSlzdG for ; Tue, 20 Dec 2011 14:53:49 +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 mail-gy0-f172.google.com (mail-gy0-f172.google.com [209.85.160.172]) by theia.denx.de (Postfix) with ESMTPS id 4AA292814A for ; Tue, 20 Dec 2011 14:53:47 +0100 (CET) Received: by ghbg18 with SMTP id g18so910995ghb.3 for ; Tue, 20 Dec 2011 05:53:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=q8gyk6iuyHZUj7CgO5JrzWyiqpcSo0EZ81UggfVPSVA=; b=F5NlBOW5pHy47eBrl7/l+Gx3C/jbi63o38a7eG6vmxgGUjSQKRicg2XiKbi1nKpKB0 TQqW+/lSe6xkhroAnxjO3s5HhBSoMQBZ+fHUi2Yxz1SOfxU1Ui+BXimvSz9r2YfXzjoG qkSHt6oMJ6r8AqpLkTrcyngKu8WokfVC5k+5Q= Received: by 10.236.192.198 with SMTP id i46mr3971795yhn.22.1324389226693; Tue, 20 Dec 2011 05:53:46 -0800 (PST) Received: from localhost.localdomain ([189.5.21.38]) by mx.google.com with ESMTPS id o7sm3370448yhl.15.2011.12.20.05.53.44 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Dec 2011 05:53:45 -0800 (PST) From: Fabio Estevam To: u-boot@lists.denx.de Date: Tue, 20 Dec 2011 11:53:30 -0200 Message-Id: <1324389212-9208-2-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1324389212-9208-1-git-send-email-festevam@gmail.com> References: <1324389212-9208-1-git-send-email-festevam@gmail.com> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v6 2/4] mx28: Allow to set MAC address for the two FECs X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de MX28 has two built-in FECs (Fast Ethernet Controller). OCOTP register can be used to only store 4 bytes of MAC addresses. In order to workaround this limitation, let the MAC address of FEC1 be the FEC0 address plus one. Signed-off-by: Fabio Estevam --- Changes since v5: No changes. Newly introduced on this series arch/arm/cpu/arm926ejs/mx28/mx28.c | 8 ++++++-- drivers/net/fec_mxc.c | 16 ++++++++++++++++ drivers/net/fec_mxc.h | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/arch/arm/cpu/arm926ejs/mx28/mx28.c b/arch/arm/cpu/arm926ejs/mx28/mx28.c index a25814e..79b4001 100644 --- a/arch/arm/cpu/arm926ejs/mx28/mx28.c +++ b/arch/arm/cpu/arm926ejs/mx28/mx28.c @@ -227,7 +227,7 @@ void set_mac_vendor(char *mac) #define MXS_OCOTP_MAX_TIMEOUT 1000000 -void imx_get_mac_from_fuse(char *mac) +void mx28_get_mac_from_fuse(int dev_id, char *mac) { struct mx28_ocotp_regs *ocotp_regs = (struct mx28_ocotp_regs *)MXS_OCOTP_BASE; @@ -249,10 +249,14 @@ void imx_get_mac_from_fuse(char *mac) mac[3] = (data >> 16) & 0xff; mac[4] = (data >> 8) & 0xff; mac[5] = data & 0xff; + /* Assume that FEC1 MAC address is MAC0 + 1 */ + if (dev_id == 1) + mac[5]+= 1; + set_mac_vendor(mac); } #else -void imx_get_mac_from_fuse(char *mac) +void mx28_get_mac_from_fuse(int dev_id, char *mac) { memset(mac, 0, 6); } diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index b05a4c0..a6bf597 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -345,11 +345,20 @@ static void fec_rbd_clean(int last, struct fec_bd *pRbd) writew(0, &pRbd->data_length); } +#ifndef CONFIG_MX28 static int fec_get_hwaddr(struct eth_device *dev, unsigned char *mac) { imx_get_mac_from_fuse(mac); return !is_valid_ether_addr(mac); } +#else +static int mx28_fec_get_hwaddr(struct eth_device *dev, int dev_id, + unsigned char *mac) +{ + mx28_get_mac_from_fuse(dev_id, mac); + return !is_valid_ether_addr(mac); +} +#endif static int fec_set_hwaddr(struct eth_device *dev) { @@ -812,10 +821,17 @@ static int fec_probe(bd_t *bd, int dev_id, int phy_id, uint32_t base_addr) eth_register(edev); +#ifndef CONFIG_MX28 if (fec_get_hwaddr(edev, ethaddr) == 0) { debug("got MAC address from fuse: %pM\n", ethaddr); memcpy(edev->enetaddr, ethaddr, 6); } +#else + if (mx28_fec_get_hwaddr(edev, dev_id, ethaddr) == 0) { + debug("got MAC%d address from fuse: %pM\n", dev_id, ethaddr); + memcpy(edev->enetaddr, ethaddr, 6); + } +#endif return ret; diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h index 8b26645..e2cfe4a 100644 --- a/drivers/net/fec_mxc.h +++ b/drivers/net/fec_mxc.h @@ -33,6 +33,7 @@ #define __FEC_MXC_H void imx_get_mac_from_fuse(unsigned char *mac); +void mx28_get_mac_from_fuse(int dev_id, unsigned char *mac); /** * Layout description of the FEC