public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: Magnus Damm <magnus.damm@gmail.com>
Cc: Chris Ball <cjb@laptop.org>,
	Yusuke Goda <yusuke.goda.sx@renesas.com>,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	linux-mmc@vger.kernel.org, Paul Mundt <lethal@linux-sh.org>,
	Cao Minh Hiep <hiepcm@gmail.com>
Subject: Re: [PATCH 2/2] mmc: sh_mmcif: mmc->f_max should be half of the bus clock
Date: Tue, 27 Mar 2012 16:12:37 +0900	[thread overview]
Message-ID: <20120327071233.GA23003@verge.net.au> (raw)
In-Reply-To: <CANqRtoRE_gWqCOBxPKW39MRY=QPvhKQG6rVz=LreYt0BcP8FPg@mail.gmail.com>

Hi Magnus,

On Tue, Mar 27, 2012 at 03:37:42PM +0900, Magnus Damm wrote:
> Hi Simon,
> 
> On Tue, Mar 27, 2012 at 3:01 PM, Simon Horman <horms@verge.net.au> wrote:
> > On Tue, Mar 27, 2012 at 01:02:38PM +0900, Magnus Damm wrote:

[snip]

> >> Anyway, I was mainly wondering about the setup of the clocks in the
> >> driver for the MMC host hardware. I got the impression that f_min and
> >> f_max are supposed to be used to point out the minimum and maximum
> >> allowed frequencies that the hardware supports. On our SoCs this
> >> depends on the rate of the parent clock and the number of bits used
> >> for the MMC host hardware divider.
> >>
> >> So the parent clock rate may be rather high, and if it happens to be
> >> set too high on a board level then the MMC hardware block won't be
> >> able to program the frequencies as low as 400 kHz. So my point is only
> >> that we need to make sure that the parent clock rate is set in such a
> >> way that we can have some at least half-high clock frequency for
> >> decent general purpose throughput but if we try to increase the clock
> >> rate too much then we may force the lowest clock rate to go above 400
> >> kHz and then I suspect we may be out of spec. All this is based on
> >> that the parent clock is set statically to some frequency during boot
> >> by the SoC or board code.
> >
> > The current code assumes that the maximum divisor is 512.
> 
> That's good!
> 
> > This may lead to f_min being greater than 400Hz if the parent
> > clock is greater than 200MHz. It seems to me that empirically this
> > has not being occurring else the WARN_ON() in __mmc_set_clock() would
> > be activated. Though perhaps no one notices it.
> 
> Sure, 400 kHz * 512 = 204.8 MHz.
> 
> The reason why we don't hit WARN_ON() may be that mmc_power_up()
> blindly sets host->ios.clock to 400 kHz, 200 kHz and so on - this
> without checking against f_min.
> 
> > In any case, in the context of the current code it seems that changing
> > sh_mmcif_probe() to set f_min to host->clk / 512 will not alter the current
> > behaviour and will simplify the code.
> 
> Yep. It seems to me (only checked sh7372 data sheet) that f_min and
> f_max should be set like this:
> 
> f_min = parent_clk / 512
> f_max = parent_clk / 2
> 
> The real question is in my opinion is how to select a good parent
> clock rate, but that's sort of out of scope here.

Agreed on all counts. I will refresh my outstanding patch series
to set f_min accordingly, the series already sets f_max as you describe.

      reply	other threads:[~2012-03-27  7:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-21  9:02 [PATCH 0/2] MMCIF Clock Fixes Simon Horman
2012-03-21  9:02 ` [PATCH 1/2] mmc: sh_mmcif: double clock speed Simon Horman
2012-03-24 17:56   ` Guennadi Liakhovetski
2012-03-26  2:21     ` Simon Horman
2012-03-21  9:02 ` [PATCH 2/2] mmc: sh_mmcif: mmc->f_max should be half of the bus clock Simon Horman
2012-03-24 18:06   ` Guennadi Liakhovetski
     [not found]     ` <20120325223033.GA6860@verge.net.au>
2012-03-26  5:45       ` Yusuke Goda
2012-03-26  5:52         ` Simon Horman
2012-03-26  6:04           ` Yusuke Goda
2012-03-26  6:17           ` Magnus Damm
2012-03-26  7:04             ` Guennadi Liakhovetski
2012-03-27  7:53               ` Guennadi Liakhovetski
2012-03-27  8:14                 ` Simon Horman
2012-03-27  1:43             ` Simon Horman
2012-03-27  2:46               ` Magnus Damm
2012-03-27  3:20                 ` Chris Ball
2012-03-27  4:02                   ` Magnus Damm
2012-03-27  6:01                     ` Simon Horman
2012-03-27  6:37                       ` Magnus Damm
2012-03-27  7:12                         ` Simon Horman [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=20120327071233.GA23003@verge.net.au \
    --to=horms@verge.net.au \
    --cc=cjb@laptop.org \
    --cc=g.liakhovetski@gmx.de \
    --cc=hiepcm@gmail.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=yusuke.goda.sx@renesas.com \
    /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