public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sean Anderson <seanga2@gmail.com>
To: Samuel Holland <samuel@sholland.org>,
	Lukasz Majewski <lukma@denx.de>, Simon Glass <sjg@chromium.org>
Cc: Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Jean-Jacques Hiblot <jjhiblot@ti.com>,
	Michal Suchanek <msuchanek@suse.de>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Peng Fan <peng.fan@nxp.com>,
	u-boot@lists.denx.de
Subject: Re: [PATCH 6/6] clk: Add a .get_parent operation
Date: Mon, 20 Feb 2023 11:13:07 -0500	[thread overview]
Message-ID: <fd064899-8604-63ae-b0f1-0dd07bfe23a9@gmail.com> (raw)
In-Reply-To: <20230220055940.41890-7-samuel@sholland.org>

On 2/20/23 00:59, Samuel Holland wrote:
> This allows clk_get_parent() to work with non-CCF clock drivers.
> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
> 
>   drivers/clk/clk-uclass.c | 18 ++++++++++++------
>   include/clk-uclass.h     |  2 ++
>   2 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
> index 53cfd819779..d0f8906cd60 100644
> --- a/drivers/clk/clk-uclass.c
> +++ b/drivers/clk/clk-uclass.c
> @@ -485,6 +485,7 @@ ulong clk_get_rate(struct clk *clk)
>   
>   struct clk *clk_get_parent(struct clk *clk)
>   {
> +	const struct clk_ops *ops;
>   	struct udevice *pdev;
>   	struct clk *pclk;
>   
> @@ -492,12 +493,17 @@ struct clk *clk_get_parent(struct clk *clk)
>   	if (!clk_valid(clk))
>   		return ERR_PTR(-ENODEV);
>   
> -	pdev = dev_get_parent(clk->dev);
> -	if (!pdev)
> -		return ERR_PTR(-ENODEV);
> -	pclk = dev_get_clk_ptr(pdev);
> -	if (!pclk)
> -		return ERR_PTR(-ENODEV);
> +	ops = clk_dev_ops(clk->dev);
> +	if (ops->get_parent) {
> +		pclk = ops->get_parent(clk);
> +	} else {
> +		pdev = dev_get_parent(clk->dev);
> +		if (!pdev)
> +			return ERR_PTR(-ENODEV);
> +		pclk = dev_get_clk_ptr(pdev);
> +		if (!pclk)
> +			return ERR_PTR(-ENODEV);
> +	}
>   
>   	return pclk;
>   }
> diff --git a/include/clk-uclass.h b/include/clk-uclass.h
> index 65ebff9ed27..4d616720865 100644
> --- a/include/clk-uclass.h
> +++ b/include/clk-uclass.h
> @@ -22,6 +22,7 @@ struct ofnode_phandle_args;
>    * @round_rate: Adjust a rate to the exact rate a clock can provide.
>    * @get_rate: Get current clock rate.
>    * @set_rate: Set current clock rate.
> + * @get_parent: Get current clock parent
>    * @set_parent: Set current clock parent
>    * @enable: Enable a clock.
>    * @disable: Disable a clock.
> @@ -36,6 +37,7 @@ struct clk_ops {
>   	ulong (*round_rate)(struct clk *clk, ulong rate);
>   	ulong (*get_rate)(struct clk *clk);
>   	ulong (*set_rate)(struct clk *clk, ulong rate);
> +	struct clk *(*get_parent)(struct clk *clk);
>   	int (*set_parent)(struct clk *clk, struct clk *parent);
>   	int (*enable)(struct clk *clk);
>   	int (*disable)(struct clk *clk);

Missing documentation.

--Sean

  reply	other threads:[~2023-02-20 16:13 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-20  5:59 [PATCH 0/6] clk: uclass fixes and improvements Samuel Holland
2023-02-20  5:59 ` [PATCH 1/6] clk: Handle error pointers in clk_valid() Samuel Holland
2023-02-20 10:46   ` Michal Suchánek
2023-02-20 15:57     ` Sean Anderson
2023-02-20 19:42       ` Michal Suchánek
2023-03-04 19:54         ` Samuel Holland
2023-03-04 20:43           ` Michal Suchánek
2023-02-20  5:59 ` [PATCH 2/6] clk: Fix error handling in clk_get_rate() Samuel Holland
2023-02-20 10:37   ` Michal Suchánek
2023-02-20 16:08     ` Sean Anderson
2023-02-20 17:27       ` Michal Suchánek
2023-02-20 17:58         ` Sean Anderson
2023-02-20  5:59 ` [PATCH 3/6] clk: Fix error handling in clk_get_parent() Samuel Holland
2023-02-20 10:39   ` Michal Suchánek
2023-03-04 19:58     ` Samuel Holland
2023-03-04 20:46       ` Michal Suchánek
2023-03-04 21:25         ` Sean Anderson
2023-02-20  5:59 ` [PATCH 4/6] clk: Fix rate caching in clk_get_parent_rate() Samuel Holland
2023-02-20 10:41   ` Michal Suchánek
2023-02-20 16:11   ` Sean Anderson
2023-03-04 20:01     ` Samuel Holland
2023-02-20  5:59 ` [PATCH 5/6] clk: Remove an unneeded check from clk_get_parent_rate() Samuel Holland
2023-02-20 10:49   ` Michal Suchánek
2023-02-20 16:12   ` Sean Anderson
2023-02-20  5:59 ` [PATCH 6/6] clk: Add a .get_parent operation Samuel Holland
2023-02-20 16:13   ` Sean Anderson [this message]
2023-02-20 16:21   ` Simon Glass

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=fd064899-8604-63ae-b0f1-0dd07bfe23a9@gmail.com \
    --to=seanga2@gmail.com \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=jjhiblot@ti.com \
    --cc=lukma@denx.de \
    --cc=msuchanek@suse.de \
    --cc=neil.armstrong@linaro.org \
    --cc=peng.fan@nxp.com \
    --cc=samuel@sholland.org \
    --cc=sjg@chromium.org \
    --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