From: elder@linaro.org (Alex Elder)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 3/7] clk: bcm281xx: add an initialized flag
Date: Mon, 2 Jun 2014 17:44:54 -0500 [thread overview]
Message-ID: <1401749098-10185-4-git-send-email-elder@linaro.org> (raw)
In-Reply-To: <1401749098-10185-1-git-send-email-elder@linaro.org>
Add a flag that tracks whether a clock has already been initialized.
Use it to avoid initializing a clock more than once.
Signed-off-by: Alex Elder <elder@linaro.org>
---
drivers/clk/bcm/clk-kona.c | 12 ++++++++++++
drivers/clk/bcm/clk-kona.h | 7 +++++++
2 files changed, 19 insertions(+)
diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c
index cacbfd6..2e27924 100644
--- a/drivers/clk/bcm/clk-kona.c
+++ b/drivers/clk/bcm/clk-kona.c
@@ -27,6 +27,9 @@
#define CCU_ACCESS_PASSWORD 0xA5A500
#define CLK_GATE_DELAY_LOOP 2000
+#define clk_is_initialized(_clk) FLAG_TEST((_clk), KONA, INITIALIZED)
+#define clk_set_initialized(_clk) FLAG_SET((_clk), KONA, INITIALIZED)
+
/* Bitfield operations */
/* Produces a mask of set bits covering a range of a 32-bit value */
@@ -1041,6 +1044,9 @@ static int kona_clk_prepare(struct clk_hw *hw)
unsigned long flags;
int ret = 0;
+ if (clk_is_initialized(bcm_clk))
+ return 0;
+
ccu = bcm_clk->ccu;
flags = ccu_lock(ccu);
__ccu_write_enable(ccu);
@@ -1057,11 +1063,17 @@ static int kona_clk_prepare(struct clk_hw *hw)
__ccu_write_disable(ccu);
ccu_unlock(ccu, flags);
+ if (!ret)
+ clk_set_initialized(bcm_clk);
+
return ret;
}
static void kona_clk_unprepare(struct clk_hw *hw)
{
+ struct kona_clk *bcm_clk = to_kona_clk(hw);
+
+ WARN_ON(!clk_is_initialized(bcm_clk));
/* Nothing to do. */
}
diff --git a/drivers/clk/bcm/clk-kona.h b/drivers/clk/bcm/clk-kona.h
index 4c7e796..ea77ec1 100644
--- a/drivers/clk/bcm/clk-kona.h
+++ b/drivers/clk/bcm/clk-kona.h
@@ -406,6 +406,7 @@ struct kona_clk {
struct clk_init_data init_data; /* includes name of this clock */
struct ccu_data *ccu; /* ccu this clock is associated with */
enum bcm_clk_type type;
+ u32 flags; /* BCM_CLK_KONA_FLAGS_* below */
union {
void *data;
struct peri_clk_data *peri;
@@ -414,6 +415,12 @@ struct kona_clk {
#define to_kona_clk(_hw) \
container_of(_hw, struct kona_clk, hw)
+/*
+ * Kona clock flags:
+ * INITIALIZED clock has been initialized already
+ */
+#define BCM_CLK_KONA_FLAGS_INITIALIZED ((u32)1 << 0) /* Clock initialized */
+
/* Initialization macro for an entry in a CCU's kona_clks[] array. */
#define KONA_CLK(_ccu_name, _clk_name, _type) \
{ \
--
1.9.1
next prev parent reply other threads:[~2014-06-02 22:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-02 22:44 [PATCH v5 0/7] clk: bcm: prerequisite and bus clock support Alex Elder
2014-06-02 22:44 ` [PATCH v5 1/7] clk: kona: move some code Alex Elder
2014-06-02 22:44 ` [PATCH v5 2/7] clk: kona: don't init clocks at startup time Alex Elder
2014-06-02 22:44 ` Alex Elder [this message]
2014-06-02 22:44 ` [PATCH v5 4/7] clk: bcm281xx: implement prerequisite clocks Alex Elder
2014-06-02 22:44 ` [PATCH v5 5/7] clk: bcm281xx: add bus clock support Alex Elder
2014-06-02 22:44 ` [PATCH v5 6/7] clk: bcm281xx: define a bus clock Alex Elder
2014-06-02 22:44 ` [PATCH v5 7/7] ARM: dts: add bus clock bsc3_apb for bcm281xx Alex Elder
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=1401749098-10185-4-git-send-email-elder@linaro.org \
--to=elder@linaro.org \
--cc=linux-arm-kernel@lists.infradead.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).