From patchwork Tue Aug 21 13:55:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10571699 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 E0D3813B6 for ; Tue, 21 Aug 2018 13:56:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D13C22A33F for ; Tue, 21 Aug 2018 13:56:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF5202A3AB; Tue, 21 Aug 2018 13:56:03 +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 7CD282A386 for ; Tue, 21 Aug 2018 13:56:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727306AbeHURQR (ORCPT ); Tue, 21 Aug 2018 13:16:17 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:42098 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727252AbeHURQR (ORCPT ); Tue, 21 Aug 2018 13:16:17 -0400 Received: by mail-wr1-f66.google.com with SMTP id v17-v6so1324129wrr.9 for ; Tue, 21 Aug 2018 06:56:01 -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=T16gbVCP6TPIcumFu0woImacmMgPy6bKhyqUl+bq5LE=; b=FTo6HcaYZ8iuUmXMVLP8yIl008bSIoNQwT9yw/4Lnc1SqaByuXqd/WSokQE/5X6nsg m2buIkbaDVM9DPiEj7OooVCrW6lKWT4DpkNGNJ/mWPQO/fj2yYtvOQDPTdbMivCXcNmM lQBpuC5WSEjx1xKS0hsbNYBybwE+6H2VQPJko= 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=T16gbVCP6TPIcumFu0woImacmMgPy6bKhyqUl+bq5LE=; b=jvBOT+5IjI+SeopGV7haE+sVbtZJq1ET2TmPOhsZKyMrgFNHLyBV7pV/6s4fORi1VA 9mT4vqW6oxNMWIlBUaoqdH5MgJbNMdf0RxWnxqxOzjPYbIApUDVC9LKn3WtBlSKL2PcJ WKXeuWuTckdd4LELwbDGcJlS5EIDV71uvnvTp4kNDwK2eQjh5UpiKCXiHjzacAIpBRwL DI5U60WvTn5Yvfcywslx0Mchlsv1RZ4eKcDiNayZ1B8uDx6R6bBeXrbUiP5z1hVAXk08 4i8+Uj7ng1d8lwn+76B2o6CnH5V7hvGtZ2jXl3QCtbXGS6PUUfoCbMgRRuAWjM8CwMfM tUpQ== X-Gm-Message-State: APzg51DyrOxHRnIEIBw2IQ+eZlWHKg25ZxjJvVAJchR8K0tiBq7iJZYX aoS7kDz75WJLWpX80rhym3/bQg3rlyw= X-Google-Smtp-Source: ANB0VdYOhSzflE9/Fa2O7lF5aBPgZfU9fqjJNi40aSHTTczNrSVWSPP6hjDzBuqnOMBbGO4ZJocsbw== X-Received: by 2002:adf:ea92:: with SMTP id s18-v6mr1316053wrm.284.1534859761228; Tue, 21 Aug 2018 06:56:01 -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 l24-v6sm16728523wrb.65.2018.08.21.06.56.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Aug 2018 06:56:00 -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, Loic Poulain Subject: [PATCH 2/6] usb: chipidea: Support generic usb extcon Date: Tue, 21 Aug 2018 15:55:52 +0200 Message-Id: <1534859756-6955-2-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534859756-6955-1-git-send-email-loic.poulain@linaro.org> References: <1534859756-6955-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 --- 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 03e52fc..c595718 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -699,6 +699,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;