From: Stephen Boyd <sboyd@codeaurora.org>
To: Georgi Djakov <georgi.djakov@linaro.org>
Cc: mturquette@linaro.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v2 3/5] clk: qcom: Add support for RCGs with shared branches
Date: Fri, 5 Jun 2015 18:39:57 -0700 [thread overview]
Message-ID: <20150606013957.GH29237@codeaurora.org> (raw)
In-Reply-To: <1433508036-28644-4-git-send-email-georgi.djakov@linaro.org>
On 06/05, Georgi Djakov wrote:
> diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
> index cb17fd4b193f..60563adad21d 100644
> --- a/drivers/clk/qcom/clk-rcg2.c
> +++ b/drivers/clk/qcom/clk-rcg2.c
> @@ -47,6 +47,8 @@
> #define N_REG 0xc
> #define D_REG 0x10
>
> +#define XO_FREQ 19200000
Hm.. we don't know that XO is always going to be 19.2 MHz.
> +
> static int clk_rcg2_is_enabled(struct clk_hw *hw)
> {
> struct clk_rcg2 *rcg = to_clk_rcg2(hw);
> @@ -308,6 +310,68 @@ const struct clk_ops clk_rcg2_ro_ops = {
> };
> EXPORT_SYMBOL_GPL(clk_rcg2_ro_ops);
>
> +static int clk_rcg2_shared_set_rate(struct clk_hw *hw, unsigned long rate,
> + unsigned long parent_rate)
> +{
> + struct clk_rcg2 *rcg = to_clk_rcg2(hw);
> + const char *name = __clk_get_name(hw->clk);
> + int ret, count;
> + unsigned int cmd = CMD_ROOT_EN;
> +
> + /* force enable RCG */
> + ret = regmap_update_bits(rcg->clkr.regmap, rcg->cmd_rcgr + CMD_REG,
> + cmd, cmd);
> + if (ret)
> + return ret;
> +
> + /* wait for RCG to turn ON */
> + for (count = 500; count > 0; count--) {
> + ret = clk_rcg2_is_enabled(hw);
> + if (ret)
> + break;
> + udelay(1);
> + }
> + if (!count)
> + pr_err("%s: RCG did not turn on\n", name);
> +
> + /* set clock rate */
> + ret = __clk_rcg2_set_rate(hw, rate);
> + if (ret)
> + return ret;
> +
> + /* clear force enable RCG */
> + ret = regmap_update_bits(rcg->clkr.regmap, rcg->cmd_rcgr + CMD_REG,
> + cmd, ~cmd);
The last argument could just be 0, save an instruction.
> + if (ret)
> + return ret;
> +
> + return 0;
This function will become more complicated.
> +}
> +
> +static int clk_rcg2_shared_enable(struct clk_hw *hw)
> +{
> + unsigned long rate = __clk_get_rate(hw->clk);
> +
> + return clk_rcg2_shared_set_rate(hw, rate, 0);
And we shouldn't configure the clock to be at any rate besides XO
speed while the clock is off because the other processors may not
be requesting enough voltage to support the clock at whatever
rate we've chosen. So we need to make set_rate() into a caching
operation when the clock is disabled in software's view.
> +}
> +
> +static void clk_rcg2_shared_disable(struct clk_hw *hw)
> +{
> + /* switch to XO, which is always-on */
> + clk_rcg2_shared_set_rate(hw, XO_FREQ, 0);
Maybe here we should just "know" that the XO frequency is either
the lowest entry in the frequency table or that it's source 0 and
make up some fake frequency struct to pass around.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2015-06-06 1:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 12:40 [PATCH v2 0/5] Add support for more MSM8916 clocks Georgi Djakov
2015-06-05 12:40 ` [PATCH v2 1/5] clk: qcom: Add support for read-only rcg2 ops Georgi Djakov
2015-06-06 1:14 ` Stephen Boyd
2015-06-05 12:40 ` [PATCH v2 2/5] clk: qcom: Add MSM8916 iommu clocks Georgi Djakov
2015-06-05 12:40 ` [PATCH v2 3/5] clk: qcom: Add support for RCGs with shared branches Georgi Djakov
2015-06-06 1:39 ` Stephen Boyd [this message]
2015-06-05 12:40 ` [PATCH v2 4/5] clk: qcom: Add MSM8916 gpu clocks Georgi Djakov
2015-06-05 12:40 ` [PATCH v2 5/5] clk: qcom: Add MSM8916 audio clocks Georgi Djakov
2015-06-06 1:41 ` Stephen Boyd
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=20150606013957.GH29237@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=georgi.djakov@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@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).