From patchwork Fri Jan 3 10:10:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 306529 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 8007E2C00A4 for ; Fri, 3 Jan 2014 21:11:59 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 240374ADDC; Fri, 3 Jan 2014 11:11:58 +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 gvBnhoM-w6JW; Fri, 3 Jan 2014 11:11:57 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3B1A74AE3B; Fri, 3 Jan 2014 11:11:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F173A4AE03 for ; Fri, 3 Jan 2014 11:11:29 +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 DHapuIHzA9xq for ; Fri, 3 Jan 2014 11:11:25 +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-ea0-f175.google.com (mail-ea0-f175.google.com [209.85.215.175]) by theia.denx.de (Postfix) with ESMTPS id 4BFE94ADDC for ; Fri, 3 Jan 2014 11:11:19 +0100 (CET) Received: by mail-ea0-f175.google.com with SMTP id z10so6666476ead.34 for ; Fri, 03 Jan 2014 02:11:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:in-reply-to:references:content-type; bh=Hmx/a1Ll1zq7szCPuy4NI0/XmYjyZaTcWY6Qd3PoolE=; b=EGhZo9iXsciTWVNmQO+c8oGBOyh3Q10PYskYiLOMimnf0JR2oEe88cddSezfS83p73 qMRKz1Jz/jq+WSIwDYoZi+G/W+MfCeB1miZ22m6XscwDo9POmSZ6UhNibGHLRmM3yP+H 41ivEBe76Fkuwe1CX5HXpv5p8TXDLPltw8ffpYbeHmBPfGizNLK2NX63YjxtAp0v4UIj UQkuEgKQ9huwdRVY1SmV4fS66CwVPkprfraChXtpSFejvHdkmOTwyDvOOKUuqJi7jMXx mckoXizG687xpVeBAvBltckADixBp8mYf6uvMF+GtzKH1hslA4MO7IVLhBIVnjEBUnuR 8XSg== X-Gm-Message-State: ALoCoQkc+1rgTMEQ0U6Us/igAQiHmM6/Uk3zL0IY1S0ogRe7oh75fXTKLo1epVWcraoK852wTYAs X-Received: by 10.14.104.7 with SMTP id h7mr941443eeg.95.1388743879294; Fri, 03 Jan 2014 02:11:19 -0800 (PST) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id a45sm143618649eem.6.2014.01.03.02.11.17 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Fri, 03 Jan 2014 02:11:18 -0800 (PST) From: Michal Simek To: Michal Simek , u-boot@lists.denx.de, Joe Hershberger , linux-arm-kernel@lists.infradead.org, Albert Aribaud , Tom Rini Date: Fri, 3 Jan 2014 11:10:47 +0100 Message-Id: <3033ad4cfeb6d552e5b1b7fc55599efff3e816d2.1388743861.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: References: In-Reply-To: References: Subject: [U-Boot] [PATCH v1 02/24] net: gem: Add OF initialization support 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 Gem can be directly initialized from DTB. Signed-off-by: Michal Simek --- Changes in v1: None drivers/net/zynq_gem.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/netdev.h | 1 + 2 files changed, 43 insertions(+) -- 1.8.2.3 diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index 6a017a8..a673fa7 100644 --- a/drivers/net/zynq_gem.c +++ b/drivers/net/zynq_gem.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include #include @@ -527,3 +529,43 @@ int zynq_gem_initialize(bd_t *bis, int base_addr, int phy_addr, u32 emio) return 1; } + +#ifdef CONFIG_OF_CONTROL +int zynq_gem_of_init(const void *blob) +{ + int offset = 0; + u32 ret = 0; + u32 reg, phy_reg; + + debug("ZYNQ GEM: Initialization\n"); + + do { + offset = fdt_node_offset_by_compatible(blob, offset, + "xlnx,ps7-ethernet-1.00.a"); + if (offset != -1) { + reg = fdtdec_get_addr(blob, offset, "reg"); + if (reg != FDT_ADDR_T_NONE) { + offset = fdtdec_lookup_phandle(blob, offset, + "phy-handle"); + if (offset != -1) + phy_reg = fdtdec_get_addr(blob, offset, + "reg"); + else + phy_reg = 0; + + debug("ZYNQ GEM: addr %x, phyaddr %x\n", + reg, phy_reg); + + ret |= zynq_gem_initialize(NULL, reg, + phy_reg, 0); + + } else { + debug("ZYNQ GEM: Can't get base address\n"); + return -1; + } + } + } while (offset != -1); + + return ret; +} +#endif diff --git a/include/netdev.h b/include/netdev.h index 25d1e46..b9eab0e 100644 --- a/include/netdev.h +++ b/include/netdev.h @@ -91,6 +91,7 @@ int xilinx_emaclite_initialize(bd_t *bis, unsigned long base_addr, int txpp, int rxpp); int xilinx_ll_temac_eth_init(bd_t *bis, unsigned long base_addr, int flags, unsigned long ctrl_addr); +int zynq_gem_of_init(const void *blob); int zynq_gem_initialize(bd_t *bis, int base_addr, int phy_addr, u32 emio); /* * As long as the Xilinx xps_ll_temac ethernet driver has not its own interface