linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hdegoede@redhat.com (Hans de Goede)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 7/7] musb: sunxi: Add support for platform_set_mode
Date: Thu, 25 Aug 2016 19:59:46 +0200	[thread overview]
Message-ID: <00986b3a-1a2a-1c67-f8bd-3a4c916cfbba@redhat.com> (raw)
In-Reply-To: <20160822161037.GK1853@uda0271908>

Hi,

On 22-08-16 18:10, Bin Liu wrote:
> 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.

Ah right, I ran some tests and indeed the hcd does not see a disconnect
on role-change unless musb_root_disconnect() gets called, I'll send a v4
fixing this.

Thank you for catching this.

Regards,

Hans


>
> 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

  reply	other threads:[~2016-08-25 17:59 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-15 19:21 [PATCH v2 0/7] musb: sunxi: Add support for run-time changing dr-mode through sysfs Hans de Goede
2016-08-15 19:21 ` [PATCH v2 1/7] phy-sun4i-usb: Use bool where appropriate Hans de Goede
2016-08-15 19:21 ` [PATCH v2 2/7] phy-sun4i-usb: Refactor forced session ending Hans de Goede
2016-08-15 19:21 ` [PATCH v2 3/7] phy-sun4i-usb: Simplify missing dr_mode handling Hans de Goede
2016-08-15 19:21 ` [PATCH v2 4/7] phy-sun4i-usb: Add support for phy_set_mode Hans de Goede
2016-08-16 13:48   ` Sergei Shtylyov
2016-08-16 20:01     ` Hans de Goede
2016-08-18  7:40       ` Felipe Balbi
2016-08-18  9:05         ` Hans de Goede
2016-08-18 10:17           ` Felipe Balbi
2016-08-19 13:27             ` Kishon Vijay Abraham I
2016-08-15 19:21 ` [PATCH v2 5/7] phy-sun4i-usb: Warn when external vbus is detected Hans de Goede
2016-08-15 19:21 ` [PATCH v2 6/7] phy-sun4i-usb: Add "allwinner, usb0-usb-a-connector" dt property Hans de Goede
2016-08-19 21:33   ` [PATCH v2 6/7] phy-sun4i-usb: Add "allwinner,usb0-usb-a-connector" " Bin Liu
2016-08-15 19:21 ` [PATCH v2 7/7] musb: sunxi: Add support for platform_set_mode Hans de Goede
2016-08-19 21:30   ` Bin Liu
2016-08-21 10:10     ` Hans de Goede
2016-08-22 14:11       ` Bin Liu
2016-08-22 15:08         ` Hans de Goede
2016-08-22 15:24           ` Bin Liu
2016-08-22 15:32             ` Hans de Goede
2016-08-22 15:38               ` Bin Liu
2016-08-22 15:55                 ` Hans de Goede
2016-08-22 16:10                   ` Bin Liu
2016-08-25 17:59                     ` Hans de Goede [this message]
2016-08-19 21:25 ` [PATCH v2 0/7] musb: sunxi: Add support for run-time changing dr-mode through sysfs Bin Liu
2016-08-21  9:29   ` Hans de Goede
2016-08-22 14:08     ` Bin Liu
2016-08-22 14:16       ` Bin Liu
2016-08-22 15:50       ` Hans de Goede
2016-08-22 16:03         ` Bin Liu
2016-08-22 19:16   ` Rask Ingemann Lambertsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=00986b3a-1a2a-1c67-f8bd-3a4c916cfbba@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).