xref: /linux/drivers/clk/sifive/sifive-prci.h (revision 8be98d2f2a0a262f8bf8a0bc1fdf522b3c7aab17)
1c816e1ddSZong Li /* SPDX-License-Identifier: GPL-2.0 */
2c816e1ddSZong Li /*
3c816e1ddSZong Li  * Copyright (C) 2018-2019 SiFive, Inc.
4c816e1ddSZong Li  * Wesley Terpstra
5c816e1ddSZong Li  * Paul Walmsley
6c816e1ddSZong Li  * Zong Li
7c816e1ddSZong Li  */
8c816e1ddSZong Li 
9c816e1ddSZong Li #ifndef __SIFIVE_CLK_SIFIVE_PRCI_H
10c816e1ddSZong Li #define __SIFIVE_CLK_SIFIVE_PRCI_H
11c816e1ddSZong Li 
12c816e1ddSZong Li #include <linux/clk/analogbits-wrpll-cln28hpc.h>
13c816e1ddSZong Li #include <linux/clk-provider.h>
14*e4d368e0SGreentime Hu #include <linux/reset/reset-simple.h>
15c816e1ddSZong Li #include <linux/platform_device.h>
16c816e1ddSZong Li 
17c816e1ddSZong Li /*
18c816e1ddSZong Li  * EXPECTED_CLK_PARENT_COUNT: how many parent clocks this driver expects:
19c816e1ddSZong Li  *     hfclk and rtcclk
20c816e1ddSZong Li  */
21c816e1ddSZong Li #define EXPECTED_CLK_PARENT_COUNT 2
22c816e1ddSZong Li 
23c816e1ddSZong Li /*
24c816e1ddSZong Li  * Register offsets and bitmasks
25c816e1ddSZong Li  */
26c816e1ddSZong Li 
27c816e1ddSZong Li /* COREPLLCFG0 */
28c816e1ddSZong Li #define PRCI_COREPLLCFG0_OFFSET		0x4
29c816e1ddSZong Li #define PRCI_COREPLLCFG0_DIVR_SHIFT	0
30c816e1ddSZong Li #define PRCI_COREPLLCFG0_DIVR_MASK	(0x3f << PRCI_COREPLLCFG0_DIVR_SHIFT)
31c816e1ddSZong Li #define PRCI_COREPLLCFG0_DIVF_SHIFT	6
32c816e1ddSZong Li #define PRCI_COREPLLCFG0_DIVF_MASK	(0x1ff << PRCI_COREPLLCFG0_DIVF_SHIFT)
33c816e1ddSZong Li #define PRCI_COREPLLCFG0_DIVQ_SHIFT	15
34c816e1ddSZong Li #define PRCI_COREPLLCFG0_DIVQ_MASK	(0x7 << PRCI_COREPLLCFG0_DIVQ_SHIFT)
35c816e1ddSZong Li #define PRCI_COREPLLCFG0_RANGE_SHIFT	18
36c816e1ddSZong Li #define PRCI_COREPLLCFG0_RANGE_MASK	(0x7 << PRCI_COREPLLCFG0_RANGE_SHIFT)
37c816e1ddSZong Li #define PRCI_COREPLLCFG0_BYPASS_SHIFT	24
38c816e1ddSZong Li #define PRCI_COREPLLCFG0_BYPASS_MASK	(0x1 << PRCI_COREPLLCFG0_BYPASS_SHIFT)
39c816e1ddSZong Li #define PRCI_COREPLLCFG0_FSE_SHIFT	25
40c816e1ddSZong Li #define PRCI_COREPLLCFG0_FSE_MASK	(0x1 << PRCI_COREPLLCFG0_FSE_SHIFT)
41c816e1ddSZong Li #define PRCI_COREPLLCFG0_LOCK_SHIFT	31
42c816e1ddSZong Li #define PRCI_COREPLLCFG0_LOCK_MASK	(0x1 << PRCI_COREPLLCFG0_LOCK_SHIFT)
43c816e1ddSZong Li 
44732374a0SPragnesh Patel /* COREPLLCFG1 */
45732374a0SPragnesh Patel #define PRCI_COREPLLCFG1_OFFSET		0x8
46732374a0SPragnesh Patel #define PRCI_COREPLLCFG1_CKE_SHIFT	31
47732374a0SPragnesh Patel #define PRCI_COREPLLCFG1_CKE_MASK	(0x1 << PRCI_COREPLLCFG1_CKE_SHIFT)
48732374a0SPragnesh Patel 
49c816e1ddSZong Li /* DDRPLLCFG0 */
50c816e1ddSZong Li #define PRCI_DDRPLLCFG0_OFFSET		0xc
51c816e1ddSZong Li #define PRCI_DDRPLLCFG0_DIVR_SHIFT	0
52c816e1ddSZong Li #define PRCI_DDRPLLCFG0_DIVR_MASK	(0x3f << PRCI_DDRPLLCFG0_DIVR_SHIFT)
53c816e1ddSZong Li #define PRCI_DDRPLLCFG0_DIVF_SHIFT	6
54c816e1ddSZong Li #define PRCI_DDRPLLCFG0_DIVF_MASK	(0x1ff << PRCI_DDRPLLCFG0_DIVF_SHIFT)
55c816e1ddSZong Li #define PRCI_DDRPLLCFG0_DIVQ_SHIFT	15
56c816e1ddSZong Li #define PRCI_DDRPLLCFG0_DIVQ_MASK	(0x7 << PRCI_DDRPLLCFG0_DIVQ_SHIFT)
57c816e1ddSZong Li #define PRCI_DDRPLLCFG0_RANGE_SHIFT	18
58c816e1ddSZong Li #define PRCI_DDRPLLCFG0_RANGE_MASK	(0x7 << PRCI_DDRPLLCFG0_RANGE_SHIFT)
59c816e1ddSZong Li #define PRCI_DDRPLLCFG0_BYPASS_SHIFT	24
60c816e1ddSZong Li #define PRCI_DDRPLLCFG0_BYPASS_MASK	(0x1 << PRCI_DDRPLLCFG0_BYPASS_SHIFT)
61c816e1ddSZong Li #define PRCI_DDRPLLCFG0_FSE_SHIFT	25
62c816e1ddSZong Li #define PRCI_DDRPLLCFG0_FSE_MASK	(0x1 << PRCI_DDRPLLCFG0_FSE_SHIFT)
63c816e1ddSZong Li #define PRCI_DDRPLLCFG0_LOCK_SHIFT	31
64c816e1ddSZong Li #define PRCI_DDRPLLCFG0_LOCK_MASK	(0x1 << PRCI_DDRPLLCFG0_LOCK_SHIFT)
65c816e1ddSZong Li 
66c816e1ddSZong Li /* DDRPLLCFG1 */
67c816e1ddSZong Li #define PRCI_DDRPLLCFG1_OFFSET		0x10
68263ac390SZong Li #define PRCI_DDRPLLCFG1_CKE_SHIFT	31
69c816e1ddSZong Li #define PRCI_DDRPLLCFG1_CKE_MASK	(0x1 << PRCI_DDRPLLCFG1_CKE_SHIFT)
70c816e1ddSZong Li 
71c61287bfSGreentime Hu /* PCIEAUX */
72c61287bfSGreentime Hu #define PRCI_PCIE_AUX_OFFSET		0x14
73c61287bfSGreentime Hu #define PRCI_PCIE_AUX_EN_SHIFT		0
74c61287bfSGreentime Hu #define PRCI_PCIE_AUX_EN_MASK		(0x1 << PRCI_PCIE_AUX_EN_SHIFT)
75c61287bfSGreentime Hu 
76c816e1ddSZong Li /* GEMGXLPLLCFG0 */
77c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_OFFSET	0x1c
78c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_DIVR_SHIFT	0
79c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_DIVR_MASK	(0x3f << PRCI_GEMGXLPLLCFG0_DIVR_SHIFT)
80c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_DIVF_SHIFT	6
81c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_DIVF_MASK	(0x1ff << PRCI_GEMGXLPLLCFG0_DIVF_SHIFT)
82c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_DIVQ_SHIFT	15
83c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_DIVQ_MASK	(0x7 << PRCI_GEMGXLPLLCFG0_DIVQ_SHIFT)
84c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_RANGE_SHIFT	18
85c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_RANGE_MASK	(0x7 << PRCI_GEMGXLPLLCFG0_RANGE_SHIFT)
86c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_BYPASS_SHIFT	24
87c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_BYPASS_MASK	(0x1 << PRCI_GEMGXLPLLCFG0_BYPASS_SHIFT)
88c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_FSE_SHIFT	25
89c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_FSE_MASK	(0x1 << PRCI_GEMGXLPLLCFG0_FSE_SHIFT)
90c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_LOCK_SHIFT	31
91c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG0_LOCK_MASK	(0x1 << PRCI_GEMGXLPLLCFG0_LOCK_SHIFT)
92c816e1ddSZong Li 
93c816e1ddSZong Li /* GEMGXLPLLCFG1 */
94c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG1_OFFSET	0x20
95263ac390SZong Li #define PRCI_GEMGXLPLLCFG1_CKE_SHIFT	31
96c816e1ddSZong Li #define PRCI_GEMGXLPLLCFG1_CKE_MASK	(0x1 << PRCI_GEMGXLPLLCFG1_CKE_SHIFT)
97c816e1ddSZong Li 
98c816e1ddSZong Li /* CORECLKSEL */
99c816e1ddSZong Li #define PRCI_CORECLKSEL_OFFSET			0x24
100c816e1ddSZong Li #define PRCI_CORECLKSEL_CORECLKSEL_SHIFT	0
101c816e1ddSZong Li #define PRCI_CORECLKSEL_CORECLKSEL_MASK					\
102c816e1ddSZong Li 		(0x1 << PRCI_CORECLKSEL_CORECLKSEL_SHIFT)
103c816e1ddSZong Li 
104c816e1ddSZong Li /* DEVICESRESETREG */
105c816e1ddSZong Li #define PRCI_DEVICESRESETREG_OFFSET				0x28
106c816e1ddSZong Li #define PRCI_DEVICESRESETREG_DDR_CTRL_RST_N_SHIFT		0
107c816e1ddSZong Li #define PRCI_DEVICESRESETREG_DDR_CTRL_RST_N_MASK			\
108c816e1ddSZong Li 		(0x1 << PRCI_DEVICESRESETREG_DDR_CTRL_RST_N_SHIFT)
109c816e1ddSZong Li #define PRCI_DEVICESRESETREG_DDR_AXI_RST_N_SHIFT		1
110c816e1ddSZong Li #define PRCI_DEVICESRESETREG_DDR_AXI_RST_N_MASK				\
111c816e1ddSZong Li 		(0x1 << PRCI_DEVICESRESETREG_DDR_AXI_RST_N_SHIFT)
112c816e1ddSZong Li #define PRCI_DEVICESRESETREG_DDR_AHB_RST_N_SHIFT		2
113c816e1ddSZong Li #define PRCI_DEVICESRESETREG_DDR_AHB_RST_N_MASK				\
114c816e1ddSZong Li 		(0x1 << PRCI_DEVICESRESETREG_DDR_AHB_RST_N_SHIFT)
115c816e1ddSZong Li #define PRCI_DEVICESRESETREG_DDR_PHY_RST_N_SHIFT		3
116c816e1ddSZong Li #define PRCI_DEVICESRESETREG_DDR_PHY_RST_N_MASK				\
117c816e1ddSZong Li 		(0x1 << PRCI_DEVICESRESETREG_DDR_PHY_RST_N_SHIFT)
118c816e1ddSZong Li #define PRCI_DEVICESRESETREG_GEMGXL_RST_N_SHIFT			5
119c816e1ddSZong Li #define PRCI_DEVICESRESETREG_GEMGXL_RST_N_MASK				\
120c816e1ddSZong Li 		(0x1 << PRCI_DEVICESRESETREG_GEMGXL_RST_N_SHIFT)
121c816e1ddSZong Li #define PRCI_DEVICESRESETREG_CHIPLINK_RST_N_SHIFT		6
122c816e1ddSZong Li #define PRCI_DEVICESRESETREG_CHIPLINK_RST_N_MASK			\
123c816e1ddSZong Li 		(0x1 << PRCI_DEVICESRESETREG_CHIPLINK_RST_N_SHIFT)
124c816e1ddSZong Li 
125*e4d368e0SGreentime Hu #define PRCI_RST_NR						7
126*e4d368e0SGreentime Hu 
127c816e1ddSZong Li /* CLKMUXSTATUSREG */
128c816e1ddSZong Li #define PRCI_CLKMUXSTATUSREG_OFFSET				0x2c
129c816e1ddSZong Li #define PRCI_CLKMUXSTATUSREG_TLCLKSEL_STATUS_SHIFT		1
130c816e1ddSZong Li #define PRCI_CLKMUXSTATUSREG_TLCLKSEL_STATUS_MASK			\
131c816e1ddSZong Li 		(0x1 << PRCI_CLKMUXSTATUSREG_TLCLKSEL_STATUS_SHIFT)
132c816e1ddSZong Li 
133efc91ae4SZong Li /* CLTXPLLCFG0 */
134efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_OFFSET		0x30
135efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_DIVR_SHIFT	0
136efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_DIVR_MASK	(0x3f << PRCI_CLTXPLLCFG0_DIVR_SHIFT)
137efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_DIVF_SHIFT	6
138efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_DIVF_MASK	(0x1ff << PRCI_CLTXPLLCFG0_DIVF_SHIFT)
139efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_DIVQ_SHIFT	15
140efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_DIVQ_MASK	(0x7 << PRCI_CLTXPLLCFG0_DIVQ_SHIFT)
141efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_RANGE_SHIFT	18
142efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_RANGE_MASK	(0x7 << PRCI_CLTXPLLCFG0_RANGE_SHIFT)
143efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_BYPASS_SHIFT	24
144efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_BYPASS_MASK	(0x1 << PRCI_CLTXPLLCFG0_BYPASS_SHIFT)
145efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_FSE_SHIFT	25
146efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_FSE_MASK	(0x1 << PRCI_CLTXPLLCFG0_FSE_SHIFT)
147efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_LOCK_SHIFT	31
148efc91ae4SZong Li #define PRCI_CLTXPLLCFG0_LOCK_MASK	(0x1 << PRCI_CLTXPLLCFG0_LOCK_SHIFT)
149efc91ae4SZong Li 
150efc91ae4SZong Li /* CLTXPLLCFG1 */
151efc91ae4SZong Li #define PRCI_CLTXPLLCFG1_OFFSET		0x34
152efc91ae4SZong Li #define PRCI_CLTXPLLCFG1_CKE_SHIFT	31
153efc91ae4SZong Li #define PRCI_CLTXPLLCFG1_CKE_MASK	(0x1 << PRCI_CLTXPLLCFG1_CKE_SHIFT)
154efc91ae4SZong Li 
155efc91ae4SZong Li /* DVFSCOREPLLCFG0 */
156efc91ae4SZong Li #define PRCI_DVFSCOREPLLCFG0_OFFSET	0x38
157efc91ae4SZong Li 
158efc91ae4SZong Li /* DVFSCOREPLLCFG1 */
159efc91ae4SZong Li #define PRCI_DVFSCOREPLLCFG1_OFFSET	0x3c
160efc91ae4SZong Li #define PRCI_DVFSCOREPLLCFG1_CKE_SHIFT	31
161efc91ae4SZong Li #define PRCI_DVFSCOREPLLCFG1_CKE_MASK	(0x1 << PRCI_DVFSCOREPLLCFG1_CKE_SHIFT)
162efc91ae4SZong Li 
163efc91ae4SZong Li /* COREPLLSEL */
164efc91ae4SZong Li #define PRCI_COREPLLSEL_OFFSET			0x40
165efc91ae4SZong Li #define PRCI_COREPLLSEL_COREPLLSEL_SHIFT	0
166efc91ae4SZong Li #define PRCI_COREPLLSEL_COREPLLSEL_MASK					\
167efc91ae4SZong Li 		(0x1 << PRCI_COREPLLSEL_COREPLLSEL_SHIFT)
168efc91ae4SZong Li 
169efc91ae4SZong Li /* HFPCLKPLLCFG0 */
170efc91ae4SZong Li #define PRCI_HFPCLKPLLCFG0_OFFSET		0x50
171efc91ae4SZong Li #define PRCI_HFPCLKPLL_CFG0_DIVR_SHIFT		0
172efc91ae4SZong Li #define PRCI_HFPCLKPLL_CFG0_DIVR_MASK					\
173efc91ae4SZong Li 		(0x3f << PRCI_HFPCLKPLLCFG0_DIVR_SHIFT)
174efc91ae4SZong Li #define PRCI_HFPCLKPLL_CFG0_DIVF_SHIFT		6
175efc91ae4SZong Li #define PRCI_HFPCLKPLL_CFG0_DIVF_MASK					\
176efc91ae4SZong Li 		(0x1ff << PRCI_HFPCLKPLLCFG0_DIVF_SHIFT)
177efc91ae4SZong Li #define PRCI_HFPCLKPLL_CFG0_DIVQ_SHIFT		15
178efc91ae4SZong Li #define PRCI_HFPCLKPLL_CFG0_DIVQ_MASK					\
179efc91ae4SZong Li 		(0x7 << PRCI_HFPCLKPLLCFG0_DIVQ_SHIFT)
180efc91ae4SZong Li #define PRCI_HFPCLKPLL_CFG0_RANGE_SHIFT		18
181efc91ae4SZong Li #define PRCI_HFPCLKPLL_CFG0_RANGE_MASK					\
182efc91ae4SZong Li 		(0x7 << PRCI_HFPCLKPLLCFG0_RANGE_SHIFT)
183efc91ae4SZong Li #define PRCI_HFPCLKPLL_CFG0_BYPASS_SHIFT	24
184efc91ae4SZong Li #define PRCI_HFPCLKPLL_CFG0_BYPASS_MASK					\
185efc91ae4SZong Li 		(0x1 << PRCI_HFPCLKPLLCFG0_BYPASS_SHIFT)
186efc91ae4SZong Li #define PRCI_HFPCLKPLL_CFG0_FSE_SHIFT		25
187efc91ae4SZong Li #define PRCI_HFPCLKPLL_CFG0_FSE_MASK					\
188efc91ae4SZong Li 		(0x1 << PRCI_HFPCLKPLLCFG0_FSE_SHIFT)
189efc91ae4SZong Li #define PRCI_HFPCLKPLL_CFG0_LOCK_SHIFT		31
190efc91ae4SZong Li #define PRCI_HFPCLKPLL_CFG0_LOCK_MASK					\
191efc91ae4SZong Li 		(0x1 << PRCI_HFPCLKPLLCFG0_LOCK_SHIFT)
192efc91ae4SZong Li 
193efc91ae4SZong Li /* HFPCLKPLLCFG1 */
194efc91ae4SZong Li #define PRCI_HFPCLKPLLCFG1_OFFSET		0x54
195efc91ae4SZong Li #define PRCI_HFPCLKPLLCFG1_CKE_SHIFT		31
196efc91ae4SZong Li #define PRCI_HFPCLKPLLCFG1_CKE_MASK					\
197efc91ae4SZong Li 		(0x1 << PRCI_HFPCLKPLLCFG1_CKE_SHIFT)
198efc91ae4SZong Li 
199efc91ae4SZong Li /* HFPCLKPLLSEL */
200efc91ae4SZong Li #define PRCI_HFPCLKPLLSEL_OFFSET		0x58
201efc91ae4SZong Li #define PRCI_HFPCLKPLLSEL_HFPCLKPLLSEL_SHIFT	0
202efc91ae4SZong Li #define PRCI_HFPCLKPLLSEL_HFPCLKPLLSEL_MASK				\
203efc91ae4SZong Li 		(0x1 << PRCI_HFPCLKPLLSEL_HFPCLKPLLSEL_SHIFT)
204efc91ae4SZong Li 
205efc91ae4SZong Li /* HFPCLKPLLDIV */
206efc91ae4SZong Li #define PRCI_HFPCLKPLLDIV_OFFSET		0x5c
207efc91ae4SZong Li 
208efc91ae4SZong Li /* PRCIPLL */
209efc91ae4SZong Li #define PRCI_PRCIPLL_OFFSET			0xe0
210efc91ae4SZong Li 
211efc91ae4SZong Li /* PROCMONCFG */
212efc91ae4SZong Li #define PRCI_PROCMONCFG_OFFSET			0xf0
213efc91ae4SZong Li 
214c816e1ddSZong Li /*
215c816e1ddSZong Li  * Private structures
216c816e1ddSZong Li  */
217c816e1ddSZong Li 
218c816e1ddSZong Li /**
219c816e1ddSZong Li  * struct __prci_data - per-device-instance data
220c816e1ddSZong Li  * @va: base virtual address of the PRCI IP block
221c816e1ddSZong Li  * @hw_clks: encapsulates struct clk_hw records
222c816e1ddSZong Li  *
223c816e1ddSZong Li  * PRCI per-device instance data
224c816e1ddSZong Li  */
225c816e1ddSZong Li struct __prci_data {
226c816e1ddSZong Li 	void __iomem *va;
227*e4d368e0SGreentime Hu 	struct reset_simple_data reset;
228c816e1ddSZong Li 	struct clk_hw_onecell_data hw_clks;
229c816e1ddSZong Li };
230c816e1ddSZong Li 
231c816e1ddSZong Li /**
232c816e1ddSZong Li  * struct __prci_wrpll_data - WRPLL configuration and integration data
233c816e1ddSZong Li  * @c: WRPLL current configuration record
234c816e1ddSZong Li  * @enable_bypass: fn ptr to code to bypass the WRPLL (if applicable; else NULL)
235c816e1ddSZong Li  * @disable_bypass: fn ptr to code to not bypass the WRPLL (or NULL)
236c816e1ddSZong Li  * @cfg0_offs: WRPLL CFG0 register offset (in bytes) from the PRCI base address
237732374a0SPragnesh Patel  * @cfg1_offs: WRPLL CFG1 register offset (in bytes) from the PRCI base address
238c816e1ddSZong Li  *
239c816e1ddSZong Li  * @enable_bypass and @disable_bypass are used for WRPLL instances
240c816e1ddSZong Li  * that contain a separate external glitchless clock mux downstream
241c816e1ddSZong Li  * from the PLL.  The WRPLL internal bypass mux is not glitchless.
242c816e1ddSZong Li  */
243c816e1ddSZong Li struct __prci_wrpll_data {
244c816e1ddSZong Li 	struct wrpll_cfg c;
245c816e1ddSZong Li 	void (*enable_bypass)(struct __prci_data *pd);
246c816e1ddSZong Li 	void (*disable_bypass)(struct __prci_data *pd);
247c816e1ddSZong Li 	u8 cfg0_offs;
248732374a0SPragnesh Patel 	u8 cfg1_offs;
249c816e1ddSZong Li };
250c816e1ddSZong Li 
251c816e1ddSZong Li /**
252c816e1ddSZong Li  * struct __prci_clock - describes a clock device managed by PRCI
253c816e1ddSZong Li  * @name: user-readable clock name string - should match the manual
254c816e1ddSZong Li  * @parent_name: parent name for this clock
255c816e1ddSZong Li  * @ops: struct clk_ops for the Linux clock framework to use for control
256c816e1ddSZong Li  * @hw: Linux-private clock data
257c816e1ddSZong Li  * @pwd: WRPLL-specific data, associated with this clock (if not NULL)
258c816e1ddSZong Li  * @pd: PRCI-specific data associated with this clock (if not NULL)
259c816e1ddSZong Li  *
260c816e1ddSZong Li  * PRCI clock data.  Used by the PRCI driver to register PRCI-provided
261c816e1ddSZong Li  * clocks to the Linux clock infrastructure.
262c816e1ddSZong Li  */
263c816e1ddSZong Li struct __prci_clock {
264c816e1ddSZong Li 	const char *name;
265c816e1ddSZong Li 	const char *parent_name;
266c816e1ddSZong Li 	const struct clk_ops *ops;
267c816e1ddSZong Li 	struct clk_hw hw;
268c816e1ddSZong Li 	struct __prci_wrpll_data *pwd;
269c816e1ddSZong Li 	struct __prci_data *pd;
270c816e1ddSZong Li };
271c816e1ddSZong Li 
272c816e1ddSZong Li #define clk_hw_to_prci_clock(pwd) container_of(pwd, struct __prci_clock, hw)
273c816e1ddSZong Li 
274c816e1ddSZong Li /*
275c816e1ddSZong Li  * struct prci_clk_desc - describes the information of clocks of each SoCs
276c816e1ddSZong Li  * @clks: point to a array of __prci_clock
277c816e1ddSZong Li  * @num_clks: the number of element of clks
278c816e1ddSZong Li  */
279c816e1ddSZong Li struct prci_clk_desc {
280c816e1ddSZong Li 	struct __prci_clock *clks;
281c816e1ddSZong Li 	size_t num_clks;
282c816e1ddSZong Li };
283c816e1ddSZong Li 
284c816e1ddSZong Li /* Core clock mux control */
285c816e1ddSZong Li void sifive_prci_coreclksel_use_hfclk(struct __prci_data *pd);
286c816e1ddSZong Li void sifive_prci_coreclksel_use_corepll(struct __prci_data *pd);
287efc91ae4SZong Li void sifive_prci_coreclksel_use_final_corepll(struct __prci_data *pd);
288efc91ae4SZong Li void sifive_prci_corepllsel_use_dvfscorepll(struct __prci_data *pd);
289efc91ae4SZong Li void sifive_prci_corepllsel_use_corepll(struct __prci_data *pd);
290efc91ae4SZong Li void sifive_prci_hfpclkpllsel_use_hfclk(struct __prci_data *pd);
291efc91ae4SZong Li void sifive_prci_hfpclkpllsel_use_hfpclkpll(struct __prci_data *pd);
292c816e1ddSZong Li 
293c816e1ddSZong Li /* Linux clock framework integration */
294c816e1ddSZong Li long sifive_prci_wrpll_round_rate(struct clk_hw *hw, unsigned long rate,
295c816e1ddSZong Li 				  unsigned long *parent_rate);
296c816e1ddSZong Li int sifive_prci_wrpll_set_rate(struct clk_hw *hw, unsigned long rate,
297c816e1ddSZong Li 			       unsigned long parent_rate);
298732374a0SPragnesh Patel int sifive_clk_is_enabled(struct clk_hw *hw);
299732374a0SPragnesh Patel int sifive_prci_clock_enable(struct clk_hw *hw);
300732374a0SPragnesh Patel void sifive_prci_clock_disable(struct clk_hw *hw);
301c816e1ddSZong Li unsigned long sifive_prci_wrpll_recalc_rate(struct clk_hw *hw,
302c816e1ddSZong Li 					    unsigned long parent_rate);
303c816e1ddSZong Li unsigned long sifive_prci_tlclksel_recalc_rate(struct clk_hw *hw,
304c816e1ddSZong Li 					       unsigned long parent_rate);
305efc91ae4SZong Li unsigned long sifive_prci_hfpclkplldiv_recalc_rate(struct clk_hw *hw,
306efc91ae4SZong Li 						   unsigned long parent_rate);
307c816e1ddSZong Li 
308c61287bfSGreentime Hu int sifive_prci_pcie_aux_clock_is_enabled(struct clk_hw *hw);
309c61287bfSGreentime Hu int sifive_prci_pcie_aux_clock_enable(struct clk_hw *hw);
310c61287bfSGreentime Hu void sifive_prci_pcie_aux_clock_disable(struct clk_hw *hw);
311c61287bfSGreentime Hu 
312c816e1ddSZong Li #endif /* __SIFIVE_CLK_SIFIVE_PRCI_H */
313