f5947f7e062c366d95191e6f723b510e015c8d3e
[openwrt/openwrt.git] / target / linux / layerscape / patches-4.4 / 8236-clk-add-API-of-clks.patch
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
5
6 Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
7 ---
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(+)
12
13 diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
14 index f13c3f4..0f6bcf5 100644
15 --- a/drivers/clk/clk.c
16 +++ b/drivers/clk/clk.c
17 @@ -359,6 +359,19 @@ static struct clk_core *clk_core_get_parent_by_index(struct clk_core *core,
18 return core->parents[index];
19 }
20
21 +struct clk *clk_get_parent_by_index(struct clk *clk, u8 index)
22 +{
23 + struct clk_core *parent;
24 +
25 + if (!clk)
26 + return NULL;
27 +
28 + parent = clk_core_get_parent_by_index(clk->core, index);
29 +
30 + return !parent ? NULL : parent->hw->clk;
31 +}
32 +EXPORT_SYMBOL_GPL(clk_get_parent_by_index);
33 +
34 struct clk_hw *
35 clk_hw_get_parent_by_index(const struct clk_hw *hw, unsigned int index)
36 {
37 @@ -2033,6 +2046,12 @@ static const struct file_operations clk_summary_fops = {
38 .release = single_release,
39 };
40
41 +unsigned int clk_get_num_parents(struct clk *clk)
42 +{
43 + return !clk ? 0 : clk->core->num_parents;
44 +}
45 +EXPORT_SYMBOL_GPL(clk_get_num_parents);
46 +
47 static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level)
48 {
49 if (!c)
50 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
51 index 7cd0171..77dfd61 100644
52 --- a/include/linux/clk-provider.h
53 +++ b/include/linux/clk-provider.h
54 @@ -650,6 +650,7 @@ unsigned int clk_hw_get_num_parents(const struct clk_hw *hw);
55 struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw);
56 struct clk_hw *clk_hw_get_parent_by_index(const struct clk_hw *hw,
57 unsigned int index);
58 +struct clk *clk_get_parent_by_index(struct clk *clk, u8 index);
59 unsigned int __clk_get_enable_count(struct clk *clk);
60 unsigned long clk_hw_get_rate(const struct clk_hw *hw);
61 unsigned long __clk_get_flags(struct clk *clk);
62 diff --git a/include/linux/clk.h b/include/linux/clk.h
63 index 0df4a51..1df90e3 100644
64 --- a/include/linux/clk.h
65 +++ b/include/linux/clk.h
66 @@ -392,6 +392,15 @@ int clk_set_parent(struct clk *clk, struct clk *parent);
67 struct clk *clk_get_parent(struct clk *clk);
68
69 /**
70 + * clk_get_num_parents - get number of possible parents
71 + * @clk: clock source
72 + *
73 + * Returns the number of possible parents of this clock,
74 + * which can then be enumerated using clk_get_parent_by_index().
75 + */
76 +unsigned int clk_get_num_parents(struct clk *clk);
77 +
78 +/**
79 * clk_get_sys - get a clock based upon the device name
80 * @dev_id: device name
81 * @con_id: connection ID
82 --
83 1.7.9.5
84