18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci// 38c2ecf20Sopenharmony_ci// Spreadtrum composite clock driver 48c2ecf20Sopenharmony_ci// 58c2ecf20Sopenharmony_ci// Copyright (C) 2017 Spreadtrum, Inc. 68c2ecf20Sopenharmony_ci// Author: Chunyan Zhang <chunyan.zhang@spreadtrum.com> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _SPRD_COMPOSITE_H_ 98c2ecf20Sopenharmony_ci#define _SPRD_COMPOSITE_H_ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include "common.h" 128c2ecf20Sopenharmony_ci#include "mux.h" 138c2ecf20Sopenharmony_ci#include "div.h" 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cistruct sprd_comp { 168c2ecf20Sopenharmony_ci struct sprd_mux_ssel mux; 178c2ecf20Sopenharmony_ci struct sprd_div_internal div; 188c2ecf20Sopenharmony_ci struct sprd_clk_common common; 198c2ecf20Sopenharmony_ci}; 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table, \ 228c2ecf20Sopenharmony_ci _mshift, _mwidth, _dshift, _dwidth, \ 238c2ecf20Sopenharmony_ci _flags, _fn) \ 248c2ecf20Sopenharmony_ci struct sprd_comp _struct = { \ 258c2ecf20Sopenharmony_ci .mux = _SPRD_MUX_CLK(_mshift, _mwidth, _table), \ 268c2ecf20Sopenharmony_ci .div = _SPRD_DIV_CLK(_dshift, _dwidth), \ 278c2ecf20Sopenharmony_ci .common = { \ 288c2ecf20Sopenharmony_ci .regmap = NULL, \ 298c2ecf20Sopenharmony_ci .reg = _reg, \ 308c2ecf20Sopenharmony_ci .hw.init = _fn(_name, _parent, \ 318c2ecf20Sopenharmony_ci &sprd_comp_ops, _flags), \ 328c2ecf20Sopenharmony_ci } \ 338c2ecf20Sopenharmony_ci } 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define SPRD_COMP_CLK_TABLE(_struct, _name, _parent, _reg, _table, \ 368c2ecf20Sopenharmony_ci _mshift, _mwidth, _dshift, _dwidth, _flags) \ 378c2ecf20Sopenharmony_ci SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table, \ 388c2ecf20Sopenharmony_ci _mshift, _mwidth, _dshift, _dwidth, \ 398c2ecf20Sopenharmony_ci _flags, CLK_HW_INIT_PARENTS) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define SPRD_COMP_CLK(_struct, _name, _parent, _reg, _mshift, \ 428c2ecf20Sopenharmony_ci _mwidth, _dshift, _dwidth, _flags) \ 438c2ecf20Sopenharmony_ci SPRD_COMP_CLK_TABLE(_struct, _name, _parent, _reg, NULL, \ 448c2ecf20Sopenharmony_ci _mshift, _mwidth, _dshift, _dwidth, _flags) 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define SPRD_COMP_CLK_DATA_TABLE(_struct, _name, _parent, _reg, _table, \ 478c2ecf20Sopenharmony_ci _mshift, _mwidth, _dshift, \ 488c2ecf20Sopenharmony_ci _dwidth, _flags) \ 498c2ecf20Sopenharmony_ci SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table, \ 508c2ecf20Sopenharmony_ci _mshift, _mwidth, _dshift, _dwidth, \ 518c2ecf20Sopenharmony_ci _flags, CLK_HW_INIT_PARENTS_DATA) 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define SPRD_COMP_CLK_DATA(_struct, _name, _parent, _reg, _mshift, \ 548c2ecf20Sopenharmony_ci _mwidth, _dshift, _dwidth, _flags) \ 558c2ecf20Sopenharmony_ci SPRD_COMP_CLK_DATA_TABLE(_struct, _name, _parent, _reg, NULL, \ 568c2ecf20Sopenharmony_ci _mshift, _mwidth, _dshift, _dwidth, \ 578c2ecf20Sopenharmony_ci _flags) 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistatic inline struct sprd_comp *hw_to_sprd_comp(const struct clk_hw *hw) 608c2ecf20Sopenharmony_ci{ 618c2ecf20Sopenharmony_ci struct sprd_clk_common *common = hw_to_sprd_clk_common(hw); 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci return container_of(common, struct sprd_comp, common); 648c2ecf20Sopenharmony_ci} 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ciextern const struct clk_ops sprd_comp_ops; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#endif /* _SPRD_COMPOSITE_H_ */ 69