From: Masahiro Yamada Date: Thu, 15 Jan 2015 16:29:27 +0900 Subject: [U-Boot] [PATCH 04/21] dm: fdt: Add a function to decode phandles with arguments In-Reply-To: <1420513543-4453-5-git-send-email-sjg@chromium.org> References: <1420513543-4453-1-git-send-email-sjg@chromium.org> <1420513543-4453-5-git-send-email-sjg@chromium.org> Message-ID: <20150115162927.F0F5.AA925319@jp.panasonic.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Simon, A nit On Mon, 5 Jan 2015 20:05:26 -0700 Simon Glass wrote: > For GPIOs and other functions we want to look up a phandle and then decode > a list of arguments for that phandle. Each phandle can have a different > number of arguments, specified by a property in the target node. This is > the "#gpio-cells" property for GPIOs. > > Add a function to provide this feature, taken modified from Linux 3.18. > > Signed-off-by: Simon Glass > --- > > include/fdtdec.h | 53 ++++++++++++++++++++++++ > lib/fdtdec.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 177 insertions(+) > > diff --git a/include/fdtdec.h b/include/fdtdec.h > index 5effa24..629e072 100644 > --- a/include/fdtdec.h > +++ b/include/fdtdec.h > @@ -133,6 +133,59 @@ enum fdt_compat_id { > COMPAT_COUNT, > }; > > +#define MAX_PHANDLE_ARGS 16 > +struct fdtdec_phandle_args { > + int node; > + int args_count; > + uint32_t args[MAX_PHANDLE_ARGS]; > +}; > + > +/** > + * fdtdec_parse_phandle_with_args() - Find a node pointed by phandle in a list > + * > + * This function is useful to parse lists of phandles and their arguments. > + * > + * Example: > + * > + * phandle1: node1 { > + * #list-cells = <2>; > + * } > + * > + * phandle2: node2 { > + * #list-cells = <1>; > + * } > + * > + * node3 { > + * list = <&phandle1 1 2 &phandle2 3>; > + * } > + * > + * To get a device_node of the `node2' node you may call this: > + * fdtdec_parse_phandle_with_args(blob, node3, "list", "#list-cells", 0, 1, > + * &args); > + * > + * (This function is a modified version of of_parse_phandle_with_args() from > + * Linux 3.18) I think this is a modified version of __of_parse_phandle_with_args() Best Regards Masahiro Yamada