From d75b33af676d0beac8398651a7f09037555a550b Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 26 Nov 2009 15:37:13 +1100 Subject: Support ePAPR compliant phandle properties Currently, the Linux kernel, libfdt and dtc, when using flattened device trees encode a node's phandle into a property named "linux,phandle". The ePAPR specification, however - aiming as it is to not be a Linux specific spec - requires that phandles be encoded in a property named simply "phandle". This patch adds support for this newer approach to dtc and libfdt. Specifically: - fdt_get_phandle() will now return the correct phandle if it is supplied in either of these properties - fdt_node_offset_by_phandle() will correctly find a node with the given phandle encoded in either property. - By default, when auto-generating phandles, dtc will encode it into both properties for maximum compatibility. A new -H option allows either only old-style or only new-style properties to be generated. - If phandle properties are explicitly supplied in the dts file, dtc will not auto-generate ones in the alternate format. - If both properties are supplied, dtc will check that they have the same value. - Some existing testcases are updated to use a mix of old and new-style phandles, partially testing the changes. - A new phandle_format test further tests the libfdt support, and the -H option. Signed-off-by: David Gibson --- livetree.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'livetree.c') diff --git a/livetree.c b/livetree.c index 2fa1490..9a482a8 100644 --- a/livetree.c +++ b/livetree.c @@ -297,12 +297,22 @@ cell_t get_node_phandle(struct node *root, struct node *node) phandle++; node->phandle = phandle; - if (!get_property(node, "linux,phandle")) + + if (!get_property(node, "linux,phandle") + && (phandle_format & PHANDLE_LEGACY)) add_property(node, build_property("linux,phandle", data_append_cell(empty_data, phandle), NULL)); - /* If the node *does* have a linux,phandle property, we must + + if (!get_property(node, "phandle") + && (phandle_format & PHANDLE_EPAPR)) + add_property(node, + build_property("phandle", + data_append_cell(empty_data, phandle), + NULL)); + + /* If the node *does* have a phandle property, we must * be dealing with a self-referencing phandle, which will be * fixed up momentarily in the caller */ -- cgit v1.2.1