From patchwork Thu Feb 13 10:30:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 319947 X-Patchwork-Delegate: trini@ti.com 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 2064C2C00B3 for ; Thu, 13 Feb 2014 21:30:57 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 98A244B5EC; Thu, 13 Feb 2014 11:30:51 +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 kxbSP+bcewfZ; Thu, 13 Feb 2014 11:30:51 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 183944B5B1; Thu, 13 Feb 2014 11:30:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 523D24B578 for ; Thu, 13 Feb 2014 11:30:35 +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 7+Nsvghc-ZZN for ; Thu, 13 Feb 2014 11:30:32 +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-ee0-f46.google.com (mail-ee0-f46.google.com [74.125.83.46]) by theia.denx.de (Postfix) with ESMTPS id 11D6B4B576 for ; Thu, 13 Feb 2014 11:30:28 +0100 (CET) Received: by mail-ee0-f46.google.com with SMTP id c13so4891557eek.19 for ; Thu, 13 Feb 2014 02:30:27 -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=fZjjhn7xG51F2iPreLXtd0O61bR6NnqiSgbUzUfgKbU=; b=ZOk4bTmJAC74LzwXsp+OaWTRVgdPezlHiN9x+YfyWfa4keQ+See5CwMEmApiEey8/H jyynyF9rx3vCHQzWYbaUXteI7Zx4OD/nGNvNRsF1xk5yhrr+8wu0e9GCS6YtDyfzYTNV FeP8+QOzdRSC7KzJv66Cg3BZZxIx8DNNcO/jlDjNEEg/kIntgsTewvH5efNuOKzfl/O/ I5Ae7m0vBVmpcUYYik35hiEovZDSfhN3ioq6cZx70onVdFGzy0/z0FJlOCO6Sib6gpJ3 aFFvzuVqK3Y7ZTItYKqneKVALB1YRBhhUlZqbkBmqw/5Mq2G6DUYuq2F++Wr1S0Ym2kr lSJg== X-Gm-Message-State: ALoCoQm5KJ8Mrhazu9mzQBSl4hAr6pTl455bFRAngqUvVcI6/ebfsaHKZyCe2xKKHPFuVGXWztZC X-Received: by 10.14.174.5 with SMTP id w5mr1092957eel.14.1392287427814; Thu, 13 Feb 2014 02:30:27 -0800 (PST) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id j41sm5289624eey.15.2014.02.13.02.30.26 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Thu, 13 Feb 2014 02:30:26 -0800 (PST) From: Michal Simek To: u-boot@lists.denx.de Date: Thu, 13 Feb 2014 11:30:05 +0100 Message-Id: X-Mailer: git-send-email 1.8.2.3 In-Reply-To: References: In-Reply-To: References: Subject: [U-Boot] [PATCH 2/5] 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 --- 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 381bca4..9affebd 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 @@ -532,3 +534,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 c684014..32b5073 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