diff mbox series

[U-Boot,v4] drivers: core: Add translation in live tree case

Message ID 20171220085212.23826-1-mario.six@gdsys.cc
State Accepted
Commit 286ede6515bdde4550c247f0d08ed28c5dbf8db2
Delegated to: Simon Glass
Headers show
Series [U-Boot,v4] drivers: core: Add translation in live tree case | expand

Commit Message

Mario Six Dec. 20, 2017, 8:52 a.m. UTC
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 <mario.six@gdsys.cc>

---
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

Comments

Stephen Warren Dec. 20, 2017, 3:45 p.m. UTC | #1
On 12/20/2017 01:52 AM, Mario Six wrote:
> 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 <mario.six@gdsys.cc>
> 
> ---
> v3 -> v4:
> * Fixed issue on 64-bit platforms

Tested-by: Stephen Warren <swarren@nvidia.com>
Simon Glass Jan. 22, 2018, 12:41 a.m. UTC | #2
On 20 December 2017 at 08:45, Stephen Warren <swarren@wwwdotorg.org> wrote:
> On 12/20/2017 01:52 AM, Mario Six wrote:
>>
>> 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 <mario.six@gdsys.cc>
>>
>> ---
>> v3 -> v4:
>> * Fixed issue on 64-bit platforms
>
>
> Tested-by: Stephen Warren <swarren@nvidia.com>

Applied to u-boot-dm, thanks!
diff mbox series

Patch

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));