Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2016 Maxime Ripard. All rights reserved.
0004  */
0005 
0006 #ifndef _CCU_GATE_H_
0007 #define _CCU_GATE_H_
0008 
0009 #include <linux/clk-provider.h>
0010 
0011 #include "ccu_common.h"
0012 
0013 struct ccu_gate {
0014     u32         enable;
0015 
0016     struct ccu_common   common;
0017 };
0018 
0019 #define SUNXI_CCU_GATE(_struct, _name, _parent, _reg, _gate, _flags)    \
0020     struct ccu_gate _struct = {                 \
0021         .enable = _gate,                    \
0022         .common = {                     \
0023             .reg        = _reg,             \
0024             .hw.init    = CLK_HW_INIT(_name,        \
0025                               _parent,      \
0026                               &ccu_gate_ops,    \
0027                               _flags),      \
0028         }                           \
0029     }
0030 
0031 #define SUNXI_CCU_GATE_HW(_struct, _name, _parent, _reg, _gate, _flags) \
0032     struct ccu_gate _struct = {                 \
0033         .enable = _gate,                    \
0034         .common = {                     \
0035             .reg        = _reg,             \
0036             .hw.init    = CLK_HW_INIT_HW(_name,     \
0037                              _parent,   \
0038                              &ccu_gate_ops, \
0039                              _flags),   \
0040         }                           \
0041     }
0042 
0043 #define SUNXI_CCU_GATE_FW(_struct, _name, _parent, _reg, _gate, _flags) \
0044     struct ccu_gate _struct = {                 \
0045         .enable = _gate,                    \
0046         .common = {                     \
0047             .reg        = _reg,             \
0048             .hw.init    = CLK_HW_INIT_FW_NAME(_name,    \
0049                                   _parent,  \
0050                                   &ccu_gate_ops, \
0051                                   _flags),  \
0052         }                           \
0053     }
0054 
0055 /*
0056  * The following macros allow the re-use of the data structure
0057  * holding the parent info.
0058  */
0059 #define SUNXI_CCU_GATE_HWS(_struct, _name, _parent, _reg, _gate, _flags) \
0060     struct ccu_gate _struct = {                 \
0061         .enable = _gate,                    \
0062         .common = {                     \
0063             .reg        = _reg,             \
0064             .hw.init    = CLK_HW_INIT_HWS(_name,    \
0065                               _parent,  \
0066                               &ccu_gate_ops, \
0067                               _flags),  \
0068         }                           \
0069     }
0070 
0071 #define SUNXI_CCU_GATE_HWS_WITH_PREDIV(_struct, _name, _parent, _reg,   \
0072                        _gate, _prediv, _flags)      \
0073     struct ccu_gate _struct = {                 \
0074         .enable = _gate,                    \
0075         .common = {                     \
0076             .reg        = _reg,             \
0077             .prediv     = _prediv,          \
0078             .features   = CCU_FEATURE_ALL_PREDIV,   \
0079             .hw.init    = CLK_HW_INIT_HWS(_name,    \
0080                               _parent,  \
0081                               &ccu_gate_ops, \
0082                               _flags),  \
0083         }                           \
0084     }
0085 
0086 #define SUNXI_CCU_GATE_DATA(_struct, _name, _data, _reg, _gate, _flags) \
0087     struct ccu_gate _struct = {                 \
0088         .enable = _gate,                    \
0089         .common = {                     \
0090             .reg        = _reg,             \
0091             .hw.init    =               \
0092                 CLK_HW_INIT_PARENTS_DATA(_name,     \
0093                              _data,     \
0094                              &ccu_gate_ops, \
0095                              _flags),   \
0096         }                           \
0097     }
0098 
0099 #define SUNXI_CCU_GATE_DATA_WITH_PREDIV(_struct, _name, _parent, _reg,  \
0100                     _gate, _prediv, _flags)     \
0101     struct ccu_gate _struct = {                 \
0102         .enable = _gate,                    \
0103         .common = {                     \
0104             .reg        = _reg,             \
0105             .prediv     = _prediv,          \
0106             .features   = CCU_FEATURE_ALL_PREDIV,   \
0107             .hw.init    = CLK_HW_INIT_PARENTS_DATA(_name, \
0108                                    _parent, \
0109                                    &ccu_gate_ops, \
0110                                    _flags), \
0111         }                           \
0112     }
0113 
0114 static inline struct ccu_gate *hw_to_ccu_gate(struct clk_hw *hw)
0115 {
0116     struct ccu_common *common = hw_to_ccu_common(hw);
0117 
0118     return container_of(common, struct ccu_gate, common);
0119 }
0120 
0121 void ccu_gate_helper_disable(struct ccu_common *common, u32 gate);
0122 int ccu_gate_helper_enable(struct ccu_common *common, u32 gate);
0123 int ccu_gate_helper_is_enabled(struct ccu_common *common, u32 gate);
0124 
0125 extern const struct clk_ops ccu_gate_ops;
0126 
0127 #endif /* _CCU_GATE_H_ */