[PATCH 5/6] of: Use the standards compliant default address cells value for x86

Herve Codina
2024-11-04T17:20:13Z

The default address cells value is 1.

According to the devicetree specification and the OpenFirmware standard
(IEEE 1275-1994) this default value should be 2.

The device tree compiler already use 2 as default value and the powerpc
PROM code also use 2 as default value. Modern implementation should have
the #address-cells property set and should not rely on this default
value.

On x86, an empty root device-tree node is created but as the hardware
is not described by a device-tree passed by the bootloader, this root
device-tree remains empty and so the #address-cells default value is
used.

In preparation of the support for device-tree overlay on PCI devices
feature on x86 (i.e. the creation of the PCI root bus device-tree node),
this default value needs to be updated. Indeed, on x86_64, addresses are
on 64bits and the upper part of an address is needed for correct address
translations. On x86_32 having the default value updated does not lead
to issues while the uppert part of a 64bits address is zero.

Changing the default value for all architectures may break device-tree
compatibility. Indeed, existing dts file without the #address-cells
property set in the root node will not be compatible with this
modification. Restrict the modification to the x86 architecture.

Instead of having 1 for this default value, be consistent with standards
and set the default address cells value to 2 in case of x86.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
drivers/of/of_private.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 04aa2a91f851..d8353f04af0a 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -29,7 +29,7 @@ struct alias_prop {
char stem[];
};

-#if defined(CONFIG_SPARC)
+#if defined(CONFIG_SPARC) || defined(CONFIG_X86)
#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2
#else
#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
--
2.46.2