Merge drm/drm-next into drm-intel-next-queued
[linux-2.6-microblaze.git] / include / linux / clk-provider.h
index bb6118f..2ae7604 100644 (file)
@@ -9,8 +9,6 @@
 #include <linux/of.h>
 #include <linux/of_clk.h>
 
-#ifdef CONFIG_COMMON_CLK
-
 /*
  * flags used across common struct clk.  these flags should only affect the
  * top-level framework.  custom flags for dealing with hardware specifics
@@ -807,7 +805,14 @@ void devm_clk_hw_unregister(struct device *dev, struct clk_hw *hw);
 /* helper functions */
 const char *__clk_get_name(const struct clk *clk);
 const char *clk_hw_get_name(const struct clk_hw *hw);
+#ifdef CONFIG_COMMON_CLK
 struct clk_hw *__clk_get_hw(struct clk *clk);
+#else
+static inline struct clk_hw *__clk_get_hw(struct clk *clk)
+{
+       return (struct clk_hw *)clk;
+}
+#endif
 unsigned int clk_hw_get_num_parents(const struct clk_hw *hw);
 struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw);
 struct clk_hw *clk_hw_get_parent_by_index(const struct clk_hw *hw,
@@ -867,8 +872,6 @@ static inline long divider_ro_round_rate(struct clk_hw *hw, unsigned long rate,
  */
 unsigned long clk_hw_round_rate(struct clk_hw *hw, unsigned long rate);
 
-struct of_device_id;
-
 struct clk_onecell_data {
        struct clk **clks;
        unsigned int clk_num;
@@ -879,8 +882,6 @@ struct clk_hw_onecell_data {
        struct clk_hw *hws[];
 };
 
-extern struct of_device_id __clk_of_table;
-
 #define CLK_OF_DECLARE(name, compat, fn) OF_DECLARE_1(clk, name, compat, fn)
 
 /*
@@ -904,6 +905,40 @@ extern struct of_device_id __clk_of_table;
                .ops            = _ops,                         \
        })
 
+#define CLK_HW_INIT_HW(_name, _parent, _ops, _flags)                   \
+       (&(struct clk_init_data) {                                      \
+               .flags          = _flags,                               \
+               .name           = _name,                                \
+               .parent_hws     = (const struct clk_hw*[]) { _parent }, \
+               .num_parents    = 1,                                    \
+               .ops            = _ops,                                 \
+       })
+
+/*
+ * This macro is intended for drivers to be able to share the otherwise
+ * individual struct clk_hw[] compound literals created by the compiler
+ * when using CLK_HW_INIT_HW. It does NOT support multiple parents.
+ */
+#define CLK_HW_INIT_HWS(_name, _parent, _ops, _flags)                  \
+       (&(struct clk_init_data) {                                      \
+               .flags          = _flags,                               \
+               .name           = _name,                                \
+               .parent_hws     = _parent,                              \
+               .num_parents    = 1,                                    \
+               .ops            = _ops,                                 \
+       })
+
+#define CLK_HW_INIT_FW_NAME(_name, _parent, _ops, _flags)              \
+       (&(struct clk_init_data) {                                      \
+               .flags          = _flags,                               \
+               .name           = _name,                                \
+               .parent_data    = (const struct clk_parent_data[]) {    \
+                                       { .fw_name = _parent },         \
+                                 },                                    \
+               .num_parents    = 1,                                    \
+               .ops            = _ops,                                 \
+       })
+
 #define CLK_HW_INIT_PARENTS(_name, _parents, _ops, _flags)     \
        (&(struct clk_init_data) {                              \
                .flags          = _flags,                       \
@@ -913,6 +948,24 @@ extern struct of_device_id __clk_of_table;
                .ops            = _ops,                         \
        })
 
+#define CLK_HW_INIT_PARENTS_HW(_name, _parents, _ops, _flags)  \
+       (&(struct clk_init_data) {                              \
+               .flags          = _flags,                       \
+               .name           = _name,                        \
+               .parent_hws     = _parents,                     \
+               .num_parents    = ARRAY_SIZE(_parents),         \
+               .ops            = _ops,                         \
+       })
+
+#define CLK_HW_INIT_PARENTS_DATA(_name, _parents, _ops, _flags)        \
+       (&(struct clk_init_data) {                              \
+               .flags          = _flags,                       \
+               .name           = _name,                        \
+               .parent_data    = _parents,                     \
+               .num_parents    = ARRAY_SIZE(_parents),         \
+               .ops            = _ops,                         \
+       })
+
 #define CLK_HW_INIT_NO_PARENT(_name, _ops, _flags)     \
        (&(struct clk_init_data) {                      \
                .flags          = _flags,               \
@@ -933,6 +986,43 @@ extern struct of_device_id __clk_of_table;
                                              _flags),                  \
        }
 
+#define CLK_FIXED_FACTOR_HW(_struct, _name, _parent,                   \
+                           _div, _mult, _flags)                        \
+       struct clk_fixed_factor _struct = {                             \
+               .div            = _div,                                 \
+               .mult           = _mult,                                \
+               .hw.init        = CLK_HW_INIT_HW(_name,                 \
+                                                _parent,               \
+                                                &clk_fixed_factor_ops, \
+                                                _flags),               \
+       }
+
+/*
+ * This macro allows the driver to reuse the _parent array for multiple
+ * fixed factor clk declarations.
+ */
+#define CLK_FIXED_FACTOR_HWS(_struct, _name, _parent,                  \
+                            _div, _mult, _flags)                       \
+       struct clk_fixed_factor _struct = {                             \
+               .div            = _div,                                 \
+               .mult           = _mult,                                \
+               .hw.init        = CLK_HW_INIT_HWS(_name,                \
+                                                 _parent,              \
+                                                 &clk_fixed_factor_ops, \
+                                                 _flags),      \
+       }
+
+#define CLK_FIXED_FACTOR_FW_NAME(_struct, _name, _parent,              \
+                                _div, _mult, _flags)                   \
+       struct clk_fixed_factor _struct = {                             \
+               .div            = _div,                                 \
+               .mult           = _mult,                                \
+               .hw.init        = CLK_HW_INIT_FW_NAME(_name,            \
+                                                     _parent,          \
+                                                     &clk_fixed_factor_ops, \
+                                                     _flags),          \
+       }
+
 #ifdef CONFIG_OF
 int of_clk_add_provider(struct device_node *np,
                        struct clk *(*clk_src_get)(struct of_phandle_args *args,
@@ -1019,5 +1109,4 @@ static inline int of_clk_detect_critical(struct device_node *np, int index,
 
 void clk_gate_restore_context(struct clk_hw *hw);
 
-#endif /* CONFIG_COMMON_CLK */
 #endif /* CLK_PROVIDER_H */