Merge remote-tracking branch 'keys/keys-next'
[deliverable/linux.git] / drivers / clk / sunxi-ng / ccu_mux.h
index 945082631e7ddc2fcf5308b7515abdd1421b62dd..47aba3a48245f8ff2093e9dacfe5d9439765eb9e 100644 (file)
@@ -5,14 +5,18 @@
 
 #include "ccu_common.h"
 
+struct ccu_mux_fixed_prediv {
+       u8      index;
+       u16     div;
+};
+
 struct ccu_mux_internal {
-       u8      shift;
-       u8      width;
+       u8              shift;
+       u8              width;
+       const u8        *table;
 
-       struct {
-               u8      index;
-               u8      div;
-       } fixed_prediv;
+       const struct ccu_mux_fixed_prediv       *fixed_predivs;
+       u8              n_predivs;
 
        struct {
                u8      index;
@@ -21,12 +25,16 @@ struct ccu_mux_internal {
        } variable_prediv;
 };
 
-#define SUNXI_CLK_MUX(_shift, _width)  \
-       {                                       \
-               .shift  = _shift,               \
-               .width  = _width,               \
+#define _SUNXI_CCU_MUX_TABLE(_shift, _width, _table)   \
+       {                                               \
+               .shift  = _shift,                       \
+               .width  = _width,                       \
+               .table  = _table,                       \
        }
 
+#define _SUNXI_CCU_MUX(_shift, _width) \
+       _SUNXI_CCU_MUX_TABLE(_shift, _width, NULL)
+
 struct ccu_mux {
        u16                     reg;
        u32                     enable;
@@ -35,9 +43,12 @@ struct ccu_mux {
        struct ccu_common       common;
 };
 
-#define SUNXI_CCU_MUX(_struct, _name, _parents, _reg, _shift, _width, _flags) \
+#define SUNXI_CCU_MUX_TABLE_WITH_GATE(_struct, _name, _parents, _table,        \
+                                    _reg, _shift, _width, _gate,       \
+                                    _flags)                            \
        struct ccu_mux _struct = {                                      \
-               .mux    = SUNXI_CLK_MUX(_shift, _width),                \
+               .enable = _gate,                                        \
+               .mux    = _SUNXI_CCU_MUX_TABLE(_shift, _width, _table), \
                .common = {                                             \
                        .reg            = _reg,                         \
                        .hw.init        = CLK_HW_INIT_PARENTS(_name,    \
@@ -49,17 +60,14 @@ struct ccu_mux {
 
 #define SUNXI_CCU_MUX_WITH_GATE(_struct, _name, _parents, _reg,                \
                                _shift, _width, _gate, _flags)          \
-       struct ccu_mux _struct = {                                      \
-               .enable = _gate,                                        \
-               .mux    = SUNXI_CLK_MUX(_shift, _width),                \
-               .common = {                                             \
-                       .reg            = _reg,                         \
-                       .hw.init        = CLK_HW_INIT_PARENTS(_name,    \
-                                                             _parents, \
-                                                             &ccu_mux_ops, \
-                                                             _flags),  \
-               }                                                       \
-       }
+       SUNXI_CCU_MUX_TABLE_WITH_GATE(_struct, _name, _parents, NULL,   \
+                                     _reg, _shift, _width, _gate,      \
+                                     _flags)
+
+#define SUNXI_CCU_MUX(_struct, _name, _parents, _reg, _shift, _width,  \
+                     _flags)                                           \
+       SUNXI_CCU_MUX_TABLE_WITH_GATE(_struct, _name, _parents, NULL,   \
+                                     _reg, _shift, _width, 0, _flags)
 
 static inline struct ccu_mux *hw_to_ccu_mux(struct clk_hw *hw)
 {
@@ -88,4 +96,18 @@ int ccu_mux_helper_set_parent(struct ccu_common *common,
                              struct ccu_mux_internal *cm,
                              u8 index);
 
+struct ccu_mux_nb {
+       struct notifier_block   clk_nb;
+       struct ccu_common       *common;
+       struct ccu_mux_internal *cm;
+
+       u32     delay_us;       /* How many us to wait after reparenting */
+       u8      bypass_index;   /* Which parent to temporarily use */
+       u8      original_index; /* This is set by the notifier callback */
+};
+
+#define to_ccu_mux_nb(_nb) container_of(_nb, struct ccu_mux_nb, clk_nb)
+
+int ccu_mux_notifier_register(struct clk *clk, struct ccu_mux_nb *mux_nb);
+
 #endif /* _CCU_MUX_H_ */
This page took 0.027628 seconds and 5 git commands to generate.