18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2020 BAIKAL ELECTRONICS, JSC 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Baikal-T1 CCU PLL interface driver 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#ifndef __CLK_BT1_CCU_PLL_H__ 88c2ecf20Sopenharmony_ci#define __CLK_BT1_CCU_PLL_H__ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 118c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 128c2ecf20Sopenharmony_ci#include <linux/regmap.h> 138c2ecf20Sopenharmony_ci#include <linux/bits.h> 148c2ecf20Sopenharmony_ci#include <linux/of.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* 178c2ecf20Sopenharmony_ci * struct ccu_pll_init_data - CCU PLL initialization data 188c2ecf20Sopenharmony_ci * @id: Clock private identifier. 198c2ecf20Sopenharmony_ci * @name: Clocks name. 208c2ecf20Sopenharmony_ci * @parent_name: Clocks parent name in a fw node. 218c2ecf20Sopenharmony_ci * @base: PLL registers base address with respect to the sys_regs base. 228c2ecf20Sopenharmony_ci * @sys_regs: Baikal-T1 System Controller registers map. 238c2ecf20Sopenharmony_ci * @np: Pointer to the node describing the CCU PLLs. 248c2ecf20Sopenharmony_ci * @flags: PLL clock flags. 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_cistruct ccu_pll_init_data { 278c2ecf20Sopenharmony_ci unsigned int id; 288c2ecf20Sopenharmony_ci const char *name; 298c2ecf20Sopenharmony_ci const char *parent_name; 308c2ecf20Sopenharmony_ci unsigned int base; 318c2ecf20Sopenharmony_ci struct regmap *sys_regs; 328c2ecf20Sopenharmony_ci struct device_node *np; 338c2ecf20Sopenharmony_ci unsigned long flags; 348c2ecf20Sopenharmony_ci}; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci/* 378c2ecf20Sopenharmony_ci * struct ccu_pll - CCU PLL descriptor 388c2ecf20Sopenharmony_ci * @hw: clk_hw of the PLL. 398c2ecf20Sopenharmony_ci * @id: Clock private identifier. 408c2ecf20Sopenharmony_ci * @reg_ctl: PLL control register base. 418c2ecf20Sopenharmony_ci * @reg_ctl1: PLL control1 register base. 428c2ecf20Sopenharmony_ci * @sys_regs: Baikal-T1 System Controller registers map. 438c2ecf20Sopenharmony_ci * @lock: PLL state change spin-lock. 448c2ecf20Sopenharmony_ci */ 458c2ecf20Sopenharmony_cistruct ccu_pll { 468c2ecf20Sopenharmony_ci struct clk_hw hw; 478c2ecf20Sopenharmony_ci unsigned int id; 488c2ecf20Sopenharmony_ci unsigned int reg_ctl; 498c2ecf20Sopenharmony_ci unsigned int reg_ctl1; 508c2ecf20Sopenharmony_ci struct regmap *sys_regs; 518c2ecf20Sopenharmony_ci spinlock_t lock; 528c2ecf20Sopenharmony_ci}; 538c2ecf20Sopenharmony_ci#define to_ccu_pll(_hw) container_of(_hw, struct ccu_pll, hw) 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cistatic inline struct clk_hw *ccu_pll_get_clk_hw(struct ccu_pll *pll) 568c2ecf20Sopenharmony_ci{ 578c2ecf20Sopenharmony_ci return pll ? &pll->hw : NULL; 588c2ecf20Sopenharmony_ci} 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistruct ccu_pll *ccu_pll_hw_register(const struct ccu_pll_init_data *init); 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_civoid ccu_pll_hw_unregister(struct ccu_pll *pll); 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#endif /* __CLK_BT1_CCU_PLL_H__ */ 65