From: Alex Elder <elder-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Mike Turquette
<mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
mporter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
bcm-xK7y4jjYLqYh9ZMKESR00Q@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2 2/5] clk: bcm281xx: implement prerequisite clocks
Date: Thu, 29 May 2014 22:20:15 -0500 [thread overview]
Message-ID: <5387F8EF.3030607@linaro.org> (raw)
In-Reply-To: <20140524005358.23136.8918@quantum>
On 05/23/2014 07:53 PM, Mike Turquette wrote:
> Quoting Alex Elder (2014-05-20 05:52:39)
>> @@ -743,11 +746,16 @@ struct clk *kona_clk_setup(struct kona_clk *bcm_clk)
>> clk = clk_register(NULL, &bcm_clk->hw);
>> if (IS_ERR(clk)) {
>> pr_err("%s: error registering clock %s (%ld)\n", __func__,
>> - init_data->name, PTR_ERR(clk));
>> + name, PTR_ERR(clk));
>> goto out_teardown;
>> }
>> BUG_ON(!clk);
>>
>> + /* Make it so we can look the clock up using clk_find() */
>
> s/clk_find/clk_get/ ?
>
>> + bcm_clk->cl.con_id = name;
>> + bcm_clk->cl.clk = clk;
>> + clkdev_add(&bcm_clk->cl);
>
> This is not so nice. I'll explain more below.
OK, despite what I said before, I do need this, or
something like it, so I can look up clocks by name.
(Continued below.)
>
>> +
>> return clk;
>> out_teardown:
>> bcm_clk_teardown(bcm_clk);
>> diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c
>> index d8a7f38..fd070d6 100644
>> --- a/drivers/clk/bcm/clk-kona.c
>> +++ b/drivers/clk/bcm/clk-kona.c
>> @@ -1195,6 +1195,48 @@ static bool __peri_clk_init(struct kona_clk *bcm_clk)
>> return true;
>> }
>>
>> +static bool __kona_clk_init(struct kona_clk *bcm_clk);
>> +static bool __kona_prereq_init(struct kona_clk *bcm_clk)
>> +{
>> + struct clk *clk;
>> + struct clk_hw *hw;
>> + struct kona_clk *prereq;
>> +
>> + BUG_ON(clk_is_initialized(bcm_clk));
>> +
>> + if (!bcm_clk->p.prereq)
>> + return true;
>> +
>> + clk = clk_get(NULL, bcm_clk->p.prereq);
>
> The clkdev global namespace is getting polluted with all of these new
> prereq clocks. If there was an associated struct device *dev with them
> then it wouldn't be a problem, but you might get collisions with other
> clock drivers that also use NULL for the device.
Yes I recognize this. Ideally a CCU would have a device struct
associated with it that I could use, because the name of a clock
is unique within that context. But I have no such device available.
(Please correct me if I'm wrong. I don't want to make one up, and
I would like to use it if it exists.)
> It would be a lot nicer for the clocks that require a prereq clock to
> just use clk_get(dev, "well_known_name"); in the same way that drivers
> use it, without considering it a special case.
I can do something like that if I can get a meaningful device
structure. Do you have any suggestions?
Other than this issue, I've implemented all of the previous
initialization routines using ->prepare() instead, and it
works fine. I'm going to send an updated series out tomorrow.
I want to look it over again after a good night's sleep...
-Alex
>> + if (IS_ERR(clk)) {
>> + pr_err("%s: unable to get prereq clock %s for %s\n",
>> + __func__, bcm_clk->p.prereq, bcm_clk->init_data.name);
>> + return false;
>> + }
>> + hw = __clk_get_hw(clk);
>> + if (!hw) {
>> + pr_err("%s: null hw pointer for clock %s\n", __func__,
>> + bcm_clk->init_data.name);
>> + return false;
>> + }
>> + prereq = to_kona_clk(hw);
>> + if (prereq->ccu != bcm_clk->ccu) {
>> + pr_err("%s: prereq clock %s CCU different for clock %s\n",
>> + __func__, bcm_clk->p.prereq, bcm_clk->init_data.name);
>> + return false;
>> + }
>> +
>> + /* Initialize the prerequisite clock first */
>> + if (!__kona_clk_init(prereq)) {
>> + pr_err("%s: failed to init prereq %s for clock %s\n",
>> + __func__, bcm_clk->p.prereq, bcm_clk->init_data.name);
>> + return false;
>> + }
>> + bcm_clk->p.prereq_clk = clk;
>
> The above seems like a lot effort to go to. Why not skip all of this and
> just implement the prerequisite logic in the .enable & .disable
> callbacks? E.g. your kona clk .enable callback would look like:
>
> diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c
> index d603c4e..51f35b4 100644
> --- a/drivers/clk/bcm/clk-kona.c
> +++ b/drivers/clk/bcm/clk-kona.c
> @@ -987,6 +987,12 @@ static int kona_peri_clk_enable(struct clk_hw *hw)
> {
> struct kona_clk *bcm_clk = to_kona_clk(hw);
> struct bcm_clk_gate *gate = &bcm_clk->u.peri->gate;
> + int ret;
> +
> + hw->prereq_bus_clk = clk_get(hw->ccu, hw->prereq);
> + ret = clk_enable(prereq_bus_clk);
> + if (ret)
> + return ret;
>
> return clk_gate(bcm_clk->ccu, bcm_clk->init_data.name, gate, true);
> }
> @@ -997,6 +1003,9 @@ static void kona_peri_clk_disable(struct clk_hw *hw)
> struct bcm_clk_gate *gate = &bcm_clk->u.peri->gate;
>
> (void)clk_gate(bcm_clk->ccu, bcm_clk->init_data.name, gate, false);
> +
> + clk_disable(hw->prereq_bus_clk);
> + clk_put(hw->prereq_bus_clk);
> }
>
> static int kona_peri_clk_is_enabled(struct clk_hw *hw)
>
>
> I guess it might take some trickery to get clk_get to work like that.
> Let me know if I've completely lost the plot.
>
> Regards,
> Mike
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-05-30 3:20 UTC|newest]
Thread overview: 15+ 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 ` [PATCH v2 1/5] clk: bcm281xx: add an initialized flag Alex Elder
[not found] ` <1400590362-11177-2-git-send-email-elder-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-05-24 0:33 ` Mike Turquette
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-24 0:53 ` Mike Turquette
2014-05-29 13:26 ` Alex Elder
2014-05-29 16:35 ` Mike Turquette
2014-05-29 16:53 ` Alex Elder
2014-05-29 17:47 ` Mike Turquette
2014-05-30 3:20 ` Alex Elder [this message]
[not found] ` <5387F8EF.3030607-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
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 ` [PATCH v2 4/5] clk: bcm281xx: define a bus clock 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=5387F8EF.3030607@linaro.org \
--to=elder-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=bcm-xK7y4jjYLqYh9ZMKESR00Q@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mporter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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).