From: Jianxin Pan <jianxin.pan@amlogic.com>
To: Jerome Brunet <jbrunet@baylibre.com>,
Neil Armstrong <narmstrong@baylibre.com>
Cc: Yixun Lan <yixun.lan@amlogic.com>,
Kevin Hilman <khilman@baylibre.com>,
Carlo Caione <carlo@caione.org>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh@kernel.org>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Boris Brezillon <boris.brezillon@bootlin.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Liang Yang <liang.yang@amlogic.com>,
Jian Hu <jian.hu@amlogic.com>,
Qiufang Dai <qiufang.dai@amlogic.com>,
Hanjie Lin <hanjie.lin@amlogic.com>,
Victor Wan <victor.wan@amlogic.com>, <linux-clk@vger.kernel.org>,
<linux-amlogic@lists.infradead.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 3/3] clk: meson: add sub MMC clock controller driver
Date: Sun, 28 Oct 2018 23:12:59 +0800 [thread overview]
Message-ID: <d284b4dd-b479-f7a7-1527-7e36b4b7451f@amlogic.com> (raw)
In-Reply-To: <f4d239df2f1333b005680f9bfdd2eba93e7f86e5.camel@baylibre.com>
Hi Jerome,
On 2018/10/25 20:54, Jerome Brunet wrote:
> On Thu, 2018-10-25 at 19:48 +0800, Jianxin Pan wrote:
>> Hi Jerome,
>>
>> On 2018/10/24 17:01, Jerome Brunet wrote:
>>> On Thu, 2018-10-18 at 13:07 +0800, Jianxin Pan wrote:
>>>> From: Yixun Lan <yixun.lan@amlogic.com>
>>>>
>>>> The patch will add a MMC clock controller driver which used by MMC or NAND,
>>>> It provide a mux and divider clock, and three phase clocks - core, tx, tx.
>>>>
[...]
>>>>
>>>> -/* Would prefer clk_regmap_div_ro_ops but clashes with qcom */
>>>> +static void clk_regmap_div_init(struct clk_hw *hw)
>>>> +{
>>>> + struct clk_regmap *clk = to_clk_regmap(hw);
>>>> + struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk);
>>>> + unsigned int val;
>>>> + int ret;
>>>> +
>>>> + ret = regmap_read(clk->map, div->offset, &val);
>>>> + if (ret)
>>>> + return;
>>>>
>>>> + val &= (clk_div_mask(div->width) << div->shift);
>>>> + if (!val)
>>>> + regmap_update_bits(clk->map, div->offset,
>>>> + clk_div_mask(div->width) << div->shift,
>>>> + clk_div_mask(div->width));
>>>
>>> This is wrong for several reasons:
>>> * You should hard code the initial value in the driver.
>>> * If shift is not 0, I doubt this will give the expected result.
>>
>> The value 0x00 of divider means nand clock off then read/write nand register is forbidden.
>
> That is not entirely true, you can access the clock register or you'd be in a
> chicken and egg situation.
>
>> Should we set the initial value in nand driver, or in sub emmc clk driver?
>
> In the nand driver, which is the consumer of the clock. see my previous comments
> about it.
>
> If your device (nand in your case) needs a (sane) clock before doing anything
> else, just call clk_set_rate() and enable it with clk_prepare_enable().
>
> Look at our MMC driver, this is the first thing done after registering the
> clocks.
>
> The controller does no care at all about the clock rate or state. It is up to
> the consumer to express their needs.
>
> On a more general note:
> I agree that having a 0 value for CLK_DIVIDER_ONE_BASED divider makes no sense.
> If you think this point needs to be addressed, please:
>
> * make separated generic patch
> * against driver/clk/clk-divider.c
> * addressing specifically CLK_DIVIDER_ONE_BASED dividers (not all, as your
> change does)
> * with some comments explaining the intent.
In our emmc driver, the CLK_DIV_MASK is hard coded before clock registering in meson_mmc_clk_init():
clk_reg |= CLK_DIV_MASK;
writel(clk_reg, host->regs + SD_EMMC_CLOCK);
It's hard coded In previous version of nand driver. I will drop the new ops.
In addition , Martin suggested in previous discussions that "sclk-div" could be used [0][1].
This divider is just like a "sclk-div" with sclk->hi->width ==0.
>
>>
>>>
>>>> +}
>>>
>>> Please drop this.
OK. Thank you.
>>>
>>>> +
>>>> +/* Would prefer clk_regmap_div_ro_ops but clashes with qcom */
>>>> const struct clk_ops clk_regmap_divider_ops = {
>>>> .recalc_rate = clk_regmap_div_recalc_rate,
>>>> .round_rate = clk_regmap_div_round_rate,
>>>> @@ -122,6 +139,14 @@ static int clk_regmap_div_set_rate(struct clk_hw *hw, unsigned long rate,
>>>> };
>>>> EXPORT_SYMBOL_GPL(clk_regmap_divider_ops);
>>>>
[...]
>>>> +
>>>> +static struct clk_regmap_mux_data mmc_clkc_mux_data = {
>>>> + .offset = SD_EMMC_CLOCK,
>>>> + .mask = 0x3,
>>>> + .shift = 6,
>>>> + .flags = CLK_DIVIDER_ROUND_CLOSEST,
>
> Missed that earlier
>
> This flag makes no sense for a mux.
> Anyway this particular mux should never round up has doing so would be unsafe.
> The clock provided to the nand or the eMMC should be the requested or lower.
>
OK, I will drop it. Thanks for your time.
>>>> +};
>>>> +
>>>> +static struct clk_regmap_div_data mmc_clkc_div_data = {
>>>> + .offset = SD_EMMC_CLOCK,
>>>> + .shift = 0,
>>>> + .width = 6,
>>>> + .flags = CLK_DIVIDER_ROUND_CLOSEST | CLK_DIVIDER_ONE_BASED,
>
> Same here, drop CLK_DIVIDER_ROUND_CLOSEST
OK, I will drop it. Thank you!
>
>>>> +};
>>>> +
>>>> +static struct meson_clk_phase_data mmc_clkc_core_phase = {
>>>> + .ph = {
>>>> + .reg_off = SD_EMMC_CLOCK,
>>>> + .shift = 8,
[...]
>
> .
>
[0] https://patchwork.kernel.org/patch/10607157/#22238243
[1]https://lore.kernel.org/lkml/CAFBinCCuqUmVNdwUm7WbkHy1eWvOA5oQ5FcOuytbYNbgGcXnRQ@mail.gmail.com/T/#u
prev parent reply other threads:[~2018-10-28 15:13 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-18 5:07 [PATCH v5 0/3] clk: meson: add a sub EMMC clock controller support Jianxin Pan
2018-10-18 5:07 ` [PATCH v5 1/3] clk: meson: add emmc sub clock phase delay driver Jianxin Pan
2018-10-18 17:14 ` Stephen Boyd
2018-10-24 8:58 ` Jerome Brunet
2018-10-24 10:57 ` Jianxin Pan
2018-10-18 5:07 ` [PATCH v5 2/3] clk: meson: add DT documentation for emmc clock controller Jianxin Pan
2018-10-18 17:08 ` Stephen Boyd
2018-10-19 15:50 ` Jianxin Pan
2018-10-19 18:04 ` Stephen Boyd
2018-10-22 6:05 ` Jianxin Pan
2018-10-24 8:58 ` Jerome Brunet
2018-10-25 7:29 ` Yixun Lan
2018-10-25 11:50 ` Jianxin Pan
2018-11-04 3:04 ` Stephen Boyd
2018-11-04 15:39 ` Jianxin Pan
2018-10-18 5:07 ` [PATCH v5 3/3] clk: meson: add sub MMC clock controller driver Jianxin Pan
2018-10-18 17:13 ` Stephen Boyd
2018-10-19 16:12 ` Jianxin Pan
2018-10-19 18:03 ` Stephen Boyd
2018-10-22 5:59 ` Jianxin Pan
2018-10-24 9:00 ` Jerome Brunet
2018-10-24 6:29 ` Jianxin Pan
2018-10-24 8:47 ` Stephen Boyd
2018-10-24 8:51 ` Jianxin Pan
2018-10-24 9:01 ` Jerome Brunet
2018-10-25 11:48 ` Jianxin Pan
2018-10-25 12:54 ` Jerome Brunet
2018-10-25 20:58 ` Martin Blumenstingl
2018-10-28 19:16 ` Jerome Brunet
2018-10-29 19:45 ` Martin Blumenstingl
2018-10-30 13:41 ` Jianxin Pan
2018-11-03 18:01 ` Jianxin Pan
2018-11-05 9:46 ` jbrunet
2018-11-05 11:29 ` Jianxin Pan
2018-10-28 15:12 ` Jianxin Pan [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=d284b4dd-b479-f7a7-1527-7e36b4b7451f@amlogic.com \
--to=jianxin.pan@amlogic.com \
--cc=boris.brezillon@bootlin.com \
--cc=carlo@caione.org \
--cc=hanjie.lin@amlogic.com \
--cc=jbrunet@baylibre.com \
--cc=jian.hu@amlogic.com \
--cc=khilman@baylibre.com \
--cc=liang.yang@amlogic.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=miquel.raynal@bootlin.com \
--cc=mturquette@baylibre.com \
--cc=narmstrong@baylibre.com \
--cc=qiufang.dai@amlogic.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=victor.wan@amlogic.com \
--cc=yixun.lan@amlogic.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;
as well as URLs for NNTP newsgroup(s).