From: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Ulf Hansson <ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: "Chris Ball" <chris-OsFVWbfNK3isTnJN9+BGXg@public.gmane.org>,
"Maxime Ripard"
<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
"David Lanzendörfer"
<david.lanzendoerfer-Z7Kmv9EsliU@public.gmane.org>,
linux-mmc <linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
devicetree <devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
"Mike Turquette"
<mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH v12 1/6] ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs
Date: Mon, 12 May 2014 13:40:02 +0200 [thread overview]
Message-ID: <5370B312.2040409@redhat.com> (raw)
In-Reply-To: <CAPDyKFqTT17L23iiF2oXj+bmJruT8_qQBecXbR9iCUKo++KDgQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Hi,
On 05/12/2014 01:34 PM, Ulf Hansson wrote:
> On 12 May 2014 13:20, Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
>> Hi,
>>
>> On 05/12/2014 11:15 AM, Ulf Hansson wrote:
>>> On 11 May 2014 09:46, Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
>>>> From: David Lanzendörfer <david.lanzendoerfer-Z7Kmv9EsliU@public.gmane.org>
>>>>
>>>> The Allwinner sunxi mmc host uses dma in bus-master mode using a built-in
>>>> designware idmac controller, which is identical to the one found in the mmc-dw
>>>> hosts. However the rest of the host is not identical to mmc-dw, it deals with
>>>> sending stop commands in hardware which makes it significantly different
>>>> from the mmc-dw devices.
>>>>
>>>> HdG: Various cleanups and fixes.
>>>>
>>>> Signed-off-by: David Lanzendörfer <david.lanzendoerfer-Z7Kmv9EsliU@public.gmane.org>
>>>> Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>>>
>>> [snip]
>>>
>>>> +
>>>> +static int sunxi_mmc_clk_set_rate(struct sunxi_mmc_host *host,
>>>> + struct mmc_ios *ios)
>>>> +{
>>>> + u32 rate, oclk_dly, rval, sclk_dly, src_clk;
>>>> + struct clk_hw *hw = __clk_get_hw(host->clk_mmc);
>>>
>>> Hi Hans,
>>>
>>> This seems like the wrong approach. But I guess it's related to the
>>> "clock phase control" API you have been discussing with the clk
>>> maintainer, Mike Turquette!?
>>
>> Yes, this is meant as a temporary solution until we get a proper
>> "clock phase control" API.
>>
>>>
>>> __clk_get_hw is supposed to be used by clk providers, not clk consumers.
>>>
>>>> + int ret;
>>>> +
>>>> + rate = clk_round_rate(host->clk_mmc, ios->clock);
>>>> + dev_dbg(mmc_dev(host->mmc), "setting clk to %d, rounded %d\n",
>>>> + ios->clock, rate);
>>>> +
>>>> + /* setting clock rate */
>>>> + ret = clk_set_rate(host->clk_mmc, rate);
>>>> + if (ret) {
>>>> + dev_err(mmc_dev(host->mmc), "error setting clk to %d: %d\n",
>>>> + rate, ret);
>>>> + return ret;
>>>> + }
>>>> +
>>>> + ret = sunxi_mmc_oclk_onoff(host, 0);
>>>> + if (ret)
>>>> + return ret;
>>>> +
>>>> + /* clear internal divider */
>>>> + rval = mmc_readl(host, REG_CLKCR);
>>>> + rval &= ~0xff;
>>>> + mmc_writel(host, REG_CLKCR, rval);
>>>> +
>>>> + /* determine delays */
>>>> + if (rate <= 400000) {
>>>> + oclk_dly = 0;
>>>> + sclk_dly = 7;
>>>> + } else if (rate <= 25000000) {
>>>> + oclk_dly = 0;
>>>> + sclk_dly = 5;
>>>> + } else if (rate <= 50000000) {
>>>> + if (ios->timing == MMC_TIMING_UHS_DDR50) {
>>>> + oclk_dly = 2;
>>>> + sclk_dly = 4;
>>>> + } else {
>>>> + oclk_dly = 3;
>>>> + sclk_dly = 5;
>>>> + }
>>>> + } else {
>>>> + /* rate > 50000000 */
>>>> + oclk_dly = 2;
>>>> + sclk_dly = 4;
>>>> + }
>>>> +
>>>> + src_clk = clk_get_rate(clk_get_parent(host->clk_mmc));
>>>> + if (src_clk >= 300000000 && src_clk <= 400000000) {
>>>> + if (oclk_dly)
>>>> + oclk_dly--;
>>>> + if (sclk_dly)
>>>> + sclk_dly--;
>>>> + }
>>>> +
>>>> + clk_sunxi_mmc_phase_control(hw, sclk_dly, oclk_dly);
>>>> +
>>>> + return sunxi_mmc_oclk_onoff(host, 1);
>>>> +}
>>>> +
>>>
>>> [snip]
>>>
>>> Besides the above, I think this looks good!
>>
>> Thanks!
>>
>> Since Mike Turquette has already merged clk_sunxi_mmc_phase_control
>> I would like to keep this as is, as I already promised Mike, I can
>> safely promise you too: I promise clean this up as soon as the
>> "clock phase control" API has been worked out.
>
> Thanks for promise. :-)
>
> Anyway, I think I would like Mike to confirm this violation is
> accepted as a temporary solution. Additionally I would like it to be
> commented in the code here, that it's a temporary solution and that it
> violates the clk API.
Thinking more about this the __clk_get_hw call really should have
been inside the clk_sunxi_mmc_phase_control function. I'll do a followup
patch for Mike / the clk tree to fix this, and do a v13 of the
sunxi-mmc driver using the updated version.
Regards,
Hans
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
next prev parent reply other threads:[~2014-05-12 11:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-11 7:46 [PATCH v12 0/6] ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs Hans de Goede
[not found] ` <1399794417-9291-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-05-11 7:46 ` [PATCH v12 1/6] " Hans de Goede
[not found] ` <1399794417-9291-2-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-05-12 9:15 ` Ulf Hansson
[not found] ` <CAPDyKFrYeBdB20qhmkcUf5ykw=SbBo6VUPXd=By9dNOvTnvFww-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-12 11:20 ` Hans de Goede
[not found] ` <5370AE98.9050808-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-05-12 11:34 ` Ulf Hansson
[not found] ` <CAPDyKFqTT17L23iiF2oXj+bmJruT8_qQBecXbR9iCUKo++KDgQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-12 11:40 ` Hans de Goede [this message]
2014-05-11 7:46 ` [PATCH v12 2/6] ARM: dts: sunxi: Add reg_vcc3v3 supply to sunxi-common-regulators.dtsi Hans de Goede
2014-05-11 7:46 ` [PATCH v12 3/6] ARM: dts: sun4i: Add reg_vcc3v3 to sun4i board mmc nodes Hans de Goede
2014-05-11 7:46 ` [PATCH v12 4/6] ARM: dts: sun5i: Add reg_vcc3v3 to sun5i " Hans de Goede
2014-05-11 7:46 ` [PATCH v12 5/6] ARM: dts: sun6i: Add reg_vcc3v3 to sun6i " Hans de Goede
2014-05-11 7:46 ` [PATCH v12 6/6] ARM: dts: sun7i: Add reg_vcc3v3 to sun7i " Hans de Goede
2014-05-11 17:08 ` [PATCH v12 0/6] ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs Maxime Ripard
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=5370B312.2040409@redhat.com \
--to=hdegoede-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=chris-OsFVWbfNK3isTnJN9+BGXg@public.gmane.org \
--cc=david.lanzendoerfer-Z7Kmv9EsliU@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
--cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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).