From: Peng Fan <[email protected]> Convert the TI MUSB driver from legacy FDT interfaces to ofnode and dev APIs to support both live device tree and flat DT backends.
In ti_musb_get_usb_index(), replace fdt_get_path()/fdt_get_alias() based string comparison with ofnode_get_aliases_node()/ofnode_equal() to match USB alias by ofnode identity rather than path strings. In ti_musb_of_to_plat(), replace devfdt_get_addr_index_ptr() with dev_read_addr_index_ptr() and add a NULL check on the result. Convert four fdtdec_get_int() calls reading "mentor,multipoint", "mentor,num-eps", "mentor,ram-bits", and "mentor,power" properties to dev_read_s32_default(). Remove DECLARE_GLOBAL_DATA_PTR and the asm/global_data.h include as gd->fdt_blob is no longer referenced. Signed-off-by: Peng Fan <[email protected]> --- drivers/usb/musb-new/ti-musb.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c index e083cb7d0ff..1c80b78b031 100644 --- a/drivers/usb/musb-new/ti-musb.c +++ b/drivers/usb/musb-new/ti-musb.c @@ -10,7 +10,6 @@ #include <dm.h> #include <log.h> #include <malloc.h> -#include <asm/global_data.h> #include <linux/printk.h> #include <linux/usb/otg.h> #include <dm/device-internal.h> @@ -20,8 +19,6 @@ #include <asm/omap_musb.h> #include "musb_uboot.h" -DECLARE_GLOBAL_DATA_PTR; - #if CONFIG_IS_ENABLED(DM_USB) /* USB 2.0 PHY Control */ #define CM_PHY_PWRDN (1 << 0) @@ -51,29 +48,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 (1); return -ENOENT; } @@ -81,15 +74,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 +103,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 +113,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 +121,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 +131,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

