Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932548AbbDOOyq (ORCPT ); Wed, 15 Apr 2015 10:54:46 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:33599 "EHLO mail-wg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932357AbbDOOyf (ORCPT ); Wed, 15 Apr 2015 10:54:35 -0400 Message-ID: <1429109670.30601.5.camel@linaro.org> Subject: Re: [PATCH v2] usb: chipidea: Use extcon framework for VBUS and ID detect From: "Ivan T. Ivanov" To: Robert Baldyga Cc: Peter Chen , Kumar Gala , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Greg Kroah-Hartman , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org Date: Wed, 15 Apr 2015 17:54:30 +0300 In-Reply-To: <552E7187.3030005@samsung.com> References: <1429104915-11079-1-git-send-email-ivan.ivanov@linaro.org> <552E7187.3030005@samsung.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.13.7-fta1.2~trusty Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5399 Lines: 136 Hi Robert, On Wed, 2015-04-15 at 16:11 +0200, Robert Baldyga wrote: > Hi Ivan, > > On 04/15/2015 03:35 PM, Ivan T. Ivanov wrote: > > On recent Qualcomm platforms VBUS and ID lines are not routed to > > USB PHY LINK controller. Use extcon framework to receive connect > > and disconnect ID and VBUS notification. > > > > Signed-off-by: Ivan T. Ivanov ivanov@linaro.org> > > --- > > > > Changes since v0 [1], as per Peter Chen suggestions: > > > > * Moved external connector parsing code to ci_get_platdata() > > * Moved external connector related variables to struct ci_hdrc_platform_data > > * Rename ci_host_notifier() to ci_id_notifier() > > * Fixed device bindings description > > * Use select EXTCON framework, instead of depends on. > > > > [1] https://lkml.org/lkml/2015/4/9/116 > > > > .../devicetree/bindings/usb/ci-hdrc-qcom.txt | 9 +++ > > drivers/usb/chipidea/Kconfig | 1 + > > drivers/usb/chipidea/core.c | 87 ++++++++++++++++++++++ > > drivers/usb/chipidea/otg.c | 26 ++++++- > > include/linux/usb/chipidea.h | 17 +++++ > > 5 files changed, 139 insertions(+), 1 deletion(-) > > > > diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt > > b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt > > index f2899b5..c635aca 100644 > > --- a/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt > > +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt > > @@ -7,6 +7,14 @@ Required properties: > > - usb-phy: phandle for the PHY device > > - dr_mode: Should be "peripheral" > > > > +Optional properties: > > +- extcon: phandles to external connector devices. First phandle > > + should point to external connector, which provide "USB" > > + cable events, the second should point to external connector > > + device, which provide "USB-HOST" cable events. If one of > > + the external connector devices is not required, empty <0> > > + phandle should be specified. > > Do you expect to have "USB" and "USB-HOST" notifiers supplied by two > different extcon drivers? It looks strange. I don't think so that we > ever will need to deal with such weird configuration. Yes. That is what I have today on my desk. > > > + > > Examples: > >        gadget@f9a55000 { > > compatible = "qcom,ci-hdrc"; > > @@ -14,4 +22,5 @@ Examples: > > dr_mode = "peripheral"; > > interrupts = <0 134 0>; > > usb-phy = <&usbphy0>; > > + extcon = <0>, <&usb_id>; > > }; > > diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig > > index 5ce3f1d..5619b8c 100644 > > --- a/drivers/usb/chipidea/Kconfig > > +++ b/drivers/usb/chipidea/Kconfig > > @@ -1,6 +1,7 @@ > > config USB_CHIPIDEA > > tristate "ChipIdea Highspeed Dual Role Controller" > > depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || > > (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA > > + select EXTCON > > help > > Say Y here if your system has a dual role high speed USB > > controller based on ChipIdea silicon IP. Currently, only the > > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c > > index 74fea4f..e1d495d 100644 > > --- a/drivers/usb/chipidea/core.c > > +++ b/drivers/usb/chipidea/core.c > > @@ -47,6 +47,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -557,9 +558,39 @@ static irqreturn_t ci_irq(int irq, void *data) > > return ret; > > } > > > > +static int ci_vbus_notifier(struct notifier_block *nb, unsigned long event, > > + void *ptr) > > +{ > > + struct ci_hdrc_cable *vbus = container_of(nb, struct ci_hdrc_cable, nb); > > + > > + if (event) > > + vbus->state = true; > > + else > > + vbus->state = false; > > + > > + return NOTIFY_DONE; > > +} > > Actually it's not true that "USB" cable state is equal to VBUS state. But this is how it supposed to work right now, no? I have to admit that the naming is really confusing. > "USB" and "USB-HOST" are mutually exclusive, and when you have ID=0, > which means "USB-HOST" is connected, "USB cable will be seen as > disconnected even when VBUS=1. > > We are currently discussing how to pass VBUS state to USB OTG drivers. > You can find discussion here: > http://www.spinics.net/lists/linux-usb/msg123895.html Sure, I am following this discussion. When it settles down, I can change this as appropriate, until then this is what we will have in 4.1. It will be messy refactoring, I think. All extcon providers and consumers are using strings to denote cable names. Not to mention that extcon-class is using "USB-Host", while all others are using "USB-HOST". Regards, Ivan -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/