1 From df2373ca941741f3f66750241a048ad4e2ff2c91 Mon Sep 17 00:00:00 2001
2 From: Zhao Qiang <qiang.zhao@nxp.com>
3 Date: Thu, 24 Nov 2016 11:47:45 +0800
4 Subject: [PATCH 236/238] clk: add API of clks
6 Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
8 drivers/clk/clk.c | 19 +++++++++++++++++++
9 include/linux/clk-provider.h | 1 +
10 include/linux/clk.h | 9 +++++++++
11 3 files changed, 29 insertions(+)
13 --- a/drivers/clk/clk.c
14 +++ b/drivers/clk/clk.c
15 @@ -359,6 +359,19 @@ static struct clk_core *clk_core_get_par
16 return core->parents[index];
19 +struct clk *clk_get_parent_by_index(struct clk *clk, u8 index)
21 + struct clk_core *parent;
26 + parent = clk_core_get_parent_by_index(clk->core, index);
28 + return !parent ? NULL : parent->hw->clk;
30 +EXPORT_SYMBOL_GPL(clk_get_parent_by_index);
33 clk_hw_get_parent_by_index(const struct clk_hw *hw, unsigned int index)
35 @@ -2033,6 +2046,12 @@ static const struct file_operations clk_
36 .release = single_release,
39 +unsigned int clk_get_num_parents(struct clk *clk)
41 + return !clk ? 0 : clk->core->num_parents;
43 +EXPORT_SYMBOL_GPL(clk_get_num_parents);
45 static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level)
48 --- a/include/linux/clk-provider.h
49 +++ b/include/linux/clk-provider.h
50 @@ -656,6 +656,7 @@ unsigned int clk_hw_get_num_parents(cons
51 struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw);
52 struct clk_hw *clk_hw_get_parent_by_index(const struct clk_hw *hw,
54 +struct clk *clk_get_parent_by_index(struct clk *clk, u8 index);
55 unsigned int __clk_get_enable_count(struct clk *clk);
56 unsigned long clk_hw_get_rate(const struct clk_hw *hw);
57 unsigned long __clk_get_flags(struct clk *clk);
58 --- a/include/linux/clk.h
59 +++ b/include/linux/clk.h
60 @@ -392,6 +392,15 @@ int clk_set_parent(struct clk *clk, stru
61 struct clk *clk_get_parent(struct clk *clk);
64 + * clk_get_num_parents - get number of possible parents
65 + * @clk: clock source
67 + * Returns the number of possible parents of this clock,
68 + * which can then be enumerated using clk_get_parent_by_index().
70 +unsigned int clk_get_num_parents(struct clk *clk);
73 * clk_get_sys - get a clock based upon the device name
74 * @dev_id: device name
75 * @con_id: connection ID