public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 07/11] dm: clk: Define clk_get_parent_rate() for clk operations
Date: Fri, 26 Apr 2019 08:04:20 +0200	[thread overview]
Message-ID: <20190426080420.033cf01c@jawa> (raw)
In-Reply-To: <DB7PR04MB449072A1241740B713D42552883E0@DB7PR04MB4490.eurprd04.prod.outlook.com>

Hi Peng,

Thank you for your feedback.

> > Subject: [PATCH v3 07/11] dm: clk: Define clk_get_parent_rate() for
> > clk operations
> > 
> > This commit adds the clk_get_parent_rate() function, which is
> > responsible for getting the rate of parent clock.
> > Unfortunately, u-boot's DM support for getting parent is different
> > (the parent relationship is in udevice) than the one in common
> > clock framework (CCF) in Linux.
> > 
> > To alleviate this problem - the clk_get_parent_rate() function has
> > been introduced to clk-uclass.c.
> > 
> > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> > 
> > ---
> > 
> > Changes in v3:
> > - The rate information is now cached into struct clk field
> > - The clk_get_parent() is used to get pointer to the parent struct
> > clk
> > 
> >  drivers/clk/clk-uclass.c | 22 ++++++++++++++++++++++
> >  include/clk.h            |  9 +++++++++
> >  2 files changed, 31 insertions(+)
> > 
> > diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
> > index 7ebe4e79fe..da6624d4f2 100644
> > --- a/drivers/clk/clk-uclass.c
> > +++ b/drivers/clk/clk-uclass.c
> > @@ -355,6 +355,28 @@ struct clk *clk_get_parent(struct clk *clk)
> >  	return pclk;
> >  }
> > 
> > +ulong clk_get_parent_rate(struct clk *clk) {
> > +	const struct clk_ops *ops;
> > +	struct clk *pclk;
> > +
> > +	debug("%s(clk=%p)\n", __func__, clk);
> > +
> > +	pclk = clk_get_parent(clk);
> > +	if (IS_ERR(pclk))
> > +		return -ENODEV;
> > +
> > +	ops = clk_dev_ops(pclk->dev);
> > +	if (!ops->get_rate)
> > +		return -ENOSYS;
> > +
> > +	/* Read the 'rate' if not already set */
> > +	if (!pclk->rate)
> > +		pclk->rate = clk_get_rate(pclk);  
> 
> Suggest a flag NOCACHE like Linux,
> in clk_get_rate, check the flag, if not set,
> just read the cached value.
> 
> How do you think?

No problem from my side. I will wait a few more days for more feedback
nad prepare next version of CCF port.

Please also look on the design decision described in the cover letter:
http://patchwork.ozlabs.org/cover/1090669/

(There is also link to github repo with those patches).
Maybe you would have other idea for solving mentioned problems?



I would also like to make the CCF code as much IMX SoC agnostic as
possible - in other words - make it working on iMX6Q and iMX8 from
the outset (so I would know that other SoCs would be easily added).

> 
> Regards,
> Peng.
> 
> > +
> > +	return pclk->rate;
> > +}
> > +
> >  ulong clk_set_rate(struct clk *clk, ulong rate)  {
> >  	const struct clk_ops *ops = clk_dev_ops(clk->dev); diff
> > --git a/include/clk.h b/include/clk.h index b44ee3b158..98c3e12fb4
> > 100644 --- a/include/clk.h
> > +++ b/include/clk.h
> > @@ -249,6 +249,15 @@ ulong clk_get_rate(struct clk *clk);  struct
> > clk *clk_get_parent(struct clk *clk);
> > 
> >  /**
> > + * clk_get_parent_rate() - Get parent of current clock rate.
> > + *
> > + * @clk:	A clock struct that was previously successfully
> > requested by
> > + *		clk_request/get_by_*().
> > + * @return clock rate in Hz, or -ve error code.
> > + */
> > +ulong clk_get_parent_rate(struct clk *clk);
> > +
> > +/**
> >   * clk_set_rate() - Set current clock rate.
> >   *
> >   * @clk:	A clock struct that was previously successfully
> > requested by --
> > 2.11.0  
> 




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: <http://lists.denx.de/pipermail/u-boot/attachments/20190426/4378824c/attachment.sig>

  reply	other threads:[~2019-04-26  6:04 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-25 10:29 [U-Boot] [PATCH v3 00/11] clk: Port Linux common clock framework [CCF] to U-boot (tag: 5.0-rc3) Lukasz Majewski
2019-04-25 10:29 ` [U-Boot] [PATCH v3 01/11] dm: Fix documentation entry as there is no UCLASS_CLOCK uclass Lukasz Majewski
2019-04-26  2:16   ` Peng Fan
2019-04-25 10:29 ` [U-Boot] [PATCH v3 02/11] cmd: Do not show frequency for clocks which .get_rate() return error Lukasz Majewski
2019-04-26  2:17   ` Peng Fan
2019-04-25 10:29 ` [U-Boot] [PATCH v3 03/11] clk: Remove clock ID check in .get_rate() of clk_fixed_* Lukasz Majewski
2019-04-26  2:17   ` Peng Fan
2019-04-25 10:29 ` [U-Boot] [PATCH v3 04/11] clk: Extend struct clk to provide information regarding clock rate Lukasz Majewski
2019-04-26  2:23   ` Peng Fan
2019-04-25 10:29 ` [U-Boot] [PATCH v3 05/11] clk: Provide struct clk for fixed rate clock (clk_fixed_rate.c) Lukasz Majewski
2019-04-26  2:29   ` Peng Fan
2019-04-25 10:29 ` [U-Boot] [PATCH v3 06/11] dm: clk: Define clk_get_parent() for clk operations Lukasz Majewski
2019-04-26  2:31   ` Peng Fan
2019-04-25 10:29 ` [U-Boot] [PATCH v3 07/11] dm: clk: Define clk_get_parent_rate() " Lukasz Majewski
2019-04-26  2:36   ` Peng Fan
2019-04-26  6:04     ` Lukasz Majewski [this message]
2019-04-25 10:29 ` [U-Boot] [PATCH v3 08/11] dm: clk: Define clk_get_by_id() " Lukasz Majewski
2019-04-26  2:39   ` Peng Fan
2019-04-25 10:29 ` [U-Boot] [PATCH v3 09/11] clk: test: Provide unit test for clk_get_by_id() method Lukasz Majewski
2019-04-25 10:29 ` [U-Boot] [PATCH v3 10/11] clk: test: Provide unit test for clk_get_parent_rate() method Lukasz Majewski
2019-04-25 10:29 ` [U-Boot] [PATCH v3 11/11] clk: Port Linux common clock framework [CCF] for imx6q to U-boot (tag: 5.0-rc3) Lukasz Majewski
2019-04-26  2:54   ` Peng Fan
2019-05-08  7:25 ` [U-Boot] [PATCH v3 00/11] clk: Port Linux common clock framework [CCF] " Lukasz Majewski
2019-05-18 16:08 ` Simon Glass
2019-05-18 21:28   ` Lukasz Majewski
2019-05-18 22:21     ` Simon Glass
2019-05-19 21:03       ` Lukasz Majewski
2019-05-20 16:09         ` Simon Glass
2019-05-21 14:48           ` Lukasz Majewski
2019-05-22  0:53             ` Simon Glass
2019-05-30  3:04               ` Peng Fan
2019-05-30  8:17                 ` Marek Vasut
2019-06-03  7:22                 ` Lukasz Majewski
2019-06-22 19:09                   ` 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=20190426080420.033cf01c@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