[U-Boot] [RFC] How to get "#address-cells" in U-Boot?
Masahiro Yamada
yamada.m at jp.panasonic.com
Mon Nov 17 11:53:45 CET 2014
On Mon, 17 Nov 2014 19:38:41 +0900
Masahiro Yamada <yamada.m at jp.panasonic.com> wrote:
> Hi.
>
>
> I want to decode the base address of device nodes of my device trees.
>
> For example, drivers/serial/ns16550.c uses fdtdec_get_addr() function
> to decode the "reg" property, but it is not very nice because
> it does not check "#address-cells".
>
> Precisely, we need to check the parent node to get "#address-cells".
> (If the parent does not have it, we need to search for it towards the root node.)
>
>
> I am looking for something like of_n_addr_cells() and of_n_size_cells() functions
> of Linux Kernel.
>
>
> I don't think it is feasible in U-Boot because
> U-Boot handles device tree blobs as they are (as flattened binaries).
>
> If we want to get properties of the parenet node, we must parse the DTB from the
> beginning. Yes, U-Boot actually parses the same DTB over and over again.
>
> Any advice? Import drivers/of/* from Linux??
>
>
>
> Simon, do you have any good idea to solve this problem by DM?
> For example, add "address_cells" and "size_cells" members to struct udevice
> and then modify drivers/core/simple-bus.c to parse "#address-cells" and "#size-cells"
> and pass them to children.
>
I almost solved this problem by myself.
We can get the properties of the parent node with
((struct udevice *)dev)->parent->of_offset
Sorry for noise.
More information about the U-Boot
mailing list