From patchwork Thu Dec 10 23:07:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 7822881 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EFC029F1C2 for ; Thu, 10 Dec 2015 23:07:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CB3420595 for ; Thu, 10 Dec 2015 23:07:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3FC0620592 for ; Thu, 10 Dec 2015 23:07:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754051AbbLJXHY (ORCPT ); Thu, 10 Dec 2015 18:07:24 -0500 Received: from mail-lf0-f51.google.com ([209.85.215.51]:35457 "EHLO mail-lf0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754001AbbLJXHT (ORCPT ); Thu, 10 Dec 2015 18:07:19 -0500 Received: by lfdl133 with SMTP id l133so66981959lfd.2 for ; Thu, 10 Dec 2015 15:07:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:organization:user-agent :mime-version:content-transfer-encoding:content-type; bh=B6gfC2PkNbOMP8o3y4fV9sZfR79JT8+9CxkEuyaaJxk=; b=k4bX0PgAm/NxYR5LeScn29TJB4rPruItKH3GpmhR8cuA2KxZ9/M/QxjjQFLepCLW1s 8WwIwQZhUVXMZhGsNqTly4acZEkLI0nnBPtg2e6dKmsVnl4BS/GQondMDZX62ULJU0gh 13HrWjxLW2kTh2qZtWx9tLG4hMZ5+GpPF0gqFdEMeIDAMpeobqSH68L/nTLtqrtFBknc As+k4Y7rdtkjh4nTpFOQdci74tsfC4rl8jJzk12VsHnrPKuCuYV1OCuYvAH+KKvNyKKm Tt1qDOfZfMp2+EhjV1sVTgwrqFfzXjf80IFU7Oq7rCILKtCibXz3ebLZHZF4ovUHiWKY NFqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:mime-version:content-transfer-encoding:content-type; bh=B6gfC2PkNbOMP8o3y4fV9sZfR79JT8+9CxkEuyaaJxk=; b=byh4gZmH0sJFqco/Sv1V7458inD2vzxmX0v5Fro961fp4264VEDev6CjTm0T9IkNkP 1u7+VWG3cEs9cAddtl1y1F2WXr2BoDvOxDjCqRj2q9vRRU0EN+pQF0gy+rptSladUrix Lu8qkgvm/guvv/F6UN8TzjScCbiBSafTqA1mDxXdkyMfuXZweUStxVrkv7Xd21yhoTgo ks2uNSqcold6V8hB/BFi71aczwSgnzv/dZFE2AEq1yzkFxegE14VzksEmyB3wU6trHb5 QSFrhQPkcNvcHQJEEfK335AQTGxn0IyzQHN+ix7ZV4534UnnjPZVQ6KDPrLAHzknGzhG jPzQ== X-Gm-Message-State: ALoCoQnioEz+38Fk9hG5+al5oocufuIGMG1Ptd1kG5vi0nMM/H7py+WnGQBnKRpLAbx3ukNEMCB9rZFXqN+zWcbNLmQA8Kdaqg== X-Received: by 10.25.170.149 with SMTP id t143mr6418602lfe.162.1449788838181; Thu, 10 Dec 2015 15:07:18 -0800 (PST) Received: from wasted.cogentembedded.com ([31.173.80.98]) by smtp.gmail.com with ESMTPSA id b13sm2729352lfb.30.2015.12.10.15.07.16 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 10 Dec 2015 15:07:17 -0800 (PST) From: Sergei Shtylyov To: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, myungjoo.ham@samsung.com, cw00.choi@samsung.com, devicetree@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-sh@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH] extcon-usb-gpio: add enable pin support Date: Fri, 11 Dec 2015 02:07:05 +0300 Message-ID: <4393960.B6dD3UkQy3@wasted.cogentembedded.com> Organization: Cogent Embedded Inc. User-Agent: KMail/4.14.10 (Linux/4.2.6-201.fc22.x86_64; KDE/4.14.14; x86_64; ; ) MIME-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sometimes there's a real OTG chip behind the USB ID signal mapped to a GPIO pin: in my case it's Maxim Integrated MAX3355E which integrates Vbus charge pump and comparators and passes thru the ID signal from an OTG connector. This chip also has the SHDN# pin which should be driven high for the normal operation and low to save power; it is connected to a GPIO pin as well on, hence we'll have to teach the driver to parse the new optional device tree property, "enable-gpio"... Signed-off-by: Sergei Shtylyov --- The patch is against the 'extcon-next' branch of the 'extcon.git' repo. Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt | 3 +++ drivers/extcon/extcon-usb-gpio.c | 5 +++++ 2 files changed, 8 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: extcon/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt =================================================================== --- extcon.orig/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt +++ extcon/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt @@ -7,6 +7,9 @@ Required properties: - compatible: Should be "linux,extcon-usb-gpio" - id-gpio: gpio for USB ID pin. See gpio binding. +Optional properties: +- enable-gpio: gpio for the enable pin. See gpio binding. + Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below: extcon_usb1 { compatible = "linux,extcon-usb-gpio"; Index: extcon/drivers/extcon/extcon-usb-gpio.c =================================================================== --- extcon.orig/drivers/extcon/extcon-usb-gpio.c +++ extcon/drivers/extcon/extcon-usb-gpio.c @@ -33,6 +33,7 @@ struct usb_extcon_info { struct device *dev; struct extcon_dev *edev; + struct gpio_desc *enable_gpiod; struct gpio_desc *id_gpiod; int id_irq; @@ -99,6 +100,8 @@ static int usb_extcon_probe(struct platf return -ENOMEM; info->dev = dev; + info->enable_gpiod = devm_gpiod_get_optional(&pdev->dev, "enable", + GPIOD_OUT_HIGH); info->id_gpiod = devm_gpiod_get(&pdev->dev, "id", GPIOD_IN); if (IS_ERR(info->id_gpiod)) { dev_err(dev, "failed to get ID GPIO\n"); @@ -155,6 +158,8 @@ static int usb_extcon_remove(struct plat cancel_delayed_work_sync(&info->wq_detcable); + gpiod_set_value_cansleep(info->enable_gpiod, 0); + return 0; }