From patchwork Mon Aug 27 09:33:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 145164 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3975599ljw; Mon, 27 Aug 2018 02:33:45 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYnjnOPjKsC0YMCKDhBzBZH39ScMws841lXnk3XmBkVt/7hq5QHwNkzJ79MldwHXyPsaoWE X-Received: by 2002:a63:c60:: with SMTP id 32-v6mr11636915pgm.155.1535362425091; Mon, 27 Aug 2018 02:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535362425; cv=none; d=google.com; s=arc-20160816; b=H2UafIYQkLSmOaYY0aGDtQkEsMRPoVrBv/yD8E8I/4lLsD6iWmgI9Xk9segI3EuhoR y/J+0fgwEVn+87D606hoMrCpEFMzsW1XGPvcrYUc9CPsNSNOj6dkiQd0MwFmfQGQUMZD Caq7crNGZKYf8P4TZCI1KaFqhpt3lMUJJ+YIDa/eeVugd49ijnpq7xN7IBRCEMgd/Gqk +/zqqjj+2dYT0VTSG+IilPkxbQjqH5xnlJ9K2FcBI60eMVy5bpHvWtX7nqHdGFB4mZnc ZnlIjXlXmt22bJiaArhggC6sKvfJ7fF6cNO86Fpq4d6IOtphnI338VzXCNF4P9R0Vw3p 9thQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=eKBz1fhih9+3Kb3HMlACxUt1yzcIHKdIj++GVtqzNHI=; b=ryTD+2x6BeUtSokAiuQwLC26tdqwHh0fmopOBh47EzXMnvV1ZRc/Dc6nQYF5jfPWI8 pasPzJ4LmKiL/dXwxgkfyGgXrxB4p1XLbmqk7sHXmbkhXKLnZC+7z1P0FrFD2xFC+NDZ Kr94lk1cZiAaGYbQk19Mm9qnKRj+F+H/P0GeTFNHgd6CSLdYMkv/iFaazSmVpHEZWldX 9x8s5RE+rzZPc9foxUdBNJUPdQ1qQqnstZRpgWS+8kGWC5rs+JGIsc/0ZstednEc8DWd vAXS+Vd46AvmB4d1+k+mgoDb3C5wIikEX+GFjag5O7r6prDbOAUZa18+WcHK2TCQaxSY TQZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FpcjuVkW; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1-v6si13854007pgf.146.2018.08.27.02.33.44; Mon, 27 Aug 2018 02:33:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FpcjuVkW; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727389AbeH0NTg (ORCPT + 5 others); Mon, 27 Aug 2018 09:19:36 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34861 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727078AbeH0NTf (ORCPT ); Mon, 27 Aug 2018 09:19:35 -0400 Received: by mail-wm0-f66.google.com with SMTP id o18-v6so7655345wmc.0 for ; Mon, 27 Aug 2018 02:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eKBz1fhih9+3Kb3HMlACxUt1yzcIHKdIj++GVtqzNHI=; b=FpcjuVkWQCKnlcVVTJPQS/UQsJBpsOsTaKqKsQ+VnzG2lQzPDLV8HxZfhIrdLGU2fL e8kRY/mazjWRd9STVwc/PkqfBCn7ukmog7jb3k6J7fMbg3U+hcJMft8AhmfheZDwl5Gw isXvVnSN2JAMFGLwZwy/UWqUeEKbJSEFOXpNM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eKBz1fhih9+3Kb3HMlACxUt1yzcIHKdIj++GVtqzNHI=; b=g8mgBE/dUd7vb+qPDNeBY+LFBXjXx+DlzJLhSuW1cj/UlPnGGSUtUsAhNngxwFnhIk Bz5VeiaJ+XCbzpw3hz4LJem7huT1LdYzhVfi5llhhaJfe7XhqRzA1pre30WVdFCxF8sx mZq5yk1Fu0pkA8Fj3RiUPz0oAhyCJxuoZyQWLqd5YvBTbpUMwyExJDWqj7COvCfyZSQB UCYvDlra486vxBay21ra5Qrc/KWW1sQpCa9ehdoh3FIeNX3Gr74NXvukO9nt+6ng8vN1 s6eTxJFvOFvQbjHOG/g/IwJ5rart0ZLZ/pQd0VUHmSA0uAbdL72E5bsjwv3qYgn4Gsm0 wx7w== X-Gm-Message-State: APzg51D6gfRVNNR7dtQxfntW08rgw0w9+zISG72EJkSm0IO5LIcw5WPu XLscaT4is7QcjO3ZzjhCkcMr9A== X-Received: by 2002:a1c:b54b:: with SMTP id e72-v6mr2024624wmf.117.1535362421510; Mon, 27 Aug 2018 02:33:41 -0700 (PDT) Received: from lpoulain-ThinkPad-T470p.home (AToulouse-655-1-762-165.w109-220.abo.wanadoo.fr. [109.220.142.165]) by smtp.gmail.com with ESMTPSA id y203-v6sm8022828wmd.1.2018.08.27.02.33.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 02:33:40 -0700 (PDT) From: Loic Poulain To: Peter.Chen@nxp.com Cc: linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, david.brown@linaro.org, robh+dt@kernel.org, bjorn.andersson@linaro.org, andy.gross@linaro.org, andy.shevchenko@gmail.com, Loic Poulain Subject: [PATCH v2 3/7] usb: chipidea: Support generic usb extcon Date: Mon, 27 Aug 2018 11:33:31 +0200 Message-Id: <1535362415-16559-3-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> References: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add compatibility for extcon-usb-gpio which can handle more than one cable per instance, allowing coherency of USB cable states (USB/USB-HOST). These states can be generated from ID or/and VBUS pins. In case only one extcon device is associated to the USB device, and this device supports USB and USB-HOST cable states, we now use it for both VBUS (USB) and ID (USB-HOST) notifier. Signed-off-by: Loic Poulain --- v2: no change drivers/usb/chipidea/core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.7.4 diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index cdac778..afe85e2 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -702,6 +702,17 @@ static int ci_get_platdata(struct device *dev, ext_id = extcon_get_edev_by_phandle(dev, 1); if (IS_ERR(ext_id) && PTR_ERR(ext_id) != -ENODEV) return PTR_ERR(ext_id); + + /* + * Some extcon devices like extcon-usb-gpio have only one + * instance for both USB and USB-HOST cable states. + */ + if (!IS_ERR(ext_vbus) && IS_ERR(ext_id)) { + if (extcon_get_state(ext_vbus, EXTCON_USB) >= 0 && + extcon_get_state(ext_vbus, EXTCON_USB_HOST) >= 0) { + ext_id = ext_vbus; + } + } } cable = &platdata->vbus_extcon;