From patchwork Thu Apr 21 18:27:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 12822207 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 1E081C433EF for ; Thu, 21 Apr 2022 18:29:36 +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:References:In-Reply-To: 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: List-Owner; bh=d/u2XIIGAvM2nZb9q5WWxW5Oj5n82nU6Cckq7tqtSNk=; b=SVWc+RQsnBApWE oFee10UdSN3sfBCRZulSUk8h0qVs3bX4HpmUAGln9oDG3w+dvErPB8cSpoSLMtgKEGbj8Ctj8DjsM Ha4YFPb6q0euIMavs3JC/2XGXXQhCBJOMc+1UwciYe2mh8Pvl33+wfeqCxBkcqsSp3A8bi1CjJnky JuVq4SeMK0aLg0FksYRwRBWfk1bTmTSfXLeLgdNNosWeH43zUxujeo3zjY37b5fdWgkhBXSiu6SIB SpvWsPb7wiMn44T8LelSGeMKbHTBZCLOiL5pW/vzEpHTHGVHnSXN9El3xuqMB27caXkNnl1gS2p4b Lq4EJB+XWxJ4L3pYoNUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhbXV-00EdNh-3m; Thu, 21 Apr 2022 18:28:25 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhbXS-00EdMP-8U for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 18:28:23 +0000 Received: by mail-pg1-x532.google.com with SMTP id i63so5316452pge.11 for ; Thu, 21 Apr 2022 11:28:19 -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:in-reply-to:references; bh=WoeAeHW5+pgaqDzt+MQVIH8ZiTqwseT46QF5bHnKTlY=; b=qXLuFnoGfr2jkk+KCzjgqPXHHV4meayjHWJhhlSGh7uLIcIv7gOYM8FfxmcUwvX3fx jZ3/ViCTj5cneAUoM9EGbFf/ZNW5Fd+ycgDRM9k5XZzTey28EE/4qDK6QPbXX1ZYoTdJ acN+Xo8jEj9vfFJKg3EHQXnSF9FryTHr3t5XNQHRNQp7N572xCTvahqniwftriKI66/3 PyhQXRG2ZiR81w0c7YSFJgOsDVP+YC3MR9ESA4eZUSmiY7sZH78oJKbtjYkHyg+PK6V8 VRthEQlXzPyfzSEiTEONs99ctVvNr9KuvK/FjDWTqWJEr2Xg6wM+Gka/O5AMoy1Oaaci XSbg== 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:in-reply-to :references; bh=WoeAeHW5+pgaqDzt+MQVIH8ZiTqwseT46QF5bHnKTlY=; b=Ps+0jW1cXjTiqNV24UcqUtVlVbKeddT9BxEfOJ2nVF8xPCH82K31CGOE0ynY06Gwvt jAuKdkvOxz5NDZRLNgUt12aHO5xWN9JZl+esm1CcJwwyvSB7yaqe5oSbJfXfD1wcmeGH zaHM58n6hhaj66K5/mHxtQEEqkpQtyKIP5jRjRsWXfODkwzD4/IHRz5qDLe/24bIgU95 qhYaPLkNh4nGPCTI+QQ6Z9pXhd+rdMNWx6KJxNxQhhTx28O6KIfrVR7I+w7dKbbLgUe/ IqzRqFF5/Fnn/nolmWY2WJqjyk/wc4B4XeKhco8TowWhHIglNWxblI4+xyntUR/L2qoC PQAw== X-Gm-Message-State: AOAM530OQtAeMAh15ZsEWZ3uNPc2a93GTJMTMuiRsXoE/Y4hNe69kp1A DW7xxour68MZI7HgrSl/mPQ= X-Google-Smtp-Source: ABdhPJxFDwn3JFhdVvifutf6KZ4J30lL9zq4foVLQ7EpaOZfJo/wQ030Mfch0S+M3IeJarLqaJzr0w== X-Received: by 2002:a63:5a20:0:b0:3aa:2fd0:9e94 with SMTP id o32-20020a635a20000000b003aa2fd09e94mr637635pgb.602.1650565699397; Thu, 21 Apr 2022 11:28:19 -0700 (PDT) Received: from mail.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id s62-20020a635e41000000b003a9eb7f65absm6509333pgb.85.2022.04.21.11.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 11:28:19 -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 1/5] mmc: sdhci-brcmstb: "mmc1: Internal clock never stabilised." seen on 72113 Date: Thu, 21 Apr 2022 14:27:59 -0400 Message-Id: <20220421182803.6495-2-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220421182803.6495-1-kdasu.kdev@gmail.com> References: <20220421182803.6495-1-kdasu.kdev@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220421_112822_344261_EDF862AC X-CRM114-Status: GOOD ( 17.65 ) 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 From: Al Cooper The problem is in the .shutdown callback that was added to the sdhci-iproc and sdhci-brcmstb drivers to save power in S5. The shutdown callback will just call the sdhci_pltfm_suspend() function to suspend the lower level driver and then stop the sdhci system clock. The problem is that in some cases there can be a worker thread in the "system_freezable_wq" work queue that is scanning for a device every second. In normal system suspend, this queue is suspended before the driver suspend is called. In shutdown the queue is not suspended and the thread my run after we stop the sdhci clock in the shutdown callback which will cause the "clock never stabilised" error. The solution will be to have the shutdown callback cancel the worker thread before calling suspend (and stopping the sdhci clock). NOTE: This is only happening on systems with the Legacy RPi SDIO core because that's the only controller that doesn't have the presence signal and needs to use a worker thread to do a 1 second poll loop. Fixes: 5b191dcba719 ("mmc: sdhci-brcmstb: Fix mmc timeout errors on S5 suspend") Signed-off-by: Al Cooper Signed-off-by: Kamal Dasu Acked-by: Florian Fainelli --- drivers/mmc/host/sdhci-brcmstb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index f24623aac2db..11037cd14cfa 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -313,6 +313,10 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) static void sdhci_brcmstb_shutdown(struct platform_device *pdev) { + struct sdhci_host *host = platform_get_drvdata(pdev); + + /* Cancel possible rescan worker thread */ + cancel_delayed_work_sync(&host->mmc->detect); sdhci_pltfm_suspend(&pdev->dev); } From patchwork Thu Apr 21 18:28:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 12822208 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 55A69C433F5 for ; Thu, 21 Apr 2022 18:29:37 +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:References:In-Reply-To: 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: List-Owner; bh=l+pom0BgMitZI5ro8bohCiBMhyyuH5elFSMRCZyV3PU=; b=X6Nt0X1DlH3NoJ qDwV25j9XHOIzP0r5/3oh8lMGB6OHZ6HLxC6l/1/kVSpONIBq03UpBggB3TzBOXHXx9IO+Uic9DzX ClNFG7m3fFTqg1vbGzixIHYgfDUQEjN5cBRJYdY9J1xVfCaHXts0NDdeborxzfFnscnjXyPfWMpxw lmBZPXE86lS3REhSdUnY+L7rgNi9BDO4s5APtsRbF9kGfsERarsTMlOV7tUMjiipL3K0WKEtvPiwi claeQrr6lV71OdQpx+FdqHsAgT0jI/xnARE9+t3bDFAQuahNSwMfe2WM5t0MJa2ZV/4GmZ2DdMNev ctWnIlwH8MVJlAuR/71A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhbXd-00EdPF-Kf; Thu, 21 Apr 2022 18:28:33 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhbXY-00EdO2-Km for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 18:28:30 +0000 Received: by mail-pg1-x536.google.com with SMTP id x191so5344774pgd.4 for ; Thu, 21 Apr 2022 11:28:27 -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:in-reply-to:references; bh=CPKL6PLS2hyZUn/37pC34jEUL96YEezJ4fK6yAcdz3U=; b=cGu4y6MRjciJ6naClINARIrx1X6zxQzq3dzW52WNR/jIO2DdeoPq1k7LZvqqXwV823 jmaB57elHt0VHSI+g+zUgiJpc57J0wE9TkVlO5OQIQtZK+1/Lmi/qQKAKFwqRCSwrF8S q765lMNfqmh4hM+COy+yzpMqwSsbVIa+qoXEjtfJ81weTbyESIUFvIvKj28rDJlgDH+S Tx9ZFENSZ5nl6IeZGNgwVGX2VW4N2bCpgW4kO9zjEPpQhlBOSdVCnUetpVGxQPijHB3E LRCnGv+1lWM7Rm08VUR0zIztC14IBbAW3Wp6QBqI4y/Wzc1xryjp8+tQu4CjRIdLyndW k1NQ== 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:in-reply-to :references; bh=CPKL6PLS2hyZUn/37pC34jEUL96YEezJ4fK6yAcdz3U=; b=pba2fCwmy2Am/oJ5NmMyZv4LZMiX0lZAkZR5OYq9tDAIj8q/mZaAaTKoK4Ea4ZQsAh T9eKAKqQfRzz+UZnyyWjSj8FPH19+Ky2nIHGRetxpSVedbhGe+PEUjYk2RH5NoZcbTaZ lqacfrOiFiK7cQBNnG2ZeGfMlGI+ud1/o29kavARE43Fu15rHdKfldm0LkXSqHZ/9cP6 10ndgq6F6gx8OgoPSEiI47T3XMv+H01NJlSxagKzZHpvUDiwdVY2i4kjS/iAKOZsDnEI 9wE+SISgtAj4kf+Zia49hL2ueMYrdNIy8UY+uZ0aK43K0j+6qL/tTtX57zqok7y78P2e e1tA== X-Gm-Message-State: AOAM532evzUA5YomoAN4Qx708r1AAxWXz1J4m4Un/d46sqCC412t1sio IwwZQ9JDNVJbqW2ZCa6VAUk= X-Google-Smtp-Source: ABdhPJwHtpFLhF3JV7jb9ZgaqCrRrg4VaK87LgaEVhBuj9pyzUfRaR01TvE4rjLhQobLXHL/JoV60Q== X-Received: by 2002:a65:5c48:0:b0:382:2c7:28e9 with SMTP id v8-20020a655c48000000b0038202c728e9mr646700pgr.472.1650565706727; Thu, 21 Apr 2022 11:28:26 -0700 (PDT) Received: from mail.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id s62-20020a635e41000000b003a9eb7f65absm6509333pgb.85.2022.04.21.11.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 11:28:26 -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 2/5] mmc: sdhci-brcmstb: Re-organize flags Date: Thu, 21 Apr 2022 14:28:00 -0400 Message-Id: <20220421182803.6495-3-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220421182803.6495-1-kdasu.kdev@gmail.com> References: <20220421182803.6495-1-kdasu.kdev@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220421_112828_726959_2B1F2109 X-CRM114-Status: GOOD ( 16.10 ) 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 From: Al Cooper Re-organize the flags by basing the bit names on the flag that they apply to. Also change the "flags" member in the "brcmstb_match_priv" struct to const. Signed-off-by: Al Cooper Signed-off-by: Kamal Dasu Acked-by: Florian Fainelli Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-brcmstb.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index 11037cd14cfa..f32aa045c26d 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -18,20 +18,22 @@ #define SDHCI_VENDOR 0x78 #define SDHCI_VENDOR_ENHANCED_STRB 0x1 -#define BRCMSTB_PRIV_FLAGS_NO_64BIT BIT(0) -#define BRCMSTB_PRIV_FLAGS_BROKEN_TIMEOUT BIT(1) +#define BRCMSTB_MATCH_FLAGS_NO_64BIT BIT(0) +#define BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT BIT(1) + +#define BRCMSTB_PRIV_FLAGS_HAS_CQE BIT(0) #define SDHCI_ARASAN_CQE_BASE_ADDR 0x200 struct sdhci_brcmstb_priv { void __iomem *cfg_regs; - bool has_cqe; + unsigned int flags; }; struct brcmstb_match_priv { void (*hs400es)(struct mmc_host *mmc, struct mmc_ios *ios); struct sdhci_ops *ops; - unsigned int flags; + const unsigned int flags; }; static void sdhci_brcmstb_hs400es(struct mmc_host *mmc, struct mmc_ios *ios) @@ -134,13 +136,13 @@ static struct sdhci_ops sdhci_brcmstb_ops_7216 = { }; static struct brcmstb_match_priv match_priv_7425 = { - .flags = BRCMSTB_PRIV_FLAGS_NO_64BIT | - BRCMSTB_PRIV_FLAGS_BROKEN_TIMEOUT, + .flags = BRCMSTB_MATCH_FLAGS_NO_64BIT | + BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT, .ops = &sdhci_brcmstb_ops, }; static struct brcmstb_match_priv match_priv_7445 = { - .flags = BRCMSTB_PRIV_FLAGS_BROKEN_TIMEOUT, + .flags = BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT, .ops = &sdhci_brcmstb_ops, }; @@ -176,7 +178,7 @@ static int sdhci_brcmstb_add_host(struct sdhci_host *host, bool dma64; int ret; - if (!priv->has_cqe) + if ((priv->flags & BRCMSTB_PRIV_FLAGS_HAS_CQE) == 0) return sdhci_add_host(host); dev_dbg(mmc_dev(host->mmc), "CQE is enabled\n"); @@ -225,7 +227,6 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) struct sdhci_brcmstb_priv *priv; struct sdhci_host *host; struct resource *iomem; - bool has_cqe = false; struct clk *clk; int res; @@ -244,10 +245,6 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) return res; memset(&brcmstb_pdata, 0, sizeof(brcmstb_pdata)); - if (device_property_read_bool(&pdev->dev, "supports-cqe")) { - has_cqe = true; - match_priv->ops->irq = sdhci_brcmstb_cqhci_irq; - } brcmstb_pdata.ops = match_priv->ops; host = sdhci_pltfm_init(pdev, &brcmstb_pdata, sizeof(struct sdhci_brcmstb_priv)); @@ -258,7 +255,10 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) pltfm_host = sdhci_priv(host); priv = sdhci_pltfm_priv(pltfm_host); - priv->has_cqe = has_cqe; + if (device_property_read_bool(&pdev->dev, "supports-cqe")) { + priv->flags |= BRCMSTB_PRIV_FLAGS_HAS_CQE; + match_priv->ops->irq = sdhci_brcmstb_cqhci_irq; + } /* Map in the non-standard CFG registers */ iomem = platform_get_resource(pdev, IORESOURCE_MEM, 1); @@ -287,14 +287,14 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) * properties through mmc_of_parse(). */ host->caps = sdhci_readl(host, SDHCI_CAPABILITIES); - if (match_priv->flags & BRCMSTB_PRIV_FLAGS_NO_64BIT) + if (match_priv->flags & BRCMSTB_MATCH_FLAGS_NO_64BIT) host->caps &= ~SDHCI_CAN_64BIT; host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1); host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_DDR50); host->quirks |= SDHCI_QUIRK_MISSING_CAPS; - if (match_priv->flags & BRCMSTB_PRIV_FLAGS_BROKEN_TIMEOUT) + if (match_priv->flags & BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT) host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; res = sdhci_brcmstb_add_host(host, priv); From patchwork Thu Apr 21 18:28:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 12822209 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 F229BC433F5 for ; Thu, 21 Apr 2022 18:29:42 +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:References:In-Reply-To: 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: List-Owner; bh=xpIcr1TYuNcn58TJc44w3f91yITM8W7ZTahxVP4WV4Y=; b=aVthsE4mZ9Tca0 jWT581mfYMueeax9GGKLg+p3Xob195acdmg6m3vmCqIwVXz/vePx1RR/hpme0scbh6msICD8vHEk1 0MMFNjyL1zge9wwR2rWFsaM3lRFDdWln4aapovpJ9wW61n/44+dOAlGmibH9Wf+ddG3V1BHLWFrzt Dv7ZDah12qtcrUV1q8FO+QcYLjZVAOMOHFSF7RdmbFjVLzsgHbCxScGbzrDyavOk1xj9CEg3SOcYO xc9DFk6+Wh3wMNj1u6xOqbpS8Mgw0mWrvHKermwYrbpG5wnxYb9WTl6k6Jkropm8ZvjwSu0ryIbyf CsFEyoQ2If7qHASkDIsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhbXn-00EdTm-UL; Thu, 21 Apr 2022 18:28:44 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhbXd-00EdOg-Cy for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 18:28:34 +0000 Received: by mail-pj1-x102f.google.com with SMTP id w5-20020a17090aaf8500b001d74c754128so1218354pjq.0 for ; Thu, 21 Apr 2022 11:28:31 -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:in-reply-to:references; bh=mxxHlhYNIG4dd3FIR1DSmPfxfi0MyzRVrwtk2D5SO70=; b=RxdLGeE8XYHgxJljVAm+AWBFmD6aB+WctKzs5SaWM9HH6YMPD57YSpgi2WhuGj0DyV rYTmYoSpypPiAgLZAhv2X+engz8F0b8tJgc/ENDdxvCb1rM2oITYT/YdtirU2z4EN0Wk BTaGwTlzC1KkH3g36aJxOztz57jTwJyR67WCCuMNLuGnZ1OQJLjWbHo5bymacR+hSXL2 o+gFDfdoUetYeQVQev3rhKrOvqJAih9s79BiHHIrxnd/tRL6RPRJimpkbwxgmYhZUpx2 BYHmwy+iYPGDbF6L/cO7XpzBFO7NJzo1fEDAVWi8a8bEFmrRI9V4k3VWcfgUFc6KJtO2 NIgA== 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:in-reply-to :references; bh=mxxHlhYNIG4dd3FIR1DSmPfxfi0MyzRVrwtk2D5SO70=; b=p020iE8w8MiqrWhPjXuaGaN1xRTUBJO/ALl5fHOQ8ccBa5HdCVD6N0pSlTI1OrwHbM SlOBDA4r4xh3+PWe10VqpBo/P4rTUfjD4nTRGWfarDvVBywhrncLucRBrXcCgWXfXhUw ASav17JuFIycQ9NACXl2F63d9Jo9i+um0bKTmz7/NCgqbrqqJsNMydV4cf/uP7NvrsvM wgPblaqitbeH6OGolxtzY0tZW45mOZEoiwYdFI/X+MaFchO40AQCRzM3L3/fpGvnA1yV 5BYBV+P3y2I0E0Xcy5poOpQeguorqJW+bF4Z3AdHb37m0pYFB+XYuJIWeLoWY/t2SCEY QWRQ== X-Gm-Message-State: AOAM533O2Cq7tp+6sXedK5hgCfMmrYYRDA2BX0m2ZJiAH250AYg5IYQP NsFazljEjmN9qQ894xa3ZEI= X-Google-Smtp-Source: ABdhPJzW3IkNZoDdc/BOxTkma8VNnnhslQRkNi+B8JWEvOJx88gT6NPVZcuQ6DRdIkxKs0aAQEhUvg== X-Received: by 2002:a17:902:7088:b0:156:1aa9:79eb with SMTP id z8-20020a170902708800b001561aa979ebmr677193plk.71.1650565710635; Thu, 21 Apr 2022 11:28:30 -0700 (PDT) Received: from mail.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id s62-20020a635e41000000b003a9eb7f65absm6509333pgb.85.2022.04.21.11.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 11:28:30 -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 3/5] mmc: sdhci-brcmstb: Enable Clock Gating to save power Date: Thu, 21 Apr 2022 14:28:01 -0400 Message-Id: <20220421182803.6495-4-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220421182803.6495-1-kdasu.kdev@gmail.com> References: <20220421182803.6495-1-kdasu.kdev@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220421_112833_484258_248B491B X-CRM114-Status: GOOD ( 19.41 ) 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 From: Al Cooper Enabling this feature will allow the controller to stop the bus clock when the bus is idle. The feature is not part of the standard and is unique to newer Arasan cores and is enabled with a bit in a vendor specific register. This feature will only be enabled for non-removable devices because they don't switch the voltage and clock gating breaks SD Card volatge switching. Signed-off-by: Al Cooper Signed-off-by: Kamal Dasu Acked-by: Florian Fainelli Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-brcmstb.c | 35 +++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index f32aa045c26d..d5cb3e8978b2 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -17,11 +17,14 @@ #define SDHCI_VENDOR 0x78 #define SDHCI_VENDOR_ENHANCED_STRB 0x1 +#define SDHCI_VENDOR_GATE_SDCLK_EN 0x2 #define BRCMSTB_MATCH_FLAGS_NO_64BIT BIT(0) #define BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT BIT(1) +#define BRCMSTB_MATCH_FLAGS_HAS_CLOCK_GATE BIT(2) #define BRCMSTB_PRIV_FLAGS_HAS_CQE BIT(0) +#define BRCMSTB_PRIV_FLAGS_GATE_CLOCK BIT(1) #define SDHCI_ARASAN_CQE_BASE_ADDR 0x200 @@ -36,6 +39,27 @@ struct brcmstb_match_priv { const unsigned int flags; }; +static inline void enable_clock_gating(struct sdhci_host *host) +{ + u32 reg; + + reg = sdhci_readl(host, SDHCI_VENDOR); + reg |= SDHCI_VENDOR_GATE_SDCLK_EN; + sdhci_writel(host, reg, SDHCI_VENDOR); +} + +void brcmstb_reset(struct sdhci_host *host, u8 mask) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_brcmstb_priv *priv = sdhci_pltfm_priv(pltfm_host); + + sdhci_reset(host, mask); + + /* Reset will clear this, so re-enable it */ + if (priv->flags & BRCMSTB_PRIV_FLAGS_GATE_CLOCK) + enable_clock_gating(host); +} + static void sdhci_brcmstb_hs400es(struct mmc_host *mmc, struct mmc_ios *ios) { struct sdhci_host *host = mmc_priv(mmc); @@ -131,7 +155,7 @@ static struct sdhci_ops sdhci_brcmstb_ops = { static struct sdhci_ops sdhci_brcmstb_ops_7216 = { .set_clock = sdhci_brcmstb_set_clock, .set_bus_width = sdhci_set_bus_width, - .reset = sdhci_reset, + .reset = brcmstb_reset, .set_uhs_signaling = sdhci_brcmstb_set_uhs_signaling, }; @@ -147,6 +171,7 @@ static struct brcmstb_match_priv match_priv_7445 = { }; static const struct brcmstb_match_priv match_priv_7216 = { + .flags = BRCMSTB_MATCH_FLAGS_HAS_CLOCK_GATE, .hs400es = sdhci_brcmstb_hs400es, .ops = &sdhci_brcmstb_ops_7216, }; @@ -273,6 +298,14 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) if (res) goto err; + /* + * Automatic clock gating does not work for SD cards that may + * voltage switch so only enable it for non-removable devices. + */ + if ((match_priv->flags & BRCMSTB_MATCH_FLAGS_HAS_CLOCK_GATE) && + (host->mmc->caps & MMC_CAP_NONREMOVABLE)) + priv->flags |= BRCMSTB_PRIV_FLAGS_GATE_CLOCK; + /* * If the chip has enhanced strobe and it's enabled, add * callback From patchwork Thu Apr 21 18:28:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 12822210 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 376FEC433EF for ; Thu, 21 Apr 2022 18:30:01 +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:References:In-Reply-To: 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: List-Owner; bh=KP3jdrmFEF5gbbT+aPHwuNtNvHEqcaZsV05ZouCXI+4=; b=A8McUP53YxXci0 +yZN/D6HXCUmfe6Eovm2fhiVtcBG2nQVcQmMV9fFYgnj86Vno9+WoZ4Hhxqm/g8fbrZB/Gz/EHCIY kMoyN5ftzKmxs2WbVxgcgzOH3S5zwnHMUSeFJyspx+809XXEj0Nh9AOwvygfB4CnREw2xl/Nd7Ja2 ziFYVdLAp8MGTfBRNW4BMkLAzdDRy/7x5+VcBYlODhCPWRynP4en1HJUZhhQwMXSfd2EV6jgGXIBM zeBz5m3L/crKxx8NH3n9R4OPNPXnsQQUeB6OMnS5B6QvvL9QJFFRZt4R/5J7noV+9pnpZLVv0J+gQ asMVajVVB32g4bo63RLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhbXx-00EdXI-S2; Thu, 21 Apr 2022 18:28:53 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhbXg-00EdPp-4S for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 18:28:37 +0000 Received: by mail-pf1-x42f.google.com with SMTP id l127so5764858pfl.6 for ; Thu, 21 Apr 2022 11:28:34 -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:in-reply-to:references; bh=DL6DI5feuJoMlU44P61YM6Wgo//JlAhCvPdBp3CmZdI=; b=qzaGT9qBstujuIErvgj5N/ijlSkXXKv1dd4yHvyPK5vMRZDLH0sQ4QgkfVIJHZqDSh ulxtbFjtU3b6rQVgtH7v6XRVBICdlTWzpSXYoUfDYLo69d1BzrIptOjfsx0aH8NANPbI UnBBTN/1kY+lmSccneUBAaxPSeeXV7QnvEggxiOiGWl4YMblpvIhhRkpGe0TKQ5/e+fA zLHDC2YOI9nK8AQZuBZndvGpt1hq29+wfpJWQ0oRkGCJ4cbjqU7U6Q82y0FkjBT4IZgX XKieTOg/lz4RPntmdRdEZrMs8VMvTMJgML4B4nCNhwpL1BY+nVx8eZqMaR/AWe72y0y6 8v5g== 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:in-reply-to :references; bh=DL6DI5feuJoMlU44P61YM6Wgo//JlAhCvPdBp3CmZdI=; b=T/rJJeA5ZQjTbMOutX8XQA+55a3YEz/Qfem2gqsyEvCpk3HK4UfcBR5EWIODTF4azS GsNagyVD9tE4CaU99E/8Wg4vy9Wyec6U5QW7xvkLgjK0QJPCxSOP4o9XQEgPxzNevF4F fhxdqGdFku4yOdbvw6984l5wj/6qwm45l1bwVFXH4Y79cRqR7v9KQGliDEMGeeKiDiEe HpsdTXkiffNjfjrCCWS//1ZXw/mWdk6U1y8I7rWrAxRbiW7s7eh6yP3DtvRjJH6d1TSM BxvwbK+HmVKt65IPIZs1eHhMHyIeM6vWoOq4a0ExR9ND9UVL47AtW44SGLWZ15//aRUJ 7lRw== X-Gm-Message-State: AOAM531kx8cJm01M0218q1y4hGZss4Ax3Yt/LWQ/Muhb5kAKlxBJ12bb 4I8+3yXEXVSPEYnVa3L+2Sc= X-Google-Smtp-Source: ABdhPJyoK0byw8pr/pHJ1F1wx9N4DUcklZjDJIgldLfZhneMCmESqNGOx0SWSjlONpCtT3CGqKFTag== X-Received: by 2002:a05:6a00:198c:b0:505:c18b:3184 with SMTP id d12-20020a056a00198c00b00505c18b3184mr795725pfl.82.1650565713816; Thu, 21 Apr 2022 11:28:33 -0700 (PDT) Received: from mail.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id s62-20020a635e41000000b003a9eb7f65absm6509333pgb.85.2022.04.21.11.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 11:28:33 -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 4/5] dt-bindings: mmc: Add Broadcom optional sdio_freq clock Date: Thu, 21 Apr 2022 14:28:02 -0400 Message-Id: <20220421182803.6495-5-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220421182803.6495-1-kdasu.kdev@gmail.com> References: <20220421182803.6495-1-kdasu.kdev@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220421_112836_197827_06E86A3D X-CRM114-Status: GOOD ( 12.23 ) 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 The 72116B0 has improved SDIO controllers that allow the max clock rate to be increased from a max of 100MHz to a max of 150MHz. Optional "sdio_freq" clock is used to drive the bus clock if present optional property "clock-frequency" specifies a base clock frequency in Hz that overrides the base clock frequency in the CAPS registers. Signed-off-by: Kamal Dasu --- .../bindings/mmc/brcm,sdhci-brcmstb.yaml | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml b/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml index dccd5ad96981..1b45a918400a 100644 --- a/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +++ b/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml @@ -10,8 +10,6 @@ maintainers: - Al Cooper - Florian Fainelli -allOf: - - $ref: mmc-controller.yaml# properties: compatible: @@ -42,23 +40,44 @@ properties: maxItems: 1 clocks: - maxItems: 1 - description: - handle to core clock for the sdhci controller. + minItems: 1 + items: + - description: handle to core clock for the sdhci controller + - description: improved 150Mhz clock for sdhci controller (Optional clock) clock-names: + minItems: 1 items: - const: sw_sdio + - const: sdio_freq # Optional clock + + clock-frequency: + description: Should be the frequency (in Hz) of the base controller clock + minimum: 400000 + maximum: 150000000 sdhci,auto-cmd12: type: boolean description: Specifies that controller should use auto CMD12 +allOf: + - $ref: mmc-controller.yaml# + - if: + properties: + clock-names: + contains: + const: sdio_freq + + - then: + required: + - clock-frequency + required: - compatible - reg - interrupts - clocks + - clock-names unevaluatedProperties: false From patchwork Thu Apr 21 18:28:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 12822211 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 A6A15C433EF for ; Thu, 21 Apr 2022 18:30:06 +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:References:In-Reply-To: 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: List-Owner; bh=F+IclGhXD57oJU18vZMU/dXddWpzAxAQNwHhXQW93pk=; b=oh26n4DvReUD5Y MyIM3jW5QLhG5lNqV35jUIU9NH8JAM70XJFXzzTqunv/8eoXvhjA6Yx1mHQwet0tsMkN459gWuwPF IsNtz7YgYzVTeKiEEdMUR1at9gvZmweZqndEQW3n3rBqFhhavFWnwWyIz0sGEPuyPdt0UG99TG31o jBVIVO11non9d2/Bu9dz5lJxJ59/Y19fD4q+XrSV+BoHeFcS6AmwBgUyz0OIPjNItawCzVgod+w8q JdLl9qXmpzPmCqWi8YdHMbijkqBmkeKVXag4Le2giALge+U3OISuSdTAQUpqyGyZIE4M8G3VUAUKV 7odVcq2SDQH7S7KFq0uQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhbY9-00EdbA-7S; Thu, 21 Apr 2022 18:29:05 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhbXk-00EdR3-1i for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 18:28:41 +0000 Received: by mail-pj1-x1033.google.com with SMTP id m14-20020a17090a34ce00b001d5fe250e23so2641097pjf.3 for ; Thu, 21 Apr 2022 11:28:37 -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:in-reply-to:references; bh=6OnAIDQW3sc6araWzxfXt0/VxstxyDY8VarbwsPQALo=; b=TQsRMtP/nSoIfo8v8k0aiH9q97snuI0PxxN5VKekSM2GFL72T/D0BDKZvEoBRavUYu wXViadj4adwf984bBzbx0G4uuPFE4cEgvXuE4+MsarKST9kZepjHx9/92lZMxB7CYbQr n0Lx0dlZ8RDj0ucYY1y9F2iQyxF77+rCOqrst9qhH0FOVOeYxgSPonURzmHmle5ygMC1 shpGNIkYIJ4T57hbmIe/RuU34qdHEM+7Ak0POFsvRgLgBt6MAMiYDQuO6s/vc0LBAHX/ 44/QUBxEUGrJuGIodbhPoC9EKfFDNisiU/Q/CBa7+Hqzc+qU138K8vcU7wkninyIUibX nvUw== 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:in-reply-to :references; bh=6OnAIDQW3sc6araWzxfXt0/VxstxyDY8VarbwsPQALo=; b=WlrBTJ41T6oYqRa3xS9dExJ6L4Y/Q11zW7E4hFi2fmM0juWPdGwcoPVKr8ZY1Brcg3 MtvgU2mqUQNUQAqeJQpDzqij+5d/SYcS0PnwcfSA++kD5qxczfKv9YQ35tV4dbxqFB4U ih6ga2iT4fAqJnLKGGABf5aC86tcPJIJJMAUkqLKAjMx3SiUiiI3YsrIJkz6iY8SIl9O pAgROXiiSUZUWdzCbIvD6MB7OfHkKdNR2iXQUHNLMhlRii+JxG901RInpyycabhcSQeA 0feFSmHwL63S6QD7bbM+v+v7iIUW3OAddFU30ObUsJwXzO3ecomz888LhRlawxzDLpW5 mBww== X-Gm-Message-State: AOAM533K6IF73JrH72lRVnb7SWfQyzEfP6lWPSQuE1mvoIGjfEBr43iS oUMVinIIi/3KdJJBJ5Xz17gfuklaOLU= X-Google-Smtp-Source: ABdhPJwFGCkoraljSmR3iJJhYP4RZC535JY3Pskc//6GndiqXEWP5+mUzddU84uzLixZxyedNBzL+w== X-Received: by 2002:a17:90b:1b01:b0:1d2:ef4a:98e1 with SMTP id nu1-20020a17090b1b0100b001d2ef4a98e1mr977058pjb.163.1650565717227; Thu, 21 Apr 2022 11:28:37 -0700 (PDT) Received: from mail.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id s62-20020a635e41000000b003a9eb7f65absm6509333pgb.85.2022.04.21.11.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 11:28:36 -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 5/5] mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0 Date: Thu, 21 Apr 2022 14:28:03 -0400 Message-Id: <20220421182803.6495-6-kdasu.kdev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220421182803.6495-1-kdasu.kdev@gmail.com> References: <20220421182803.6495-1-kdasu.kdev@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220421_112840_136220_5484BB93 X-CRM114-Status: GOOD ( 17.33 ) 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 From: Al Cooper The 72116B0 has improved SDIO controllers that allow the max clock rate to be increased from a max of 100MHz to a max of 150MHz. The driver will need to get the clock and increase it's default rate and override the caps register, that still indicates a max of 100MHz. The new clock will be named "sdio_freq" in the DT node's "clock-names" list. The driver will use a DT property, "clock-frequency", to enable this functionality and will get the actual rate in MHz from the property to allow various speeds to be requested. Signed-off-by: Al Cooper Signed-off-by: Kamal Dasu --- drivers/mmc/host/sdhci-brcmstb.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index d5cb3e8978b2..4f3629a8e70a 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -250,6 +250,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) struct sdhci_pltfm_host *pltfm_host; const struct of_device_id *match; struct sdhci_brcmstb_priv *priv; + uint32_t base_clock_hz = 0; struct sdhci_host *host; struct resource *iomem; struct clk *clk; @@ -330,6 +331,30 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) if (match_priv->flags & BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT) host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; + /* Change the base clock frequency if the DT property exists */ + if (device_property_read_u32(&pdev->dev, "clock-frequency", + &base_clock_hz) == 0) { + struct clk *master_clk; + u32 actual_clock_mhz; + + master_clk = devm_clk_get(&pdev->dev, "sdio_freq"); + if (IS_ERR(master_clk)) { + dev_warn(&pdev->dev, + "Clock for \"sdio_freq\" was not found\n"); + } else { + clk_set_rate(master_clk, base_clock_hz); + actual_clock_mhz = clk_get_rate(master_clk) / 1000000; + + host->caps &= ~SDHCI_CLOCK_V3_BASE_MASK; + host->caps |= + (actual_clock_mhz << SDHCI_CLOCK_BASE_SHIFT); + /* Disable presets because they are now incorrect */ + host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN; + dev_dbg(&pdev->dev, + "Base Clock Frequency changed to %dMHz\n", + actual_clock_mhz); + } + } res = sdhci_brcmstb_add_host(host, priv); if (res) goto err;