usb: fix musb gadget to enable OTG mode conditionally
Subsystems (2)
v2 cover usb: fix musb gadget to enable OTG mode conditionally
Hello,
While working on an musb glue layer for an embedded USB device controller, I encountered the following issue.
The aforementioned UDC is not OTG capable, so I built the musb driver as gadget only and noticed that the musb_gadget code was trying to enable the OTG side of the controller, which does exist in silicon. While testing the glue layer code, the musb core was then trying to use Host Negotiation Protocol, which induces a panic.
The patch that comes as a follow-up of this message is an attempt to fix the issue before submitting the glue layer code which is still in progress; v2 only fixes the Cc: list which wasn't picked up at first by git-send-email, sorry for the inconvenience.
Changes were rebased on top of Felipe Balbi's USB Subsystem master branch, built successfully and tested on device without reproducing the issue.
The following changes since commit 3fc848d423216db97a4db9b4b9633561244e100a:
usb: fix musb gadget to enable OTG mode conditionally
are available in the git repository at:
git://seketeli.fr/~apelete/linux-usb.git musb-hnp-fix
Apelete Seketeli (1):
usb: fix musb gadget to enable OTG mode conditionally
drivers/usb/musb/musb_gadget.c | 4 ++++ 1 file changed, 4 insertions(+)
Signature · 1 line
1.7.10.4
PATCH v2 1/1 usb: fix musb gadget to enable OTG mode conditionally
The musb driver is usable in host, gadget or dual role mode depending on the kernel configuration.
However, the musb gadget part of the driver is enabling OTG mode whether the driver is built for dual role or gadget only mode. This induces a bug for gadget only USB device controllers where the kernel tries to use Host Negotiation Protocol with such controllers, which causes a panic.
This behaviour is now fixed by enabling OTG mode only when musb driver is built for dual role mode.
--- drivers/usb/musb/musb_gadget.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/musb/musb_gadget.c +4 -0
@@ -1796,7 +1796,11 @@ int musb_gadget_setup(struct musb *musb)/* this "gadget" abstracts/virtualizes the controller */ musb->g.name = musb_driver_name; +#if IS_ENABLED (CONFIG_USB_MUSB_DUAL_ROLE ) musb->g.is_otg =1 ; +#elif IS_ENABLED (CONFIG_USB_MUSB_GADGET ) + musb->g.is_otg =0 ; +#endif musb_g_init_endpoints (musb);
Signature · 1 line
1.7.10.4