mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ludovic Desroches <ludovic.desroches@atmel.com>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ludovic Desroches <ludovic.desroches@atmel.com>,
	<ulf.hansson@linaro.org>, <linux-mmc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <nicolas.ferre@atmel.com>
Subject: Re: [PATCH] mmc: sdhci-of-at91: add presets setup
Date: Thu, 28 Apr 2016 14:23:19 +0200	[thread overview]
Message-ID: <20160428122319.GB3891@odux.rfo.atmel.com> (raw)
In-Reply-To: <5721CAB2.5000207@intel.com>

On Thu, Apr 28, 2016 at 11:32:50AM +0300, Adrian Hunter wrote:
> On 21/04/16 16:54, Ludovic Desroches wrote:
> > The controller claims to support SDR104. In fact, it only supports a
> > degraded SDR104 since the maximum frequency of the SD clock is 120 MHz
> > instead of 208 MHz.
> > The sdhci core is unaware of it and will compute a wrong clock divider.
> > We can deal with this specific case by using presets.
> > 
> > Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> > ---
> >  drivers/mmc/host/sdhci-of-at91.c | 24 ++++++++++++++++++++++++
> >  1 file changed, 24 insertions(+)
> > 
> > diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
> > index c1923c0..76308b1 100644
> > --- a/drivers/mmc/host/sdhci-of-at91.c
> > +++ b/drivers/mmc/host/sdhci-of-at91.c
> > @@ -18,6 +18,7 @@
> >  #include <linux/delay.h>
> >  #include <linux/err.h>
> >  #include <linux/io.h>
> > +#include <linux/kernel.h>
> >  #include <linux/mmc/host.h>
> >  #include <linux/mmc/slot-gpio.h>
> >  #include <linux/module.h>
> > @@ -163,6 +164,7 @@ static int sdhci_at91_probe(struct platform_device *pdev)
> >  	unsigned int			clk_base, clk_mul;
> >  	unsigned int			gck_rate, real_gck_rate;
> >  	int				ret;
> > +	unsigned int			preset_div, preset_common = 0x400; /* drv type B, programmable clock mode */
> 
> preset_common is a constant, so why not #define it?

No reason, a mistake, I'll fix it.

> 
> >  
> >  	match = of_match_device(sdhci_at91_dt_match, &pdev->dev);
> >  	if (!match)
> > @@ -230,6 +232,28 @@ static int sdhci_at91_probe(struct platform_device *pdev)
> >  			 clk_mul, real_gck_rate);
> >  	}
> >  
> > +	/*
> > +	 * We have to set preset values because it depends on the clk_mul
> > +	 * value. Moreover, SDR104 is supported in a degraded mode since the
> > +	 * maximum sd clock value is 120 MHz instead of 208 MHz. For that
> > +	 * reason, we need to use presets to support SDR104.
> > +	 */
> > +	preset_div = DIV_ROUND_UP(real_gck_rate, 24000000) - 1;
> > +	writew(preset_common | preset_div,
> > +	       host->ioaddr + SDHCI_PRESET_FOR_SDR12);
> > +	preset_div = DIV_ROUND_UP(real_gck_rate, 50000000) - 1;
> > +	writew(preset_common | preset_div,
> > +	       host->ioaddr + SDHCI_PRESET_FOR_SDR25);
> > +	preset_div = DIV_ROUND_UP(real_gck_rate, 100000000) - 1;
> > +	writew(preset_common | preset_div,
> > +	       host->ioaddr + SDHCI_PRESET_FOR_SDR50);
> > +	preset_div = DIV_ROUND_UP(real_gck_rate, 120000000) - 1;
> > +	writew(preset_common | preset_div,
> > +	       host->ioaddr + SDHCI_PRESET_FOR_SDR104);
> > +	preset_div = DIV_ROUND_UP(real_gck_rate, 50000000) - 1;
> > +	writew(preset_common | preset_div,
> > +	       host->ioaddr + SDHCI_PRESET_FOR_DDR50);
> > +
> >  	clk_prepare_enable(priv->mainck);
> >  	clk_prepare_enable(priv->gck);
> >  
> > 
> 

      reply	other threads:[~2016-04-28 12:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21 13:54 Ludovic Desroches
2016-04-28  8:32 ` Adrian Hunter
2016-04-28 12:23   ` Ludovic Desroches [this message]

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=20160428122319.GB3891@odux.rfo.atmel.com \
    --to=ludovic.desroches@atmel.com \
    --cc=adrian.hunter@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    --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

all inboxes | Powered by JetHome®