From: Peng Fan <[email protected]> Convert the TI MUSB driver to use dev and ofnode-based device tree APIs instead of legacy FDT interfaces.
Replace dev_of_offset(), fdt_get_alias(), fdtdec_get_int(), and related helpers with their ofnode equivalents such as dev_ofnode(), ofnode_get_aliases_node(), ofnode_equal(), and dev_read_s32_default(). The USB index lookup is updated to compare ofnode handles instead of device tree path strings. Also remove direct dependency on gd->fdt_blob. No functional changes. Signed-off-by: Peng Fan <[email protected]> --- drivers/usb/musb-new/ti-musb.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c index e083cb7d0ff..3dd6e3eb718 100644 --- a/drivers/usb/musb-new/ti-musb.c +++ b/drivers/usb/musb-new/ti-musb.c @@ -51,29 +51,25 @@ static void ti_musb_set_phy_power(struct udevice *dev, u8 on) #if CONFIG_IS_ENABLED(OF_CONTROL) -static int ti_musb_get_usb_index(int node) +static int ti_musb_get_usb_index(ofnode node) { - const void *fdt = gd->fdt_blob; int i = 0; - char path[64]; - const char *alias_path; + ofnode alias_path; char alias[16]; - fdt_get_path(fdt, node, path, sizeof(path)); - do { snprintf(alias, sizeof(alias), "usb%d", i); - alias_path = fdt_get_alias(fdt, alias); - if (alias_path == NULL) { + alias_path = ofnode_get_aliases_node(alias); + if (!ofnode_valid(alias_path)) { debug("USB index not found\n"); return -ENOENT; } - if (!strcmp(path, alias_path)) + if (ofnode_equal(node, alias_path)) return i; i++; - } while (alias_path); + } while (ofnode_valid(alias_path)); return -ENOENT; } @@ -81,15 +77,16 @@ static int ti_musb_get_usb_index(int node) static int ti_musb_of_to_plat(struct udevice *dev) { struct ti_musb_plat *plat = dev_get_plat(dev); - const void *fdt = gd->fdt_blob; - int node = dev_of_offset(dev); + ofnode node = dev_ofnode(dev); ofnode phys_node; ofnode ctrl_mod_node; int usb_index; int ret; struct musb_hdrc_config *musb_config; - plat->base = devfdt_get_addr_index_ptr(dev, 1); + plat->base = dev_read_addr_index_ptr(dev, 1); + if (!plat->base) + return -EINVAL; phys_node = ofnode_get_by_phandle(dev_read_u32_default(dev, "phys", 0)); ctrl_mod_node = ofnode_get_by_phandle(ofnode_read_u32_default(phys_node, "ti,ctrl_mod", 0)); @@ -109,7 +106,7 @@ static int ti_musb_of_to_plat(struct udevice *dev) musb_config = malloc(sizeof(struct musb_hdrc_config)); memset(musb_config, 0, sizeof(struct musb_hdrc_config)); - ret = fdtdec_get_int(fdt, node, "mentor,multipoint", -1); + ret = dev_read_s32_default(dev, "mentor,multipoint", -1); if (ret < 0) { pr_err("MUSB multipoint DT entry missing\n"); return -ENOENT; @@ -119,7 +116,7 @@ static int ti_musb_of_to_plat(struct udevice *dev) musb_config->dyn_fifo = 1; - ret = fdtdec_get_int(fdt, node, "mentor,num-eps", -1); + ret = dev_read_s32_default(dev, "mentor,num-eps", -1); if (ret < 0) { pr_err("MUSB num-eps DT entry missing\n"); return -ENOENT; @@ -127,7 +124,7 @@ static int ti_musb_of_to_plat(struct udevice *dev) musb_config->num_eps = ret; } - ret = fdtdec_get_int(fdt, node, "mentor,ram-bits", -1); + ret = dev_read_s32_default(dev, "mentor,ram-bits", -1); if (ret < 0) { pr_err("MUSB ram-bits DT entry missing\n"); return -ENOENT; @@ -137,7 +134,7 @@ static int ti_musb_of_to_plat(struct udevice *dev) plat->plat.config = musb_config; - ret = fdtdec_get_int(fdt, node, "mentor,power", -1); + ret = dev_read_s32_default(dev, "mentor,power", -1); if (ret < 0) { pr_err("MUSB mentor,power DT entry missing\n"); return -ENOENT; -- 2.51.0

