Re: [PATCH v2 7/7] musb: sunxi: Add support for platform_set_mode

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

 



On Mon, Aug 22, 2016 at 05:55:50PM +0200, Hans de Goede wrote:
> Hi,
> 
> On 22-08-16 17:38, Bin Liu wrote:
> >On Mon, Aug 22, 2016 at 05:32:57PM +0200, Hans de Goede wrote:
> 
> <snip>
> 
> >>>>>>>When switching from host to peripheral mode, if an usb device is still
> >>>>>>>plugged and enumerated, how do you handle the device disconnect?
> >>>>>>
> >>>>>>The phy code will report vbus low for long enough for the musb to end
> >>>>>>the current session. It already does this for boards which do not
> >>>>>>have working vbus detection.
> >>>>>
> >>>>>But you didn't disconnect DP/DM, right? then musb detects vbus is gone
> >>>>>without receiving disconnect event, this is vbus error case, not a normal
> >>>>>teardown.
> >>>>
> >>>>Correct, there is no way to disconnect DP/DM and reporting Vbus low for
> >>>>a while does the trick.
> >>>
> >>>Without physically disconnecting DP/DM, we still have a way to properly
> >>>teardown the enumerated devices. Please check musb_softconnect_write()
> >>>in musb_debugfs.c.
> >>
> >>That is manipulating the session bit in the devctl reg, that does not
> >>work to switch from device to host role or from host to device role,
> >>at least not on allwinner's musb implementation. I've already tried that
> >>before writing the code to report VBus low.
> >
> >I would think you have to call musb_root_disconnect() first to notify
> >the core to teardown the enumerated devices.
> 
> I tried that it does not help. It only affects the software state, the
> hardware will still stay in host-mode if it does not see vbus low for
> long enough).

I didn't mean to use musb_root_disconnect() to replace your
implementation. I suggest to add this call before lowing vbus to let the
core tearing down the numerated devices.

> 
> Note this is on devices which lack vbus detection (again this is simply
> physically not available on the PCB, just like some PCB's miss the
> id-pin). Normally this never is an issue, because when a host cable gets
> unplugged from a AB connector we see the id pin go high, disable the
> boards driving of Vbus and then the phy's Vbus detect will report low to
> the musb controller.

In this case, DP/DM get disconnected before vbus line, so
musb_root_disconnect() gets called in handling the disconnect interrupt
event. I think it is better simulate this in your usecase, which does
not generate disconnect event.

Regards,
-Bin.

> 
> Anyways this is a solved problem, the reporting of Vbus low has been
> working fine for both boards which lack vbus-detection as well as
> for role-changing from sysfs.
> 
> Regards,
> 
> Hans
--
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