Merge branches 'clk-qcom-rpmh', 'clk-npcm7xx', 'clk-of-parent-count' and 'clk-qcom...
[platform/kernel/linux-rpi.git] / include / linux / clk-provider.h
index f711be6..f2c8fb8 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/io.h>
 #include <linux/of.h>
+#include <linux/of_clk.h>
 
 #ifdef CONFIG_COMMON_CLK
 
@@ -399,6 +400,7 @@ struct clk_divider {
        spinlock_t      *lock;
 };
 
+#define clk_div_mask(width)    ((1 << (width)) - 1)
 #define to_clk_divider(_hw) container_of(_hw, struct clk_divider, hw)
 
 #define CLK_DIVIDER_ONE_BASED          BIT(0)
@@ -419,6 +421,10 @@ long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
                               unsigned long rate, unsigned long *prate,
                               const struct clk_div_table *table,
                               u8 width, unsigned long flags);
+long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
+                                 unsigned long rate, unsigned long *prate,
+                                 const struct clk_div_table *table, u8 width,
+                                 unsigned long flags, unsigned int val);
 int divider_get_val(unsigned long rate, unsigned long parent_rate,
                const struct clk_div_table *table, u8 width,
                unsigned long flags);
@@ -449,8 +455,9 @@ void clk_hw_unregister_divider(struct clk_hw *hw);
  *
  * @hw:                handle between common and hardware-specific interfaces
  * @reg:       register controlling multiplexer
+ * @table:     array of register values corresponding to the parent index
  * @shift:     shift to multiplexer bit field
- * @width:     width of mutliplexer bit field
+ * @mask:      mask of mutliplexer bit field
  * @flags:     hardware-specific flags
  * @lock:      register lock
  *
@@ -510,6 +517,10 @@ struct clk_hw *clk_hw_register_mux_table(struct device *dev, const char *name,
                void __iomem *reg, u8 shift, u32 mask,
                u8 clk_mux_flags, u32 *table, spinlock_t *lock);
 
+int clk_mux_val_to_index(struct clk_hw *hw, u32 *table, unsigned int flags,
+                        unsigned int val);
+unsigned int clk_mux_index_to_val(u32 *table, unsigned int flags, u8 index);
+
 void clk_unregister_mux(struct clk *clk);
 void clk_hw_unregister_mux(struct clk_hw *hw);
 
@@ -774,6 +785,17 @@ static inline long divider_round_rate(struct clk_hw *hw, unsigned long rate,
                                         rate, prate, table, width, flags);
 }
 
+static inline long divider_ro_round_rate(struct clk_hw *hw, unsigned long rate,
+                                        unsigned long *prate,
+                                        const struct clk_div_table *table,
+                                        u8 width, unsigned long flags,
+                                        unsigned int val)
+{
+       return divider_ro_round_rate_parent(hw, clk_hw_get_parent(hw),
+                                           rate, prate, table, width, flags,
+                                           val);
+}
+
 /*
  * FIXME clock api without lock protection
  */
@@ -781,8 +803,6 @@ unsigned long clk_hw_round_rate(struct clk_hw *hw, unsigned long rate);
 
 struct of_device_id;
 
-typedef void (*of_clk_init_cb_t)(struct device_node *);
-
 struct clk_onecell_data {
        struct clk **clks;
        unsigned int clk_num;
@@ -869,13 +889,10 @@ struct clk_hw *of_clk_hw_simple_get(struct of_phandle_args *clkspec,
 struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data);
 struct clk_hw *of_clk_hw_onecell_get(struct of_phandle_args *clkspec,
                                     void *data);
-unsigned int of_clk_get_parent_count(struct device_node *np);
 int of_clk_parent_fill(struct device_node *np, const char **parents,
                       unsigned int size);
-const char *of_clk_get_parent_name(struct device_node *np, int index);
 int of_clk_detect_critical(struct device_node *np, int index,
                            unsigned long *flags);
-void of_clk_init(const struct of_device_id *matches);
 
 #else /* !CONFIG_OF */
 
@@ -922,26 +939,16 @@ of_clk_hw_onecell_get(struct of_phandle_args *clkspec, void *data)
 {
        return ERR_PTR(-ENOENT);
 }
-static inline unsigned int of_clk_get_parent_count(struct device_node *np)
-{
-       return 0;
-}
 static inline int of_clk_parent_fill(struct device_node *np,
                                     const char **parents, unsigned int size)
 {
        return 0;
 }
-static inline const char *of_clk_get_parent_name(struct device_node *np,
-                                                int index)
-{
-       return NULL;
-}
 static inline int of_clk_detect_critical(struct device_node *np, int index,
                                          unsigned long *flags)
 {
        return 0;
 }
-static inline void of_clk_init(const struct of_device_id *matches) {}
 #endif /* CONFIG_OF */
 
 /*