Skip to contentSkip to conversation

About convert to LIVE DT

U-Boot Kever Yang 3 participants 6 messages Feb 4, 2018 – Feb 13, 2018

lore
Share & tools
lore

Kever Yang

author
#0 lore raw

Hi Simon, Philipp,

When I try to convert to live dt, I fount there are many APIs work
in fdt are missing in live dt,

do you have any suggestion to add these APIs in live dt quickly? I need:

fdtdec_get_addr_size_auto_noparent
fdt_alloc_phandle
fdt_device_is_available
fdt_for_each_subnode
fdt_getprop
fdt_getprop_u32_default_node
fdt_get_named_resource
fdt_get_name
fdt_get_path
fdt_get_phandle
fdt_node_depth
fdt_node_offset_by_phandle
fdt_node_offset_by_phandle_node
fdt_path_offset
fdt_set_phandle
fdt_stringlist_get
fdt_stringlist_search
fdt_subnode_offset
fdt_supernode_atdepth_offset

Thanks,

- Kever

#1 lore raw

Hi Kever,

Quoted 8 lines · Kever Yang

Hi Simon, Philipp,

When I try to convert to live dt, I fount there are many APIs work
in fdt are missing in live dt,

do you have any suggestion to add these APIs in live dt quickly? I need:

fdtdec_get_addr_size_auto_noparent

dev_read_addr_size() - not having a parent doesn't happen with livetree

Quoted 1 line

fdt_alloc_phandle

We don't support changing the live tree yet.

Quoted 1 line

fdt_device_is_available

dev_read_enabled()

Quoted 1 line

fdt_for_each_subnode

dev_for_each_subnode()

Quoted 1 line

fdt_getprop

dev_read_prop()

Quoted 1 line

fdt_getprop_u32_default_node

This is an odd function. Can you first check that the property exists, and then use a dev_read_...() function to read it?

Quoted 1 line

fdt_get_named_resource

dev_read_resource_byname()

Quoted 1 line

fdt_get_name

dev_read_name() - although I see that the comment is wrong

Quoted 1 line

fdt_get_path

Not available but you can add it

Quoted 1 line

fdt_get_phandle

Why do you need this?

Quoted 3 lines

fdt_node_depth
fdt_node_offset_by_phandle
fdt_node_offset_by_phandle_node

uclass_get_device_by_phandle() or similar?

Quoted 1 line

fdt_path_offset

ofnode_path() although it does not return a device. Best avoided.

Quoted 1 line

fdt_set_phandle

You can't change the livtree at present.

Quoted 1 line

fdt_stringlist_get

dev_read_string_index()

Quoted 1 line

fdt_stringlist_search

dev_read_stringlist_search()

Quoted 1 line

fdt_subnode_offset

Why do you want that?

Quoted 1 line

fdt_supernode_atdepth_offset

This should be found by scanning, generally using separate drivers for each DT node.

If you like you could send a patch with the info above, to doc/driver-model/livetree.txt to help others.

Regards,
Simon

author
#2 lore raw
Quoted 32 lines · Simon Glass

Hi Kever,

Quoted 8 lines · Kever Yang

Hi Simon, Philipp,

When I try to convert to live dt, I fount there are many APIs work
in fdt are missing in live dt,

do you have any suggestion to add these APIs in live dt quickly? I need:

fdtdec_get_addr_size_auto_noparent

dev_read_addr_size() - not having a parent doesn't happen with livetree

Quoted 1 line

fdt_alloc_phandle

We don't support changing the live tree yet.

Quoted 1 line

fdt_device_is_available

dev_read_enabled()

Quoted 1 line

fdt_for_each_subnode

dev_for_each_subnode()

Quoted 1 line

fdt_getprop

dev_read_prop()

Quoted 1 line

fdt_getprop_u32_default_node

This is an odd function. Can you first check that the property exists, and then use a dev_read_...() function to read it?

Quoted 1 line

fdt_get_named_resource

dev_read_resource_byname()

Quoted 8 lines
Quoted 1 line

fdt_get_name

dev_read_name() - although I see that the comment is wrong

Quoted 1 line

fdt_get_path

Not available but you can add it

Quoted 1 line

fdt_get_phandle

Why do you need this?

