From: Mike Turquette <mturquette@linaro.org>
To: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, srinivas.kandagatla@gmail.com,
maxime.coquelin@st.com, patrice.chotard@st.com,
sboyd@codeaurora.org, chris@printf.net, ulf.hansson@linaro.org
Cc: peter.griffin@linaro.org, lee.jones@linaro.org,
peppe.cavallaro@st.com, olivier.bideau@st.com,
gabriel.fernandez@st.com, linux-mmc@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH 1/4] clk: st: STiH410: Fix pdiv and fdiv divisor when setting rate
Date: Tue, 20 Jan 2015 09:37:55 -0800 [thread overview]
Message-ID: <20150120173755.22722.80361@quantum> (raw)
In-Reply-To: <1421767964-8798-2-git-send-email-peter.griffin@linaro.org>
Quoting Peter Griffin (2015-01-20 07:32:41)
> Debugging eMMC on upstream kernels it has been noticed that when the
> targetpack configures MMC0 clock to 200Mhz (required to switch to
> HS200) then everything works OK. However if the kernel sets the
> clock rate using clk_set_rate, then the eMMC card initialisation
> fails with timeouts. Lower clock speeds (the default being 50Mhz)
> work ok, but they we fail to get good eMMC transfer rates.
>
> Looking through the vendor kernel clock driver reveals Giuseppe
> had already fixed this issue, but the patch hasn't made its way
> upstream.
>
> The issue is fixed by changing the logic to manage the pdiv and
> fdiv divisors used for setting the rate inside the flexgen driver code.
>
> Pdiv is mainly targeted for low freq results, while fdiv should be
> used for divs =< 64. The other way can lead to 'duty cycle'
> issues.
>
> I have changed the original patch to keep the original behaviour
> in cases where the div is >64 which matches the original comment
> and patch description more closely. Although no clocks appear to hit
> this case currently when booting an upstream kernel.
>
> Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Applied to clk-next.
Regards,
Mike
> ---
> drivers/clk/st/clk-flexgen.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/clk/st/clk-flexgen.c b/drivers/clk/st/clk-flexgen.c
> index 2282cef..3a484b3 100644
> --- a/drivers/clk/st/clk-flexgen.c
> +++ b/drivers/clk/st/clk-flexgen.c
> @@ -138,16 +138,27 @@ static int flexgen_set_rate(struct clk_hw *hw, unsigned long rate,
> struct flexgen *flexgen = to_flexgen(hw);
> struct clk_hw *pdiv_hw = &flexgen->pdiv.hw;
> struct clk_hw *fdiv_hw = &flexgen->fdiv.hw;
> - unsigned long primary_div = 0;
> + unsigned long div = 0;
> int ret = 0;
>
> pdiv_hw->clk = hw->clk;
> fdiv_hw->clk = hw->clk;
>
> - primary_div = clk_best_div(parent_rate, rate);
> + div = clk_best_div(parent_rate, rate);
>
> - clk_divider_ops.set_rate(fdiv_hw, parent_rate, parent_rate);
> - ret = clk_divider_ops.set_rate(pdiv_hw, rate, rate * primary_div);
> + /*
> + * pdiv is mainly targeted for low freq results, while fdiv
> + * should be used for div <= 64. The other way round can
> + * lead to 'duty cycle' issues.
> + */
> +
> + if (div <= 64) {
> + clk_divider_ops.set_rate(pdiv_hw, parent_rate, parent_rate);
> + ret = clk_divider_ops.set_rate(fdiv_hw, rate, rate * div);
> + } else {
> + clk_divider_ops.set_rate(fdiv_hw, parent_rate, parent_rate);
> + ret = clk_divider_ops.set_rate(pdiv_hw, rate, rate * div);
> + }
>
> return ret;
> }
> --
> 1.9.1
>
next prev parent reply other threads:[~2015-01-20 17:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-20 15:32 [PATCH 0/4] Add sd/emmc support for stih407 family silicon Peter Griffin
[not found] ` <1421767964-8798-1-git-send-email-peter.griffin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-01-20 15:32 ` [PATCH 1/4] clk: st: STiH410: Fix pdiv and fdiv divisor when setting rate Peter Griffin
2015-01-20 17:37 ` Mike Turquette [this message]
2015-01-20 15:32 ` [PATCH 2/4] sdhci-st: Add support for stih407 family silicon Peter Griffin
2015-01-21 10:26 ` Ulf Hansson
2015-01-20 15:32 ` [PATCH 3/4] mmc: sdhci-st: Update ST SDHCI binding documentation Peter Griffin
2015-01-20 15:32 ` [PATCH 4/4] ARM: STi: DT: STiH407: Add dt nodes for sdhci and emmc Peter Griffin
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=20150120173755.22722.80361@quantum \
--to=mturquette@linaro.org \
--cc=chris@printf.net \
--cc=devicetree@vger.kernel.org \
--cc=gabriel.fernandez@st.com \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=maxime.coquelin@st.com \
--cc=olivier.bideau@st.com \
--cc=patrice.chotard@st.com \
--cc=peppe.cavallaro@st.com \
--cc=peter.griffin@linaro.org \
--cc=sboyd@codeaurora.org \
--cc=srinivas.kandagatla@gmail.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;
as well as URLs for NNTP newsgroup(s).