From patchwork Fri Oct 26 02:31:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 194345 X-Patchwork-Delegate: vanbaren@cideas.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 F2CE42C008E for ; Fri, 26 Oct 2012 13:34:54 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E08F14A635; Fri, 26 Oct 2012 04:33:51 +0200 (CEST) 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 hg370rQiwpgC; Fri, 26 Oct 2012 04:33:51 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EAD574A491; Fri, 26 Oct 2012 04:32:44 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ED8684A488 for ; Fri, 26 Oct 2012 04:31:40 +0200 (CEST) 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 I-8E2tJ2MnhA for ; Fri, 26 Oct 2012 04:31:40 +0200 (CEST) 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-gg0-f202.google.com (mail-gg0-f202.google.com [209.85.161.202]) by theia.denx.de (Postfix) with ESMTPS id 6D2A54A453 for ; Fri, 26 Oct 2012 04:31:25 +0200 (CEST) Received: by mail-gg0-f202.google.com with SMTP id i4so300469ggm.3 for ; Thu, 25 Oct 2012 19:31:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=i6YCYRbois8z20a8CdEg5uPJSuSwy9lmRJAhsAcC2gg=; b=YvfzwaCVNizDbruEc4T0O8LKtuCkboxDhQ7KiOx3wGkyWfOcKo9RaZM0mugwv8fZrq DVLNPuhhH32Fo8UTRL5+qUD8kcuVHTQgqcbYKms8t+jujvhgAln3emfr0D3ca5XdA/+L IRmFOsBBdhOP6uwPjfvrT4UxDVHgwn1wxMtb3wIXWEjOvLu1iNTdukTj4EZWFqTxxXCy mH5QMCX8JQX8kJDWqgfnNoqLpbosT/bF0FqB4Qug1dDGzdSfFvLlTbPr7Q14X9Vm8LiM 2ktPbkC8KYurRbrhSlGZnW3+Nqypvy3fWTxRvVnvds62kxvs9+0TgzbJ6mlksv1uRHaf qPHA== Received: by 10.236.151.39 with SMTP id a27mr14339266yhk.42.1351218682400; Thu, 25 Oct 2012 19:31:22 -0700 (PDT) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id i27si18123yhb.0.2012.10.25.19.31.22 (version=TLSv1/SSLv3 cipher=AES128-SHA); Thu, 25 Oct 2012 19:31:22 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 4D8E01E0048; Thu, 25 Oct 2012 19:31:22 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 03D1016187C; Thu, 25 Oct 2012 19:31:21 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 25 Oct 2012 19:31:05 -0700 Message-Id: <1351218671-15228-9-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1351218671-15228-1-git-send-email-sjg@chromium.org> References: <1351218671-15228-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQk6CvHTL4+HI2zQLYaLbBA7DVXD9gCbForEmjY+3282IzuTqMQh1Dc+qh+u2lAgnNHE51YjOv+HFYwX5C2DWB63AXkx/m0pNMCcouyyuuzYRwQI8hRz8okyqtT9z/4e7aIGPdDXoPzTTpQWFUncEz6PUdf2JAZ8vvuIQdccSyallDwntka8S6IOzK6fr2znXbZfaY5I Cc: Tom Rini , Jerry Van Baren , Devicetree Discuss Subject: [U-Boot] [PATCH 08/14] fdt: Add fdtdec_get_uint64 to decode a 64-bit value from a property 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 From: Che-Liang Chiou It decodes a 64-bit value from a property that is at least 8 bytes long. Signed-off-by: Che-Liang Chiou Signed-off-by: Simon Glass --- include/fdtdec.h | 15 +++++++++++++++ lib/fdtdec.c | 13 +++++++++++++ 2 files changed, 28 insertions(+), 0 deletions(-) diff --git a/include/fdtdec.h b/include/fdtdec.h index 82fdb99..12f73a7 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -191,6 +191,21 @@ s32 fdtdec_get_int(const void *blob, int node, const char *prop_name, s32 default_val); /** + * Look up a 64-bit integer property in a node and return it. The property + * must have at least 8 bytes of data (2 cells). The first two cells are + * concatenated to form a 8 bytes value, where the first cell is top half and + * the second cell is bottom half. + * + * @param blob FDT blob + * @param node node to examine + * @param prop_name name of property to find + * @param default_val default value to return if the property is not found + * @return integer value, if found, or default_val if not + */ +uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name, + uint64_t default_val); + +/** * Checks whether a node is enabled. * This looks for a 'status' property. If this exists, then returns 1 if * the status is 'ok' and 0 otherwise. If there is no status property, diff --git a/lib/fdtdec.c b/lib/fdtdec.c index fbb2827..6c417d2 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -111,6 +111,19 @@ s32 fdtdec_get_int(const void *blob, int node, const char *prop_name, return default_val; } +uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name, + uint64_t default_val) +{ + const uint64_t *cell64; + int length; + + cell64 = fdt_getprop(blob, node, prop_name, &length); + if (!cell64 || length < sizeof(*cell64)) + return default_val; + + return fdt64_to_cpu(*cell64); +} + int fdtdec_get_is_enabled(const void *blob, int node) { const char *cell;