Most of the APIs are used in this file or other files in this folder,
https://github.com/rockchip-linux/u-boot/blob/release/drivers/video/drm/rockchip_display.c
It needs to handle quite complicated dts node for display system in rockchip drm display driver(not upstream yet):
https://github.com/rockchip-linux/u-boot/blob/release/arch/arm/dts/rk3128.dtsi#L421
https://github.com/rockchip-linux/u-boot/blob/release/arch/arm/dts/rk3126-bnd-d708.dts#L114

Thanks,
- Kever

Quoted 31 lines
Quoted 4 lines

fdt_node_depth
fdt_node_offset_by_phandle
fdt_node_offset_by_phandle_node

uclass_get_device_by_phandle() or similar?

Quoted 1 line

fdt_path_offset

ofnode_path() although it does not return a device. Best avoided.

Quoted 1 line

fdt_set_phandle

You can't change the livtree at present.

Quoted 1 line

fdt_stringlist_get

dev_read_string_index()

Quoted 1 line

fdt_stringlist_search

dev_read_stringlist_search()

Quoted 1 line

fdt_subnode_offset

Why do you want that?

Quoted 1 line

fdt_supernode_atdepth_offset

This should be found by scanning, generally using separate drivers for each DT node.

If you like you could send a patch with the info above, to doc/driver-model/livetree.txt to help others.

Regards,
Simon

#3 lore raw

Hi Kever,

Quoted 42 lines · Kever Yang
Quoted 39 lines · Simon Glass

Hi Kever,

Quoted 8 lines · Kever Yang

Hi Simon, Philipp,

When I try to convert to live dt, I fount there are many APIs work
in fdt are missing in live dt,

do you have any suggestion to add these APIs in live dt quickly? I need:

fdtdec_get_addr_size_auto_noparent

dev_read_addr_size() - not having a parent doesn't happen with livetree

Quoted 1 line

fdt_alloc_phandle

We don't support changing the live tree yet.

Quoted 1 line

fdt_device_is_available

dev_read_enabled()

Quoted 1 line

fdt_for_each_subnode

dev_for_each_subnode()

Quoted 1 line

fdt_getprop

dev_read_prop()

Quoted 1 line

fdt_getprop_u32_default_node

This is an odd function. Can you first check that the property exists, and then use a dev_read_...() function to read it?

Quoted 1 line

fdt_get_named_resource

dev_read_resource_byname()

Quoted 1 line

fdt_get_name

dev_read_name() - although I see that the comment is wrong

Quoted 1 line

fdt_get_path

Not available but you can add it

Quoted 1 line

fdt_get_phandle

Quoted 8 lines
Quoted 1 line

Why do you need this?

Most of the APIs are used in this file or other files in this folder,
https://github.com/rockchip-linux/u-boot/blob/release/drivers/video/drm/rockchip_display.c
It needs to handle quite complicated dts node for display system in rockchip drm display driver(not upstream yet):
https://github.com/rockchip-linux/u-boot/blob/release/arch/arm/dts/rk3128.dtsi#L421
https://github.com/rockchip-linux/u-boot/blob/release/arch/arm/dts/rk3126-bnd-d708.dts#L114

One difference I see with Linux is that U-Boot creates devices for all nodes automatically, provided that they have a compatible string and matching driver. This should simplify things in U-Boot.

The supernode-at-depth function looks like it just takes the parent of the parent when an argument of -2 is used.

The existing rockchip driver in U-Boot handles a similar binding, doesn't it? It has phandles and multiple nodes and subnodes.

Quoted 30 lines

Thanks,
- Kever

Quoted 27 lines
Quoted 4 lines

fdt_node_depth
fdt_node_offset_by_phandle
fdt_node_offset_by_phandle_node

uclass_get_device_by_phandle() or similar?

Quoted 1 line

fdt_path_offset

ofnode_path() although it does not return a device. Best avoided.

Quoted 1 line

fdt_set_phandle

You can't change the livtree at present.

Quoted 1 line

fdt_stringlist_get

dev_read_string_index()

Quoted 1 line

fdt_stringlist_search

dev_read_stringlist_search()

Quoted 1 line

fdt_subnode_offset

Why do you want that?

Quoted 1 line

fdt_supernode_atdepth_offset

This should be found by scanning, generally using separate drivers for each DT node.

If you like you could send a patch with the info above, to doc/driver-model/livetree.txt to help others.

Regards,
Simon

author
#4 lore raw

Simon,

Quoted 55 lines · Simon Glass

Hi Kever,

