Skip to contentSkip to conversation

How to get "#address-cells" in U-Boot?

RFC Masahiro Yamada 2 participants 5 messages Nov 17, 2014

lore
Share & tools
lore
#0 lore raw

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.

Best Regards
Masahiro Yamada

#1 lore raw

Another question.

Can U-boot handle the address transformation?

If the upper "bus" node has "ranges" property,
it must also be checked to get the correct base address, I think.

Quoted 33 lines · On Mon, 17 Nov 2014 19:38:41 +0900 Masahiro Yamada <[email protected]>…

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.

#2 lore raw

Hi.

Quoted 7 lines

Another question.

Can U-boot handle the address transformation?

If the upper "bus" node has "ranges" property,
it must also be checked to get the correct base address, I think.

I take this question back too.
Sorry for noise.

Quoted 42 lines
Quoted 23 lines · On Mon, 17 Nov 2014 19:38:41 +0900 Masahiro Yamada <[email protected]>…

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.

Quoted 10 lines

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.

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#3 lore raw

Hi Masahiro,

Quoted 6 lines · Masahiro Yamada

Hi.

Quoted 3 lines

Another question.

Quoted 8 lines
Quoted 4 lines

Can U-boot handle the address transformation?

If the upper "bus" node has "ranges" property,
it must also be checked to get the correct base address, I think.

I take this question back too.
Sorry for noise.

OK no problem! Also see fdt_address_cells() and fdt_size_cells() which are in libfdt now.

- Simon

Quoted 47 lines
Quoted 45 lines
Quoted 23 lines · On Mon, 17 Nov 2014 19:38:41 +0900 Masahiro Yamada <[email protected]>…

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.

Quoted 10 lines

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.

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#4 lore raw
In reply to Masahiro Yamada
Quoted 23 lines · On Mon, 17 Nov 2014 19:38:41 +0900 Masahiro Yamada <[email protected]>…

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.

Quoted 9 lines

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.