From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: Roger Quadros <rogerq@ti.com>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
Chanwoo Choi <cw00.choi@samsung.com>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Kukjin Kim <kgene@kernel.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org
Cc: Peter Chen <peter.chen@freescale.com>,
"Ivan T. Ivanov" <iivanov@mm-sol.com>,
balbi@kernel.com, kishon@ti.com,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Subject: Re: [RFC v4 4/7] extcon: usb-gpio: Add support for VBUS detection
Date: Thu, 09 Jun 2016 10:43:04 +0200 [thread overview]
Message-ID: <57592C18.8020609@samsung.com> (raw)
In-Reply-To: <57592B02.2070609@ti.com>
On 06/09/2016 10:38 AM, Roger Quadros wrote:
> Hi,
>
> On 08/06/16 16:48, Krzysztof Kozlowski wrote:
>> Add VBUS pin detection support to extcon-usb-gpio driver for boards
>> which have both VBUS and ID pins, or only one of them.
>>
>> The logic behind reporting USB and USB-HOST extcon cables is not
>> affected. The driver however will report extcon changes for USB-VBUS and
>> USB-ID.
>>
>> Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
>> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
>>
>> ---
>>
>> Some parts base on old Robert's patchset.
>> ---
>> drivers/extcon/extcon-usb-gpio.c | 125 +++++++++++++++++++++++++++++++--------
>> 1 file changed, 99 insertions(+), 26 deletions(-)
>>
>> diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
>> index a36aab007022..85b8a0ce5731 100644
>> --- a/drivers/extcon/extcon-usb-gpio.c
>> +++ b/drivers/extcon/extcon-usb-gpio.c
>> @@ -35,7 +35,9 @@ struct usb_extcon_info {
>> struct extcon_dev *edev;
>>
>> struct gpio_desc *id_gpiod;
>> + struct gpio_desc *vbus_gpiod;
>> int id_irq;
>> + int vbus_irq;
>>
>> unsigned long debounce_jiffies;
>> struct delayed_work wq_detcable;
>> @@ -44,6 +46,8 @@ struct usb_extcon_info {
>> static const unsigned int usb_extcon_cable[] = {
>> EXTCON_USB,
>> EXTCON_USB_HOST,
>> + EXTCON_USB_ID,
>> + EXTCON_USB_VBUS,
>> EXTCON_NONE,
>> };
>>
>> @@ -55,7 +59,8 @@ static void usb_extcon_detect_cable(struct work_struct *work)
>> wq_detcable);
>>
>> /* check ID and update cable state */
>> - id = gpiod_get_value_cansleep(info->id_gpiod);
>> + id = info->id_gpiod ? gpiod_get_value_cansleep(info->id_gpiod) : 1;
>> +
>> if (id) {
>> /*
>> * ID = 1 means USB HOST cable detached.
>> @@ -73,6 +78,14 @@ static void usb_extcon_detect_cable(struct work_struct *work)
>> extcon_set_cable_state_(info->edev, EXTCON_USB, false);
>> extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, true);
>> }
>> +
>> + if (info->id_gpiod)
>> + extcon_set_cable_state_(info->edev, EXTCON_USB_ID, id);
>> + if (info->vbus_gpiod) {
>> + int vbus = gpiod_get_value_cansleep(info->vbus_gpiod);
>> +
>> + extcon_set_cable_state_(info->edev, EXTCON_USB_VBUS, vbus);
>> + }
>
> What happens if either id_gpiod or vbus_gpiod is present?
>
> As per the DT binding document
> "In general we have three cases:
> 1. If VBUS and ID gpios are present we pass them as is
> USB-HOST = !ID, USB = VBUS
> 2. If only VBUS gpio is present we assume that ID pin is always High.
> USB-HOST = false, USB = VBUS.
> 3. If only ID pin is available we infer the VBUS pin states based on ID.
> USB-HOST = !ID, USB = ID"
>
> So do you want to be consistent and infer VBUS and ID states based on the other?
Right, I couldn't make up my mind whether I want to change/improve
existing logic or just add VBUS/ID raw notifying. Finally I left
original code for USB/USB-HOST cables alone.
Best regards,
Krzysztof
next prev parent reply other threads:[~2016-06-09 8:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20160608134820epcas1p4ee75a89888f2ae2adb733124a330bd2c@epcas1p4.samsung.com>
2016-06-08 13:47 ` [RFC v4 0/7] extcon: usb-gpio: fixes and improvements Krzysztof Kozlowski
2016-06-08 13:48 ` [RFC v4 1/7] Documentation: extcon: usb-gpio: update usb-gpio binding description Krzysztof Kozlowski
2016-06-10 14:00 ` Rob Herring
2016-06-08 13:48 ` [RFC v4 2/7] Revert "extcon: usb-gpio: switch to use pm wakeirq apis" Krzysztof Kozlowski
2016-06-09 8:00 ` Roger Quadros
2016-06-09 8:10 ` Krzysztof Kozlowski
2016-06-09 8:20 ` Roger Quadros
2016-06-08 13:48 ` [RFC v4 3/7] extcon: Add raw VBUS and ID cable states Krzysztof Kozlowski
2016-06-08 13:48 ` [RFC v4 4/7] extcon: usb-gpio: Add support for VBUS detection Krzysztof Kozlowski
2016-06-09 8:38 ` Roger Quadros
2016-06-09 8:41 ` Roger Quadros
2016-06-09 8:43 ` Krzysztof Kozlowski [this message]
2016-06-09 12:13 ` Roger Quadros
2016-06-08 13:48 ` [RFC v4 5/7] extcon: usb-gpio: make debounce value configurable in devicetree Krzysztof Kozlowski
2016-06-08 13:48 ` [RFC v4 6/7] ARM: exynos_defconfig: Enable EXTCON_USB_GPIO for Odroid XU3 USB OTG Krzysztof Kozlowski
2016-06-08 13:48 ` [RFC v4 7/7] ARM: dts: exynos: Add extcon-usb-gpio node for Odroid XU3 Krzysztof Kozlowski
2016-06-09 8:35 ` [RFC v4 0/7] extcon: usb-gpio: fixes and improvements Chanwoo Choi
2016-06-09 8:39 ` Krzysztof Kozlowski
2016-06-09 9:32 ` Chanwoo Choi
2016-08-01 12:23 ` Roger Quadros
2016-08-01 12:57 ` Chanwoo Choi
2016-06-26 16:39 ` Tobias Jakobi
2016-06-27 5:22 ` Krzysztof Kozlowski
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=57592C18.8020609@samsung.com \
--to=k.kozlowski@samsung.com \
--cc=b.zolnierkie@samsung.com \
--cc=balbi@kernel.com \
--cc=cw00.choi@samsung.com \
--cc=devicetree@vger.kernel.org \
--cc=iivanov@mm-sol.com \
--cc=kgene@kernel.org \
--cc=kishon@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mark.rutland@arm.com \
--cc=myungjoo.ham@samsung.com \
--cc=peter.chen@freescale.com \
--cc=robh+dt@kernel.org \
--cc=rogerq@ti.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;
as well as URLs for NNTP newsgroup(s).