Quoted 40 lines · Kever Yang
Quoted 38 lines · Simon Glass

Hi Kever,

Quoted 8 lines · Kever Yang

Hi Simon, Philipp,

When I try to convert to live dt, I fount there are many APIs work
in fdt are missing in live dt,

do you have any suggestion to add these APIs in live dt quickly? I need:

fdtdec_get_addr_size_auto_noparent

dev_read_addr_size() - not having a parent doesn't happen with livetree

Quoted 1 line

fdt_alloc_phandle

We don't support changing the live tree yet.

Quoted 1 line

fdt_device_is_available

dev_read_enabled()

Quoted 1 line

fdt_for_each_subnode

dev_for_each_subnode()

Quoted 1 line

fdt_getprop

dev_read_prop()

Quoted 1 line

fdt_getprop_u32_default_node

This is an odd function. Can you first check that the property exists, and then use a dev_read_...() function to read it?

Quoted 1 line

fdt_get_named_resource

dev_read_resource_byname()

Quoted 1 line

fdt_get_name

dev_read_name() - although I see that the comment is wrong

Quoted 1 line

fdt_get_path

Not available but you can add it

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

fdt_get_phandle

Why do you need this?

Most of the APIs are used in this file or other files in this folder,
https://github.com/rockchip-linux/u-boot/blob/release/drivers/video/drm/rockchip_display.c
It needs to handle quite complicated dts node for display system in rockchip drm display driver(not upstream yet):
https://github.com/rockchip-linux/u-boot/blob/release/arch/arm/dts/rk3128.dtsi#L421
https://github.com/rockchip-linux/u-boot/blob/release/arch/arm/dts/rk3126-bnd-d708.dts#L114

One difference I see with Linux is that U-Boot creates devices for all nodes automatically, provided that they have a compatible string and matching driver. This should simplify things in U-Boot.

Quoted 5 lines

The supernode-at-depth function looks like it just takes the parent of the parent when an argument of -2 is used.

The existing rockchip driver in U-Boot handles a similar binding, doesn't it? It has phandles and multiple nodes and subnodes.

