From: Abel Vesa <abel.vesa@nxp.com>
To: Shawn Guo <shawnguo@kernel.org>, Stephen Boyd <sboyd@kernel.org>,
Peng Fan <peng.fan@nxp.com>, Dong Aisheng <aisheng.dong@nxp.com>,
Anson Huang <anson.huang@nxp.com>
Cc: NXP Linux Team <linux-imx@nxp.com>,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Abel Vesa <abel.vesa@nxp.com>
Subject: [RFC 1/4] clk: Add CLK_GET_PARENT_NOCACHE flag
Date: Wed, 21 Oct 2020 20:36:52 +0300 [thread overview]
Message-ID: <1603301815-24670-2-git-send-email-abel.vesa@nxp.com> (raw)
In-Reply-To: <1603301815-24670-1-git-send-email-abel.vesa@nxp.com>
This can be used by the clocks that have their parents changed from EL3.
This way the clk_get_parent will read the value from register instead of
using the value stored in the core framework.
Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
Suggested-by: Peng Fan <peng.fan@nxp.com>
---
drivers/clk/clk.c | 31 +++++++++++++++++--------------
include/linux/clk-provider.h | 1 +
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 90d2373..474315d 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2401,6 +2401,16 @@ int clk_set_max_rate(struct clk *clk, unsigned long rate)
}
EXPORT_SYMBOL_GPL(clk_set_max_rate);
+static struct clk_core *__clk_get_parent(struct clk_core *core)
+{
+ u8 index = 0;
+
+ if (core->num_parents > 1 && core->ops->get_parent)
+ index = core->ops->get_parent(core->hw);
+
+ return clk_core_get_parent_by_index(core, index);
+}
+
/**
* clk_get_parent - return the parent of a clk
* @clk: the clk whose parent gets returned
@@ -2415,24 +2425,17 @@ struct clk *clk_get_parent(struct clk *clk)
return NULL;
clk_prepare_lock();
- /* TODO: Create a per-user clk and change callers to call clk_put */
- parent = !clk->core->parent ? NULL : clk->core->parent->hw->clk;
+ if (clk->core && (clk->core->flags & CLK_GET_PARENT_NOCACHE))
+ parent = __clk_get_parent(clk->core)->hw->clk;
+ else
+ /* TODO: Create a per-user clk and change callers to call clk_put */
+ parent = !clk->core->parent ? NULL : clk->core->parent->hw->clk;
clk_prepare_unlock();
return parent;
}
EXPORT_SYMBOL_GPL(clk_get_parent);
-static struct clk_core *__clk_init_parent(struct clk_core *core)
-{
- u8 index = 0;
-
- if (core->num_parents > 1 && core->ops->get_parent)
- index = core->ops->get_parent(core->hw);
-
- return clk_core_get_parent_by_index(core, index);
-}
-
static void clk_core_reparent(struct clk_core *core,
struct clk_core *new_parent)
{
@@ -3353,7 +3356,7 @@ static void clk_core_reparent_orphans_nolock(void)
* parent.
*/
hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) {
- struct clk_core *parent = __clk_init_parent(orphan);
+ struct clk_core *parent = __clk_get_parent(orphan);
/*
* We need to use __clk_set_parent_before() and _after() to
@@ -3454,7 +3457,7 @@ static int __clk_core_init(struct clk_core *core)
goto out;
}
- parent = core->parent = __clk_init_parent(core);
+ parent = core->parent = __clk_get_parent(core);
/*
* Populate core->parent if parent has already been clk_core_init'd. If
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index d98e41f..94a78b3 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -33,6 +33,7 @@
/* duty cycle call may be forwarded to the parent clock */
#define CLK_DUTY_CYCLE_PARENT BIT(13)
#define CLK_SET_PARENT_NOCACHE BIT(14) /* do not use the cached clk parent */
+#define CLK_GET_PARENT_NOCACHE BIT(15) /* read the parent from reg */
struct clk;
struct clk_hw;
--
2.7.4
next prev parent reply other threads:[~2020-10-21 17:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-21 17:36 [RFC 0/4] clk: imx: Register the dram_apb and dram_alt as read-only Abel Vesa
2020-10-21 17:36 ` Abel Vesa [this message]
2020-10-21 17:36 ` [RFC 2/4] clk: Add clk_gate_ro_ops for read-only gate clocks Abel Vesa
2020-10-21 17:36 ` [RFC 3/4] clk: imx: composite-8m: Add DRAM clock registration variant Abel Vesa
2020-10-21 17:36 ` [RFC 4/4] clk: imx8m: Use dram variant registration for dram clocks Abel Vesa
2020-11-17 2:47 ` [RFC 0/4] clk: imx: Register the dram_apb and dram_alt as read-only Peng Fan
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=1603301815-24670-2-git-send-email-abel.vesa@nxp.com \
--to=abel.vesa@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=anson.huang@nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=sboyd@kernel.org \
--cc=shawnguo@kernel.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
all inboxes | Powered by JetHome®