From patchwork Wed Dec 20 08:52:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Six X-Patchwork-Id: 851325 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=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3z1pSl5dTJz9s4s for ; Wed, 20 Dec 2017 19:52:54 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id B91C2C2201B; Wed, 20 Dec 2017 08:52:50 +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_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS 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 69D23C21DDB; Wed, 20 Dec 2017 08:52:47 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D6836C21DDB; Wed, 20 Dec 2017 08:52:45 +0000 (UTC) Received: from smtprelay04.ispgateway.de (smtprelay04.ispgateway.de [80.67.29.8]) by lists.denx.de (Postfix) with ESMTPS id 4959FC21DA3 for ; Wed, 20 Dec 2017 08:52:45 +0000 (UTC) Received: from [80.151.34.241] (helo=bob3.testumgebung.local) by smtprelay04.ispgateway.de with esmtpa (Exim 4.89) (envelope-from ) id 1eRa7P-0004eU-Ap; Wed, 20 Dec 2017 09:52:51 +0100 From: Mario Six To: U-Boot Mailing List , Simon Glass , Stephen Warren , Tom Rini Date: Wed, 20 Dec 2017 09:52:12 +0100 Message-Id: <20171220085212.23826-1-mario.six@gdsys.cc> X-Mailer: git-send-email 2.11.0 X-Df-Sender: bWFyaW8uc2l4QGdkc3lzLmNj Subject: [U-Boot] [PATCH v4] drivers: core: Add translation in live tree case 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" The function dev_read_addr calls ofnode_get_addr_index in the live tree case, which does not apply bus translations to the address read from the device tree. This results in illegal addresses on boards that rely on bus translations being applied. Fix this situation by applying bus translations in the live tree case as well. Signed-off-by: Mario Six Tested-by: Stephen Warren --- v3 -> v4: * Fixed issue on 64-bit platforms v2 -> v3: * Fixed endianness issue on little-endian platforms v1 -> v2: * Added IS_ENABLED(CONFIG_OF_TRANSLATE) case distinction --- drivers/core/ofnode.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 2.13.6 diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 0030ab962e..2dbf3a7cd7 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -205,8 +205,13 @@ fdt_addr_t ofnode_get_addr_index(ofnode node, int index) &flags); if (!prop_val) return FDT_ADDR_T_NONE; - na = of_n_addr_cells(ofnode_to_np(node)); - return of_read_number(prop_val, na); + + if (IS_ENABLED(CONFIG_OF_TRANSLATE)) { + return of_translate_address(ofnode_to_np(node), prop_val); + } else { + na = of_n_addr_cells(ofnode_to_np(node)); + return of_read_number(prop_val, na); + } } else { return fdt_get_base_address(gd->fdt_blob, ofnode_to_offset(node));