On 2/13/26 6:15 AM, Siddharth Vadapalli wrote:

[...]

+++ b/drivers/usb/cdns3/core.c
@@ -392,6 +392,63 @@ static const struct udevice_id cdns3_ids[] = {
        { },
  };
+/*
+ * The VBUS Valid Bit in the OTG Status register can be used to determine
+ * the role. When VBUS Valid is set, it indicates that a USB Host is supplying
+ * power, so the Controller should assume the PERIPHERAL role. If it isn't set,
+ * it indicates the absence of a USB Host, so the Controller should assume the
+ * HOST role. If the OTG Status register is inaccessible, return an error.
+ */
+static int cdns3_get_otg_mode(ofnode node

Pass struct udevice *parent instead of node here ...

, enum usb_dr_mode *mode)
+{
+       struct cdns3 cdns, *cdnsp;
+       void __iomem *otg_regs;
+       fdt_addr_t otg_addr;
+       int otg_reg_index;
+       int vbus;
+
+       otg_reg_index = ofnode_stringlist_search(node, "reg-names", "otg");
+       if (otg_reg_index < 0) {
+               printf("%s: dr_mode is otg but otg register name is missing\n", 
__func__);
+               return -ENOENT;
+       }
+
+       otg_addr = ofnode_get_addr_index(node, otg_reg_index);
+       if (otg_addr == FDT_ADDR_T_NONE) {
+               printf("%s: address of otg registers is unspecified\n", 
__func__);
+               return -ENOENT;
+       }
+
+       otg_regs = map_physmem(otg_addr, 0, MAP_NOCACHE);
+       if (!otg_regs) {
+               printf("%s: failed to map otg registers\n", __func__);
+               return -EINVAL;
+       }

... and replace all that ^ with devfdt_remap_addr_name(parent, "otg") . That should work.

Reply via email to