aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/clk-provider.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/clk-provider.h')
-rw-r--r--include/linux/clk-provider.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 7e59253b8603..939533da93a7 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -29,6 +29,7 @@
29#define CLK_IS_BASIC BIT(5) /* Basic clk, can't do a to_clk_foo() */ 29#define CLK_IS_BASIC BIT(5) /* Basic clk, can't do a to_clk_foo() */
30#define CLK_GET_RATE_NOCACHE BIT(6) /* do not use the cached clk rate */ 30#define CLK_GET_RATE_NOCACHE BIT(6) /* do not use the cached clk rate */
31#define CLK_SET_RATE_NO_REPARENT BIT(7) /* don't re-parent on rate change */ 31#define CLK_SET_RATE_NO_REPARENT BIT(7) /* don't re-parent on rate change */
32#define CLK_GET_ACCURACY_NOCACHE BIT(8) /* do not use the cached clk accuracy */
32 33
33struct clk_hw; 34struct clk_hw;
34 35
@@ -108,6 +109,25 @@ struct clk_hw;
108 * which is likely helpful for most .set_rate implementation. 109 * which is likely helpful for most .set_rate implementation.
109 * Returns 0 on success, -EERROR otherwise. 110 * Returns 0 on success, -EERROR otherwise.
110 * 111 *
112 * @recalc_accuracy: Recalculate the accuracy of this clock. The clock accuracy
113 * is expressed in ppb (parts per billion). The parent accuracy is
114 * an input parameter.
115 * Returns the calculated accuracy. Optional - if this op is not
116 * set then clock accuracy will be initialized to parent accuracy
117 * or 0 (perfect clock) if clock has no parent.
118 *
119 * @set_rate_and_parent: Change the rate and the parent of this clock. The
120 * requested rate is specified by the second argument, which
121 * should typically be the return of .round_rate call. The
122 * third argument gives the parent rate which is likely helpful
123 * for most .set_rate_and_parent implementation. The fourth
124 * argument gives the parent index. This callback is optional (and
125 * unnecessary) for clocks with 0 or 1 parents as well as
126 * for clocks that can tolerate switching the rate and the parent
127 * separately via calls to .set_parent and .set_rate.
128 * Returns 0 on success, -EERROR otherwise.
129 *
130 *
111 * The clk_enable/clk_disable and clk_prepare/clk_unprepare pairs allow 131 * The clk_enable/clk_disable and clk_prepare/clk_unprepare pairs allow
112 * implementations to split any work between atomic (enable) and sleepable 132 * implementations to split any work between atomic (enable) and sleepable
113 * (prepare) contexts. If enabling a clock requires code that might sleep, 133 * (prepare) contexts. If enabling a clock requires code that might sleep,
@@ -139,6 +159,11 @@ struct clk_ops {
139 u8 (*get_parent)(struct clk_hw *hw); 159 u8 (*get_parent)(struct clk_hw *hw);
140 int (*set_rate)(struct clk_hw *hw, unsigned long, 160 int (*set_rate)(struct clk_hw *hw, unsigned long,
141 unsigned long); 161 unsigned long);
162 int (*set_rate_and_parent)(struct clk_hw *hw,
163 unsigned long rate,
164 unsigned long parent_rate, u8 index);
165 unsigned long (*recalc_accuracy)(struct clk_hw *hw,
166 unsigned long parent_accuracy);
142 void (*init)(struct clk_hw *hw); 167 void (*init)(struct clk_hw *hw);
143}; 168};
144 169
@@ -194,6 +219,7 @@ struct clk_hw {
194struct clk_fixed_rate { 219struct clk_fixed_rate {
195 struct clk_hw hw; 220 struct clk_hw hw;
196 unsigned long fixed_rate; 221 unsigned long fixed_rate;
222 unsigned long fixed_accuracy;
197 u8 flags; 223 u8 flags;
198}; 224};
199 225
@@ -201,6 +227,9 @@ extern const struct clk_ops clk_fixed_rate_ops;
201struct clk *clk_register_fixed_rate(struct device *dev, const char *name, 227struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
202 const char *parent_name, unsigned long flags, 228 const char *parent_name, unsigned long flags,
203 unsigned long fixed_rate); 229 unsigned long fixed_rate);
230struct clk *clk_register_fixed_rate_with_accuracy(struct device *dev,
231 const char *name, const char *parent_name, unsigned long flags,
232 unsigned long fixed_rate, unsigned long fixed_accuracy);
204 233
205void of_fixed_clk_setup(struct device_node *np); 234void of_fixed_clk_setup(struct device_node *np);
206 235
@@ -433,6 +462,7 @@ struct clk *clk_get_parent_by_index(struct clk *clk, u8 index);
433unsigned int __clk_get_enable_count(struct clk *clk); 462unsigned int __clk_get_enable_count(struct clk *clk);
434unsigned int __clk_get_prepare_count(struct clk *clk); 463unsigned int __clk_get_prepare_count(struct clk *clk);
435unsigned long __clk_get_rate(struct clk *clk); 464unsigned long __clk_get_rate(struct clk *clk);
465unsigned long __clk_get_accuracy(struct clk *clk);
436unsigned long __clk_get_flags(struct clk *clk); 466unsigned long __clk_get_flags(struct clk *clk);
437bool __clk_is_prepared(struct clk *clk); 467bool __clk_is_prepared(struct clk *clk);
438bool __clk_is_enabled(struct clk *clk); 468bool __clk_is_enabled(struct clk *clk);
@@ -458,6 +488,8 @@ struct clk_onecell_data {
458 unsigned int clk_num; 488 unsigned int clk_num;
459}; 489};
460 490
491extern struct of_device_id __clk_of_table;
492
461#define CLK_OF_DECLARE(name, compat, fn) \ 493#define CLK_OF_DECLARE(name, compat, fn) \
462 static const struct of_device_id __clk_of_table_##name \ 494 static const struct of_device_id __clk_of_table_##name \
463 __used __section(__clk_of_table) \ 495 __used __section(__clk_of_table) \
@@ -512,6 +544,20 @@ static inline const char *of_clk_get_parent_name(struct device_node *np,
512 * for improved portability across platforms 544 * for improved portability across platforms
513 */ 545 */
514 546
547#if IS_ENABLED(CONFIG_PPC)
548
549static inline u32 clk_readl(u32 __iomem *reg)
550{
551 return ioread32be(reg);
552}
553
554static inline void clk_writel(u32 val, u32 __iomem *reg)
555{
556 iowrite32be(val, reg);
557}
558
559#else /* platform dependent I/O accessors */
560
515static inline u32 clk_readl(u32 __iomem *reg) 561static inline u32 clk_readl(u32 __iomem *reg)
516{ 562{
517 return readl(reg); 563 return readl(reg);
@@ -522,5 +568,7 @@ static inline void clk_writel(u32 val, u32 __iomem *reg)
522 writel(val, reg); 568 writel(val, reg);
523} 569}
524 570
571#endif /* platform dependent I/O accessors */
572
525#endif /* CONFIG_COMMON_CLK */ 573#endif /* CONFIG_COMMON_CLK */
526#endif /* CLK_PROVIDER_H */ 574#endif /* CLK_PROVIDER_H */