From patchwork Tue May 10 20:14:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 95027 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 C4A86B6EEB for ; Wed, 11 May 2011 06:15:17 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E70AB2808A; Tue, 10 May 2011 22:15:13 +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 WEuCJKTsS0CM; Tue, 10 May 2011 22:15:13 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 18C232808B; Tue, 10 May 2011 22:15:01 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 802A428086 for ; Tue, 10 May 2011 22:14:58 +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 ycPV4P5ZrAJV for ; Tue, 10 May 2011 22:14:57 +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 DB3EHSOBE006.bigfish.com (db3ehsobe006.messaging.microsoft.com [213.199.154.144]) by theia.denx.de (Postfix) with ESMTPS id 0734428081 for ; Tue, 10 May 2011 22:14:54 +0200 (CEST) Received: from mail72-db3-R.bigfish.com (10.3.81.249) by DB3EHSOBE006.bigfish.com (10.3.84.26) with Microsoft SMTP Server id 14.1.225.8; Tue, 10 May 2011 20:14:54 +0000 Received: from mail72-db3 (localhost.localdomain [127.0.0.1]) by mail72-db3-R.bigfish.com (Postfix) with ESMTP id 386564C0CE0; Tue, 10 May 2011 20:14:54 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839h62h) X-Spam-TCS-SCL: 1:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail72-db3 (localhost.localdomain [127.0.0.1]) by mail72-db3 (MessageSwitch) id 130505849432671_12133; Tue, 10 May 2011 20:14:54 +0000 (UTC) Received: from DB3EHSMHS006.bigfish.com (unknown [10.3.81.246]) by mail72-db3.bigfish.com (Postfix) with ESMTP id EF64CE40051; Tue, 10 May 2011 20:14:53 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by DB3EHSMHS006.bigfish.com (10.3.87.106) with Microsoft SMTP Server (TLS) id 14.1.225.8; Tue, 10 May 2011 20:14:53 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server id 14.1.270.2; Tue, 10 May 2011 15:14:52 -0500 Received: from efes.am.freescale.net (efes.am.freescale.net [10.82.123.3]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id p4AKEp12002754; Tue, 10 May 2011 15:14:51 -0500 (CDT) From: Timur Tabi To: , , Date: Tue, 10 May 2011 15:14:50 -0500 Message-ID: <1305058491-19720-1-git-send-email-timur@freescale.com> X-Mailer: git-send-email 1.7.3.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Subject: [U-Boot] [PATCH 1/2] fdt: introduce fdt_create_phandle() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The ePAPR specification says that phandle properties should be called "phandle", and not "linux,phandle". To facilitate the migration from "linux,phandle" to "phandle", introduce function fdt_create_phandle(), which creates a phandle in a given node. For now, we create both the "phandle" and "linux,phandle" properties. A later version of this function will remove support for "linux,phandle". Signed-off-by: Timur Tabi --- common/fdt_support.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/fdt_support.h | 1 + 2 files changed, 41 insertions(+), 0 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index 85715ff..dd9deaf 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -1201,6 +1201,46 @@ int fdt_alloc_phandle(void *blob) return phandle + 1; } +/* + * fdt_create_phandle: Create a phandle property for the given node + * + * @fdt: ptr to device tree + * @nodeoffset: node to update + * @phandle: phandle value to set (must be unique) +*/ +int fdt_create_phandle(void *fdt, int nodeoffset, uint32_t phandle) +{ + int ret; + +#ifdef DEBUG + int off = fdt_node_offset_by_phandle(fdt, phandle); + + if ((off >= 0) && (off != nodeoffset)) { + char buf[64]; + + fdt_get_path(fdt, nodeoffset, buf, sizeof(buf)); + printf("Trying to update node %s with phandle %u ", + buf, phandle); + + fdt_get_path(fdt, off, buf, sizeof(buf)); + printf("that already exists in node %s.\n", buf); + return -FDT_ERR_BADPHANDLE; + } +#endif + + ret = fdt_setprop_cell(fdt, nodeoffset, "phandle", phandle); + if (ret < 0) + return ret; + + /* + * For now, also set the deprecated "linux,phandle" property, so that we + * don't break older kernels. + */ + ret = fdt_setprop_cell(fdt, nodeoffset, "linux,phandle", phandle); + + return ret; +} + #if defined(CONFIG_VIDEO) int fdt_add_edid(void *blob, const char *compat, unsigned char *edid_buf) { diff --git a/include/fdt_support.h b/include/fdt_support.h index ce6817b..366062f 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -88,6 +88,7 @@ u64 fdt_translate_address(void *blob, int node_offset, const u32 *in_addr); int fdt_node_offset_by_compat_reg(void *blob, const char *compat, phys_addr_t compat_off); int fdt_alloc_phandle(void *blob); +int fdt_create_phandle(void *fdt, int nodeoffset, uint32_t phandle); int fdt_add_edid(void *blob, const char *compat, unsigned char *buf); #endif /* ifdef CONFIG_OF_LIBFDT */