Re: [RFC PATCH 4/4] usb: dwc3: introduce dual role switch function with debugfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 25, 2014 at 09:53:20AM -0500, Felipe Balbi wrote:
> Hi,
> 
> On Thu, Sep 25, 2014 at 03:21:47PM +0800, Huang Rui wrote:
> > This patch implemented a feature to dynamic switch to host or device
> > role under debugfs for some physical limitation that unable to
> > leverage connector A/B cables (ID pin) to change roles.
> > 
> > The default role should be set as OTG mode. Then use below commands:
> > 
> > [1] switch to host:
> > echo host > /sys/kernel/debug/dwc3.0.auto/mode
> > 
> > [2] switch to device:
> > echo device > /sys/kernel/debug/dwc3.0.auto/mode
> > 
> > [3] switch to otg (default mode):
> > echo otg > /sys/kernel/debug/dwc3.0.auto/mode
> 
> thanks, but not thanks. This is not how things should be done.
> 
> > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> > index 6138c5d..7b50584 100644
> > --- a/drivers/usb/dwc3/core.c
> > +++ b/drivers/usb/dwc3/core.c
> > @@ -61,7 +61,7 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
> >   * dwc3_core_soft_reset - Issues core soft reset and PHY reset
> >   * @dwc: pointer to our context structure
> >   */
> > -static int dwc3_core_soft_reset(struct dwc3 *dwc)
> > +int dwc3_core_soft_reset(struct dwc3 *dwc)
> 
> this should not be exposed.
> 
> > @@ -228,7 +228,7 @@ static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
> >   *
> >   * Returns 0 on success otherwise negative errno.
> >   */
> > -static int dwc3_event_buffers_setup(struct dwc3 *dwc)
> > +int dwc3_event_buffers_setup(struct dwc3 *dwc)
> 
> this should not be exposed.
> 
> > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> > index a1c7dc5..3a30f33 100644
> > --- a/drivers/usb/dwc3/core.h
> > +++ b/drivers/usb/dwc3/core.h
> > @@ -643,6 +643,8 @@ struct dwc3_scratchpad_array {
> >   * @maximum_speed: maximum speed requested (mainly for testing purposes)
> >   * @revision: revision register contents
> >   * @quirks: represents different SOCs hardware work-arounds and quirks
> > + * @has_gadget: true when gadget is initialized
> > + * @has_xhci: true when xhci is initialized
> 
> you shouldn't need these.
> 
> > diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
> > index 9ac37fe..76384df 100644
> > --- a/drivers/usb/dwc3/debugfs.c
> > +++ b/drivers/usb/dwc3/debugfs.c
> > @@ -32,6 +32,7 @@
> >  #include "gadget.h"
> >  #include "io.h"
> >  #include "debug.h"
> > +#include "drd.h"
> 
> and debugfs is definitely *not* the way to get this going.
> 
> What you need here is something to talk to usbcore and udc-core and
> orchestrate the mode change through usb_add_hcd()/usb_add_gadget_udc()
> and their counterparts.
> 
> George Cherian is already working on a version of that.
> 

I saw your tree have a dwc3-role-switch branch, is that you mentioned
here for the working.

Thanks,
Rui
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux