[U-Boot] [PATCH v2] core: ofnode: Fix translation for #size-cells == 0
Simon Glass
sjg at chromium.org
Mon Mar 19 17:58:59 UTC 2018
On 12 March 2018 at 07:53, Mario Six <mario.six at gdsys.cc> wrote:
> Commit 286ede6 ("drivers: core: Add translation in live tree case") made
> dev_get_addr always use proper bus translations for addresses read from
> the device tree. But this leads to problems with certain busses, e.g.
> I2C busses, which run into an error during translation, and hence stop
> working.
>
> It turns out that of_translate_address() and fdt_translate_address()
> stop the address translation with an error when they're asked to
> translate addresses for busses where #size-cells == 0 (comment from
> drivers/core/of_addr.c):
>
> * Note: We consider that crossing any level with #size-cells == 0 to mean
> * that translation is impossible (that is we are not dealing with a value
> * that can be mapped to a cpu physical address). This is not really specified
> * that way, but this is traditionally the way IBM at least do things
>
> To fix this case, we check in both the live-tree and non-live tree-case,
> whether the bus of the device whose address is about to be translated
> has size-cell size zero. If this is the case, we just read the address
> as a plain integer and return it, and only apply bus translations if the
> size-cell size if greater than zero.
>
> Signed-off-by: Mario Six <mario.six at gdsys.cc>
> Signed-off-by: Martin Fuzzey <mfuzzey at parkeon.com>
> Reported-by: Martin Fuzzey <mfuzzey at parkeon.com>
> Fixes: 286ede6 ("drivers: core: Add translation in live tree case")
> ---
>
> v1 -> v2:
> * Add unit tests for address translation as suggested by Simon Glass
>
> ---
> arch/sandbox/dts/test.dts | 48 +++++++++++++++++++++++++++++++++++++++++++++++
> drivers/core/fdtaddr.c | 17 +++++++++++------
> drivers/core/ofnode.c | 5 ++++-
> include/dm/uclass-id.h | 1 +
> test/dm/test-fdt.c | 43 ++++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 107 insertions(+), 7 deletions(-)
>
Reviewed-by: Simon Glass <sjg at chromium.org>
More information about the U-Boot
mailing list