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: 3430841 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F14879F295 for ; Fri, 3 Jan 2014 10:13:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1E643200F3 for ; Fri, 3 Jan 2014 10:13:19 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A9D44200D6 for ; Fri, 3 Jan 2014 10:13:17 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vz1jh-00079s-CI; Fri, 03 Jan 2014 10:12:13 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vz1jR-0003E5-TH; Fri, 03 Jan 2014 10:11:57 +0000 Received: from mail-ea0-f177.google.com ([209.85.215.177]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vz1j9-00039a-6W for linux-arm-kernel@lists.infradead.org; Fri, 03 Jan 2014 10:11:40 +0000 Received: by mail-ea0-f177.google.com with SMTP id n15so6623701ead.22 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=h+AmiJQ70/3nGoOQJ8ARe0b9F8L59XV7roN3OArKrvK7yZRXXlb39bBULKV+xFlcJK BpzRBWZwSigqucBlgNJGzHSt9XcC36TaaQUyoia1g9GcJLVeVRi/7rUWF1M7RplzY2Q7 WWki2tZGse5KGr34Hv6g2MdxdKe7NlimNd3Iqlwri8XkiyzZC9+Eoa8LW1OcJqX12I48 pf6vjNMjX/RDGg95ofMOI0fSANrU4uJDN/FLKZnWuGSEt8ZQEHcduVNGEZvWoxdeBpKv Pw301NhBdHTuFnL/Z4W3Qd6hOoLjMPijju9uPtfr+uKO1WjZbP7XF4OPnCIUu+xxDiH4 Q2EQ== X-Gm-Message-State: ALoCoQk8TYHk2QvyUNxLABwarrHc45aK/xnUNE/uLMS/6xL5CZevSt8sDVQhW5OA3zfUVVFuf5uZ 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 Subject: [PATCH v1 02/24] net: gem: Add OF initialization support 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140103_051139_401427_D28E3104 X-CRM114-Status: GOOD ( 16.12 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS, 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 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