18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _CCU_MULT_H_ 38c2ecf20Sopenharmony_ci#define _CCU_MULT_H_ 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include "ccu_common.h" 68c2ecf20Sopenharmony_ci#include "ccu_frac.h" 78c2ecf20Sopenharmony_ci#include "ccu_mux.h" 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_cistruct ccu_mult_internal { 108c2ecf20Sopenharmony_ci u8 offset; 118c2ecf20Sopenharmony_ci u8 shift; 128c2ecf20Sopenharmony_ci u8 width; 138c2ecf20Sopenharmony_ci u8 min; 148c2ecf20Sopenharmony_ci u8 max; 158c2ecf20Sopenharmony_ci}; 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, _offset, _min, _max) \ 188c2ecf20Sopenharmony_ci { \ 198c2ecf20Sopenharmony_ci .min = _min, \ 208c2ecf20Sopenharmony_ci .max = _max, \ 218c2ecf20Sopenharmony_ci .offset = _offset, \ 228c2ecf20Sopenharmony_ci .shift = _shift, \ 238c2ecf20Sopenharmony_ci .width = _width, \ 248c2ecf20Sopenharmony_ci } 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define _SUNXI_CCU_MULT_MIN(_shift, _width, _min) \ 278c2ecf20Sopenharmony_ci _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, 1, _min, 0) 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define _SUNXI_CCU_MULT_OFFSET(_shift, _width, _offset) \ 308c2ecf20Sopenharmony_ci _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, _offset, 1, 0) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define _SUNXI_CCU_MULT(_shift, _width) \ 338c2ecf20Sopenharmony_ci _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, 1, 1, 0) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistruct ccu_mult { 368c2ecf20Sopenharmony_ci u32 enable; 378c2ecf20Sopenharmony_ci u32 lock; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci struct ccu_frac_internal frac; 408c2ecf20Sopenharmony_ci struct ccu_mult_internal mult; 418c2ecf20Sopenharmony_ci struct ccu_mux_internal mux; 428c2ecf20Sopenharmony_ci struct ccu_common common; 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#define SUNXI_CCU_N_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \ 468c2ecf20Sopenharmony_ci _mshift, _mwidth, _gate, _lock, \ 478c2ecf20Sopenharmony_ci _flags) \ 488c2ecf20Sopenharmony_ci struct ccu_mult _struct = { \ 498c2ecf20Sopenharmony_ci .enable = _gate, \ 508c2ecf20Sopenharmony_ci .lock = _lock, \ 518c2ecf20Sopenharmony_ci .mult = _SUNXI_CCU_MULT(_mshift, _mwidth), \ 528c2ecf20Sopenharmony_ci .common = { \ 538c2ecf20Sopenharmony_ci .reg = _reg, \ 548c2ecf20Sopenharmony_ci .hw.init = CLK_HW_INIT(_name, \ 558c2ecf20Sopenharmony_ci _parent, \ 568c2ecf20Sopenharmony_ci &ccu_mult_ops, \ 578c2ecf20Sopenharmony_ci _flags), \ 588c2ecf20Sopenharmony_ci }, \ 598c2ecf20Sopenharmony_ci } 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistatic inline struct ccu_mult *hw_to_ccu_mult(struct clk_hw *hw) 628c2ecf20Sopenharmony_ci{ 638c2ecf20Sopenharmony_ci struct ccu_common *common = hw_to_ccu_common(hw); 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci return container_of(common, struct ccu_mult, common); 668c2ecf20Sopenharmony_ci} 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ciextern const struct clk_ops ccu_mult_ops; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#endif /* _CCU_MULT_H_ */ 71