From 9bf19639a76a35cf63a0b7293dc4cf9d9294f526 Mon Sep 17 00:00:00 2001 From: "Markus Schneider-Pargmann (TI.com)" Date: Mon, 9 Feb 2026 10:24:37 +0100 Subject: usb: musb-new: Relative ctrl_mod address parsing For the upstream DT the ctrl_mod node is using a relative register address which is not translated by the current code. Make address parsing understand relative addresses. Reviewed-by: Mattijs Korpershoek Signed-off-by: Markus Schneider-Pargmann (TI.com) Reviewed-by: Marek Vasut --- drivers/usb/musb-new/ti-musb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c index bcd31adba52..75dc2dc1874 100644 --- a/drivers/usb/musb-new/ti-musb.c +++ b/drivers/usb/musb-new/ti-musb.c @@ -83,17 +83,17 @@ 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); - int phys; - int ctrl_mod; + 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); - phys = fdtdec_lookup_phandle(fdt, node, "phys"); - ctrl_mod = fdtdec_lookup_phandle(fdt, phys, "ti,ctrl_mod"); - plat->ctrl_mod_base = (void *)fdtdec_get_addr(fdt, ctrl_mod, "reg"); + 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)); + plat->ctrl_mod_base = (void *)ofnode_get_addr(ctrl_mod_node); usb_index = ti_musb_get_usb_index(node); switch (usb_index) { case 1: -- cgit v1.3.1 From 4cf2275ee741d318c46c2ccef4c5db905f186d79 Mon Sep 17 00:00:00 2001 From: "Markus Schneider-Pargmann (TI.com)" Date: Mon, 9 Feb 2026 10:24:38 +0100 Subject: usb: musb-new: Add compatibles for ti,musb-am33xx The upstream devicetree am33xx.dtsi does not have a "ti,am33xx-usb" compatible, it uses "ti,sysc-omap4" for the same node. The implementation of ti-musb uses a wrapper driver that binds to ti,am33xx-usb and creates new devices ti-musb-host and ti-musb-peripheral depending on the dr_mode property. To avoid this wrapper driver with the upstream devicetree, add compatibles for "ti,musb-am33xx" to both ti-musb-host and ti-musb-peripheral. Add a bind function that checks for the correct dr_mode value and rejects binding if it is not the correct driver. Reviewed-by: Mattijs Korpershoek Signed-off-by: Markus Schneider-Pargmann (TI.com) Reviewed-by: Marek Vasut --- drivers/usb/musb-new/ti-musb.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c index 75dc2dc1874..cc6c3b94a65 100644 --- a/drivers/usb/musb-new/ti-musb.c +++ b/drivers/usb/musb-new/ti-musb.c @@ -183,6 +183,21 @@ static int ti_musb_host_remove(struct udevice *dev) } #if CONFIG_IS_ENABLED(OF_CONTROL) +static const struct udevice_id ti_musb_host_periph_ids[] = { + { .compatible = "ti,musb-am33xx" }, + { } +}; + +static int ti_musb_host_bind(struct udevice *dev) +{ + enum usb_dr_mode dr_mode = usb_get_dr_mode(dev_ofnode(dev)); + + if (dr_mode != USB_DR_MODE_HOST && dr_mode != USB_DR_MODE_OTG) + return -ENODEV; + + return 0; +} + static int ti_musb_host_of_to_plat(struct udevice *dev) { struct ti_musb_plat *plat = dev_get_plat(dev); @@ -206,6 +221,8 @@ U_BOOT_DRIVER(ti_musb_host) = { .name = "ti-musb-host", .id = UCLASS_USB, #if CONFIG_IS_ENABLED(OF_CONTROL) + .of_match = ti_musb_host_periph_ids, + .bind = ti_musb_host_bind, .of_to_plat = ti_musb_host_of_to_plat, #endif .probe = ti_musb_host_probe, @@ -221,6 +238,16 @@ struct ti_musb_peripheral { }; #if CONFIG_IS_ENABLED(OF_CONTROL) +static int ti_musb_peripheral_bind(struct udevice *dev) +{ + enum usb_dr_mode dr_mode = usb_get_dr_mode(dev_ofnode(dev)); + + if (dr_mode != USB_DR_MODE_PERIPHERAL) + return -ENODEV; + + return 0; +} + static int ti_musb_peripheral_of_to_plat(struct udevice *dev) { struct ti_musb_plat *plat = dev_get_plat(dev); @@ -283,6 +310,8 @@ U_BOOT_DRIVER(ti_musb_peripheral) = { .name = "ti-musb-peripheral", .id = UCLASS_USB_GADGET_GENERIC, #if CONFIG_IS_ENABLED(OF_CONTROL) + .of_match = ti_musb_host_periph_ids, + .bind = ti_musb_peripheral_bind, .of_to_plat = ti_musb_peripheral_of_to_plat, #endif .ops = &ti_musb_gadget_ops, -- cgit v1.3.1