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_NKMP_H_
0007 #define _CCU_NKMP_H_
0008 
0009 #include <linux/clk-provider.h>
0010 
0011 #include "ccu_common.h"
0012 #include "ccu_div.h"
0013 #include "ccu_mult.h"
0014 
0015 /*
0016  * struct ccu_nkmp - Definition of an N-K-M-P clock
0017  *
0018  * Clocks based on the formula parent * N * K >> P / M
0019  */
0020 struct ccu_nkmp {
0021     u32         enable;
0022     u32         lock;
0023 
0024     struct ccu_mult_internal    n;
0025     struct ccu_mult_internal    k;
0026     struct ccu_div_internal     m;
0027     struct ccu_div_internal     p;
0028 
0029     unsigned int        fixed_post_div;
0030     unsigned int        max_rate;
0031 
0032     struct ccu_common   common;
0033 };
0034 
0035 #define SUNXI_CCU_NKMP_WITH_GATE_LOCK(_struct, _name, _parent, _reg,    \
0036                       _nshift, _nwidth,         \
0037                       _kshift, _kwidth,         \
0038                       _mshift, _mwidth,         \
0039                       _pshift, _pwidth,         \
0040                       _gate, _lock, _flags)     \
0041     struct ccu_nkmp _struct = {                 \
0042         .enable     = _gate,                \
0043         .lock       = _lock,                \
0044         .n      = _SUNXI_CCU_MULT(_nshift, _nwidth),    \
0045         .k      = _SUNXI_CCU_MULT(_kshift, _kwidth),    \
0046         .m      = _SUNXI_CCU_DIV(_mshift, _mwidth), \
0047         .p      = _SUNXI_CCU_DIV(_pshift, _pwidth), \
0048         .common     = {                 \
0049             .reg        = _reg,             \
0050             .hw.init    = CLK_HW_INIT(_name,        \
0051                               _parent,      \
0052                               &ccu_nkmp_ops,    \
0053                               _flags),      \
0054         },                          \
0055     }
0056 
0057 static inline struct ccu_nkmp *hw_to_ccu_nkmp(struct clk_hw *hw)
0058 {
0059     struct ccu_common *common = hw_to_ccu_common(hw);
0060 
0061     return container_of(common, struct ccu_nkmp, common);
0062 }
0063 
0064 extern const struct clk_ops ccu_nkmp_ops;
0065 
0066 #endif /* _CCU_NKMP_H_ */