From patchwork Sun Jun 26 07:28:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 70868 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp555344qgy; Sun, 26 Jun 2016 00:31:39 -0700 (PDT) X-Received: by 10.66.86.103 with SMTP id o7mr23161607paz.5.1466926293449; Sun, 26 Jun 2016 00:31:33 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y67si18102318pfy.250.2016.06.26.00.31.33; Sun, 26 Jun 2016 00:31:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752261AbcFZH3O (ORCPT + 30 others); Sun, 26 Jun 2016 03:29:14 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:35616 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752080AbcFZH2t (ORCPT ); Sun, 26 Jun 2016 03:28:49 -0400 Received: by mail-pf0-f181.google.com with SMTP id c2so51926164pfa.2 for ; Sun, 26 Jun 2016 00:28:48 -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=80R/9+LOUigICDWZqVjHHhmqILwAkDpUBezM9ObR0s0=; b=juyKHf/2jihJBnWuEi+aQWA+sPgFm4J3mxMcjNAdV0fm9J0eXZZ64rhghLro79ZqTU rA2dPUq+22xsRg0aLupYFymDGzHvl2Xz2E4vLuelBfsN7/WHs558818F6sZ/yGUs2kMc W8xfxORen2iIf/lNhtZ970lXxsWSru2av1Ewk= 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:in-reply-to :references; bh=80R/9+LOUigICDWZqVjHHhmqILwAkDpUBezM9ObR0s0=; b=iQwU/b+yob0zJlsD54XaR/VWa5gEi/iKximMtPiy2eZHRt+ekiBCaGMvBsaJjrj22G YAmDPqa1K6LZc/DGI9n/0MzsuWHSm7jeM/Q3L3BZO0CfXqOPI5BDUn7pkbkzXJvGVfTe Yr9MpuVg5RMJOCJHqs5NDtEu0v0CdieLQbUI7YPyrmyH6zT5XJW52sVUz20N4l5FdQTO 9ERPauJjfBs+d9Y5xgPemq+PzX6pcD8TL+G+axDO94mwjJnxW2NBWdmurH/4icdEEHIs ik+dhPcRNfrIiP6GiRynS0cV3VdjZ8g9Z24sXdr2Ki6Mb5fB50xZZYHUZpoUsCCbg8uo rIhw== X-Gm-Message-State: ALyK8tIJTYDScPkOJz8/gBOeHDWs/5KNwsaEwbRoQlPNBPNZC/XOolq5bYOesnc1afQD3b/6 X-Received: by 10.98.111.138 with SMTP id k132mr22614985pfc.105.1466926128391; Sun, 26 Jun 2016 00:28:48 -0700 (PDT) Received: from localhost.localdomain (ip68-101-172-78.sd.sd.cox.net. [68.101.172.78]) by smtp.gmail.com with ESMTPSA id f138sm3790495pfa.17.2016.06.26.00.28.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Jun 2016 00:28:47 -0700 (PDT) From: Stephen Boyd To: linux-usb@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Andy Gross , Bjorn Andersson , Neil Armstrong , Arnd Bergmann , Felipe Balbi , Peter Chen , Greg Kroah-Hartman , "Ivan T. Ivanov" Subject: [PATCH 05/21] usb: chipidea: Handle extcon events properly Date: Sun, 26 Jun 2016 00:28:22 -0700 Message-Id: <20160626072838.28082-6-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.9.0.rc2.8.ga28705d In-Reply-To: <20160626072838.28082-1-stephen.boyd@linaro.org> References: <20160626072838.28082-1-stephen.boyd@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We're currently emulating the vbus and id interrupts in the OTGSC read API, but we also need to make sure that if we're handling the events with extcon that we don't enable the interrupts for those events in the hardware. Therefore, properly emulate this register if we're using extcon, but don't enable the interrupts. This allows me to get my cable connect/disconnect working properly without getting spurious interrupts on my device that uses an extcon for these two events. Cc: Peter Chen Cc: Greg Kroah-Hartman Cc: "Ivan T. Ivanov" Fixes: 3ecb3e09b042 ("usb: chipidea: Use extcon framework for VBUS and ID detect") Signed-off-by: Stephen Boyd --- drivers/usb/chipidea/otg.c | 46 +++++++++++++++++++++++++++++++++++++++----- include/linux/usb/chipidea.h | 2 ++ 2 files changed, 43 insertions(+), 5 deletions(-) -- 2.9.0.rc2.8.ga28705d diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index 763a8332b009..b6a88bea4cac 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -44,12 +44,15 @@ u32 hw_read_otgsc(struct ci_hdrc *ci, u32 mask) else val &= ~OTGSC_BSVIS; - cable->changed = false; - if (cable->state) val |= OTGSC_BSV; else val &= ~OTGSC_BSV; + + if (cable->enabled) + val |= OTGSC_BSVIE; + else + val &= ~OTGSC_BSVIE; } cable = &ci->platdata->id_extcon; @@ -59,15 +62,18 @@ u32 hw_read_otgsc(struct ci_hdrc *ci, u32 mask) else val &= ~OTGSC_IDIS; - cable->changed = false; - if (cable->state) val |= OTGSC_ID; else val &= ~OTGSC_ID; + + if (cable->enabled) + val |= OTGSC_IDIE; + else + val &= ~OTGSC_IDIE; } - return val; + return val & mask; } /** @@ -77,6 +83,36 @@ u32 hw_read_otgsc(struct ci_hdrc *ci, u32 mask) */ void hw_write_otgsc(struct ci_hdrc *ci, u32 mask, u32 data) { + struct ci_hdrc_cable *cable; + + cable = &ci->platdata->vbus_extcon; + if (!IS_ERR(cable->edev)) { + if (data & mask & OTGSC_BSVIS) + cable->changed = false; + + /* Don't enable vbus interrupt if using external notifier */ + if (data & mask & OTGSC_BSVIE) { + cable->enabled = true; + data &= ~OTGSC_BSVIE; + } else if (mask & OTGSC_BSVIE) { + cable->enabled = false; + } + } + + cable = &ci->platdata->id_extcon; + if (!IS_ERR(cable->edev)) { + if (data & mask & OTGSC_IDIS) + cable->changed = false; + + /* Don't enable id interrupt if using external notifier */ + if (data & mask & OTGSC_IDIE) { + cable->enabled = true; + data &= ~OTGSC_IDIE; + } else if (mask & OTGSC_IDIE) { + cable->enabled = false; + } + } + hw_write(ci, OP_OTGSC, mask | OTGSC_INT_STATUS_BITS, data); } diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index 5dd75fa47dd8..f9be467d6695 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h @@ -14,6 +14,7 @@ struct ci_hdrc; * struct ci_hdrc_cable - structure for external connector cable state tracking * @state: current state of the line * @changed: set to true when extcon event happen + * @enabled: set to true if we've enabled the vbus or id interrupt * @edev: device which generate events * @ci: driver state of the chipidea device * @nb: hold event notification callback @@ -22,6 +23,7 @@ struct ci_hdrc; struct ci_hdrc_cable { bool state; bool changed; + bool enabled; struct extcon_dev *edev; struct ci_hdrc *ci; struct notifier_block nb;