From patchwork Sun Jun 13 14:59:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 460108 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BF86C48BE8 for ; Sun, 13 Jun 2021 15:02:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 396EC61354 for ; Sun, 13 Jun 2021 15:02:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231946AbhFMPE0 (ORCPT ); Sun, 13 Jun 2021 11:04:26 -0400 Received: from mail-lj1-f178.google.com ([209.85.208.178]:34633 "EHLO mail-lj1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231755AbhFMPEZ (ORCPT ); Sun, 13 Jun 2021 11:04:25 -0400 Received: by mail-lj1-f178.google.com with SMTP id bn21so16487085ljb.1; Sun, 13 Jun 2021 08:02:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ASZtt9RicUC6Li5nnAiBicxpu/Z78FYFE+q293rWAv4=; b=WjENKTp316jAB/g3HUjC5zwc5CBlihmCSLBIhFpD/wzCb2VjZpLJ1F57d2ky/M8Kda 5D8IjWM1UgO/ivr/ItE2579NYXdqi4689uTwS8tvsybXCDRxuns0zle+ZomNBrroJTPe UeZzk831ppOrd2bDRaJmEU3zDUUHiLvnN7fIGQOGYvoQDoT3l+iTzV0VGtYj6QfjLBAq 67PeR5J2ZaTOEicGb02kOjgWy3mFmxvjYU+vFFCmyfcgTozXtMF0W5ZQhxathC6LJlsP RwYbfXFH/yrkUW3aeHkl2YbHuN7Iric782426fQWHVsuaQ65qyjPHHGycg/4nIAKxTZm haBg== 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:mime-version :content-transfer-encoding; bh=ASZtt9RicUC6Li5nnAiBicxpu/Z78FYFE+q293rWAv4=; b=cMGeAi9LQo+v8V7t6K2m2An1eT6hS1tmg1p6gKTLvoyntk3jDS8QIxuVwT39125h0D YQrbsDm7vgyfla5WpP5tKz8ODpisDKKRt5kcpqd4a90GFDflVGzU+rBGNYTAoFA7/lXa qB+nIEKPgLi78jty51GQI9YB3X4YN2fQByMbDUOzHv+MpFv+htPLPFjwKNbn1cjt61Nq j5bkgoaffcHstnvZp2k+otelEEcZzdVjpL9JF/fCh+uf7UbSSH8ji+2hqET/MOXNMbwi z1xJxYhd/29bw0rna+anwufv1AWEbPjfVFYkXjMNqaVILcWxV1GEqlWo+650HvTr94aK KzxA== X-Gm-Message-State: AOAM531aUHqYTJi/JfIp0k/PrLl2WzsTjz6W89lXjrj3Lx4duDljT4V/ sxC/5KLXAJP6d98eI7Mbvp4= X-Google-Smtp-Source: ABdhPJzDUZYYGFXmlBUv9wVpn8FtmOm3sjTTS5l1UfkXwSPIEyrBJss8+Yy1uo0ZkV2fLg7B/cSSag== X-Received: by 2002:a2e:1414:: with SMTP id u20mr10180144ljd.416.1623596483438; Sun, 13 Jun 2021 08:01:23 -0700 (PDT) Received: from localhost.localdomain (46-138-6-137.dynamic.spd-mgts.ru. [46.138.6.137]) by smtp.gmail.com with ESMTPSA id b16sm1473192ljh.93.2021.06.13.08.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 08:01:23 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Peter Chen , Greg Kroah-Hartman , Felipe Balbi , Maxim Schwalm Cc: linux-tegra@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/2] usb: phy: tegra: Wait for VBUS wakeup status deassertion on suspend Date: Sun, 13 Jun 2021 17:59:35 +0300 Message-Id: <20210613145936.9902-1-digetx@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Some devices need an extra delay after losing VBUS, otherwise VBUS may be detected as active at suspend time, preventing the PHY's suspension by the VBUS detection sensor. This problem was found on Asus Transformer TF700T (Tegra30) tablet device, where the USB PHY wakes up immediately from suspend because VBUS sensor continues to detect VBUS as active after disconnection. We need to poll the PHY's VBUS wakeup status until it's deasserted before suspending PHY in order to fix this minor trouble. Fixes: 35192007d28d ("usb: phy: tegra: Support waking up from a low power mode") Reported-by: Maxim Schwalm # Asus TF700T Tested-by: Maxim Schwalm # Asus TF700T Signed-off-by: Dmitry Osipenko Reviewed-by: Peter Chen Reviewed-by: Peter Chen --- drivers/usb/phy/phy-tegra-usb.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index fc5c6cab58ba..ff482c694200 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -64,6 +64,7 @@ #define A_VBUS_VLD_WAKEUP_EN BIT(30) #define USB_PHY_VBUS_WAKEUP_ID 0x408 +#define VBUS_WAKEUP_STS BIT(10) #define VBUS_WAKEUP_WAKEUP_EN BIT(30) #define USB1_LEGACY_CTRL 0x410 @@ -645,6 +646,15 @@ static int utmi_phy_power_off(struct tegra_usb_phy *phy) void __iomem *base = phy->regs; u32 val; + /* + * Give hardware time to settle down after VBUS disconnection, + * otherwise PHY will immediately wake up from suspend. + */ + if (phy->wakeup_enabled && phy->mode != USB_DR_MODE_HOST) + readl_relaxed_poll_timeout(base + USB_PHY_VBUS_WAKEUP_ID, + val, !(val & VBUS_WAKEUP_STS), + 5000, 100000); + utmi_phy_clk_disable(phy); /* PHY won't resume if reset is asserted */ From patchwork Sun Jun 13 14:59:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 459686 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EFFBC48BCF for ; Sun, 13 Jun 2021 15:02:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F6A061358 for ; Sun, 13 Jun 2021 15:02:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231959AbhFMPE2 (ORCPT ); Sun, 13 Jun 2021 11:04:28 -0400 Received: from mail-lj1-f178.google.com ([209.85.208.178]:35502 "EHLO mail-lj1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231782AbhFMPE0 (ORCPT ); Sun, 13 Jun 2021 11:04:26 -0400 Received: by mail-lj1-f178.google.com with SMTP id n17so16509076ljg.2; Sun, 13 Jun 2021 08:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vwLc+Cwj3JuQAE0/T4amXW2tbDrWfyGTYXqxA4e2OyA=; b=fO7EoFAKItDv6Z5MzvtL7UIFVHmALkSBXDxitKBqJcSK0fFZQCJSLujj2XcnyKI+VX UPSlVQcQ1VdALrAa9IDI+So8b/movDBeyejfwjs87iGRpR6jnGbhaZPaV1lts2ECkk9C ES6dOlnHjCVR1/yet35rL+phW8tVlj8jaqBHPkE/ciJJIgm4edVxY+r/b/IcGLiv3kqt yATCv6Oe6JXFTRhQxdYhSDoDcNrHp5rfRkN9jbJJoMwqGX0wi+o+RRh5bY444ir2osnI yHNhB2L4RYkkYj7IRxYIPjSQ5fMdjoNgdrfOsEYpPT3y0rl/xLf0Jk+PhIifeCnNkEXs QF9A== 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:mime-version:content-transfer-encoding; bh=vwLc+Cwj3JuQAE0/T4amXW2tbDrWfyGTYXqxA4e2OyA=; b=iwoYqgOiZ63oapBQu8ODulM5jfdw7d2TpYHs1HMiMW129TwxnDf+HQdtf+w0DOBUHt nDjUVTt4jANXi66L/JyJw7lg5Y8QOrlk6bbnpvppqfuiD/+/KBYpKgqmTNNwUGu6mtsQ YhnCpbk5lvntjFO/Qrk+L2pr0eDq787+E6pPubgnU/cYz2I+ixvVYXN4vplQjRF4JNQ2 IY5BRstJ1I7QtQIan9xCNnnGmYhfxvupwznlKz3fCcw0k3OpAB+WWK/W6NSXc4210EKV kUwefz5ke/sVPRqZzwCVMuFPbA56NHwmSL+LEAAanh8XMcF2fIyCEPISxSsATEZp0J7T CEnQ== X-Gm-Message-State: AOAM530OmTv4j7zV7O8o8IZCoVab6Cv/12OIKYYXmvjeX2a5xjRu2qYd O7dmCKxFccvnwJ5GVKBxUOQ= X-Google-Smtp-Source: ABdhPJz5iw9M2VyooUEsY/17QxKjJSsLfqND4f//c5Q67oFJL4LNqLskgq1PIW/4rG6V0gvzNJWn7g== X-Received: by 2002:a2e:9c4a:: with SMTP id t10mr10577162ljj.307.1623596484035; Sun, 13 Jun 2021 08:01:24 -0700 (PDT) Received: from localhost.localdomain (46-138-6-137.dynamic.spd-mgts.ru. [46.138.6.137]) by smtp.gmail.com with ESMTPSA id b16sm1473192ljh.93.2021.06.13.08.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 08:01:23 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Peter Chen , Greg Kroah-Hartman , Felipe Balbi , Maxim Schwalm Cc: linux-tegra@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/2] usb: phy: tegra: Correct definition of B_SESS_VLD_WAKEUP_EN bit Date: Sun, 13 Jun 2021 17:59:36 +0300 Message-Id: <20210613145936.9902-2-digetx@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210613145936.9902-1-digetx@gmail.com> References: <20210613145936.9902-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The B_SESS_VLD_WAKEUP_EN bit 6 was added by a mistake in a previous commit. This bit corresponds to B_SESS_END_WAKEUP_EN, which we don't use. The B_VBUS_VLD_WAKEUP_EN doesn't exist at all and B_SESS_VLD_WAKEUP_EN needs to be in place of it. We don't utilize B-sensors in the driver, so it never was a problem, nevertheless let's correct the definition of the bits. Fixes: 35192007d28d ("usb: phy: tegra: Support waking up from a low power mode") Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-tegra-usb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index ff482c694200..cd425b937750 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -58,8 +58,7 @@ #define USB_WAKEUP_DEBOUNCE_COUNT(x) (((x) & 0x7) << 16) #define USB_PHY_VBUS_SENSORS 0x404 -#define B_SESS_VLD_WAKEUP_EN BIT(6) -#define B_VBUS_VLD_WAKEUP_EN BIT(14) +#define B_SESS_VLD_WAKEUP_EN BIT(14) #define A_SESS_VLD_WAKEUP_EN BIT(22) #define A_VBUS_VLD_WAKEUP_EN BIT(30) @@ -548,7 +547,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy) val = readl_relaxed(base + USB_PHY_VBUS_SENSORS); val &= ~(A_VBUS_VLD_WAKEUP_EN | A_SESS_VLD_WAKEUP_EN); - val &= ~(B_VBUS_VLD_WAKEUP_EN | B_SESS_VLD_WAKEUP_EN); + val &= ~(B_SESS_VLD_WAKEUP_EN); writel_relaxed(val, base + USB_PHY_VBUS_SENSORS); val = readl_relaxed(base + UTMIP_BAT_CHRG_CFG0);