[U-Boot] [PATCH] fdt: Allow fdt_translate_address() to work with buses

Simon Glass sjg at chromium.org
Mon Jan 4 00:04:40 CET 2016


It is common for I2C and SPI buses to have a single-cell address and a size
of 0. These produce a warning at present. For example on snow:

__of_translate_address: Bad cell count for gpc4
__of_translate_address: Bad cell count for gpx0
__of_translate_address: Bad cell count for gpv2
__of_translate_address: Bad cell count for gpv4

One of the nodes in question looks like this in part:

	pinctrl_2: pinctrl at 10d10000 {
		#address-cells = <1>;
		#size-cells = <0>;
		gpv2: gpv2 {
			reg = <0x060>;
		};
		gpv4: gpv4 {
			reg = <0xc0>;
		};
	};

This is clearly valid so it looks like the conversion to use
fdt_translate_address() in dev_get_addr() is not currently a good move.

Przemyslaw Marczak sent three patches to resolve this for exynos boards:

https://patchwork.ozlabs.org/patch/557008/
https://patchwork.ozlabs.org/patch/557010/
https://patchwork.ozlabs.org/patch/557009/

But this involves creating a new function, and everyone will need to know
when to use which one. Also the problem may affect other boards.

Instead we can relax the contraint that there must be at least one size
cell. This fixes the problem on snow and should not affect anything else,
since the error check should not fire on normal device trees anyway.

After the release we will have more time to come up with a better solution,
if one exists.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 common/fdt_support.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 66464db..43c5fa8 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -952,8 +952,7 @@ void fdt_del_node_and_alias(void *blob, const char *alias)
 /* Max address size we deal with */
 #define OF_MAX_ADDR_CELLS	4
 #define OF_BAD_ADDR	FDT_ADDR_T_NONE
-#define OF_CHECK_COUNTS(na, ns)	((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
-			(ns) > 0)
+#define OF_CHECK_COUNTS(na, ns)	((na) > 0 && (na) <= OF_MAX_ADDR_CELLS)
 
 /* Debug utility */
 #ifdef DEBUG
-- 
2.6.0.rc2.230.g3dd15c0



More information about the U-Boot mailing list