public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wenyou Yang <wenyou.yang@microchip.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/3] clk: at91: clk-system: add set/get_rate operations
Date: Fri, 9 Feb 2018 11:34:52 +0800	[thread overview]
Message-ID: <20180209033452.15448-4-wenyou.yang@microchip.com> (raw)
In-Reply-To: <20180209033452.15448-1-wenyou.yang@microchip.com>

To support set/get the clock rate, add set/get_rate operations.

Signed-off-by: Wenyou Yang <wenyou.yang@microchip.com>
---

 drivers/clk/at91/clk-system.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/clk/at91/clk-system.c b/drivers/clk/at91/clk-system.c
index 24b271aa18..81fe47a9d7 100644
--- a/drivers/clk/at91/clk-system.c
+++ b/drivers/clk/at91/clk-system.c
@@ -44,6 +44,30 @@ static inline int is_pck(int id)
 	return (id >= 8) && (id <= 15);
 }
 
+static ulong system_clk_get_rate(struct clk *clk)
+{
+	struct clk clk_dev;
+	int ret;
+
+	ret = clk_get_by_index(clk->dev, 0, &clk_dev);
+	if (ret)
+		return -EINVAL;
+
+	return clk_get_rate(&clk_dev);
+}
+
+static ulong system_clk_set_rate(struct clk *clk, ulong rate)
+{
+	struct clk clk_dev;
+	int ret;
+
+	ret = clk_get_by_index(clk->dev, 0, &clk_dev);
+	if (ret)
+		return -EINVAL;
+
+	return clk_set_rate(&clk_dev, rate);
+}
+
 static int system_clk_enable(struct clk *clk)
 {
 	struct pmc_platdata *plat = dev_get_platdata(clk->dev);
@@ -73,6 +97,8 @@ static int system_clk_enable(struct clk *clk)
 
 static struct clk_ops system_clk_ops = {
 	.of_xlate = at91_clk_of_xlate,
+	.get_rate = system_clk_get_rate,
+	.set_rate = system_clk_set_rate,
 	.enable = system_clk_enable,
 };
 
-- 
2.16.0.rc1

  parent reply	other threads:[~2018-02-09  3:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09  3:34 [U-Boot] [PATCH 0/3] clk: at91: add usb and plladiv drivers Wenyou Yang
2018-02-09  3:34 ` [U-Boot] [PATCH 1/3] clk: at91: add USB Host clock driver Wenyou Yang
2018-03-16 13:50   ` [U-Boot] [U-Boot,1/3] " Tom Rini
2018-02-09  3:34 ` [U-Boot] [PATCH 2/3] clk: at91: add PLLADIV driver Wenyou Yang
2018-03-16 13:50   ` [U-Boot] [U-Boot,2/3] " Tom Rini
2018-02-09  3:34 ` Wenyou Yang [this message]
2018-03-16 13:50   ` [U-Boot] [U-Boot, 3/3] clk: at91: clk-system: add set/get_rate operations Tom Rini
2018-03-06  4:02 ` [U-Boot] [PATCH 0/3] clk: at91: add usb and plladiv drivers Wenyou Yang

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=20180209033452.15448-4-wenyou.yang@microchip.com \
    --to=wenyou.yang@microchip.com \
    --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