From: Roger Quadros <rogerq@ti.com>
To: Chanwoo Choi <cw00.choi@samsung.com>,
Peter Chen <peter.chen@freescale.com>,
"Ivan T. Ivanov" <iivanov@mm-sol.com>
Cc: Chanwoo Choi <cwchoi00@gmail.com>, <balbi@ti.com>,
<jun.li@freescale.com>, <linux-kernel@vger.kernel.org>,
<r.baldyga@samsung.com>, <kishon@ti.com>,
<myungjoo.ham@samsung.com>
Subject: Re: [PATCH v2 0/2] extcon: Inform the state of both ID and VBUS pin for USB
Date: Tue, 2 Jun 2015 09:51:41 +0300 [thread overview]
Message-ID: <556D527D.6080709@ti.com> (raw)
In-Reply-To: <55685855.1040401@samsung.com>
Chanwoo,
On 29/05/15 15:15, Chanwoo Choi wrote:
> Dear all,
>
> On 05/29/2015 07:53 PM, Chanwoo Choi wrote:
>> Hi Peter,
>>
>> On 05/29/2015 10:22 AM, Peter Chen wrote:
>>> On Thu, May 28, 2015 at 05:23:57PM +0300, Roger Quadros wrote:
>>>> +Peter & Li,
>>>>
>>>> Ivan,
>>>>
>>>> On 28/05/15 11:45, Ivan T. Ivanov wrote:
>>>>>
>>>>> Hi Chanwoo,
>>>>>
>>>>> On Wed, 2015-05-27 at 21:15 +0900, Chanwoo Choi wrote:
>>>>>> Previously, I discussed how to inform the changed state of both ID
>>>>>> and VBUS pin for USB connector on patch-set[1].
>>>>>> [1] https://lkml.org/lkml/2015/4/2/310
>>>>>>
>>>>>> So, this patch adds the extcon_set_cable_line_state() function to inform
>>>>>> the additional state of external connectors without additional register/
>>>>>> unregister functions. This function uses the existing notifier chain
>>>>>> which is registered by extcon_register_notifier() / extcon_register_interest().
>>>>>>
>>>>>> The extcon_set_cable_line_state() can inform the new state of both
>>>>>> ID and VBUS pin state through extcon_set_cable_line_state().
>>>>>>
>>>>>> For exmaple:
>>>>>> - On extcon-usb-gpio.c as extcon provider driver as following:
>>>>>> static void usb_extcon_detect_cable(struct work_struct *work)
>>>>>> {
>>>>>> ...
>>>>>> /* check ID and update cable state */
>>>>>> id = gpiod_get_value_cansleep(info->id_gpiod);
>>>>>> if (id) {
>>>>>> extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, false);
>>>>>> extcon_set_cable_state_(info->edev, EXTCON_USB, true);
>>>>>>
>>>>>> extcon_set_cable_line_state(info->edev, EXTCON_USB,
>>>>>> EXTCON_USB_ID_HIGH);
>>>>>
>>>>> I am getting more and more confused :-). Why EXTCON_USB is now used for ID notifications?
>>>>> It should be EXTCON_USB_HOST, no? Why we need another function, framework already have
>>>>> required information from the function one line above, do I miss something?
>>>>
>>>> This is because the existing EXTCON_USB_HOST and EXTCON_USB do not capture all
>>>> the 4 states of ID and VBUS pins that we need for a real USB driver to work.
>>>>
>>>> It looks like it was designed from user space users perspective where they are
>>>> only interested in USB role. i.e. host or peripheral.
>>>>
>>>> Right now we are mixing both ID/VBUS and HOST/Peripheral states.
>>>> This will break when we consider OTG role switching.
>>>> With role switching, the USB device might start as a peripheral but switch role to host
>>>> on the fly and the existing setup (including these patches) can't cater to that
>>>> if user space is relying on EXTCON_USB_HOST/EXTCON_USB events.
>>>> Because they are hard-wired to the ID pin state which doesn't change during
>>>> role switch without cable switch.
>>>>
>>>> The USB driver doesn't care about EXTCON_USB_HOST/peripheral states.
>>>> It just needs ID/VBUS states and should decide the Host/Peripheral state from
>>>> that and other inputs (like HNP/user request/etc).
>>>>
>>>> The flow could be like this
>>>>
>>>> (extcon-usb-driver) -> [ID/VBUS states] -> (USB driver) -> [HOST/Peripheral states]
>>>
>>> Agree. Chanwoo, USB driver knows better than extcon driver about USB
>>> role (host/peripheral), so the app should use USB interface to know it,
>>> in fact, I don't be aware any use case needs to know USB role?
>>> Are there any users for EXTCON_USB and EXTCON_USB_HOST currently?
>>
>> You're right. But, extcon can just distinguish the type of external connectors
>> and inform the type to the user-space and extcon consumer driver in kernel-space.
>>
>> When USB mouse or keyboard is attached, user-space can check the state of externel connector which is attaced to the H/W target as following:
>> - /sys/class/extcon/extconX/cable.0/name -> USB
>> - /sys/class/extcon/extconX/cable.0/state -> 0
>> - /sys/class/extcon/extconX/cable.1/name -> USB-HOST
>> - /sys/class/extcon/extconX/cable.1/state -> 1
>>
>
> On last month, Robert Baldyga sent the patch[1] for extcon-usb-gpio driver.
> [1] https://lkml.org/lkml/2015/4/2/311
> - [PATCH v3 2/4] extcon: usb-gpio: add support for VBUS detection
>
> This patch[1] included a following table which show the type of external connectors
> according to both ID and VBUS pin state.
>
> State | ID | VBUS
> ----------------------------------------
> [1] USB | H | H
> [2] none | H | L
> [3] USB & USB-HOST | L | H
> [4] USB-HOST | L | L
>
> So, I think that extcon-usb-gpio.c could set below two status with set:
> - the state of whether USB/USB-HOST are attached or detached -> send the state to both kernel-space and user-space.
> : extcon_set_cable_state_()
> - the h/w line state of both ID and VBUS pin state -> send the state to only kernel space.
> : extcon_set_cable_line_state()
>
> [1]
> State | ID | VBUS
> ----------------------------------------
> [1] USB | H | H
>
> extcon_set_cable_state_(edev, EXTCON_USB, true);
> extcon_set_cable_state_(edev, EXTCON_USB_HOST, false);
>
> extcon_set_cable_line_state(edev, EXTCON_USB, EXTCON_USB_ID_HIGH);
> extcon_set_cable_line_state(edev, EXTCON_USB, EXTCON_USB_VBUS_HIGH);
>
>
> [2]
> State | ID | VBUS
> ----------------------------------------
> [2] none | H | L
>
> extcon_set_cable_state_(edev, EXTCON_USB, false);
> extcon_set_cable_state_(edev, EXTCON_USB_HOST, false);
>
> extcon_set_cable_line_state(edev, EXTCON_USB, EXTCON_USB_ID_HIGH);
> extcon_set_cable_line_state(edev, EXTCON_USB, EXTCON_USB_VBUS_LOW);
>
>
> [3]
> State | ID | VBUS
> ----------------------------------------
> [3] USB & USB-HOST | L | H
>
> extcon_set_cable_state_(edev, EXTCON_USB, false);
> extcon_set_cable_state_(edev, EXTCON_USB_HOST, true);
>
> extcon_set_cable_line_state(edev, EXTCON_USB, EXTCON_USB_ID_LOW);
> extcon_set_cable_line_state(edev, EXTCON_USB, EXTCON_USB_VBUS_HIGH);
>
>
> [4]
> State | ID | VBUS
> ----------------------------------------
> [4] USB-HOST | L | L
>
> extcon_set_cable_state_(edev, EXTCON_USB, false);
> extcon_set_cable_state_(edev, EXTCON_USB_HOST, true);
>
> extcon_set_cable_line_state(edev, EXTCON_USB, EXTCON_USB_ID_LOW);
> extcon_set_cable_line_state(edev, EXTCON_USB, EXTCON_USB_VBUS_LOW);
>
> If I know the wrong knowledge, please let me know your comment and advice.
I don't see any issues with extcon_get_cable_line_state(). I would prefer that
than changing existing APIS.
User space users will still fail in the dynamic role swap case [3]. But probably nobody
cares about it as nobody seems to be complaining or using role-swap :)
So we can choose to ignore that and solve it when someone complains.
cheers,
-roger
next prev parent reply other threads:[~2015-06-02 6:52 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-27 12:15 Chanwoo Choi
2015-05-27 12:15 ` [PATCH v2 1/2] extcon: Add extcon_set_cable_line_state() to inform the additional state of external connectors Chanwoo Choi
2015-05-27 14:38 ` Roger Quadros
2015-05-27 15:06 ` Chanwoo Choi
2015-05-28 9:02 ` Ivan T. Ivanov
[not found] ` <CAGTfZH2rn7OfqaTmr0d5-MfWW3ZFdt05_7vtLKqbEQee53999w@mail.gmail.com>
2015-05-28 9:37 ` Ivan T. Ivanov
2015-05-29 7:58 ` Chanwoo Choi
2015-05-27 12:15 ` [PATCH v2 2/2] extcon: usb-gpio: Update the ID pin state of USB when cable state is changed Chanwoo Choi
2015-05-27 14:40 ` Roger Quadros
2015-05-27 14:09 ` [PATCH v2 0/2] extcon: Inform the state of both ID and VBUS pin for USB Roger Quadros
2015-05-27 14:19 ` Chanwoo Choi
2015-05-28 8:45 ` Ivan T. Ivanov
2015-05-28 14:23 ` Roger Quadros
2015-05-29 1:22 ` Peter Chen
2015-05-29 10:53 ` Chanwoo Choi
2015-05-29 12:15 ` Chanwoo Choi
2015-06-02 6:51 ` Roger Quadros [this message]
2015-05-29 7:35 ` Ivan T. Ivanov
2015-05-29 7:36 ` Ivan T. Ivanov
2015-05-29 10:39 ` Chanwoo Choi
2015-05-29 10:44 ` Chanwoo Choi
2015-05-29 14:32 ` Ivan T. Ivanov
2015-05-29 17:15 ` Chanwoo Choi
2015-05-29 17:39 ` Chanwoo Choi
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=556D527D.6080709@ti.com \
--to=rogerq@ti.com \
--cc=balbi@ti.com \
--cc=cw00.choi@samsung.com \
--cc=cwchoi00@gmail.com \
--cc=iivanov@mm-sol.com \
--cc=jun.li@freescale.com \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=peter.chen@freescale.com \
--cc=r.baldyga@samsung.com \
/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
Powered by JetHome