devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Kamal Dasu <kdasu.kdev@gmail.com>,
	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,
	linux-mmc@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 3/5] mmc: sdhci-brcmstb: Enable Clock Gating to save power
Date: Wed, 27 Apr 2022 09:44:32 +0300	[thread overview]
Message-ID: <af7d438f-914b-e93c-5dd4-b046156d7e2e@intel.com> (raw)
In-Reply-To: <20220421182803.6495-4-kdasu.kdev@gmail.com>

On 21/04/22 21:28, Kamal Dasu wrote:
> From: Al Cooper <alcooperx@gmail.com>
> 
> 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 <alcooperx@gmail.com>
> Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  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


  parent reply	other threads:[~2022-04-27  6:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 18:27 [PATCH 0/5] mmc: sdhci-brcmstb: host controller clock enhancements Kamal Dasu
2022-04-21 18:27 ` [PATCH 1/5] mmc: sdhci-brcmstb: "mmc1: Internal clock never stabilised." seen on 72113 Kamal Dasu
2022-04-22 17:14   ` Florian Fainelli
2022-04-27  4:41   ` Adrian Hunter
2022-04-21 18:28 ` [PATCH 2/5] mmc: sdhci-brcmstb: Re-organize flags Kamal Dasu
2022-04-22 17:14   ` Florian Fainelli
2022-04-27  6:43   ` Adrian Hunter
2022-04-21 18:28 ` [PATCH 3/5] mmc: sdhci-brcmstb: Enable Clock Gating to save power Kamal Dasu
2022-04-22 17:14   ` Florian Fainelli
2022-04-27  6:44   ` Adrian Hunter [this message]
2022-04-21 18:28 ` [PATCH 4/5] dt-bindings: mmc: Add Broadcom optional sdio_freq clock Kamal Dasu
2022-04-22 17:07   ` Krzysztof Kozlowski
2022-04-27 15:40     ` Kamal Dasu
2022-04-21 18:28 ` [PATCH 5/5] mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0 Kamal Dasu
2022-04-27  6:45   ` Adrian Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=af7d438f-914b-e93c-5dd4-b046156d7e2e@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=alcooperx@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=kdasu.kdev@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).