From patchwork Fri Feb 23 16:38:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Tomsich X-Patchwork-Id: 877190 X-Patchwork-Delegate: agust@denx.de 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=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3znxpx3vwDz9ryL for ; Sat, 24 Feb 2018 03:42:49 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 4350BC21FEA; Fri, 23 Feb 2018 16:40:09 +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=RCVD_IN_DNSWL_BLOCKED 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 8B1A3C21FC5; Fri, 23 Feb 2018 16:39:27 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 65596C21FC8; Fri, 23 Feb 2018 16:39:17 +0000 (UTC) Received: from mail.theobroma-systems.com (vegas.theobroma-systems.com [144.76.126.164]) by lists.denx.de (Postfix) with ESMTPS id 5DA2DC21ED5 for ; Fri, 23 Feb 2018 16:39:13 +0000 (UTC) Received: from [86.59.122.178] (port=36650 helo=android.lan) by mail.theobroma-systems.com with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA256:128) (Exim 4.80) (envelope-from ) id 1epGNK-0005jb-I5; Fri, 23 Feb 2018 17:39:10 +0100 From: Philipp Tomsich To: u-boot@lists.denx.de Date: Fri, 23 Feb 2018 17:38:50 +0100 Message-Id: <1519403933-64408-3-git-send-email-philipp.tomsich@theobroma-systems.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1519403933-64408-1-git-send-email-philipp.tomsich@theobroma-systems.com> References: <1519403933-64408-1-git-send-email-philipp.tomsich@theobroma-systems.com> Subject: [U-Boot] [PATCH 2/5] core: add ofnode_get_by_phandle() api 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Kever Yang We need to get ofnode from a phandle, add interface to support both live dt and fdt. Signed-off-by: Kever Yang Reviewed-by: Simon Glass Reviewed-by: Philipp Tomsich Tested-by: Klaus Goger Signed-off-by: Philipp Tomsich --- drivers/core/ofnode.c | 13 +++++++++++++ include/dm/ofnode.h | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index dd6d57c..d0bdea0 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -188,6 +188,19 @@ const char *ofnode_get_name(ofnode node) return fdt_get_name(gd->fdt_blob, ofnode_to_offset(node), NULL); } +ofnode ofnode_get_by_phandle(uint phandle) +{ + ofnode node; + + if (of_live_active()) + node = np_to_ofnode(of_find_node_by_phandle(phandle)); + else + node.of_offset = fdt_node_offset_by_phandle(gd->fdt_blob, + phandle); + + return node; +} + int ofnode_read_size(ofnode node, const char *propname) { int len; diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 6938e62..0d00840 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -318,6 +318,14 @@ ofnode ofnode_get_parent(ofnode node); const char *ofnode_get_name(ofnode node); /** + * ofnode_get_by_phandle() - get ofnode from phandle + * + * @phandle: phandle to look up + * @return ofnode reference to the phandle + */ +ofnode ofnode_get_by_phandle(uint phandle); + +/** * ofnode_read_size() - read the size of a property * * @node: node to check