This source file includes following definitions.
- clk_is_enabled_regmap
- clk_enable_regmap
- clk_disable_regmap
- devm_clk_register_regmap
1
2
3
4
5
6 #include <linux/device.h>
7 #include <linux/clk-provider.h>
8 #include <linux/regmap.h>
9 #include <linux/export.h>
10
11 #include "clk-regmap.h"
12
13
14
15
16
17
18
19
20
21
22 int clk_is_enabled_regmap(struct clk_hw *hw)
23 {
24 struct clk_regmap *rclk = to_clk_regmap(hw);
25 unsigned int val;
26 int ret;
27
28 ret = regmap_read(rclk->regmap, rclk->enable_reg, &val);
29 if (ret != 0)
30 return ret;
31
32 if (rclk->enable_is_inverted)
33 return (val & rclk->enable_mask) == 0;
34 else
35 return (val & rclk->enable_mask) != 0;
36 }
37 EXPORT_SYMBOL_GPL(clk_is_enabled_regmap);
38
39
40
41
42
43
44
45
46
47
48 int clk_enable_regmap(struct clk_hw *hw)
49 {
50 struct clk_regmap *rclk = to_clk_regmap(hw);
51 unsigned int val;
52
53 if (rclk->enable_is_inverted)
54 val = 0;
55 else
56 val = rclk->enable_mask;
57
58 return regmap_update_bits(rclk->regmap, rclk->enable_reg,
59 rclk->enable_mask, val);
60 }
61 EXPORT_SYMBOL_GPL(clk_enable_regmap);
62
63
64
65
66
67
68
69
70
71
72 void clk_disable_regmap(struct clk_hw *hw)
73 {
74 struct clk_regmap *rclk = to_clk_regmap(hw);
75 unsigned int val;
76
77 if (rclk->enable_is_inverted)
78 val = rclk->enable_mask;
79 else
80 val = 0;
81
82 regmap_update_bits(rclk->regmap, rclk->enable_reg, rclk->enable_mask,
83 val);
84 }
85 EXPORT_SYMBOL_GPL(clk_disable_regmap);
86
87
88
89
90
91
92
93
94
95
96 int devm_clk_register_regmap(struct device *dev, struct clk_regmap *rclk)
97 {
98 if (dev && dev_get_regmap(dev, NULL))
99 rclk->regmap = dev_get_regmap(dev, NULL);
100 else if (dev && dev->parent)
101 rclk->regmap = dev_get_regmap(dev->parent, NULL);
102
103 return devm_clk_hw_register(dev, &rclk->hw);
104 }
105 EXPORT_SYMBOL_GPL(devm_clk_register_regmap);