All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: chipidea: udc: Link otg and gadget
@ 2025-11-19 15:26 Johan Korsnes
  2025-11-19 15:32 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Korsnes @ 2025-11-19 15:26 UTC (permalink / raw)
  To: linux-usb; +Cc: Johan Korsnes, Xu Yang, Peter Chen, Greg Kroah-Hartman

Link OTG with gadget, same as other UDC drivers.

Signed-off-by: Johan Korsnes <johan.korsnes@remarkable.no>
Cc: Xu Yang <xu.yang_2@nxp.com>
Cc: Peter Chen <peter.chen@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/chipidea/udc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 64a421ae0f05..1d2f9543ea37 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -2125,6 +2125,9 @@ static int ci_udc_start(struct usb_gadget *gadget,
 
 	ci->driver = driver;
 
+	if (!IS_ERR_OR_NULL(ci->usb_phy))
+		otg_set_peripheral(ci->usb_phy->otg, &ci->gadget);
+
 	/* Start otg fsm for B-device */
 	if (ci_otg_is_fsm_mode(ci) && ci->fsm.id) {
 		ci_hdrc_otg_fsm_start(ci);
@@ -2166,6 +2169,9 @@ static int ci_udc_stop(struct usb_gadget *gadget)
 	spin_lock_irqsave(&ci->lock, flags);
 	ci->driver = NULL;
 
+	if (!IS_ERR_OR_NULL(ci->usb_phy))
+		otg_set_peripheral(ci->usb_phy->otg, NULL);
+
 	if (ci->vbus_active) {
 		hw_device_state(ci, 0);
 		spin_unlock_irqrestore(&ci->lock, flags);
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: chipidea: udc: Link otg and gadget
  2025-11-19 15:26 [PATCH] usb: chipidea: udc: Link otg and gadget Johan Korsnes
@ 2025-11-19 15:32 ` Greg Kroah-Hartman
  2025-11-19 16:05   ` Johan Korsnes
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2025-11-19 15:32 UTC (permalink / raw)
  To: Johan Korsnes; +Cc: linux-usb, Xu Yang, Peter Chen

On Wed, Nov 19, 2025 at 04:26:41PM +0100, Johan Korsnes wrote:
> Link OTG with gadget, same as other UDC drivers.

I do not understand this changelog, sorry.  Can you please expand on it?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: chipidea: udc: Link otg and gadget
  2025-11-19 15:32 ` Greg Kroah-Hartman
@ 2025-11-19 16:05   ` Johan Korsnes
  0 siblings, 0 replies; 3+ messages in thread
From: Johan Korsnes @ 2025-11-19 16:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Xu Yang, Peter Chen

On 19/11/2025 16:32, Greg Kroah-Hartman wrote:
> On Wed, Nov 19, 2025 at 04:26:41PM +0100, Johan Korsnes wrote:
>> Link OTG with gadget, same as other UDC drivers.
> 
> I do not understand this changelog, sorry.  Can you please expand on it?
> 
> thanks,
> 
> greg k-h

I'll submit a v2 with a proper description. It might also be that this
link between otg and gadget is not appropriate for the ChipIdea driver.

I've (ab)used this link to obtain the gadget state via the usb_phy in
a different driver. Since some of the other UDC drivers set up the link
I just assumed it had been forgotten for the CI one. I'll double check!

Kind regards,
Johan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-19 16:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-19 15:26 [PATCH] usb: chipidea: udc: Link otg and gadget Johan Korsnes
2025-11-19 15:32 ` Greg Kroah-Hartman
2025-11-19 16:05   ` Johan Korsnes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.