From patchwork Fri Oct 5 12:09:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Vernier X-Patchwork-Id: 189462 X-Patchwork-Delegate: albert.aribaud@free.fr 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 E6E952C0086 for ; Fri, 5 Oct 2012 22:11:21 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E4F4A28091; Fri, 5 Oct 2012 14:11:19 +0200 (CEST) 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 E213T8gFWWlM; Fri, 5 Oct 2012 14:11:19 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 33A892809A; Fri, 5 Oct 2012 14:10:37 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3843E28084 for ; Fri, 5 Oct 2012 14:10:29 +0200 (CEST) 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 C465-u8oM343 for ; Fri, 5 Oct 2012 14:10:28 +0200 (CEST) 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-lb0-f172.google.com (mail-lb0-f172.google.com [209.85.217.172]) by theia.denx.de (Postfix) with ESMTPS id 95F2228089 for ; Fri, 5 Oct 2012 14:10:18 +0200 (CEST) Received: by mail-lb0-f172.google.com with SMTP id k13so1325163lbo.3 for ; Fri, 05 Oct 2012 05:10:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references:x-gm-message-state; bh=IYxwSc9BSadYF/9f6ZOx/bSha7oGuGqn2/45QikKeFM=; b=N+f+10I8CUdE0aIYZNdIlIyENMxXX46JMSC1K1GRKUC2s8q58/lwfrWRUherenAZxK i3wBzbR/mbMLaiUepwuInSkdC7kGloWp2NJnUV83UU/K21lFT6JsxAxHwlsNKYUE3+gj gJ+MXM0OOHCDAIJFXeLxzCsI/I9NcBbwfU7UeUmHx2iUjOuugymlcgDfMJEpDDpXZ1D6 5y0NkRxRorvEkCRxSoG8mHK5dXttOL9WcJvg9HoeygoJYlHWh4QpAnUhH2bEQ5k+68wk 8urO4LuXIgRPHfX+udmj5uKXahmQnYch/lOR/LzH+wPvrf35l61Prqbo1RplsomCTf9o CYTw== Received: by 10.152.144.2 with SMTP id si2mr6789819lab.26.1349439018016; Fri, 05 Oct 2012 05:10:18 -0700 (PDT) Received: from latmask.orsoc.lan (c213-89-175-97.bredband.comhem.se. [213.89.175.97]) by mx.google.com with ESMTPS id fp7sm1102794lab.4.2012.10.05.05.10.17 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 05 Oct 2012 05:10:17 -0700 (PDT) From: Yann Vernier To: u-boot@lists.denx.de Date: Fri, 5 Oct 2012 14:09:50 +0200 Message-Id: <1349438998-10954-4-git-send-email-yann.vernier@orsoc.se> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1349438998-10954-1-git-send-email-yann.vernier@orsoc.se> References: <1349438998-10954-1-git-send-email-yann.vernier@orsoc.se> In-Reply-To: <20121004111506.1777a119@lilith> References: <20121004111506.1777a119@lilith> X-Gm-Message-State: ALoCoQlkUaxUV/vTwF/UpObU0xU6VABUaSktOcHPvp21+sPNbwC0Wi138794H2WLeKQg16nD5zIz Subject: [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment 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 Removed board specific MAC reading code from driver. Should move the reading to the cm4008/cm41xx board code. --- drivers/net/ks8695eth.c | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/drivers/net/ks8695eth.c b/drivers/net/ks8695eth.c index b4904b6..2dda7ab 100644 --- a/drivers/net/ks8695eth.c +++ b/drivers/net/ks8695eth.c @@ -71,30 +71,13 @@ volatile uint8_t ks8695_bufs[BUFSIZE*(TXDESCS+RXDESCS)] __attribute__((aligned(2 /****************************************************************************/ -/* - * Ideally we want to use the MAC address stored in flash. - * But we do some sanity checks in case they are not present - * first. - */ -unsigned char eth_mac[] = { - 0x00, 0x13, 0xc6, 0x00, 0x00, 0x00 -}; - -void ks8695_getmac(void) +static int ks8695_set_mac_address(struct eth_device *dev) { - unsigned char *fp; - int i; - - /* Check if flash MAC is valid */ - fp = (unsigned char *) 0x0201c000; - for (i = 0; (i < 6); i++) { - if ((fp[i] != 0) && (fp[i] != 0xff)) - break; - } - - /* If we found a valid looking MAC address then use it */ - if (i < 6) - memcpy(ð_mac[0], fp, 6); + /* Set MAC address */ + ks8695_write(KS8695_LAN_MAC_LOW, (dev->enetaddr[5] | (dev->enetaddr[4] << 8) | + (dev->enetaddr[3] << 16) | (dev->enetaddr[2] << 24))); + ks8695_write(KS8695_LAN_MAC_HIGH, (dev->enetaddr[1] | (dev->enetaddr[0] << 8))); + return 0; } /****************************************************************************/ @@ -109,12 +92,8 @@ static int ks8695_eth_init(struct eth_device *dev, bd_t *bd) ks8695_write(KS8695_LAN_DMA_TX, 0x80000000); ks8695_write(KS8695_LAN_DMA_RX, 0x80000000); - ks8695_getmac(); - /* Set MAC address */ - ks8695_write(KS8695_LAN_MAC_LOW, (eth_mac[5] | (eth_mac[4] << 8) | - (eth_mac[3] << 16) | (eth_mac[2] << 24))); - ks8695_write(KS8695_LAN_MAC_HIGH, (eth_mac[1] | (eth_mac[0] << 8))); + ks8695_set_mac_address(dev); /* Turn the 4 port switch on */ i = ks8695_read(KS8695_SWITCH_CTRL0); @@ -150,7 +129,7 @@ static int ks8695_eth_init(struct eth_device *dev, bd_t *bd) ks8695_write(KS8695_LAN_DMA_RX, 0x71); ks8695_write(KS8695_LAN_DMA_RX_START, 0x1); - printf("KS8695 ETHERNET: %pM\n", eth_mac); + printf("KS8695 ETHERNET: %pM\n", dev->enetaddr); return 0; } @@ -234,6 +213,7 @@ int ks8695_eth_initialize(void) dev->halt = ks8695_eth_halt; dev->send = ks8695_eth_send; dev->recv = ks8695_eth_recv; + dev->write_hwaddr = ks8695_set_mac_address; strcpy(dev->name, "ks8695eth"); eth_register(dev);