From patchwork Mon Nov 19 06:14:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J, KEERTHY" X-Patchwork-Id: 999659 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="Dy7WGYDu"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42yzBF3vKlz9sB7 for ; Mon, 19 Nov 2018 17:16:37 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 3135AC2247D; Mon, 19 Nov 2018 06:15:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id EFB4DC224FB; Mon, 19 Nov 2018 06:15:13 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7B1FBC224DD; Mon, 19 Nov 2018 06:15:09 +0000 (UTC) Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lists.denx.de (Postfix) with ESMTPS id 570D7C224A5 for ; Mon, 19 Nov 2018 06:15:06 +0000 (UTC) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAJ6F40j092205; Mon, 19 Nov 2018 00:15:04 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1542608104; bh=xstkj+kHuvZV+1bmsl6DbmPF3T4X2K81THaKyLfX5fM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Dy7WGYDutRaipcpqCCPmIwoa+T88Q6xHJBPW2s4hzhDBnnxTdSlmYRCdY58rZdqa5 RyqeZXBpEawW3BgveiNidXfxPvwhMltriL+htrJ/6BJ7uzqMRhYMWFQWpwROQNytq3 OxvYr88ocfW331Oe9LexmrRD1iAs1H0GogNtHCvc= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAJ6F4sT082088 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 19 Nov 2018 00:15:04 -0600 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 19 Nov 2018 00:15:04 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 19 Nov 2018 00:15:04 -0600 Received: from ula0393675.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAJ6EusG018592; Mon, 19 Nov 2018 00:15:01 -0600 From: Keerthy To: , Date: Mon, 19 Nov 2018 11:44:48 +0530 Message-ID: <1542608088-27843-3-git-send-email-j-keerthy@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1542608088-27843-1-git-send-email-j-keerthy@ti.com> References: <1542608088-27843-1-git-send-email-j-keerthy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de, t-kristo@ti.com Subject: [U-Boot] [PATCH v3 2/2] core: ofnode: Add ofnode_get_addr_size_index X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add ofnode_get_addr_size_index function to fetch the address and size of the reg space based on index. Signed-off-by: Keerthy Signed-off-by: Keerthy --- drivers/core/ofnode.c | 14 ++++++++++---- include/dm/ofnode.h | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 0e584c1..db29a33 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -251,17 +251,16 @@ int ofnode_read_size(ofnode node, const char *propname) return -EINVAL; } -fdt_addr_t ofnode_get_addr_index(ofnode node, int index) +fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size) { int na, ns; - fdt_size_t size; if (ofnode_is_np(node)) { const __be32 *prop_val; uint flags; prop_val = of_get_address(ofnode_to_np(node), index, - (u64 *)&size, &flags); + (u64 *)size, &flags); if (!prop_val) return FDT_ADDR_T_NONE; @@ -278,12 +277,19 @@ fdt_addr_t ofnode_get_addr_index(ofnode node, int index) ns = ofnode_read_simple_size_cells(ofnode_get_parent(node)); return fdtdec_get_addr_size_fixed(gd->fdt_blob, ofnode_to_offset(node), "reg", - index, na, ns, &size, true); + index, na, ns, size, true); } return FDT_ADDR_T_NONE; } +fdt_addr_t ofnode_get_addr_index(ofnode node, int index) +{ + fdt_size_t size; + + return ofnode_get_addr_size_index(node, index, &size); +} + fdt_addr_t ofnode_get_addr(ofnode node) { return ofnode_get_addr_index(node, 0); diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 2fc9fa3..8bfe062 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -356,6 +356,20 @@ int ofnode_read_size(ofnode node, const char *propname); phys_addr_t ofnode_get_addr_index(ofnode node, int index); /** + * ofnode_get_addr_size_index() - get an address/size from a node + * based on index + * + * This reads the register address from a node + * + * @node: node to read from + * @index: Index of address to read (0 for first) + * @size: Pointer to size of the address + * @return address, or FDT_ADDR_T_NONE if not present or invalid + */ +phys_addr_t ofnode_get_addr_size_index(ofnode node, int index, + fdt_size_t *size); + +/** * ofnode_get_addr() - get an address from a node * * This reads the register address from a node