From: Stephen Boyd <sboyd@codeaurora.org>
To: Georgi Djakov <georgi.djakov@linaro.org>
Cc: agross@codeaurora.org, mturquette@baylibre.com,
linux-clk@vger.kernel.org, bjorn.andersson@sonymobile.com,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v3 5/8] clk: qcom: Add support for RPM Clocks
Date: Tue, 27 Oct 2015 16:15:57 -0700 [thread overview]
Message-ID: <20151027231556.GR19782@codeaurora.org> (raw)
In-Reply-To: <1445360280-2347-6-git-send-email-georgi.djakov@linaro.org>
On 10/20, Georgi Djakov wrote:
> diff --git a/drivers/clk/qcom/clk-smd-rpm.c b/drivers/clk/qcom/clk-smd-rpm.c
> new file mode 100644
> index 000000000000..aa634bdf0aae
> --- /dev/null
> +++ b/drivers/clk/qcom/clk-smd-rpm.c
> @@ -0,0 +1,260 @@
> +
> +static int clk_smd_rpm_set_rate_active(struct clk_smd_rpm *r,
> + unsigned long value)
> +{
> + struct clk_smd_rpm_req req = {
> + .key = r->rpm_key,
> + .nbytes = sizeof(u32),
> + .value = DIV_ROUND_UP(value, 1000), /* RPM expects kHz */
> + };
> +
> + return qcom_rpm_smd_write(r->rpm, QCOM_SMD_RPM_ACTIVE_STATE,
> + r->rpm_res_type, r->rpm_clk_id, &req,
> + sizeof(req));
> +}
> +
> +static int clk_smd_rpm_set_rate_sleep(struct clk_smd_rpm *r,
> + unsigned long value)
> +{
> + struct clk_smd_rpm_req req = {
> + .key = r->rpm_key,
> + .nbytes = sizeof(u32),
> + .value = DIV_ROUND_UP(value, 1000), /* RPM expects kHz */
Don't we need to do all the cpu_to_le32() stuff on these
structures?
> + };
> +
> + return qcom_rpm_smd_write(r->rpm, QCOM_SMD_RPM_SLEEP_STATE,
> + r->rpm_res_type, r->rpm_clk_id, &req,
> + sizeof(req));
> +}
> +
[..]
> +
> +static int clk_smd_rpm_prepare(struct clk_hw *hw)
> +{
> + struct clk_smd_rpm *r = to_clk_smd_rpm(hw);
> + struct clk_smd_rpm *peer = r->peer;
> + unsigned long this_rate = 0, this_sleep_rate = 0;
> + unsigned long peer_rate = 0, peer_sleep_rate = 0;
> + unsigned long active_rate, sleep_rate;
> + int ret = 0;
> +
> + mutex_lock(&rpm_clk_lock);
> +
> + /* Don't send requests to the RPM if the rate has not been set. */
> + if (!r->rate)
> + goto out;
> +
> + to_active_sleep(r, r->rate, &this_rate, &this_sleep_rate);
> +
> + /* Take peer clock's rate into account only if it's enabled. */
> + if (peer->enabled)
> + to_active_sleep(peer, peer->rate,
> + &peer_rate, &peer_sleep_rate);
> +
> + active_rate = max(this_rate, peer_rate);
> +
> + if (r->branch)
> + active_rate = !!active_rate;
> +
> + ret = clk_smd_rpm_set_rate_active(r, active_rate);
> + if (ret)
> + goto out;
> +
> + sleep_rate = max(this_sleep_rate, peer_sleep_rate);
> + if (r->branch)
> + sleep_rate = !!sleep_rate;
> +
> + ret = clk_smd_rpm_set_rate_sleep(r, sleep_rate);
> + if (ret)
> + /* Undo the active set vote and restore it */
> + ret = clk_smd_rpm_set_rate_active(r, peer_rate);
> +
> +out:
> + if (!ret)
> + r->enabled = true;
> +
> + mutex_unlock(&rpm_clk_lock);
> +
> + return ret;
> +}
> +
> +static void clk_smd_rpm_unprepare(struct clk_hw *hw)
> +{
> + struct clk_smd_rpm *r = to_clk_smd_rpm(hw);
> +
> + mutex_lock(&rpm_clk_lock);
> +
> + if (r->rate) {
The style is different than the prepare path here. Why? Please
use if (!r->rate) instead and move the local variables below to
the top of the function.
> + struct clk_smd_rpm *peer = r->peer;
> + unsigned long peer_rate = 0, peer_sleep_rate = 0;
> + unsigned long active_rate, sleep_rate;
> + int ret;
> +
> + /* Take peer clock's rate into account only if it's enabled. */
> + if (peer->enabled)
> + to_active_sleep(peer, peer->rate, &peer_rate,
> + &peer_sleep_rate);
> +
> + active_rate = r->branch ? !!peer_rate : peer_rate;
> + ret = clk_smd_rpm_set_rate_active(r, active_rate);
> + if (ret)
> + goto out;
> +
> + sleep_rate = r->branch ? !!peer_sleep_rate : peer_sleep_rate;
> + ret = clk_smd_rpm_set_rate_sleep(r, sleep_rate);
> + if (ret)
> + goto out;
> + }
> + r->enabled = false;
> +
> +out:
> + mutex_unlock(&rpm_clk_lock);
> +}
> +
> +static int clk_smd_rpm_set_rate(struct clk_hw *hw, unsigned long rate,
> + unsigned long parent_rate)
> +{
> + struct clk_smd_rpm *r = to_clk_smd_rpm(hw);
> + int ret = 0;
> +
> + mutex_lock(&rpm_clk_lock);
> +
> + if (r->enabled) {
Same comment here. De-indent the code below.
> + struct clk_smd_rpm *peer = r->peer;
> + unsigned long active_rate, sleep_rate;
> + unsigned long this_rate = 0, this_sleep_rate = 0;
> + unsigned long peer_rate = 0, peer_sleep_rate = 0;
> +
> + to_active_sleep(r, rate, &this_rate, &this_sleep_rate);
> +
> + /* Take peer clock's rate into account only if it's enabled. */
> + if (peer->enabled)
> + to_active_sleep(peer, peer->rate,
> + &peer_rate, &peer_sleep_rate);
> +
> + active_rate = max(this_rate, peer_rate);
> + ret = clk_smd_rpm_set_rate_active(r, active_rate);
> + if (ret)
> + goto out;
> +
> + sleep_rate = max(this_sleep_rate, peer_sleep_rate);
> + ret = clk_smd_rpm_set_rate_sleep(r, sleep_rate);
> + if (ret)
> + goto out;
> + }
> + r->rate = rate;
> +out:
> + mutex_unlock(&rpm_clk_lock);
> +
> + return ret;
> +}
> +
> +
> diff --git a/drivers/clk/qcom/clk-smd-rpm.h b/drivers/clk/qcom/clk-smd-rpm.h
> new file mode 100644
> index 000000000000..d5dafad6b0fc
> --- /dev/null
> +++ b/drivers/clk/qcom/clk-smd-rpm.h
> @@ -0,0 +1,142 @@
> +
> +#define __DEFINE_CLK_SMD_RPM(_name, active, type, r_id, stat_id, dep, key) \
> + static struct clk_smd_rpm active; \
Can you please align the '\' at the same column on the right
side?
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2015-10-27 23:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-20 16:57 [PATCH v3 0/8] Add initial support for RPM clocks Georgi Djakov
2015-10-20 16:57 ` [PATCH v3 1/8] arm64: dts: qcom: 8x16: Add fixed rate on-board oscillator Georgi Djakov
2015-10-22 2:52 ` Andy Gross
2015-10-27 23:17 ` Stephen Boyd
2015-10-20 16:57 ` [PATCH v3 2/8] clk: qcom: msm8916: Set the parent of xo to xo_board Georgi Djakov
2015-10-26 22:43 ` Stephen Boyd
2015-10-20 16:57 ` [PATCH v3 3/8] clk: qcom: msm8916: Ignore sleep_clk_src registration errors Georgi Djakov
2015-10-26 22:44 ` Stephen Boyd
2015-10-20 16:57 ` [PATCH v3 4/8] arm64: dts: qcom: 8x16: Add fixed rate sleep clock oscillator Georgi Djakov
2015-10-20 16:57 ` [PATCH v3 5/8] clk: qcom: Add support for RPM Clocks Georgi Djakov
2015-10-27 23:15 ` Stephen Boyd [this message]
2015-10-20 16:57 ` [PATCH v3 6/8] clk: qcom: Add RPM clock controller driver Georgi Djakov
2015-10-27 23:23 ` Stephen Boyd
2015-10-20 16:57 ` [PATCH v3 7/8] clk: qcom: msm8916: Use RPMCC if it is enabled Georgi Djakov
2015-10-20 16:58 ` [PATCH v3 8/8] clk: qcom: msm8916: Remove hard-coded sleep_clk_src Georgi Djakov
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=20151027231556.GR19782@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=agross@codeaurora.org \
--cc=bjorn.andersson@sonymobile.com \
--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@baylibre.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.