openwrt/target/linux/layerscape/patches-4.4/8236-clk-add-API-of-clks.patch

85 lines
2.6 KiB
Diff
Raw Normal View History

From df2373ca941741f3f66750241a048ad4e2ff2c91 Mon Sep 17 00:00:00 2001
From: Zhao Qiang <qiang.zhao@nxp.com>
Date: Thu, 24 Nov 2016 11:47:45 +0800
Subject: [PATCH 236/238] clk: add API of clks
Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
---
drivers/clk/clk.c | 19 +++++++++++++++++++
include/linux/clk-provider.h | 1 +
include/linux/clk.h | 9 +++++++++
3 files changed, 29 insertions(+)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index f13c3f4..0f6bcf5 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -359,6 +359,19 @@ static struct clk_core *clk_core_get_parent_by_index(struct clk_core *core,
return core->parents[index];
}
+struct clk *clk_get_parent_by_index(struct clk *clk, u8 index)
+{
+ struct clk_core *parent;
+
+ if (!clk)
+ return NULL;
+
+ parent = clk_core_get_parent_by_index(clk->core, index);
+
+ return !parent ? NULL : parent->hw->clk;
+}
+EXPORT_SYMBOL_GPL(clk_get_parent_by_index);
+
struct clk_hw *
clk_hw_get_parent_by_index(const struct clk_hw *hw, unsigned int index)
{
@@ -2033,6 +2046,12 @@ static const struct file_operations clk_summary_fops = {
.release = single_release,
};
+unsigned int clk_get_num_parents(struct clk *clk)
+{
+ return !clk ? 0 : clk->core->num_parents;
+}
+EXPORT_SYMBOL_GPL(clk_get_num_parents);
+
static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level)
{
if (!c)
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 7cd0171..77dfd61 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -650,6 +650,7 @@ unsigned int clk_hw_get_num_parents(const struct clk_hw *hw);
struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw);
struct clk_hw *clk_hw_get_parent_by_index(const struct clk_hw *hw,
unsigned int index);
+struct clk *clk_get_parent_by_index(struct clk *clk, u8 index);
unsigned int __clk_get_enable_count(struct clk *clk);
unsigned long clk_hw_get_rate(const struct clk_hw *hw);
unsigned long __clk_get_flags(struct clk *clk);
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 0df4a51..1df90e3 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -392,6 +392,15 @@ int clk_set_parent(struct clk *clk, struct clk *parent);
struct clk *clk_get_parent(struct clk *clk);
/**
+ * clk_get_num_parents - get number of possible parents
+ * @clk: clock source
+ *
+ * Returns the number of possible parents of this clock,
+ * which can then be enumerated using clk_get_parent_by_index().
+ */
+unsigned int clk_get_num_parents(struct clk *clk);
+
+/**
* clk_get_sys - get a clock based upon the device name
* @dev_id: device name
* @con_id: connection ID
--
1.7.9.5