162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2020 BAIKAL ELECTRONICS, JSC
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Baikal-T1 CCU PLL interface driver
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci#ifndef __CLK_BT1_CCU_PLL_H__
862306a36Sopenharmony_ci#define __CLK_BT1_CCU_PLL_H__
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include <linux/clk-provider.h>
1162306a36Sopenharmony_ci#include <linux/spinlock.h>
1262306a36Sopenharmony_ci#include <linux/regmap.h>
1362306a36Sopenharmony_ci#include <linux/bits.h>
1462306a36Sopenharmony_ci#include <linux/of.h>
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci/*
1762306a36Sopenharmony_ci * CCU PLL private flags
1862306a36Sopenharmony_ci * @CCU_PLL_BASIC: Basic PLL required by the kernel as early as possible.
1962306a36Sopenharmony_ci */
2062306a36Sopenharmony_ci#define CCU_PLL_BASIC		BIT(0)
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci/*
2362306a36Sopenharmony_ci * struct ccu_pll_init_data - CCU PLL initialization data
2462306a36Sopenharmony_ci * @id: Clock private identifier.
2562306a36Sopenharmony_ci * @name: Clocks name.
2662306a36Sopenharmony_ci * @parent_name: Clocks parent name in a fw node.
2762306a36Sopenharmony_ci * @base: PLL registers base address with respect to the sys_regs base.
2862306a36Sopenharmony_ci * @sys_regs: Baikal-T1 System Controller registers map.
2962306a36Sopenharmony_ci * @np: Pointer to the node describing the CCU PLLs.
3062306a36Sopenharmony_ci * @flags: PLL clock flags.
3162306a36Sopenharmony_ci * @features: PLL private features.
3262306a36Sopenharmony_ci */
3362306a36Sopenharmony_cistruct ccu_pll_init_data {
3462306a36Sopenharmony_ci	unsigned int id;
3562306a36Sopenharmony_ci	const char *name;
3662306a36Sopenharmony_ci	const char *parent_name;
3762306a36Sopenharmony_ci	unsigned int base;
3862306a36Sopenharmony_ci	struct regmap *sys_regs;
3962306a36Sopenharmony_ci	struct device_node *np;
4062306a36Sopenharmony_ci	unsigned long flags;
4162306a36Sopenharmony_ci	unsigned long features;
4262306a36Sopenharmony_ci};
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci/*
4562306a36Sopenharmony_ci * struct ccu_pll - CCU PLL descriptor
4662306a36Sopenharmony_ci * @hw: clk_hw of the PLL.
4762306a36Sopenharmony_ci * @id: Clock private identifier.
4862306a36Sopenharmony_ci * @reg_ctl: PLL control register base.
4962306a36Sopenharmony_ci * @reg_ctl1: PLL control1 register base.
5062306a36Sopenharmony_ci * @sys_regs: Baikal-T1 System Controller registers map.
5162306a36Sopenharmony_ci * @lock: PLL state change spin-lock.
5262306a36Sopenharmony_ci */
5362306a36Sopenharmony_cistruct ccu_pll {
5462306a36Sopenharmony_ci	struct clk_hw hw;
5562306a36Sopenharmony_ci	unsigned int id;
5662306a36Sopenharmony_ci	unsigned int reg_ctl;
5762306a36Sopenharmony_ci	unsigned int reg_ctl1;
5862306a36Sopenharmony_ci	struct regmap *sys_regs;
5962306a36Sopenharmony_ci	spinlock_t lock;
6062306a36Sopenharmony_ci};
6162306a36Sopenharmony_ci#define to_ccu_pll(_hw) container_of(_hw, struct ccu_pll, hw)
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_cistatic inline struct clk_hw *ccu_pll_get_clk_hw(struct ccu_pll *pll)
6462306a36Sopenharmony_ci{
6562306a36Sopenharmony_ci	return pll ? &pll->hw : NULL;
6662306a36Sopenharmony_ci}
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_cistruct ccu_pll *ccu_pll_hw_register(const struct ccu_pll_init_data *init);
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_civoid ccu_pll_hw_unregister(struct ccu_pll *pll);
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci#endif /* __CLK_BT1_CCU_PLL_H__ */
73