diff options
author | Dario Binacchi <dariobin@libero.it> | 2020-12-30 00:16:21 +0100 |
---|---|---|
committer | Lokesh Vutla <lokeshvutla@ti.com> | 2021-01-12 10:58:05 +0530 |
commit | d64b9cdcd475eb7f07b49741ded87e24dae4a5fc (patch) | |
tree | 5cb04e031a5c12974c1df61cc4ab3407edca52b2 /include/asm-generic/global_data.h | |
parent | 52b61c944ce536f975d095d4fa32d8bb656661fd (diff) | |
download | u-boot-d64b9cdcd475eb7f07b49741ded87e24dae4a5fc.tar.gz |
fdt: translate address if #size-cells = <0>
The __of_translate_address routine translates an address from the
device tree into a CPU physical address. A note in the description of
the routine explains that the crossing of any level with
since inherited from IBM. This does not happen for Texas Instruments, or
at least for the beaglebone device tree. Without this patch, in fact,
the translation into physical addresses of the registers contained in the
am33xx-clocks.dtsi nodes would not be possible. They all have a parent
with #size-cells = <0>.
The CONFIG_OF_TRANSLATE_ZERO_SIZE_CELLS symbol makes translation
possible even in the case of crossing levels with #size-cells = <0>.
The patch acts conservatively on address translation, except for
removing a check within the of_translate_one function in the
drivers/core/of_addr.c file:
+
ranges = of_get_property(parent, rprop, &rlen);
- if (ranges == NULL && !of_empty_ranges_quirk(parent)) {
- debug("no ranges; cannot translate\n");
- return 1;
- }
if (ranges == NULL || rlen == 0) {
offset = of_read_number(addr, na);
memset(addr, 0, pna * 4);
debug("empty ranges; 1:1 translation\n");
There are two reasons:
1 The function of_empty_ranges_quirk always returns false, invalidating
the following if statement in case of null ranges. Therefore one of
the two checks is useless.
2 The implementation of the of_translate_one function found in the
common/fdt_support.c file has removed this check while keeping the one
about the 1:1 translation.
The patch adds a test and modifies a check for the correctness of an
address in the case of enabling translation also for zero size cells.
The added test checks translations of addresses generated by nodes of
a device tree similar to those you can find in the files am33xx.dtsi
and am33xx-clocks.dtsi for which the patch was created.
The patch was also tested on a beaglebone black board. The addresses
generated for the registers of the loaded drivers are those specified
by the AM335x reference manual.
Signed-off-by: Dario Binacchi <dariobin@libero.it>
Tested-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/asm-generic/global_data.h')
-rw-r--r-- | include/asm-generic/global_data.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 31e249177c..efa09a1943 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -184,6 +184,12 @@ struct global_data { #ifdef CONFIG_DM /** + * @dm_flags: additional flags for Driver Model + * + * See &enum gd_dm_flags + */ + unsigned long dm_flags; + /** * @dm_root: root instance for Driver Model */ struct udevice *dm_root; @@ -471,6 +477,12 @@ struct global_data { #define gd_acpi_ctx() NULL #endif +#if CONFIG_IS_ENABLED(DM) +#define gd_size_cells_0() (gd->dm_flags & GD_DM_FLG_SIZE_CELLS_0) +#else +#define gd_size_cells_0() (0) +#endif + /** * enum gd_flags - global data flags * @@ -555,6 +567,18 @@ enum gd_flags { GD_FLG_SMP_READY = 0x40000, }; +/** + * enum gd_dm_flags - global data flags for Driver Model + * + * See field dm_flags of &struct global_data. + */ +enum gd_dm_flags { + /** + * @GD_DM_FLG_SIZE_CELLS_0: Enable #size-cells=<0> translation + */ + GD_DM_FLG_SIZE_CELLS_0 = 0x00001, +}; + #endif /* __ASSEMBLY__ */ #endif /* __ASM_GENERIC_GBL_DATA_H */ |