From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755900AbbE2Kjr (ORCPT ); Fri, 29 May 2015 06:39:47 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:32769 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755481AbbE2Kji (ORCPT ); Fri, 29 May 2015 06:39:38 -0400 X-AuditID: cbfee691-f79ca6d00000456a-7c-556841e8c208 Message-id: <556841E8.9090105@samsung.com> Date: Fri, 29 May 2015 19:39:36 +0900 From: Chanwoo Choi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-version: 1.0 To: Roger Quadros Cc: "Ivan T. Ivanov" , Chanwoo Choi , balbi@ti.com, peter.chen@freescale.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 References: <1432728910-10761-1-git-send-email-cw00.choi@samsung.com> <1432802731.2348.25.camel@mm-sol.com> <556724FD.2010606@ti.com> In-reply-to: <556724FD.2010606@ti.com> Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRmVeSWpSXmKPExsWyRsSkWPeFY0aoQdt6E4uD9+stnh3Vtng2 8SGjxdXZ29gsLjztYbO4vGsOm8XtxhVsFsdm/2WyeHB4J7tFzyMtBy6Pf4f7mTx2zrrL7rFp /zRmj74tqxg9jt/YzuTxeZNcAFsUl01Kak5mWWqRvl0CV8a7cykFizQrTn15xNzA+Feui5GT Q0LARKJpwSZWCFtM4sK99WxdjFwcQgJLGSWeHrgJ5HCAFb1bIAIRX8QosbrlCjuE84BRYuGq m0wg3bwCWhIbJlxkBmlgEVCV+DVTESTMBhTe/+IGG4gtKhAmsXL6FRaIckGJ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b5knMArMQrJkFpKyWUjKFjAyr2IUTS1ILihOSs810itOzC0uzUvXS87P 3cQIjvtn0jsYVzVYHGIU4GBU4uG1uJseKsSaWFZcmXuIUYKDWUmEd5dORqgQb0piZVVqUX58 UWlOavEhRlNgEExklhJNzgempLySeENjEzMjSyNzQwsjY3Mlcd6T+T6hQgLpiSWp2ampBalF MH1MHJxSDYzrFNek7H90yFrxivD9MtNNHY+Y+KMyzueJfQnj5DsTorfpibHlDzMtnqrzS3Kc iya9Lv6wuetCEhPv5PLQ6VdKJ98sSfnCe630H+O+fdf51tRe7jxY82mR4583FVtO/ljm35Bf svHTBNfU5M1hItY7csPTHnssEOHYWxNwT/f8yfbPe1ZKTWlXYinOSDTUYi4qTgQADi3RRxED AAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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