[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <556841E8.9090105@samsung.com>
Date: Fri, 29 May 2015 19:39:36 +0900
From: Chanwoo Choi <cw00.choi@...sung.com>
To: Roger Quadros <rogerq@...com>
Cc: "Ivan T. Ivanov" <iivanov@...sol.com>,
Chanwoo Choi <cwchoi00@...il.com>, balbi@...com,
peter.chen@...escale.com, jun.li@...escale.com,
linux-kernel@...r.kernel.org, r.baldyga@...sung.com, kishon@...com,
myungjoo.ham@...sung.com
Subject: Re: [PATCH v2 0/2] extcon: Inform the state of both ID and VBUS pin
for USB
Hi Roger,
On 05/28/2015 11:23 PM, 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]
>
> If that is not going to happen then we will have to switch to this
>
> (usb phy driver) -> [ID/VBUS states] -> (USB driver) -> (extcon f/w) -> [Host/Peripheral states]
>
>
> Felipe, Peter, Li,
>
> what do you guys suggest?
The EXTCON framework have to definitely distinguish the correct type of external connectors which is connected to H/W target or other machines. And then the EXTCON framework inform the state and type of attached external connector to the extcon consumer and user-space. It is absolutely necessary role of EXTCON framework.
The EXTCON_USB_HOST connector is different from EXTCON_USB connector. When USB mouse or keyboard is attached to H/W target, EXTCON fwk will inform both correct type(USB_HOST) and state(1) of attached external connector. If EXTCON fwk don't support the EXTCON_USB_HOST, when USB mouse/keyboard is attached, EXTCON cannot provide the information of attached external connectors.
The EXTCON don't have the permission of USB operation but have the role to inform the correct type of external connectors to the extcon consumer.
As you said, USB driver and framework can receive the notifier event of only ID/VBUS pin state. If USB driver don't need the state of EXTCON_USB_HOST, USB driver don't have to recevie the event of EXTCON_USB_HOST. Just USB driver might receive the ID/VBUS event by extcon_register_notifier().
>
> cheers,
> -roger
>
>>
>>> } else {
>>> extcon_set_cable_state_(info->edev, EXTCON_USB, false);
>>> extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, true);
>>>
>>> extcon_set_cable_line_state(info->edev, EXTCON_USB,
>>> EXTCON_USB_ID_LOW);
>>> }
>>> }
>>>
>>> - On specific extcon consumder driver as following:
>>> static int xxx_probe(struct platform_device *pdev)
>>> {
>>> struct notifier_chain nh;
>>>
>>> nb.notifier_call = extcon_usb_notifier;
>>> ret = extcon_register_notifier(edev, EXTCON_USB, &nb);
>>
>> This is bit misleading. 'nb' could not be in stack.
Right. It is my mistake. I'll fix it for example.
Thanks,
Chanwoo Choi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists