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: 144728 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp5306634ljj; Tue, 21 Aug 2018 06:56:03 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzrFEOafVQ1TFN4JGsZm/cbPXNJahScrMaYMCOx6Wxn6xV8/pbb5zNW2x9A2dq72y1p+A6v X-Received: by 2002:a63:cd02:: with SMTP id i2-v6mr46350169pgg.93.1534859763732; Tue, 21 Aug 2018 06:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534859763; cv=none; d=google.com; s=arc-20160816; b=VnIsay0BOENnxvQpa7bHzrQaIcSfeEt3fYSyj/3r3/1N9r6qZ9TIomBEvy/sjlnVbJ S0mJon40r2f2dT38BxTw54IE1ICv0yP8FxoBhS1WN094i1oxyhmGp2yXWN5HFyHyod8X fz+5AB/694wVvlu7jk/LTWc47wMWDTRMemidb7uBRsn4xtbatMkGnLQRbDhHvLUI7Jwz 3XCsA/v3a44lUSWy71no2zEE5tpi1B5kS9DcijAhLwbOp01SI6bVnSPrA3sVxRfWaeWu 3E4ttl9tdEiDyXm4e0KQ1UQd/WiG8fROQv3eaRsGKda6SAX3kcd+mry9No4dioG2jyMc 6x0Q== 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=T16gbVCP6TPIcumFu0woImacmMgPy6bKhyqUl+bq5LE=; b=hH9mdAZDE9wCCrj9YweZcunRQaNMuNhqTsAMqrIJZTVWdem6yjP3TsZIdRizsNm7wY FN9YS6D69pdTpZwvxCW7kJ51cb3brqp5y2JB9YUQK5mpvS8gdwKshBLWUd0py/LZMhPa fENLyLYaL4PQlRIccBc+J23ERoxcI+cSRlsWQeAAqx1HE8frU+DsrvqUR08ojDCEPsb4 /JduqPxarNH8dTTnWmshdStQyodAnzKs5hZuyhSr9ray57D8xoI95YFSOeFz9qTYPGo0 i9V0RBvn3nHFR2ewcOHz9oIpCEcVNz6yewAkVKLhEFI4jcGnUlZBSHj/pMioNHTztVHV U6eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FTo6HcaY; 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 f25-v6si7569484pgm.58.2018.08.21.06.56.03; Tue, 21 Aug 2018 06:56:03 -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=FTo6HcaY; 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 S1727306AbeHURQR (ORCPT + 5 others); 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-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 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(+) -- 2.7.4 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;