Received: by 2002:a05:6359:322:b0:b3:69d0:12d8 with SMTP id ef34csp97853rwb; Wed, 10 Aug 2022 15:37:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR5BdAFMigBnE56eLSRRa6CKjevOWDylcDo/EUr9AsJzQ2s9bNxmghjZrH1yEMKawJEA+SIa X-Received: by 2002:a17:906:4787:b0:734:1ad4:aff0 with SMTP id cw7-20020a170906478700b007341ad4aff0mr672257ejc.317.1660171041772; Wed, 10 Aug 2022 15:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660171041; cv=none; d=google.com; s=arc-20160816; b=DaodiQejj9sWdLoqb6hTQvfY2Hdzu0oopbzdqJfvsCxAv8as/eA4owEweHvj9FFq1U lclMZa0N1NKifXLNfwOdFriPQ5IeMXOvxbc7SMtwK+uAhpIvZVXzlH3zsULY3vGd3quv v1LnEmDsqW3Wsa7nIkwXNB5/4uWNxg/QBjNXfZWmac6S9aqlRxRCiOQiIQOJmROQLLgn h578uCrLJ8FpGiYiai5B4uF/nD/7GcH2sLSo13fPYq4VqjLyJPQW+mYCWsJm6QfTK7f8 LHEUjNkq6LHnVkQ+a9eNMx/wYZjq+cGuLk+ftFVAc04+JoiZso5Wptkbpj9ywva/GI+9 dbSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=Ei64+VEKclLsM5qrzZu0dqiqpVuMadQ8WSJ6SrSoMJY=; b=fOwagAXxwai8ZaqX0SLjhxymPWw5/DFK59NYW48UtAKE3wUXaYtgNmm+ELigBuVgDi v3IyA6IxBsIZ19+BnMZMn6RmjU+ZD67HHoYZBaIe5rNaeKmIWVY31MJmosVJFcC6x0YQ Ii11fKGFZWojge611PwLUIGoEuFVarqIFbKxO2uNi3t2RalZ+z2foFROtpONpmr4iC6J j7Qss4v538V0q7OJ//J3ZyiYRrJXP5ilY+5iG2RPrOmpHLWSRbvbPL3g5jGN7Soicqve wowi1k4mMVtMPfrS55kllHNJJY8aDsBqcowweeF57r85trQ5mlNNAkWd5Qiu1WNBTUK9 hKLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JgYGzOHH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o7-20020a50c907000000b0043be4e916b3si11177686edh.126.2022.08.10.15.36.51; Wed, 10 Aug 2022 15:37:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JgYGzOHH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233473AbiHJW1y (ORCPT + 99 others); Wed, 10 Aug 2022 18:27:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbiHJW1v (ORCPT ); Wed, 10 Aug 2022 18:27:51 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85D0C8D3FA; Wed, 10 Aug 2022 15:27:50 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id v14so6734039qkf.4; Wed, 10 Aug 2022 15:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc; bh=Ei64+VEKclLsM5qrzZu0dqiqpVuMadQ8WSJ6SrSoMJY=; b=JgYGzOHH4+2+22+5NR2HmYc0TEyXYdkb0a0S/KfVY5qMNUAD5zsxchwOlk2JuQd3hZ iCp28MYSI26L6kswEHZ8a+1b5k07EWT1Cwgr4zmYEtw3y1Bc/4Vj9b69WlggOg3ZlXnx MK2dI/FJ8uZE6uqXVSKDky/5ziX7kuP2dlwO26Oe77GUP2vjclSh5N/bZ3y5DrBLH1PB 5Br8wZZ4BKs0RndGX/cpu8p4jIbu8aYhBWpHTax7K+jym2Hc83Zo0eb8ZElTvRwoiN2v wkMfiqdvIbHLj7iqbhQJ3nLl0e5heK1q4lVaOITTNuJJ9YseHr/YGJtypeuCZZ4ULPcB X66g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc; bh=Ei64+VEKclLsM5qrzZu0dqiqpVuMadQ8WSJ6SrSoMJY=; b=2wD0wwmFLFAQnnbgTBOcs7x/O8jD/9AQQMip32Y0Jg5EY80F3dQxUqBrKKYA2yxE5n JvBlEYeX5vAT7ABH97a25+dEDMk8blr5DotbgzavyIa3Zak86lWY7IX8i6XcNmHjpa4c mVm3G7YtvxGhCFy5ef4z/jQQdG81Ud6ttVvvFA/VMKl9SQmYxexRdK8/psKPRESwkqeL JwQioU5DP51iv81GsH+S09diiqMXt5NDGE1p1VrLRYX/WGQOE2eJ9+anAUkEeRprwXAh dm+kdKGxIEAJmlk/wgVa9QOY10vrAMeuE4VgMEb3BocAaOpvd1xnPuz7J84K831earB0 jtXw== X-Gm-Message-State: ACgBeo0u6Y9JnTezmH0CBb1Dn4YRsjX+jC8ionvI9/nLTGD28YldZXTe 22rdmp8dpJ2rabkET+rYUkw= X-Received: by 2002:a05:620a:28d4:b0:6b9:5667:46ce with SMTP id l20-20020a05620a28d400b006b9566746cemr11364761qkp.216.1660170469452; Wed, 10 Aug 2022 15:27:49 -0700 (PDT) Received: from stbirv-lnx-2.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id y29-20020a37f61d000000b006b8e8c657ccsm711341qkj.117.2022.08.10.15.27.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Aug 2022 15:27:48 -0700 (PDT) From: justinpopo6@gmail.com To: mathias.nyman@intel.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: f.fainelli@gmail.com, Justin Chen Subject: [PATCH 1/2] usb: host: xhci-plat: suspend and resume clocks Date: Wed, 10 Aug 2022 15:27:34 -0700 Message-Id: <1660170455-15781-2-git-send-email-justinpopo6@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1660170455-15781-1-git-send-email-justinpopo6@gmail.com> References: <1660170455-15781-1-git-send-email-justinpopo6@gmail.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Justin Chen Introduce XHCI_SUSPEND_RESUME_CLKS quirk as a means to suspend and resume clocks if the hardware is capable of doing so. We assume that clocks will be needed if the device may wake. Signed-off-by: Justin Chen --- drivers/usb/host/xhci-plat.c | 16 +++++++++++++++- drivers/usb/host/xhci.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 0448558..a68b2b0 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -432,7 +432,16 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev) * xhci_suspend() needs `do_wakeup` to know whether host is allowed * to do wakeup during suspend. */ - return xhci_suspend(xhci, device_may_wakeup(dev)); + ret = xhci_suspend(xhci, device_may_wakeup(dev)); + if (ret) + return ret; + + if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) { + clk_disable_unprepare(xhci->clk); + clk_disable_unprepare(xhci->reg_clk); + } + + return 0; } static int __maybe_unused xhci_plat_resume(struct device *dev) @@ -441,6 +450,11 @@ static int __maybe_unused xhci_plat_resume(struct device *dev) struct xhci_hcd *xhci = hcd_to_xhci(hcd); int ret; + if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) { + clk_prepare_enable(xhci->clk); + clk_prepare_enable(xhci->reg_clk); + } + ret = xhci_priv_resume_quirk(hcd); if (ret) return ret; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 1960b47..182d1d4 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1899,6 +1899,7 @@ struct xhci_hcd { #define XHCI_NO_SOFT_RETRY BIT_ULL(40) #define XHCI_BROKEN_D3COLD BIT_ULL(41) #define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42) +#define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43) unsigned int num_active_eps; unsigned int limit_active_eps; -- 2.7.4