From patchwork Thu Jul 14 17:41:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 12918296 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 722C0C433EF for ; Thu, 14 Jul 2022 17:43:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=dowf9ciFumfB40rhPcmsSlBOy0cUQ43hzCZRpYeVZC8=; b=vEvN3Bxba5Uana 1EC526si5YFcX9BTTmig4XSLkGvL1sTwYYa8vx43nQnOKoIm2Hg8VjwnqrATOKrnJhhkhsRnLHVCk nJrVrPO1VB6hoDisHEGuvkFta7g7qgbfAremk1ALi5wHLt2WAOBxRBRPRcLFMbivw6gqvGTpxOvv4 sSBFcDHwuswHe9XPYqlzS/6JcPqpIQjzrLG3qcP/Dh/eJwWoPr+iIThbcNOm6y+ZyDpfO1pMojnGV e+kS9NusAKC/VE1JhA3U8jAfv59STbpQT7kR66CUm0R2K0zvpVHZ8JGr1AJmbnlzwuuvhqF+CYuCL VQDh8XI4HJWRW5229iMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oC2r7-00Gp6v-Jl; Thu, 14 Jul 2022 17:42:29 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oC2r2-00Gp1L-Ut for linux-arm-kernel@lists.infradead.org; Thu, 14 Jul 2022 17:42:27 +0000 Received: by mail-pj1-x1030.google.com with SMTP id s21so3481395pjq.4 for ; Thu, 14 Jul 2022 10:42:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=7yjL2expcxBKXOQuAJE5MbH5QFMOzJ52MUra63CEevk=; b=DRcAN2xwgo/Uxp6vYzqLufhSw3/fvkjTqPz/ZCng/QQjbjoO5bdGJvVu/Kw+q5rII4 xdgJa9QK+/262nHBzbquVQxcPt/wTK7eB1hR2L8BTS7PWlpDq2KpYZ+e0FfRQz+3ig6s HgTQdUEzbV60X0e9VjTRzqofl4POzSN4w0r4UyAnjwVC7LUhqtwMmvk8gESVj7G2Aba0 QWemcUlkZrXiEY83A4vXljsSFkxWow1hDBX0azTlPfrM9+E5wHUkJpngB3B7KD0SzNyG EtztQU2WCrLB2w6bSL7sKvQQ/tfJyrQbCP0SDQBfsZ3NM4r+CODdBCwWJvGVd84eu+kt 0HCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7yjL2expcxBKXOQuAJE5MbH5QFMOzJ52MUra63CEevk=; b=BxLPgM5CuZPcWzIJNEFDyknEWIe6mNIclNXkJ3F+Ne0h/h6QYUsDX35+y9j9A6IKmj gsIHtHkxaoXf0PsxdSPGWtrnH3Mu1U5bV6jdGGjpFXYkNR39OWcoiefcehj/sj0uiASy s0jDw3HODPxF2JoYMraBSD/jjSuUczAotldB80dVIgmNLvOWyEEjlzAsLW27LDdx5mTA +1VJR/wLNk3ozAEsPRUW96YyvB0bYo5F7LkZLzCB4zGap2khTtr3YwTE2PcwjbnNiTWY Jar3BrvBsVfgWehbtyjoV1f50xWHDINT0Tk5iNQAMBRzVVIaXq5t8IziuPEZf1D0ZU0l 7LRg== X-Gm-Message-State: AJIora+Srmj7Ag86PCh1I4zRMZCQ0Iy9bUCxW/OKD6sd/RdYEKLIXvBf JQsC3ZXQ8wrl4vt1/sPe54k= X-Google-Smtp-Source: AGRyM1vw7XtwZtH7FPoxIJ53uJpJ1+HL66UlZ8Xf8qvbh8BcwfgqOCIZmEZcxfoAFotdfAbGihwYRg== X-Received: by 2002:a17:90b:4a8b:b0:1ef:fba9:1c0b with SMTP id lp11-20020a17090b4a8b00b001effba91c0bmr17387713pjb.239.1657820535896; Thu, 14 Jul 2022 10:42:15 -0700 (PDT) Received: from mail.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id s13-20020a170902b18d00b0016c35b21901sm1734006plr.195.2022.07.14.10.42.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 10:42:15 -0700 (PDT) From: Kamal Dasu To: ulf.hansson@linaro.org, robh+dt@kernel.org, krzk+dt@kernel.org, alcooperx@gmail.com Cc: f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, adrian.hunter@intel.com, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Kamal Dasu Subject: [PATCH] mmc: sdhci-brcmstb: use clk_get_rate(base_clk) in PM resume Date: Thu, 14 Jul 2022 13:41:32 -0400 Message-Id: <20220714174132.18541-1-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220714_104225_013964_0805C271 X-CRM114-Status: GOOD ( 11.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use clk_get_rate for base_clk on resume before setting new rate. This change ensures that the clock api returns current rate and sets the clock to the desired rate and honors CLK_GET_NO_CACHE attribute used by clock api. Fixes: 97904a59855c (mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0) Signed-off-by: Kamal Dasu Acked-by: Florian Fainelli --- drivers/mmc/host/sdhci-brcmstb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index 28e9cf995c41..aff36a933ebe 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -406,7 +406,14 @@ static int sdhci_brcmstb_resume(struct device *dev) ret = sdhci_pltfm_resume(dev); if (!ret && priv->base_freq_hz) { ret = clk_prepare_enable(priv->base_clk); - if (!ret) + /* + * Note: using clk_get_rate() below as clk_get_rate() + * honors CLK_GET_RATE_NOCACHE attribute, but clk_set_rate() + * may do implicit get_rate() calls that do not honor + * CLK_GET_RATE_NOCACHE. + */ + if (!ret && + (clk_get_rate(priv->base_clk) != priv->base_freq_hz)) ret = clk_set_rate(priv->base_clk, priv->base_freq_hz); }