diff mbox

[U-Boot,v2,5/6] clk: add API to enable clock

Message ID 1452658573-6942-6-git-send-email-yamada.masahiro@socionext.com
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Masahiro Yamada Jan. 13, 2016, 4:16 a.m. UTC
The most basic thing for clock is to enable it, but it is missing
in this uclass.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
  - Add clk_enable() function

 drivers/clk/clk-uclass.c | 10 ++++++++++
 include/clk.h            | 18 ++++++++++++++++++
 2 files changed, 28 insertions(+)

Comments

Simon Glass Jan. 18, 2016, 3:58 a.m. UTC | #1
On 12 January 2016 at 21:16, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> The most basic thing for clock is to enable it, but it is missing
> in this uclass.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> Acked-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2:
>   - Add clk_enable() function
>
>  drivers/clk/clk-uclass.c | 10 ++++++++++
>  include/clk.h            | 18 ++++++++++++++++++
>  2 files changed, 28 insertions(+)

Applied to u-boot-dm, thanks!
diff mbox

Patch

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index a5bef59..ac3909d 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -32,6 +32,16 @@  long clk_set_rate(struct udevice *dev, ulong rate)
 	return ops->set_rate(dev, rate);
 }
 
+int clk_enable(struct udevice *dev, int periph)
+{
+	struct clk_ops *ops = clk_get_ops(dev);
+
+	if (!ops->enable)
+		return -ENOSYS;
+
+	return ops->enable(dev, periph);
+}
+
 long clk_get_periph_rate(struct udevice *dev, int periph)
 {
 	struct clk_ops *ops = clk_get_ops(dev);
diff --git a/include/clk.h b/include/clk.h
index 61bb468..de15999 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -33,6 +33,15 @@  struct clk_ops {
 	long (*set_rate)(struct udevice *dev, ulong rate);
 
 	/**
+	 * enable() - Enable the clock for a peripheral
+	 *
+	 * @dev:	clock provider
+	 * @periph:	Peripheral ID to enable
+	 * @return zero on success, or -ve error code
+	 */
+	int (*enable)(struct udevice *dev, int periph);
+
+	/**
 	 * get_periph_rate() - Get clock rate for a peripheral
 	 *
 	 * @dev:	Device to check (UCLASS_CLK)
@@ -71,6 +80,15 @@  long clk_get_rate(struct udevice *dev);
 long clk_set_rate(struct udevice *dev, ulong rate);
 
 /**
+ * clk_enable() - Enable the clock for a peripheral
+ *
+ * @dev:	clock provider
+ * @periph:	Peripheral ID to enable
+ * @return zero on success, or -ve error code
+ */
+int clk_enable(struct udevice *dev, int periph);
+
+/**
  * clk_get_periph_rate() - Get current clock rate for a peripheral
  *
  * @dev:	Device to check (UCLASS_CLK)