[U-Boot] [PATCH v2 12/19] rockchip: board: rk3066: convert board_usb_init to live tree functions
Paweł Jarosz
paweljarosz3691 at gmail.com
Fri Aug 11 20:57:07 UTC 2017
Use live tree functions to fill dwc2_plat_otg_data structure in board_usb_init.
Signed-off-by: Paweł Jarosz <paweljarosz3691 at gmail.com>
---
Changes since v1:
- none
arch/arm/mach-rockchip/rk3066-board.c | 52 +++++------------------------------
1 file changed, 7 insertions(+), 45 deletions(-)
diff --git a/arch/arm/mach-rockchip/rk3066-board.c b/arch/arm/mach-rockchip/rk3066-board.c
index 8fa06a2..2b96eb2 100644
--- a/arch/arm/mach-rockchip/rk3066-board.c
+++ b/arch/arm/mach-rockchip/rk3066-board.c
@@ -90,55 +90,17 @@ static struct dwc2_plat_otg_data rk3066_otg_data = {
int board_usb_init(int index, enum usb_init_type init)
{
- int node, phy_node;
- const char *mode;
- bool matched = false;
- const void *blob = gd->fdt_blob;
- u32 grf_phy_offset;
-
- /* find the usb_otg node */
- node = fdt_node_offset_by_compatible(blob, -1,
- "rockchip,rk3066-usb");
-
- while (node > 0) {
- mode = fdt_getprop(blob, node, "dr_mode", NULL);
- if (mode && strcmp(mode, "otg") == 0) {
- matched = true;
- break;
- }
-
- node = fdt_node_offset_by_compatible(blob, node,
- "rockchip,rk3066-usb");
- }
- if (!matched) {
- debug("Not found usb_otg device\n");
- return -ENODEV;
- }
- rk3066_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
+ ofnode otg_node;
+ u32 reg;
- node = fdtdec_lookup_phandle(blob, node, "phys");
- if (node <= 0) {
- debug("Not found usb phy device\n");
+ otg_node = ofnode_path("/usb at 10180000");
+ if (!ofnode_valid(otg_node)) {
+ debug("Not found usb otg device\n");
return -ENODEV;
}
- phy_node = fdt_parent_offset(blob, node);
- if (phy_node <= 0) {
- debug("Not found usb phy device\n");
- return -ENODEV;
- }
-
- rk3066_otg_data.phy_of_node = phy_node;
- grf_phy_offset = fdtdec_get_addr(blob, node, "reg");
-
- node = fdt_node_offset_by_compatible(blob, -1,
- "rockchip,rk3066-grf");
- if (node <= 0) {
- debug("Not found grf device\n");
- return -ENODEV;
- }
- rk3066_otg_data.regs_phy = grf_phy_offset +
- fdtdec_get_addr(blob, node, "reg");
+ ofnode_read_u32(otg_node, "reg", ®);
+ rk3066_otg_data.regs_otg = reg;
return dwc2_udc_probe(&rk3066_otg_data);
}
--
2.7.4
More information about the U-Boot
mailing list