From patchwork Thu Jan 28 21:26:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 8154151 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EF07C9F9A0 for ; Thu, 28 Jan 2016 21:39:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2C98520165 for ; Thu, 28 Jan 2016 21:39:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5BBA92017D for ; Thu, 28 Jan 2016 21:39:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOuGq-0008Ee-DR; Thu, 28 Jan 2016 21:38:28 +0000 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOu89-0006AZ-HC for linux-arm-kernel@lists.infradead.org; Thu, 28 Jan 2016 21:29:31 +0000 Received: by mail-pa0-x22e.google.com with SMTP id cy9so29209383pac.0 for ; Thu, 28 Jan 2016 13:29:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=boundarydevices-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cb5vZk1SV98kgQCiqGjjb87HLp7+Lt68Owz84vFhWyQ=; b=F8ryloZ3C5/I09YBn9SWh5W9cbPCRUVt5P/pigdQknu5kXFWclPrhHsgtNh/9ibOV5 OcL7NFTR4eD/y/Rehodr8SEtwS6bAOBBNU2nDdUx4e8YeRTquLSqsf0ydF7peNxQy8wL J8s1UYeuynE/lviCofyLJpa/AD+RUSFY64iRVbHNhShDDSLbCPdkIFzUoQBwzT83QtUk u0dAU4pn+xuZixSAWKkRRWLrrPNDNNAh6i2g56E1nF7smdOHSCWpkKomyEv9dKq3D9ed 5mRy9isY55ymwMLlIl8DfF4xhsIUuBciIoH6NXLj7Jg2w+uw23y9zR5BfO/2PKPcM4aE 5QiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cb5vZk1SV98kgQCiqGjjb87HLp7+Lt68Owz84vFhWyQ=; b=jfRCVwOvJBZY6n8okBsQaEI8XEF21Kdu49pEu88Km2vcdjXReKKdq43n/fHpQeji5I SK3DTMbzKwALYS7mKptp4PE3t3TqIaO4ynWSRWX0oUt9AXpfnwnNGbFNqu225c1GFVnx oxAZdPHSw2ecUqska7me9/VcIkJVCQhCw5c6sy8NMw7dhJy8MItvSCE7RKyyDM1HmfK7 w3kWt+5rAJSy9aIAOq7q94/ErbLg4Lf6Rm78Mf4SSXAjyWXp87jbGhphpmYhwbcZZJpl EOEotbeMb+52tyoLKrmr3gsXB5r/0VGywAeAKfboIestb0VqY6gRqUsj+UOy9F3wpojR 95mg== X-Gm-Message-State: AG10YOQa0in/f9H1Vw90XNm3BSpbtYztW130T6d/xV9GFLmiDorLpaZmDy2Awf0Xum0d8A== X-Received: by 10.67.7.3 with SMTP id cy3mr7999050pad.100.1454016548866; Thu, 28 Jan 2016 13:29:08 -0800 (PST) Received: from localhost.localdomain (wsip-70-184-93-199.ph.ph.cox.net. [70.184.93.199]) by smtp.googlemail.com with ESMTPSA id c90sm18583190pfd.31.2016.01.28.13.29.07 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Jan 2016 13:29:08 -0800 (PST) From: Troy Kisky To: netdev@vger.kernel.org, davem@davemloft.net, B38611@freescale.com Subject: [PATCH net-next 36/40] net: fec: use mac set by bootloader before fuses Date: Thu, 28 Jan 2016 14:26:00 -0700 Message-Id: <1454016364-30985-37-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454016364-30985-1-git-send-email-troy.kisky@boundarydevices.com> References: <1454016364-30985-1-git-send-email-troy.kisky@boundarydevices.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160128_132929_815416_D950AEE2 X-CRM114-Status: GOOD ( 12.04 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fabio.estevam@freescale.com, andrew@lunn.ch, linux@arm.linux.org.uk, Troy Kisky , laci@boundarydevices.com, l.stach@pengutronix.de, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org, tremyfr@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a bootloader initializes the mac, prefer that to device tree or fuses. Signed-off-by: Troy Kisky --- drivers/net/ethernet/freescale/fec_main.c | 33 +++++++++++++------------------ 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 9db645d..11968a9 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -1625,16 +1625,24 @@ static void fec_get_mac(struct net_device *ndev) struct fec_platform_data *pdata = dev_get_platdata(&fep->pdev->dev); unsigned char *iap, tmpaddr[ETH_ALEN]; - /* - * try to get mac address in following order: + /* try to get mac address in following order: * * 1) module parameter via kernel command line in form * fec.macaddr=0x00,0x04,0x9f,0x01,0x30,0xe0 */ iap = macaddr; - /* - * 2) from device tree data + /* 2) FEC mac registers set by bootloader + */ + if (!is_valid_ether_addr(iap)) { + *((__be32 *)&tmpaddr[0]) = + cpu_to_be32(readl(fep->hwp + FEC_ADDR_LOW)); + *((__be16 *)&tmpaddr[4]) = + cpu_to_be16(readl(fep->hwp + FEC_ADDR_HIGH) >> 16); + iap = &tmpaddr[0]; + } + + /* 3) from device tree data */ if (!is_valid_ether_addr(iap)) { struct device_node *np = fep->pdev->dev.of_node; @@ -1645,8 +1653,7 @@ static void fec_get_mac(struct net_device *ndev) } } - /* - * 3) from flash or fuse (via platform data) + /* 4) from flash or fuse (via platform data) */ if (!is_valid_ether_addr(iap)) { #ifdef CONFIG_M5272 @@ -1658,19 +1665,7 @@ static void fec_get_mac(struct net_device *ndev) #endif } - /* - * 4) FEC mac registers set by bootloader - */ - if (!is_valid_ether_addr(iap)) { - *((__be32 *) &tmpaddr[0]) = - cpu_to_be32(readl(fep->hwp + FEC_ADDR_LOW)); - *((__be16 *) &tmpaddr[4]) = - cpu_to_be16(readl(fep->hwp + FEC_ADDR_HIGH) >> 16); - iap = &tmpaddr[0]; - } - - /* - * 5) random mac address + /* 5) random mac address */ if (!is_valid_ether_addr(iap)) { /* Report it and use a random ethernet address instead */