u-boot-brain/include/asm-generic
Dario Binacchi d64b9cdcd4 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>
2021-01-12 10:58:05 +05:30
..
bitops include: Add generic bitops headers 2015-11-05 10:51:57 -05:00
atomic-long.h atomic-long: Fix warnings on arm64 2018-01-28 09:39:05 -05:00
atomic.h Add include/asm-generic/atomic.h 2018-09-25 21:49:18 -04:00
bitsperlong.h linux/bitops.h: GENMASK copy from linux 2015-10-21 09:14:07 -04:00
global_data.h fdt: translate address if #size-cells = <0> 2021-01-12 10:58:05 +05:30
gpio.h gpio: fix gpio_request_by_name() description 2020-10-22 11:26:14 -04:00
int-ll64.h arch: types.h: factor out fixed width typedefs to int-ll64.h 2018-09-10 20:48:16 -04:00
io.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
ioctl.h x86: Fix support for booting bzImage 2010-05-06 00:17:01 +02:00
pe.h efi_loader: use predefined constants in crt0_*_efi.S 2019-07-16 22:17:14 +00:00
sections.h efi_loader: pre-seed UEFI variables 2020-07-16 12:37:02 +02:00
signal.h asm-generic/signal.h: import from linux 2010-01-17 20:36:05 -05:00
types.h arch: types.h: factor out fixed width typedefs to int-ll64.h 2018-09-10 20:48:16 -04:00
u-boot.h asm-generic/u-boot.h: Remove bi_memstart & bi_memsize from bd_info 2020-08-26 09:20:05 +02:00
unaligned.h efi_loader: allow unaligned memory access 2018-06-03 15:27:21 +02:00