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: 10576769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 495A713B8 for ; Mon, 27 Aug 2018 09:33:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B5222847D for ; Mon, 27 Aug 2018 09:33:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F2AA297A9; Mon, 27 Aug 2018 09:33:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8A732847D for ; Mon, 27 Aug 2018 09:33:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727389AbeH0NTg (ORCPT ); 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-Google-Smtp-Source: ANB0VdaW5qAyrZbPemYsKUKtCPpZ+IHK1589hr6tcddfm3WWZINkfX/nsdyS5l1WWcwKRKV1LRjlUA== 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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;