blob: bea9bd8a437002bc0e895a917e05d4dd86bcfedc [file] [log] [blame]
Kongyang Liu5f364e02024-06-11 17:41:14 +08001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright (c) 2024, Kongyang Liu <seashell11234455@gmail.com>
4 *
5 */
6
7#ifndef __clk_SOPHGO_PLL_H__
8#define __clk_SOPHGO_PLL_H__
9
10#include <clk.h>
11
12#include "clk-common.h"
13
14struct cv1800b_clk_synthesizer {
15 struct cv1800b_clk_regbit en;
16 struct cv1800b_clk_regbit clk_half;
17 u32 ctrl;
18 u32 set;
19};
20
21struct cv1800b_clk_ipll {
22 struct clk clk;
23 const char *name;
24 const char *parent_name;
25 void __iomem *base;
26 u32 pll_reg;
27 struct cv1800b_clk_regbit pll_pwd;
28 struct cv1800b_clk_regbit pll_status;
29};
30
31struct cv1800b_clk_fpll {
32 struct cv1800b_clk_ipll ipll;
33 struct cv1800b_clk_synthesizer syn;
34};
35
36#define CV1800B_IPLL(_id, _name, _parent_name, _pll_reg, _pll_pwd_offset, \
37 _pll_pwd_shift, _pll_status_offset, _pll_status_shift, \
38 _flags) \
39 { \
40 .clk = { \
41 .id = CV1800B_CLK_ID_TRANSFORM(_id), \
42 .flags = _flags, \
43 }, \
44 .name = _name, \
45 .parent_name = _parent_name, \
46 .pll_reg = _pll_reg, \
47 .pll_pwd = CV1800B_CLK_REGBIT(_pll_pwd_offset, _pll_pwd_shift), \
48 .pll_status = CV1800B_CLK_REGBIT(_pll_status_offset, \
49 _pll_status_shift), \
50 }
51
52#define CV1800B_FPLL(_id, _name, _parent_name, _pll_reg, _pll_pwd_offset, \
53 _pll_pwd_shift, _pll_status_offset, _pll_status_shift, \
54 _syn_en_offset, _syn_en_shift, _syn_clk_half_offset, \
55 _syn_clk_half_shift, _syn_ctrl_offset, _syn_set_offset, \
56 _flags) \
57 { \
58 .ipll = CV1800B_IPLL(_id, _name, _parent_name, _pll_reg, \
59 _pll_pwd_offset, _pll_pwd_shift, \
60 _pll_status_offset, _pll_status_shift, \
61 _flags), \
62 .syn = { \
63 .en = CV1800B_CLK_REGBIT(_syn_en_offset, _syn_en_shift),\
64 .clk_half = CV1800B_CLK_REGBIT(_syn_clk_half_offset, \
65 _syn_clk_half_shift), \
66 .ctrl = _syn_ctrl_offset, \
67 .set = _syn_set_offset, \
68 }, \
69 }
70
71extern const struct clk_ops cv1800b_ipll_ops;
72extern const struct clk_ops cv1800b_fpll_ops;
73
74#endif /* __clk_SOPHGO_PLL_H__ */