From: elder@linaro.org (Alex Elder)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/5] clk: bcm281xx: add an initialized flag
Date: Thu, 29 May 2014 08:26:55 -0500 [thread overview]
Message-ID: <5387359F.7080507@linaro.org> (raw)
In-Reply-To: <20140524003344.23136.68999@quantum>
On 05/23/2014 07:33 PM, Mike Turquette wrote:
> Quoting Alex Elder (2014-05-20 05:52:38)
>> Add a flag that tracks whether a clock has already been initialized.
>> This will be used by the next patch to avoid initializing a clock
>> more than once when it's listed as a prerequisite.
>>
>> Signed-off-by: Alex Elder <elder@linaro.org>
>> ---
>> drivers/clk/bcm/clk-kona.c | 17 +++++++++++++++--
>> drivers/clk/bcm/clk-kona.h | 7 +++++++
>> 2 files changed, 22 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c
>> index d603c4e..d8a7f38 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 */
>> @@ -1194,13 +1197,23 @@ static bool __peri_clk_init(struct kona_clk *bcm_clk)
>>
>> static bool __kona_clk_init(struct kona_clk *bcm_clk)
>> {
>> + bool ret;
>> +
>> + if (clk_is_initialized(bcm_clk))
>> + return true;
>> +
>> switch (bcm_clk->type) {
>> case bcm_clk_peri:
>> - return __peri_clk_init(bcm_clk);
>> + ret = __peri_clk_init(bcm_clk);
>
> Hi Alex,
>
> Going through this code, it's a bit hard to keep up ;-)
Here's how the structures are organized:
- A Kona clock is either a peripheral or a bus clock,
but a lot of things are handled generically at the
Kona level of abstraction.
- A peripheral clock has a selector (mux), up to two
dividers, and a gate. All of these are optional.
- A bus clock has a gate, which is optional. (There
are a few other things but I'm just ignoring them
for now.)
- Each of these sort of sub-components (gate, divider,
etc.) are handled on their own. In other words, there
are gate routines that operate on a gate regardless
of whether it's on bus or peripheral clock.
- These sub-components are grouped like this because
there are some weird gating requirements. (I've
said before I wanted to try to split things off where
possible to use the common framework code more, but
that opportunity hasn't arisen yet.)
> Does the call to __peri_clk_init enable the prereq clocks? If so, is
> their clk->prepare_count and clk->enable_count properly incremented?
My use of the term "enable" is imprecise.
The purpose of these *_init() routines is to set the hardware
to a known initial state. Right now, *defining* what that
state should be has not been sent out for review, but that's
the reason it's set up this way. The model is basically, when
you want to make a change, you record what the new value should
be and the *_commit() it. Special values, used at initialization
time, indicate we don't have a desired value but we don't know
what the hardware is currently is set to either. When those
special values (like BAD_SCALED_DIV_VALUE) are seen, the current
value is read from the hardware rather than written.
Anyway, to (hopefully) answer your question...
All of the prerequisite activity occurs in __kona_clk_init(),
which is called for every Kona clock. The first thing that
does is call __kona_prereq_init(), in order to set up and
initialize (using __kona_clk_init()) the prerequisite clock
if there is one.
*After* the prerequisite clock is set up, the rest of the
original clock initialization occurs, by calling (e.g.)
__peri_clk_init().
Sorry to be so verbose but I think it helps to understand
the design underlying this stuff.
I'm going to be submitting a new version of this series
today. It will pull out the clk_lookup field and
some comments that you spotted that are just dead code.
-Alex
> Thanks,
> Mike
>
>> + break;
>> default:
>> + ret = false;
>> BUG();
>> }
>> - return -EINVAL;
>> + if (ret)
>> + clk_set_initialized(bcm_clk);
>> +
>> + return ret;
>> }
>>
>> /* Set a CCU and all its clocks into their desired initial state */
>> diff --git a/drivers/clk/bcm/clk-kona.h b/drivers/clk/bcm/clk-kona.h
>> index 2537b30..10e238d 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
>>
WARNING: multiple messages have this Message-ID (diff)
From: Alex Elder <elder@linaro.org>
To: Mike Turquette <mturquette@linaro.org>,
mporter@linaro.org, bcm@fixthebug.org,
devicetree@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/5] clk: bcm281xx: add an initialized flag
Date: Thu, 29 May 2014 08:26:55 -0500 [thread overview]
Message-ID: <5387359F.7080507@linaro.org> (raw)
In-Reply-To: <20140524003344.23136.68999@quantum>
On 05/23/2014 07:33 PM, Mike Turquette wrote:
> Quoting Alex Elder (2014-05-20 05:52:38)
>> Add a flag that tracks whether a clock has already been initialized.
>> This will be used by the next patch to avoid initializing a clock
>> more than once when it's listed as a prerequisite.
>>
>> Signed-off-by: Alex Elder <elder@linaro.org>
>> ---
>> drivers/clk/bcm/clk-kona.c | 17 +++++++++++++++--
>> drivers/clk/bcm/clk-kona.h | 7 +++++++
>> 2 files changed, 22 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c
>> index d603c4e..d8a7f38 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 */
>> @@ -1194,13 +1197,23 @@ static bool __peri_clk_init(struct kona_clk *bcm_clk)
>>
>> static bool __kona_clk_init(struct kona_clk *bcm_clk)
>> {
>> + bool ret;
>> +
>> + if (clk_is_initialized(bcm_clk))
>> + return true;
>> +
>> switch (bcm_clk->type) {
>> case bcm_clk_peri:
>> - return __peri_clk_init(bcm_clk);
>> + ret = __peri_clk_init(bcm_clk);
>
> Hi Alex,
>
> Going through this code, it's a bit hard to keep up ;-)
Here's how the structures are organized:
- A Kona clock is either a peripheral or a bus clock,
but a lot of things are handled generically at the
Kona level of abstraction.
- A peripheral clock has a selector (mux), up to two
dividers, and a gate. All of these are optional.
- A bus clock has a gate, which is optional. (There
are a few other things but I'm just ignoring them
for now.)
- Each of these sort of sub-components (gate, divider,
etc.) are handled on their own. In other words, there
are gate routines that operate on a gate regardless
of whether it's on bus or peripheral clock.
- These sub-components are grouped like this because
there are some weird gating requirements. (I've
said before I wanted to try to split things off where
possible to use the common framework code more, but
that opportunity hasn't arisen yet.)
> Does the call to __peri_clk_init enable the prereq clocks? If so, is
> their clk->prepare_count and clk->enable_count properly incremented?
My use of the term "enable" is imprecise.
The purpose of these *_init() routines is to set the hardware
to a known initial state. Right now, *defining* what that
state should be has not been sent out for review, but that's
the reason it's set up this way. The model is basically, when
you want to make a change, you record what the new value should
be and the *_commit() it. Special values, used at initialization
time, indicate we don't have a desired value but we don't know
what the hardware is currently is set to either. When those
special values (like BAD_SCALED_DIV_VALUE) are seen, the current
value is read from the hardware rather than written.
Anyway, to (hopefully) answer your question...
All of the prerequisite activity occurs in __kona_clk_init(),
which is called for every Kona clock. The first thing that
does is call __kona_prereq_init(), in order to set up and
initialize (using __kona_clk_init()) the prerequisite clock
if there is one.
*After* the prerequisite clock is set up, the rest of the
original clock initialization occurs, by calling (e.g.)
__peri_clk_init().
Sorry to be so verbose but I think it helps to understand
the design underlying this stuff.
I'm going to be submitting a new version of this series
today. It will pull out the clk_lookup field and
some comments that you spotted that are just dead code.
-Alex
> Thanks,
> Mike
>
>> + break;
>> default:
>> + ret = false;
>> BUG();
>> }
>> - return -EINVAL;
>> + if (ret)
>> + clk_set_initialized(bcm_clk);
>> +
>> + return ret;
>> }
>>
>> /* Set a CCU and all its clocks into their desired initial state */
>> diff --git a/drivers/clk/bcm/clk-kona.h b/drivers/clk/bcm/clk-kona.h
>> index 2537b30..10e238d 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-05-29 13:26 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-20 12:52 [PATCH v2 0/5] clk: bcm: prerequisite and bus clock support Alex Elder
2014-05-20 12:52 ` Alex Elder
2014-05-20 12:52 ` Alex Elder
2014-05-20 12:52 ` [PATCH v2 1/5] clk: bcm281xx: add an initialized flag Alex Elder
2014-05-20 12:52 ` Alex Elder
2014-05-20 12:52 ` Alex Elder
2014-05-24 0:33 ` Mike Turquette
2014-05-24 0:33 ` Mike Turquette
2014-05-24 0:33 ` Mike Turquette
2014-05-29 13:26 ` Alex Elder [this message]
2014-05-29 13:26 ` Alex Elder
2014-05-20 12:52 ` [PATCH v2 2/5] clk: bcm281xx: implement prerequisite clocks Alex Elder
2014-05-20 12:52 ` Alex Elder
2014-05-24 0:53 ` Mike Turquette
2014-05-24 0:53 ` Mike Turquette
2014-05-29 13:26 ` Alex Elder
2014-05-29 13:26 ` Alex Elder
2014-05-29 13:26 ` Alex Elder
2014-05-29 16:35 ` Mike Turquette
2014-05-29 16:35 ` Mike Turquette
2014-05-29 16:53 ` Alex Elder
2014-05-29 16:53 ` Alex Elder
2014-05-29 16:53 ` Alex Elder
2014-05-29 17:47 ` Mike Turquette
2014-05-29 17:47 ` Mike Turquette
2014-05-30 3:20 ` Alex Elder
2014-05-30 3:20 ` Alex Elder
2014-05-30 3:20 ` Alex Elder
2014-05-30 14:05 ` Alex Elder
2014-05-30 14:05 ` Alex Elder
2014-05-30 14:05 ` Alex Elder
2014-05-20 12:52 ` [PATCH v2 3/5] clk: bcm281xx: add bus clock support Alex Elder
2014-05-20 12:52 ` Alex Elder
2014-05-20 12:52 ` [PATCH v2 4/5] clk: bcm281xx: define a bus clock Alex Elder
2014-05-20 12:52 ` Alex Elder
[not found] ` <1400590362-11177-1-git-send-email-elder-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-05-20 12:55 ` [PATCH v2 5/5] 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=5387359F.7080507@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 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.