Yes, but it does not able to migrate to support both live dt and fdt, because there is no same api in live dt, and here is what I do locally for live dt:
823 phandle = ofnode_read_u32_default(node, "connect",
-1);
824 if (phandle < 0)
{
825 printf("Warn: can't find connect node's
handle\n");
826
continue;
827
}
828 ep_node =
of_find_node_by_phandle(phandle);
829 if (!ofnode_valid(np_to_ofnode(ep_node)))
{
830 printf("Warn: can't find endpoint node from
phandle\n");
831
continue;
832
}
833 port_node =
of_get_parent(ep_node);
834 if (!ofnode_valid(np_to_ofnode(port_node)))
{
835 printf("Warn: can't find port node from
phandle\n");
836
continue;
837
}
838 vop_node =
of_get_parent(port_node);
839 if (!ofnode_valid(np_to_ofnode(vop_node)))
{
840 printf("Warn: can't find crtc node from
phandle\n");
841
continue;
842
}
843 ret =
uclass_get_device_by_ofnode(UCLASS_VIDEO_CRTC,
844
np_to_ofnode(vop_node),
845 &crtc_dev);

In usb phy, we have similar requirement, but only need find "-1" depth parent.

Thanks,
- Kever

Quoted 32 lines
Quoted 29 lines

Thanks,
- Kever

Quoted 26 lines
Quoted 3 lines

fdt_node_depth
fdt_node_offset_by_phandle
fdt_node_offset_by_phandle_node

uclass_get_device_by_phandle() or similar?

Quoted 1 line

fdt_path_offset

ofnode_path() although it does not return a device. Best avoided.

Quoted 1 line

fdt_set_phandle

You can't change the livtree at present.

Quoted 1 line

fdt_stringlist_get

dev_read_string_index()

Quoted 1 line

fdt_stringlist_search

dev_read_stringlist_search()

Quoted 1 line

fdt_subnode_offset

Why do you want that?

Quoted 1 line

fdt_supernode_atdepth_offset

This should be found by scanning, generally using separate drivers for each DT node.

If you like you could send a patch with the info above, to doc/driver-model/livetree.txt to help others.

Regards,
Simon

#5 lore raw

Kever,

Quoted 116 lines · Kever Yang

Simon,

Quoted 55 lines · Simon Glass

Hi Kever,

Quoted 40 lines · Kever Yang
Quoted 38 lines · Simon Glass

Hi Kever,

Quoted 8 lines · Kever Yang

Hi Simon, Philipp,

When I try to convert to live dt, I fount there are many APIs work
in fdt are missing in live dt,

do you have any suggestion to add these APIs in live dt quickly? I need:

fdtdec_get_addr_size_auto_noparent

dev_read_addr_size() - not having a parent doesn't happen with livetree

Quoted 1 line

fdt_alloc_phandle

We don't support changing the live tree yet.

Quoted 1 line

fdt_device_is_available

dev_read_enabled()

Quoted 1 line

fdt_for_each_subnode

dev_for_each_subnode()

Quoted 1 line

fdt_getprop

dev_read_prop()

Quoted 1 line

fdt_getprop_u32_default_node

This is an odd function. Can you first check that the property exists, and then use a dev_read_...() function to read it?

Quoted 1 line

fdt_get_named_resource

dev_read_resource_byname()

Quoted 1 line

fdt_get_name

dev_read_name() - although I see that the comment is wrong

Quoted 1 line

fdt_get_path

Not available but you can add it

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

fdt_get_phandle

Why do you need this?

Most of the APIs are used in this file or other files in this folder,
https://github.com/rockchip-linux/u-boot/blob/release/drivers/video/drm/rockchip_display.c
It needs to handle quite complicated dts node for display system in rockchip drm display driver(not upstream yet):
https://github.com/rockchip-linux/u-boot/blob/release/arch/arm/dts/rk3128.dtsi#L421
https://github.com/rockchip-linux/u-boot/blob/release/arch/arm/dts/rk3126-bnd-d708.dts#L114

One difference I see with Linux is that U-Boot creates devices for all nodes automatically, provided that they have a compatible string and matching driver. This should simplify things in U-Boot.

Quoted 5 lines

The supernode-at-depth function looks like it just takes the parent of the parent when an argument of -2 is used.

The existing rockchip driver in U-Boot handles a similar binding, doesn't it? It has phandles and multiple nodes and subnodes.

Yes, but it does not able to migrate to support both live dt and fdt, because there is no same api in live dt, and here is what I do locally for live dt:
823 phandle = ofnode_read_u32_default(node, "connect",
-1);
824 if (phandle < 0)
{
825 printf("Warn: can't find connect node's
handle\n");
826
continue;
827
}
828 ep_node =
of_find_node_by_phandle(phandle);
829 if (!ofnode_valid(np_to_ofnode(ep_node)))
{
830 printf("Warn: can't find endpoint node from
phandle\n");
831
continue;
832
}
833 port_node =
of_get_parent(ep_node);
834 if (!ofnode_valid(np_to_ofnode(port_node)))
{
835 printf("Warn: can't find port node from
phandle\n");
836
continue;
837
}
838 vop_node =
of_get_parent(port_node);
839 if (!ofnode_valid(np_to_ofnode(vop_node)))
{
840 printf("Warn: can't find crtc node from
phandle\n");
841
continue;
842
}
843 ret =
uclass_get_device_by_ofnode(UCLASS_VIDEO_CRTC,
844
np_to_ofnode(vop_node),
845 &crtc_dev);

Quoted 2 lines

In usb phy, we have similar requirement, but only need find "-1" depth parent.

Can you use dev_get_parent() to get the parent and then use dev_read_*() on the parent?

Quoted 33 lines

Thanks,
- Kever

Quoted 31 lines
Quoted 29 lines

Thanks,
- Kever

Quoted 26 lines
Quoted 3 lines

fdt_node_depth
fdt_node_offset_by_phandle
fdt_node_offset_by_phandle_node

uclass_get_device_by_phandle() or similar?

Quoted 1 line

fdt_path_offset

ofnode_path() although it does not return a device. Best avoided.

Quoted 1 line

fdt_set_phandle

You can't change the livtree at present.

Quoted 1 line

fdt_stringlist_get

dev_read_string_index()

Quoted 1 line

fdt_stringlist_search

dev_read_stringlist_search()

Quoted 1 line

fdt_subnode_offset

Why do you want that?

Quoted 1 line

fdt_supernode_atdepth_offset

This should be found by scanning, generally using separate drivers for each DT node.

If you like you could send a patch with the info above, to doc/driver-model/livetree.txt to help others.

Regards,
Simon