From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH v3 03/12] clk: Unconditionally recursively en-/dis-able clocks
Date: Thu, 6 Feb 2020 22:45:32 +0100 [thread overview]
Message-ID: <20200206224532.7948ac20@jawa> (raw)
In-Reply-To: <33db3690-e3ce-f25b-80c5-741d5e1d4773@gmail.com>
Hi Sean,
> For clocks not in the CCF, their parents will not have UCLASS_CLK, so
> we just enable them as normal. The enable count is local to the
> struct clk, but this will never result in the actual en-/dis-able op
> being called (unless the same struct clk is enabled twice).
>
> For clocks in the CCF, we always traverse up the tree when enabling.
> Previously, CCF clocks without id set would be skipped, stopping the
> traversal too early.
>
> Signed-off-by: Sean Anderson <seanga2@gmail.com>
Acked-by: Lukasz Majewski <lukma@denx.de>
> ---
> Changes for v3:
> - New.
>
> drivers/clk/clk-uclass.c | 58
> +++++++++++++++++----------------------- 1 file changed, 25
> insertions(+), 33 deletions(-)
>
> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
> index 9aa8537004..87d101aab4 100644
> --- a/drivers/clk/clk-uclass.c
> +++ b/drivers/clk/clk-uclass.c
> @@ -490,7 +490,6 @@ int clk_set_parent(struct clk *clk, struct clk
> *parent) int clk_enable(struct clk *clk)
> {
> const struct clk_ops *ops;
> - struct clk *clkp = NULL;
> int ret;
>
> debug("%s(clk=%p)\n", __func__, clk);
> @@ -499,32 +498,28 @@ int clk_enable(struct clk *clk)
> ops = clk_dev_ops(clk->dev);
>
> if (CONFIG_IS_ENABLED(CLK_CCF)) {
> - /* Take id 0 as a non-valid clk, such as dummy */
> - if (clk->id && !clk_get_by_id(clk->id, &clkp)) {
> - if (clkp->enable_count) {
> - clkp->enable_count++;
> - return 0;
> - }
> - if (clkp->dev->parent &&
> - device_get_uclass_id(clkp->dev) ==
> UCLASS_CLK) {
> - ret =
> clk_enable(dev_get_clk_ptr(clkp->dev->parent));
> - if (ret) {
> - printf("Enable %s failed\n",
> -
> clkp->dev->parent->name);
> - return ret;
> - }
> + if (clk->enable_count) {
> + clk->enable_count++;
> + return 0;
> + }
> + if (clk->dev->parent &&
> + device_get_uclass_id(clk->dev->parent) ==
> UCLASS_CLK) {
> + ret =
> clk_enable(dev_get_clk_ptr(clk->dev->parent));
> + if (ret) {
> + printf("Enable %s failed\n",
> + clk->dev->parent->name);
> + return ret;
> }
> }
>
> if (ops->enable) {
> ret = ops->enable(clk);
> if (ret) {
> - printf("Enable %s failed\n",
> clk->dev->name);
> + printf("Enable %s failed (error
> %d)\n", clk->dev->name, ret); return ret;
> }
> }
> - if (clkp)
> - clkp->enable_count++;
> + clk->enable_count++;
> } else {
> if (!ops->enable)
> return -ENOSYS;
> @@ -550,7 +545,6 @@ int clk_enable_bulk(struct clk_bulk *bulk)
> int clk_disable(struct clk *clk)
> {
> const struct clk_ops *ops;
> - struct clk *clkp = NULL;
> int ret;
>
> debug("%s(clk=%p)\n", __func__, clk);
> @@ -559,29 +553,27 @@ int clk_disable(struct clk *clk)
> ops = clk_dev_ops(clk->dev);
>
> if (CONFIG_IS_ENABLED(CLK_CCF)) {
> - if (clk->id && !clk_get_by_id(clk->id, &clkp)) {
> - if (clkp->enable_count == 0) {
> - printf("clk %s already disabled\n",
> - clkp->dev->name);
> - return 0;
> - }
> -
> - if (--clkp->enable_count > 0)
> - return 0;
> + if (clk->enable_count == 0) {
> + printf("clk %s already disabled\n",
> + clk->dev->name);
> + return 0;
> }
>
> + if (--clk->enable_count > 0)
> + return 0;
> +
> if (ops->disable) {
> ret = ops->disable(clk);
> if (ret)
> return ret;
> }
>
> - if (clkp && clkp->dev->parent &&
> - device_get_uclass_id(clkp->dev) == UCLASS_CLK) {
> - ret =
> clk_disable(dev_get_clk_ptr(clkp->dev->parent));
> + if (clk->dev->parent &&
> + device_get_uclass_id(clk->dev) == UCLASS_CLK) {
> + ret =
> clk_disable(dev_get_clk_ptr(clk->dev->parent)); if (ret) {
> - printf("Disable %s failed\n",
> - clkp->dev->parent->name);
> + printf("Disable %s failed (error
> %d)\n",
> + clk->dev->parent->name, ret);
> return ret;
> }
> }
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200206/fd5b0c00/attachment.sig>
next prev parent reply other threads:[~2020-02-06 21:45 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-02 19:56 [PATCH v3 00/12] riscv: Add Sipeed Maix support Sean Anderson
2020-02-02 19:58 ` [PATCH v3 01/12] clk: Always use the supplied struct clk Sean Anderson
2020-02-06 21:21 ` Lukasz Majewski
[not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA46D30F5@ATCPCS16.andestech.com>
2020-02-12 1:23 ` Rick Chen
2020-02-02 19:58 ` [PATCH v3 02/12] clk: Check that ops of composite clock components, exist before calling Sean Anderson
2020-02-06 21:41 ` Lukasz Majewski
2020-02-02 19:59 ` [PATCH v3 03/12] clk: Unconditionally recursively en-/dis-able clocks Sean Anderson
2020-02-06 21:45 ` Lukasz Majewski [this message]
2020-02-02 20:01 ` [PATCH v3 04/12] reset: Add generic reset driver Sean Anderson
2020-02-03 0:04 ` Simon Glass
2020-02-03 23:14 ` Sean Anderson
2020-02-04 11:06 ` Bin Meng
2020-02-04 14:14 ` Sean Anderson
2020-02-02 20:02 ` [PATCH v3 05/12] dm: Add support for simple-pm-bus Sean Anderson
2020-02-03 0:04 ` Simon Glass
2020-02-03 23:15 ` Sean Anderson
2020-02-05 0:16 ` Simon Glass
2020-02-04 11:13 ` Bin Meng
2020-02-02 20:04 ` [PATCH v3 06/12] riscv: Add headers for asm/global_data.h Sean Anderson
2020-02-04 11:17 ` Bin Meng
2020-02-02 20:05 ` [PATCH v3 07/12] riscv: Add option to support RISC-V privileged spec 1.9.1 Sean Anderson
2020-02-04 11:21 ` Bin Meng
2020-02-04 14:19 ` Sean Anderson
2020-02-04 14:38 ` Bin Meng
2020-02-04 14:48 ` Sean Anderson
2020-02-04 16:04 ` Bin Meng
2020-02-04 16:07 ` Sean Anderson
2020-02-02 20:06 ` [PATCH v3 08/12] riscv: Allow use of reset drivers Sean Anderson
2020-02-04 11:22 ` Bin Meng
2020-02-02 20:07 ` [PATCH v3 09/12] riscv: Add K210 pll support Sean Anderson
2020-02-02 20:07 ` [PATCH v3 10/12] riscv: Add K210 clock support Sean Anderson
2020-02-06 21:51 ` Lukasz Majewski
2020-02-02 20:10 ` [PATCH v3 11/12] riscv: Add device tree for K210 Sean Anderson
2020-02-04 11:32 ` Bin Meng
2020-02-04 14:23 ` Sean Anderson
2020-02-04 14:40 ` Bin Meng
2020-02-02 20:10 ` [PATCH v3 12/12] riscv: Add initial Sipeed Maix support Sean Anderson
2020-02-04 11:38 ` Bin Meng
2020-02-04 14:26 ` Sean Anderson
2020-02-04 14:42 ` Bin Meng
2020-02-04 14:49 ` Sean Anderson
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=20200206224532.7948ac20@jawa \
--to=lukma@denx.de \
--cc=u-boot@lists.denx.de \
/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