Skip to contentSkip to conversation

Revert "usb: cdns3: use VBUS Valid to determine role for dr_mode OTG"

PATCH In review Prasanth Babu Mantena 4 participants 8 messages Mar 12 – Apr 4

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert "usb: cdns3: use VBUS Valid to determine role for dr_mode OTG"

While USB DFU boot works with this patch, but the non USB boot modes like SD Boot and flash boot fails for J784S4 EVM device.

So, Reverting this patch.

This reverts commit bfb530e06ca6c19f66c079601e568c761a001993.

---
 drivers/usb/cdns3/core.c | 53 ----------------------------------------
 drivers/usb/cdns3/drd.c  | 11 ---------
 2 files changed, 64 deletions(-)
drivers/usb/cdns3/core.c +0 -53
index 10bc4cabed4..4434dc15bec 100644
@@ -392,52 +392,6 @@ 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(struct udevice *parent, enum usb_dr_mode *mode)
-{
-	/* Create a temporary child device for using devfdt_remap_addr_name() */
-	struct udevice child = {
-		.parent = parent,
-	};
-	struct cdns3 cdns, *cdnsp;
-	void __iomem *otg_regs;
-
-	dev_set_ofnode(&child, ofnode_first_subnode(dev_ofnode(parent)));
-	otg_regs = devfdt_remap_addr_name(&child, "otg");
-	if (!otg_regs) {
-		dev_err(parent, "failed to get otg registers for child node\n");
-		return -ENXIO;
-	}
-
-	/*
-	 * As mentioned in drivers/usb/cdns3/drd.c, there are two versions
-	 * of the Controller. The following logic detects the version of the
-	 * Controller and interprets the register layout accordingly.
-	 */
-	cdnsp = &cdns;
-	cdnsp->otg_v0_regs = otg_regs;
-	if (!readl(&cdnsp->otg_v0_regs->cmd)) {
-		cdnsp->otg_regs = otg_regs;
-	} else {
-		cdnsp->otg_v1_regs = otg_regs;
-		cdnsp->otg_regs = (void *)&cdnsp->otg_v1_regs->cmd;
-	}
-
-	/* Use VBUS Valid to determine role */
-	if (readl(&cdnsp->otg_regs->sts) & OTGSTS_VBUS_VALID)
-		*mode = USB_DR_MODE_PERIPHERAL;
-	else
-		*mode = USB_DR_MODE_HOST;
-
-	return 0;
-}
-
 int cdns3_bind(struct udevice *parent)
 {
 	enum usb_dr_mode dr_mode;
@@ -459,13 +413,6 @@ int cdns3_bind(struct udevice *parent)
 	if (dr_mode == USB_DR_MODE_UNKNOWN)
 		dr_mode = usb_get_dr_mode(dev_ofnode(parent));
 
-	/* Use VBUS Valid to determine role */
-	if (dr_mode == USB_DR_MODE_OTG) {
-		ret = cdns3_get_otg_mode(parent, &dr_mode);
-		if (ret < 0)
-			return ret;
-	}
-
 	switch (dr_mode) {
 #if defined(CONFIG_SPL_USB_HOST) || \
 	(!defined(CONFIG_XPL_BUILD) && defined(CONFIG_USB_HOST))
drivers/usb/cdns3/drd.c +0 -11
index 0ca40a5cc8d..cbb13342343 100644
@@ -301,17 +301,6 @@ int cdns3_drd_init(struct cdns3 *cdns)
 		cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
 	}
 
-	/*
-	 * In the absence of STRAP configuration, use VBUS Valid to
-	 * determine the appropriate role to be assigned to dr_mode.
-	 */
-	if (cdns->dr_mode == USB_DR_MODE_OTG) {
-		if (cdns3_get_vbus(cdns))
-			cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
-		else
-			cdns->dr_mode = USB_DR_MODE_HOST;
-	}
-
 	state = readl(&cdns->otg_regs->sts);
 	if (OTGSTS_OTG_NRDY(state) != 0) {
 		dev_err(cdns->dev, "Cadence USB3 OTG device not ready\n");
Signature · 1 line
2.34.1
#1 lore raw
Quoted 96 lines · Prasanth Babu Mantena

While USB DFU boot works with this patch, but the non USB boot modes like SD Boot and flash boot fails for J784S4 EVM device.

So, Reverting this patch.

This reverts commit bfb530e06ca6c19f66c079601e568c761a001993.

---
 drivers/usb/cdns3/core.c | 53 ----------------------------------------
 drivers/usb/cdns3/drd.c  | 11 ---------
 2 files changed, 64 deletions(-)
drivers/usb/cdns3/core.c +0 -53
index 10bc4cabed4..4434dc15bec 100644
@@ -392,52 +392,6 @@ 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(struct udevice *parent, enum usb_dr_mode *mode)
-{
-	/* Create a temporary child device for using devfdt_remap_addr_name() */
-	struct udevice child = {
-		.parent = parent,
-	};
-	struct cdns3 cdns, *cdnsp;
-	void __iomem *otg_regs;
-
-	dev_set_ofnode(&child, ofnode_first_subnode(dev_ofnode(parent)));
-	otg_regs = devfdt_remap_addr_name(&child, "otg");
-	if (!otg_regs) {
-		dev_err(parent, "failed to get otg registers for child node\n");
-		return -ENXIO;
-	}
-
-	/*
-	 * As mentioned in drivers/usb/cdns3/drd.c, there are two versions
-	 * of the Controller. The following logic detects the version of the
-	 * Controller and interprets the register layout accordingly.
-	 */
-	cdnsp = &cdns;
-	cdnsp->otg_v0_regs = otg_regs;
-	if (!readl(&cdnsp->otg_v0_regs->cmd)) {
-		cdnsp->otg_regs = otg_regs;
-	} else {
-		cdnsp->otg_v1_regs = otg_regs;
-		cdnsp->otg_regs = (void *)&cdnsp->otg_v1_regs->cmd;
-	}
-
-	/* Use VBUS Valid to determine role */
-	if (readl(&cdnsp->otg_regs->sts) & OTGSTS_VBUS_VALID)
-		*mode = USB_DR_MODE_PERIPHERAL;
-	else
-		*mode = USB_DR_MODE_HOST;
-
-	return 0;
-}
-
 int cdns3_bind(struct udevice *parent)
 {
 	enum usb_dr_mode dr_mode;
@@ -459,13 +413,6 @@ int cdns3_bind(struct udevice *parent)
 	if (dr_mode == USB_DR_MODE_UNKNOWN)
 		dr_mode = usb_get_dr_mode(dev_ofnode(parent));
 
-	/* Use VBUS Valid to determine role */
-	if (dr_mode == USB_DR_MODE_OTG) {
-		ret = cdns3_get_otg_mode(parent, &dr_mode);
-		if (ret < 0)
-			return ret;
-	}
-
 	switch (dr_mode) {
 #if defined(CONFIG_SPL_USB_HOST) || \
 	(!defined(CONFIG_XPL_BUILD) && defined(CONFIG_USB_HOST))
drivers/usb/cdns3/drd.c +0 -4
index 0ca40a5cc8d..cbb13342343 100644
@@ -301,17 +301,6 @@ int cdns3_drd_init(struct cdns3 *cdns)
 		cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
 	}
 
-	/*
-	 * In the absence of STRAP configuration, use VBUS Valid to
-	 * determine the appropriate role to be assigned to dr_mode.
-	 */

drivers/usb/cdns3/drd.c int cdns3_drd_init(struct cdns3 *cdns) · line 306

Quoted 10 lines
drivers/usb/cdns3/drd.c +0 -7
-	if (cdns->dr_mode == USB_DR_MODE_OTG) {
-		if (cdns3_get_vbus(cdns))
-			cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
-		else
-			cdns->dr_mode = USB_DR_MODE_HOST;
-	}
-
 	state = readl(&cdns->otg_regs->sts);
 	if (OTGSTS_OTG_NRDY(state) != 0) {
 		dev_err(cdns->dev, "Cadence USB3 OTG device not ready\n");

Adding in the USB custodian as this revert is intended for master and v2026.04 I assume as the commit being reverted is also in master. Thanks.

Signature · 1 line
Tom
#2 lore raw
Quoted 104 lines · Tom Rini
Quoted 102 lines · Prasanth Babu Mantena

While USB DFU boot works with this patch, but the non USB boot modes like SD Boot and flash boot fails for J784S4 EVM device.

So, Reverting this patch.

This reverts commit bfb530e06ca6c19f66c079601e568c761a001993.

---
  drivers/usb/cdns3/core.c | 53 ----------------------------------------
  drivers/usb/cdns3/drd.c  | 11 ---------
  2 files changed, 64 deletions(-)
drivers/usb/cdns3/core.c +0 -53
index 10bc4cabed4..4434dc15bec 100644
@@ -392,52 +392,6 @@ 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(struct udevice *parent, enum usb_dr_mode *mode)
-{
-	/* Create a temporary child device for using devfdt_remap_addr_name() */
-	struct udevice child = {
-		.parent = parent,
-	};
-	struct cdns3 cdns, *cdnsp;
-	void __iomem *otg_regs;
-
-	dev_set_ofnode(&child, ofnode_first_subnode(dev_ofnode(parent)));
-	otg_regs = devfdt_remap_addr_name(&child, "otg");
-	if (!otg_regs) {
-		dev_err(parent, "failed to get otg registers for child node\n");
-		return -ENXIO;
-	}
-
-	/*
-	 * As mentioned in drivers/usb/cdns3/drd.c, there are two versions
-	 * of the Controller. The following logic detects the version of the
-	 * Controller and interprets the register layout accordingly.
-	 */
-	cdnsp = &cdns;
-	cdnsp->otg_v0_regs = otg_regs;
-	if (!readl(&cdnsp->otg_v0_regs->cmd)) {
-		cdnsp->otg_regs = otg_regs;
-	} else {
-		cdnsp->otg_v1_regs = otg_regs;
-		cdnsp->otg_regs = (void *)&cdnsp->otg_v1_regs->cmd;
-	}
-
-	/* Use VBUS Valid to determine role */
-	if (readl(&cdnsp->otg_regs->sts) & OTGSTS_VBUS_VALID)
-		*mode = USB_DR_MODE_PERIPHERAL;
-	else
-		*mode = USB_DR_MODE_HOST;
-
-	return 0;
-}
-
  int cdns3_bind(struct udevice *parent)
  {
  	enum usb_dr_mode dr_mode;
@@ -459,13 +413,6 @@ int cdns3_bind(struct udevice *parent)
  	if (dr_mode == USB_DR_MODE_UNKNOWN)
  		dr_mode = usb_get_dr_mode(dev_ofnode(parent));
 
-	/* Use VBUS Valid to determine role */
-	if (dr_mode == USB_DR_MODE_OTG) {
-		ret = cdns3_get_otg_mode(parent, &dr_mode);
-		if (ret < 0)
-			return ret;
-	}
-
  	switch (dr_mode) {
  #if defined(CONFIG_SPL_USB_HOST) || \
  	(!defined(CONFIG_XPL_BUILD) && defined(CONFIG_USB_HOST))
drivers/usb/cdns3/drd.c +0 -10
index 0ca40a5cc8d..cbb13342343 100644
@@ -301,17 +301,6 @@ int cdns3_drd_init(struct cdns3 *cdns)
  		cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
  	}
 
-	/*
-	 * In the absence of STRAP configuration, use VBUS Valid to
-	 * determine the appropriate role to be assigned to dr_mode.
-	 */
-	if (cdns->dr_mode == USB_DR_MODE_OTG) {
-		if (cdns3_get_vbus(cdns))
-			cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
-		else
-			cdns->dr_mode = USB_DR_MODE_HOST;
-	}
Quoted 8 lines

drivers/usb/cdns3/drd.c int cdns3_drd_init(struct cdns3 *cdns) · line 306

Quoted 4 lines
drivers/usb/cdns3/drd.c +0 -1
-
  	state = readl(&cdns->otg_regs->sts);
  	if (OTGSTS_OTG_NRDY(state) != 0) {
  		dev_err(cdns->dev, "Cadence USB3 OTG device not ready\n");

Adding in the USB custodian as this revert is intended for master and v2026.04 I assume as the commit being reverted is also in master. Thanks.

This may be related to

[PATCH] usb: cdns3: fix cdns3_bind() to avoid returning error and probe parent

?

Can you coordinate with Siddharth Vadapalli ?

#3 lore raw
Quoted 115 lines · Marek Vasut
Quoted 106 lines · Tom Rini
Quoted 104 lines · Prasanth Babu Mantena

While USB DFU boot works with this patch, but the non USB boot modes like SD Boot and flash boot fails for J784S4 EVM device.

So, Reverting this patch.

This reverts commit bfb530e06ca6c19f66c079601e568c761a001993.

---
  drivers/usb/cdns3/core.c | 53 ---------------------------------------- drivers/usb/cdns3/drd.c  | 11 ---------

  2 files changed, 64 deletions(-)
drivers/usb/cdns3/core.c +0 -3
index 10bc4cabed4..4434dc15bec 100644
@@ -392,52 +392,6 @@ 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(struct udevice *parent, enum usb_dr_mode *mode)
-{
-    /* Create a temporary child device for using devfdt_remap_addr_name() */
-    struct udevice child = {
-        .parent = parent,
-    };
-    struct cdns3 cdns, *cdnsp;
-    void __iomem *otg_regs;

drivers/usb/cdns3/core.c +0 -31
-
-    dev_set_ofnode(&child, ofnode_first_subnode(dev_ofnode(parent)));
-    otg_regs = devfdt_remap_addr_name(&child, "otg");
-    if (!otg_regs) {
-        dev_err(parent, "failed to get otg registers for child node\n");
-        return -ENXIO;
-    }
-
-    /*
-     * As mentioned in drivers/usb/cdns3/drd.c, there are two versions
-     * of the Controller. The following logic detects the version of the
-     * Controller and interprets the register layout accordingly.
-     */
-    cdnsp = &cdns;
-    cdnsp->otg_v0_regs = otg_regs;
-    if (!readl(&cdnsp->otg_v0_regs->cmd)) {
-        cdnsp->otg_regs = otg_regs;
-    } else {
-        cdnsp->otg_v1_regs = otg_regs;
-        cdnsp->otg_regs = (void *)&cdnsp->otg_v1_regs->cmd;
-    }
-
-    /* Use VBUS Valid to determine role */
-    if (readl(&cdnsp->otg_regs->sts) & OTGSTS_VBUS_VALID)
-        *mode = USB_DR_MODE_PERIPHERAL;
-    else
-        *mode = USB_DR_MODE_HOST;
-
-    return 0;
-}
-

  int cdns3_bind(struct udevice *parent)
  {
      enum usb_dr_mode dr_mode;

drivers/usb/cdns3/core.c +0 -7
@@ -459,13 +413,6 @@ int cdns3_bind(struct udevice *parent)
       if (dr_mode == USB_DR_MODE_UNKNOWN)
           dr_mode = usb_get_dr_mode(dev_ofnode(parent));
-    /* Use VBUS Valid to determine role */
-    if (dr_mode == USB_DR_MODE_OTG) {
-        ret = cdns3_get_otg_mode(parent, &dr_mode);
-        if (ret < 0)
-            return ret;
-    }
-
       switch (dr_mode) {
   #if defined(CONFIG_SPL_USB_HOST) || \
       (!defined(CONFIG_XPL_BUILD) && defined(CONFIG_USB_HOST))
drivers/usb/cdns3/drd.c +0 -10
index 0ca40a5cc8d..cbb13342343 100644
@@ -301,17 +301,6 @@ int cdns3_drd_init(struct cdns3 *cdns)
           cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
       }
-    /*
-     * In the absence of STRAP configuration, use VBUS Valid to
-     * determine the appropriate role to be assigned to dr_mode.
-     */
-    if (cdns->dr_mode == USB_DR_MODE_OTG) {
-        if (cdns3_get_vbus(cdns))
-            cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
-        else
-            cdns->dr_mode = USB_DR_MODE_HOST;
-    }
Quoted 8 lines

drivers/usb/cdns3/drd.c int cdns3_drd_init(struct cdns3 *cdns) · line 306

Quoted 4 lines
drivers/usb/cdns3/drd.c +0 -1
-
       state = readl(&cdns->otg_regs->sts);
       if (OTGSTS_OTG_NRDY(state) != 0) {
           dev_err(cdns->dev, "Cadence USB3 OTG device not ready\n");

Adding in the USB custodian as this revert is intended for master and v2026.04 I assume as the commit being reverted is also in master. Thanks.

Quoted 7 lines

This may be related to

[PATCH] usb: cdns3: fix cdns3_bind() to avoid returning error and probe parent

?

Can you coordinate with Siddharth Vadapalli ?

Please refer to my response at:
https://lore.kernel.org/r/[email protected]/
on the patch quoted above
([PATCH] usb: cdns3: fix cdns3_bind() to avoid returning error and probe parent)

A common .probe as a stub will not work and probing the parent in cdns3_bind() doesn't seem to be acceptable. So reverting the commit appears to be the only option at the moment to fix non-USB Boot Modes.

Regards,
Siddharth.

#4 lore raw

Hello Marek,

Quoted 123 lines · Siddharth Vadapalli
Quoted 122 lines · Marek Vasut
Quoted 107 lines · Tom Rini
Quoted 105 lines · Prasanth Babu Mantena

While USB DFU boot works with this patch, but the non USB boot modes like SD Boot and flash boot fails for J784S4 EVM device.

So, Reverting this patch.

This reverts commit bfb530e06ca6c19f66c079601e568c761a001993.

---
  drivers/usb/cdns3/core.c | 53 ---------------------------------------- drivers/usb/cdns3/drd.c  | 11 ---------

  2 files changed, 64 deletions(-)
drivers/usb/cdns3/core.c +0 -3
index 10bc4cabed4..4434dc15bec 100644
@@ -392,52 +392,6 @@ 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(struct udevice *parent, enum usb_dr_mode *mode)
-{
-    /* Create a temporary child device for using devfdt_remap_addr_name() */
-    struct udevice child = {
-        .parent = parent,
-    };
-    struct cdns3 cdns, *cdnsp;
-    void __iomem *otg_regs;

drivers/usb/cdns3/core.c +0 -31
-
-    dev_set_ofnode(&child, ofnode_first_subnode(dev_ofnode(parent)));
-    otg_regs = devfdt_remap_addr_name(&child, "otg");
-    if (!otg_regs) {
-        dev_err(parent, "failed to get otg registers for child node\n");
-        return -ENXIO;
-    }
-
-    /*
-     * As mentioned in drivers/usb/cdns3/drd.c, there are two versions
-     * of the Controller. The following logic detects the version of the
-     * Controller and interprets the register layout accordingly.
-     */
-    cdnsp = &cdns;
-    cdnsp->otg_v0_regs = otg_regs;
-    if (!readl(&cdnsp->otg_v0_regs->cmd)) {
-        cdnsp->otg_regs = otg_regs;
-    } else {
-        cdnsp->otg_v1_regs = otg_regs;
-        cdnsp->otg_regs = (void *)&cdnsp->otg_v1_regs->cmd;
-    }
-
-    /* Use VBUS Valid to determine role */
-    if (readl(&cdnsp->otg_regs->sts) & OTGSTS_VBUS_VALID)
-        *mode = USB_DR_MODE_PERIPHERAL;
-    else
-        *mode = USB_DR_MODE_HOST;
-
-    return 0;
-}
-

  int cdns3_bind(struct udevice *parent)
  {
      enum usb_dr_mode dr_mode;

drivers/usb/cdns3/core.c +0 -7
@@ -459,13 +413,6 @@ int cdns3_bind(struct udevice *parent)
       if (dr_mode == USB_DR_MODE_UNKNOWN)
           dr_mode = usb_get_dr_mode(dev_ofnode(parent));
-    /* Use VBUS Valid to determine role */
-    if (dr_mode == USB_DR_MODE_OTG) {
-        ret = cdns3_get_otg_mode(parent, &dr_mode);
-        if (ret < 0)
-            return ret;
-    }
-
       switch (dr_mode) {
   #if defined(CONFIG_SPL_USB_HOST) || \
       (!defined(CONFIG_XPL_BUILD) && defined(CONFIG_USB_HOST))
drivers/usb/cdns3/drd.c +0 -10
index 0ca40a5cc8d..cbb13342343 100644
@@ -301,17 +301,6 @@ int cdns3_drd_init(struct cdns3 *cdns)
           cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
       }
-    /*
-     * In the absence of STRAP configuration, use VBUS Valid to
-     * determine the appropriate role to be assigned to dr_mode.
-     */
-    if (cdns->dr_mode == USB_DR_MODE_OTG) {
-        if (cdns3_get_vbus(cdns))
-            cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
-        else
-            cdns->dr_mode = USB_DR_MODE_HOST;
-    }
Quoted 8 lines

drivers/usb/cdns3/drd.c int cdns3_drd_init(struct cdns3 *cdns) · line 306

Quoted 4 lines
drivers/usb/cdns3/drd.c +0 -1
-
       state = readl(&cdns->otg_regs->sts);
       if (OTGSTS_OTG_NRDY(state) != 0) {
           dev_err(cdns->dev, "Cadence USB3 OTG device not ready\n");

Adding in the USB custodian as this revert is intended for master and v2026.04 I assume as the commit being reverted is also in master. Thanks.

This may be related to

[PATCH] usb: cdns3: fix cdns3_bind() to avoid returning error and probe parent

?

Quoted 7 lines
Quoted 1 line

Can you coordinate with Siddharth Vadapalli ?

Please refer to my response at:
https://lore.kernel.org/r/[email protected]/
on the patch quoted above
([PATCH] usb: cdns3: fix cdns3_bind() to avoid returning error and probe parent)

A common .probe as a stub will not work and probing the parent in cdns3_bind() doesn't seem to be acceptable. So reverting the commit appears to be the only option at the moment to fix non-USB Boot Modes.

Please note that this revert patch is required to fix non-USB Boot Mode. If you have a suggestion for an alternative, please let me know.

Regards,
Siddharth.

#5 lore raw

On 4/2/26 1:03 PM, Siddharth Vadapalli wrote:

Hi,

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

Adding in the USB custodian as this revert is intended for master and v2026.04 I assume as the commit being reverted is also in master. Thanks.

This may be related to

[PATCH] usb: cdns3: fix cdns3_bind() to avoid returning error and probe parent

?

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

Can you coordinate with Siddharth Vadapalli ?

Please refer to my response at:
https://lore.kernel.org/r/[email protected]/
on the patch quoted above
([PATCH] usb: cdns3: fix cdns3_bind() to avoid returning error and probe parent)

A common .probe as a stub will not work and probing the parent in cdns3_bind() doesn't seem to be acceptable. So reverting the commit appears to be the only option at the moment to fix non-USB Boot Modes.

Please note that this revert patch is required to fix non-USB Boot Mode. If you have a suggestion for an alternative, please let me know.

I replied to [PATCH] usb: cdns3: fix cdns3_bind() to avoid returning error and probe parent now, we can continue there.

If this patch is a stop-gap measure to avoid breakage on TI platform for v2026.04 release, then let's pick it up.

And I'm sorry for my slow response, I am buried in email.

#6 lore raw
In reply to Siddharth Vadapalli
Quoted 125 lines · Siddharth Vadapalli
Quoted 124 lines · Marek Vasut
Quoted 111 lines · Tom Rini
Quoted 109 lines · Prasanth Babu Mantena

While USB DFU boot works with this patch, but the non USB boot modes like SD Boot and flash boot fails for J784S4 EVM device.

So, Reverting this patch.

This reverts commit bfb530e06ca6c19f66c079601e568c761a001993.

---
  drivers/usb/cdns3/core.c | 53
----------------------------------------
  drivers/usb/cdns3/drd.c  | 11 ---------

  2 files changed, 64 deletions(-)
drivers/usb/cdns3/core.c +0 -2
index 10bc4cabed4..4434dc15bec 100644
@@ -392,52 +392,6 @@ 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(struct udevice *parent, enum usb_dr_mode *mode)
-{
-    /* Create a temporary child device for using devfdt_remap_addr_name() */
-    struct udevice child = {
-        .parent = parent,
-    };
-    struct cdns3 cdns, *cdnsp;
-    void __iomem *otg_regs;
-
-    dev_set_ofnode(&child, ofnode_first_subnode(dev_ofnode(parent))); -    otg_regs = devfdt_remap_addr_name(&child, "otg");
-    if (!otg_regs) {
-        dev_err(parent, "failed to get otg registers for child node\n");
-        return -ENXIO;
-    }
-
-    /*
-     * As mentioned in drivers/usb/cdns3/drd.c, there are two versions -     * of the Controller. The following logic detects the version of the
-     * Controller and interprets the register layout accordingly. -     */
-    cdnsp = &cdns;
-    cdnsp->otg_v0_regs = otg_regs;
-    if (!readl(&cdnsp->otg_v0_regs->cmd)) {
-        cdnsp->otg_regs = otg_regs;
-    } else {
-        cdnsp->otg_v1_regs = otg_regs;
-        cdnsp->otg_regs = (void *)&cdnsp->otg_v1_regs->cmd; -    }

drivers/usb/cdns3/core.c +0 -10
-
-    /* Use VBUS Valid to determine role */
-    if (readl(&cdnsp->otg_regs->sts) & OTGSTS_VBUS_VALID)
-        *mode = USB_DR_MODE_PERIPHERAL;
-    else
-        *mode = USB_DR_MODE_HOST;
-
-    return 0;
-}
-

  int cdns3_bind(struct udevice *parent)
  {
      enum usb_dr_mode dr_mode;

drivers/usb/cdns3/core.c +0 -7
@@ -459,13 +413,6 @@ int cdns3_bind(struct udevice *parent)
       if (dr_mode == USB_DR_MODE_UNKNOWN)
           dr_mode = usb_get_dr_mode(dev_ofnode(parent));
-    /* Use VBUS Valid to determine role */
-    if (dr_mode == USB_DR_MODE_OTG) {
-        ret = cdns3_get_otg_mode(parent, &dr_mode);
-        if (ret < 0)
-            return ret;
-    }
-
       switch (dr_mode) {
   #if defined(CONFIG_SPL_USB_HOST) || \
       (!defined(CONFIG_XPL_BUILD) && defined(CONFIG_USB_HOST))
drivers/usb/cdns3/drd.c +0 -10
index 0ca40a5cc8d..cbb13342343 100644
@@ -301,17 +301,6 @@ int cdns3_drd_init(struct cdns3 *cdns)
           cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
       }
-    /*
-     * In the absence of STRAP configuration, use VBUS Valid to
-     * determine the appropriate role to be assigned to dr_mode.
-     */
-    if (cdns->dr_mode == USB_DR_MODE_OTG) {
-        if (cdns3_get_vbus(cdns))
-            cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
-        else
-            cdns->dr_mode = USB_DR_MODE_HOST;
-    }
Quoted 8 lines

drivers/usb/cdns3/drd.c int cdns3_drd_init(struct cdns3 *cdns) · line 306

Quoted 4 lines
drivers/usb/cdns3/drd.c +0 -1
-
       state = readl(&cdns->otg_regs->sts);
       if (OTGSTS_OTG_NRDY(state) != 0) {
           dev_err(cdns->dev, "Cadence USB3 OTG device not ready\n");

Adding in the USB custodian as this revert is intended for master and v2026.04 I assume as the commit being reverted is also in master. Thanks.

This may be related to

[PATCH] usb: cdns3: fix cdns3_bind() to avoid returning error and probe parent

Quoted 7 lines
Quoted 3 lines

?

Can you coordinate with Siddharth Vadapalli ?

Please refer to my response at:
https://lore.kernel.org/r/[email protected]/
on the patch quoted above
([PATCH] usb: cdns3: fix cdns3_bind() to avoid returning error and probe parent)

I just replied to it (sorry, I am completely drowning in emails).

Quoted 1 line

A common .probe as a stub will not work and probing the parent in cdns3_bind() doesn't seem to be acceptable. So reverting the commit appears to be the only option at the moment to fix non-USB Boot Modes.

If this is a stop-gap measure for this release, to avoid breakage on TI platforms, sure, go with the revert.

But it would be nice if the bind in probe could be fixed properly at some point. I think it might be doable, see my reply to [PATCH] usb: cdns3: fix cdns3_bind() to avoid returning error and probe parent .

#7 lore raw
In reply to Prasanth Babu Mantena
Quoted 8 lines · Prasanth Babu Mantena

While USB DFU boot works with this patch, but the non USB boot modes like SD Boot and flash boot fails for J784S4 EVM device.

So, Reverting this patch.

This reverts commit bfb530e06ca6c19f66c079601e568c761a001993.

[...]

Applied to u-boot/master, thanks!

[1/1] Revert "usb: cdns3: use VBUS Valid to determine role for dr_mode OTG"

      commit: 214aababe07de0598bd26ecb0c8fb2e2843ff7d5
Signature · 1 line
Tom