From patchwork Sun Oct 21 14:23:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Eastwood X-Patchwork-Id: 1622601 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 19563DFFF1 for ; Sun, 21 Oct 2012 14:26:12 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TPwRd-00029O-A2; Sun, 21 Oct 2012 14:24:01 +0000 Received: from mail-la0-f49.google.com ([209.85.215.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TPwRG-00026b-5g for linux-arm-kernel@lists.infradead.org; Sun, 21 Oct 2012 14:23:40 +0000 Received: by mail-la0-f49.google.com with SMTP id z14so1064159lag.36 for ; Sun, 21 Oct 2012 07:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=gD1XTG2MVwwRXmgdUC5KdsO2nS2/xdPX1fzkVNk1AWg=; b=dSEZaDuGwWtimGxuUDjMsLP0qbblcdGvfWBF5eCkuI6Uc+iyzlrGZozh+XG/H9Ptr7 2TdhDtG4TiD4LdDajiQElIVoO1iBjW/NWn9U4poiGI0tvxLpmFVMpPOvqH2etxlm1YXi /tV3WwFUUW0UJ+zUKE/1n1i8IQEE3dh81h/Z+ubxgOLTu16ahn2w79OHZC2Ujb8cdgql Q4OzE+45QhhCJbtJ2G7tVSXK/3BXjPaEwR0SzlghVdF/gJ1n42OVthxIu29W3K6q+dki XRWRYZIW0CjL0OK3GcYXNv8YxQovWNI7DRt9uHfET/vcz4B5p2amKVfRddWAy8q4/ED2 LkHQ== Received: by 10.112.39.233 with SMTP id s9mr2659778lbk.71.1350829416768; Sun, 21 Oct 2012 07:23:36 -0700 (PDT) Received: from localhost.localdomain ([90.149.223.57]) by mx.google.com with ESMTPS id jk8sm2149775lab.7.2012.10.21.07.23.35 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 21 Oct 2012 07:23:36 -0700 (PDT) From: Joachim Eastwood To: nicolas.ferre@atmel.com, davem@davemloft.net, hskinnemoen@gmail.com, egtvedt@samfundet.no, plagnioj@jcrosoft.com, bgat@billgatliff.com Subject: [PATCH 3/5] net/at91_ether: move eth addr quirk into csb337 board setup Date: Sun, 21 Oct 2012 16:23:10 +0200 Message-Id: <1350829392-3812-4-git-send-email-manabian@gmail.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1350829392-3812-1-git-send-email-manabian@gmail.com> References: <1350829392-3812-1-git-send-email-manabian@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (manabian[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: netdev@vger.kernel.org, Joachim Eastwood , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Move Ethernet address byte order fix for csb337 into it's board setup. This will allow us to remove the last mach include from at91_ether and also to share the address setup with the macb driver. Signed-off-by: Joachim Eastwood --- arch/arm/mach-at91/board-csb337.c | 35 +++++++++++++++++++++++++++++++ drivers/net/ethernet/cadence/Kconfig | 1 - drivers/net/ethernet/cadence/at91_ether.c | 26 ++++++----------------- 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c index 3e37437..5522132 100644 --- a/arch/arm/mach-at91/board-csb337.c +++ b/arch/arm/mach-at91/board-csb337.c @@ -217,6 +217,40 @@ static struct gpio_led csb_leds[] = { } }; +/* + * MicroMonitor (uMon) on the CSB337 store the ethernet address in the + * wrong byte order (and continues to do so, for bug-compatibility). + */ +#define MACB_SA1B 0x0098 +#define MACB_SA1T 0x009c +static void __init csb337_fix_eth_addr(void) +{ + void __iomem *emac; + u32 lo, hi, tmp; + int i; + + emac = ioremap(AT91RM9200_BASE_EMAC, SZ_16K); + if (!emac) { + printk(KERN_ERR "csb337: unable to fixup Ethernet address\n"); + return; + } + + /* Fix byte order on all 4 address registers */ + for (i = 0; i < 4; i++) { + lo = readl(emac + MACB_SA1B + i * 8); + hi = readl(emac + MACB_SA1T + i * 8); + + tmp = (lo & 0xff) << 8 | (lo & 0xff00) >> 8; + writel(tmp, emac + MACB_SA1T + i * 8); + + tmp = (hi & 0xff) << 8 | (hi & 0xff00) >> 8 + | (lo & 0xff0000) << 8 + | (lo & 0xff000000) >> 8; + writel(tmp, emac + MACB_SA1B + i * 8); + } + + iounmap(emac); +} static void __init csb337_board_init(void) { @@ -225,6 +259,7 @@ static void __init csb337_board_init(void) at91_register_uart(0, 0, 0); at91_add_device_serial(); /* Ethernet */ + csb337_fix_eth_addr(); at91_add_device_eth(&csb337_eth_data); /* USB Host */ at91_add_device_usbh(&csb337_usbh_data); diff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig index f6d0956..40172d1 100644 --- a/drivers/net/ethernet/cadence/Kconfig +++ b/drivers/net/ethernet/cadence/Kconfig @@ -21,7 +21,6 @@ if NET_CADENCE config ARM_AT91_ETHER tristate "AT91RM9200 Ethernet support" - depends on ARM && ARCH_AT91RM9200 select NET_CORE select MACB ---help--- diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c index 375d272..5ed1a63 100644 --- a/drivers/net/ethernet/cadence/at91_ether.c +++ b/drivers/net/ethernet/cadence/at91_ether.c @@ -32,8 +32,6 @@ #include #include -#include - #include "macb.h" #define DRV_NAME "at91_ether" @@ -55,30 +53,18 @@ * U-Boot on the AT91RM9200-DK do not do this. * * - Likewise it must store the addresses in the correct byte order. - * MicroMonitor (uMon) on the CSB337 does this incorrectly (and - * continues to do so, for bug-compatibility). */ static short __init unpack_mac_address(struct net_device *dev, unsigned int hi, unsigned int lo) { char addr[6]; - if (machine_is_csb337()) { - addr[5] = (lo & 0xff); /* The CSB337 bootloader stores the MAC the wrong-way around */ - addr[4] = (lo & 0xff00) >> 8; - addr[3] = (lo & 0xff0000) >> 16; - addr[2] = (lo & 0xff000000) >> 24; - addr[1] = (hi & 0xff); - addr[0] = (hi & 0xff00) >> 8; - } - else { - addr[0] = (lo & 0xff); - addr[1] = (lo & 0xff00) >> 8; - addr[2] = (lo & 0xff0000) >> 16; - addr[3] = (lo & 0xff000000) >> 24; - addr[4] = (hi & 0xff); - addr[5] = (hi & 0xff00) >> 8; - } + addr[0] = (lo & 0xff); + addr[1] = (lo & 0xff00) >> 8; + addr[2] = (lo & 0xff0000) >> 16; + addr[3] = (lo & 0xff000000) >> 24; + addr[4] = (hi & 0xff); + addr[5] = (hi & 0xff00) >> 8; if (is_valid_ether_addr(addr)) { memcpy(dev->dev_addr, &addr, 6);