18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */ 28c2ecf20Sopenharmony_ci// 38c2ecf20Sopenharmony_ci// OWL gate clock driver 48c2ecf20Sopenharmony_ci// 58c2ecf20Sopenharmony_ci// Copyright (c) 2014 Actions Semi Inc. 68c2ecf20Sopenharmony_ci// Author: David Liu <liuwei@actions-semi.com> 78c2ecf20Sopenharmony_ci// 88c2ecf20Sopenharmony_ci// Copyright (c) 2018 Linaro Ltd. 98c2ecf20Sopenharmony_ci// Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef _OWL_GATE_H_ 128c2ecf20Sopenharmony_ci#define _OWL_GATE_H_ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include "owl-common.h" 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_cistruct owl_gate_hw { 178c2ecf20Sopenharmony_ci u32 reg; 188c2ecf20Sopenharmony_ci u8 bit_idx; 198c2ecf20Sopenharmony_ci u8 gate_flags; 208c2ecf20Sopenharmony_ci}; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistruct owl_gate { 238c2ecf20Sopenharmony_ci struct owl_gate_hw gate_hw; 248c2ecf20Sopenharmony_ci struct owl_clk_common common; 258c2ecf20Sopenharmony_ci}; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#define OWL_GATE_HW(_reg, _bit_idx, _gate_flags) \ 288c2ecf20Sopenharmony_ci { \ 298c2ecf20Sopenharmony_ci .reg = _reg, \ 308c2ecf20Sopenharmony_ci .bit_idx = _bit_idx, \ 318c2ecf20Sopenharmony_ci .gate_flags = _gate_flags, \ 328c2ecf20Sopenharmony_ci } 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define OWL_GATE(_struct, _name, _parent, _reg, \ 358c2ecf20Sopenharmony_ci _bit_idx, _gate_flags, _flags) \ 368c2ecf20Sopenharmony_ci struct owl_gate _struct = { \ 378c2ecf20Sopenharmony_ci .gate_hw = OWL_GATE_HW(_reg, _bit_idx, _gate_flags), \ 388c2ecf20Sopenharmony_ci .common = { \ 398c2ecf20Sopenharmony_ci .regmap = NULL, \ 408c2ecf20Sopenharmony_ci .hw.init = CLK_HW_INIT(_name, \ 418c2ecf20Sopenharmony_ci _parent, \ 428c2ecf20Sopenharmony_ci &owl_gate_ops, \ 438c2ecf20Sopenharmony_ci _flags), \ 448c2ecf20Sopenharmony_ci } \ 458c2ecf20Sopenharmony_ci } \ 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#define OWL_GATE_NO_PARENT(_struct, _name, _reg, \ 488c2ecf20Sopenharmony_ci _bit_idx, _gate_flags, _flags) \ 498c2ecf20Sopenharmony_ci struct owl_gate _struct = { \ 508c2ecf20Sopenharmony_ci .gate_hw = OWL_GATE_HW(_reg, _bit_idx, _gate_flags), \ 518c2ecf20Sopenharmony_ci .common = { \ 528c2ecf20Sopenharmony_ci .regmap = NULL, \ 538c2ecf20Sopenharmony_ci .hw.init = CLK_HW_INIT_NO_PARENT(_name, \ 548c2ecf20Sopenharmony_ci &owl_gate_ops, \ 558c2ecf20Sopenharmony_ci _flags), \ 568c2ecf20Sopenharmony_ci }, \ 578c2ecf20Sopenharmony_ci } \ 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistatic inline struct owl_gate *hw_to_owl_gate(const struct clk_hw *hw) 608c2ecf20Sopenharmony_ci{ 618c2ecf20Sopenharmony_ci struct owl_clk_common *common = hw_to_owl_clk_common(hw); 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci return container_of(common, struct owl_gate, common); 648c2ecf20Sopenharmony_ci} 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_civoid owl_gate_set(const struct owl_clk_common *common, 678c2ecf20Sopenharmony_ci const struct owl_gate_hw *gate_hw, bool enable); 688c2ecf20Sopenharmony_ciint owl_gate_clk_is_enabled(const struct owl_clk_common *common, 698c2ecf20Sopenharmony_ci const struct owl_gate_hw *gate_hw); 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ciextern const struct clk_ops owl_gate_ops; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci#endif /* _OWL_GATE_H_ */ 74