1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (C) 2020 BAIKAL ELECTRONICS, JSC 4 * 5 * Baikal-T1 CCU PLL interface driver 6 */ 7 #ifndef __CLK_BT1_CCU_PLL_H__ 8 #define __CLK_BT1_CCU_PLL_H__ 9 10 #include <linux/clk-provider.h> 11 #include <linux/spinlock.h> 12 #include <linux/regmap.h> 13 #include <linux/bits.h> 14 #include <linux/of.h> 15 16 /* 17 * struct ccu_pll_init_data - CCU PLL initialization data 18 * @id: Clock private identifier. 19 * @name: Clocks name. 20 * @parent_name: Clocks parent name in a fw node. 21 * @base: PLL registers base address with respect to the sys_regs base. 22 * @sys_regs: Baikal-T1 System Controller registers map. 23 * @np: Pointer to the node describing the CCU PLLs. 24 * @flags: PLL clock flags. 25 */ 26 struct ccu_pll_init_data { 27 unsigned int id; 28 const char *name; 29 const char *parent_name; 30 unsigned int base; 31 struct regmap *sys_regs; 32 struct device_node *np; 33 unsigned long flags; 34 }; 35 36 /* 37 * struct ccu_pll - CCU PLL descriptor 38 * @hw: clk_hw of the PLL. 39 * @id: Clock private identifier. 40 * @reg_ctl: PLL control register base. 41 * @reg_ctl1: PLL control1 register base. 42 * @sys_regs: Baikal-T1 System Controller registers map. 43 * @lock: PLL state change spin-lock. 44 */ 45 struct ccu_pll { 46 struct clk_hw hw; 47 unsigned int id; 48 unsigned int reg_ctl; 49 unsigned int reg_ctl1; 50 struct regmap *sys_regs; 51 spinlock_t lock; 52 }; 53 #define to_ccu_pll(_hw) container_of(_hw, struct ccu_pll, hw) 54 ccu_pll_get_clk_hw(struct ccu_pll * pll)55static inline struct clk_hw *ccu_pll_get_clk_hw(struct ccu_pll *pll) 56 { 57 return pll ? &pll->hw : NULL; 58 } 59 60 struct ccu_pll *ccu_pll_hw_register(const struct ccu_pll_init_data *init); 61 62 void ccu_pll_hw_unregister(struct ccu_pll *pll); 63 64 #endif /* __CLK_BT1_CCU_PLL_H__ */ 65