1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright 2017-2019 NXP
4  */
5 
6 #ifndef __IMX7_CRM_H__
7 #define __IMX7_CRM_H__
8 
9 /*
10  * GPRx Registers
11  */
12 #define CCM_GPR0			0x0
13 #define CCM_GPRx_OFFSET			0x10
14 #define CCM_GPRx(idx)			(((idx) * CCM_GRPx_OFFSET) + CCM_GPR0)
15 #define CCM_GPRx_SET(idx)		(CCM_GPRx(idx) + 0x4)
16 #define CCM_GPRx_CLR(idx)		(CCM_GPRx(idx) + 0x8)
17 #define CCM_GPRx_TOG(idx)		(CCM_GPRx(idx) + 0xC)
18 
19 /*
20  * PLL_CTRLx Registers (PLL Control)
21  */
22 #define CCM_PLL_CTRL0		0x800
23 #define CCM_PLL_CTRLx_OFFSET	0x10
24 #define CCM_PLL_CTRLx(idx)	(((idx) * CCM_PLL_CTRLx_OFFSET) + CCM_PLL_CTRL0)
25 #define CCM_PLL_CTRLx_SET(idx)	(CCM_PLL_CTRLx(idx) + 0x4)
26 #define CCM_PLL_CTRLx_CLR(idx)	(CCM_PLL_CTRLx(idx) + 0x8)
27 #define CCM_PLL_CTRLx_TOG(idx)	(CCM_PLL_CTRLx(idx) + 0xC)
28 
29 /*
30  * CCGRx Registers (Clock Gating)
31  */
32 #define CCM_CCGR0		0x4000
33 #define CCM_CCGRx_OFFSET	0x10
34 #define CCM_CCGRx(idx)		(((idx) * CCM_CCGRx_OFFSET) + CCM_CCGR0)
35 #define CCM_CCGRx_SET(idx)	(CCM_CCGRx(idx) + 0x4)
36 #define CCM_CCGRx_CLR(idx)	(CCM_CCGRx(idx) + 0x8)
37 #define CCM_CCGRx_TOG(idx)	(CCM_CCGRx(idx) + 0xC)
38 
39 #define BS_CCM_CCGRx_SETTING(idx)	((idx) * 4)
40 #define BM_CCM_CCGRx_SETTING(idx)	\
41 			SHIFT_U32(0x3, BS_CCM_CCGRx_SETTING(idx))
42 #define CCM_CCGRx_DISABLE(idx)		\
43 			SHIFT_U32(0, BS_CCM_CCGRx_SETTING(idx))
44 #define CCM_CCGRx_RUN(idx)		\
45 			BIT32(BS_CCM_CCGRx_SETTING(idx))
46 #define CCM_CCGRx_RUN_WAIT(idx)		\
47 			SHIFT_U32(0x2, BS_CCM_CCGRx_SETTING(idx))
48 #define CCM_CCGRx_ALWAYS_ON(idx)	\
49 			SHIFT_U32(0x3, BS_CCM_CCGRx_SETTING(idx))
50 
51 /*
52  * TARGET_ROOTx Registers (Target)
53  */
54 #define CCM_TARGET_ROOT0		0x8000
55 #define CCM_TARGET_ROOTx_OFFSET		0x80
56 #define CCM_TARGET_ROOTx(idx)		\
57 		(((idx) * CCM_TARGET_ROOTx_OFFSET) + CCM_TARGET_ROOT0)
58 #define CCM_TARGET_ROOTx_SET(idx)	(CCM_TARGET_ROOTx(idx) + 0x4)
59 #define CCM_TARGET_ROOTx_CLR(idx)	(CCM_TARGET_ROOTx(idx) + 0x8)
60 #define CCM_TARGET_ROOTx_TOG(idx)	(CCM_TARGET_ROOTx(idx) + 0xC)
61 
62 /*
63  * MISC_ROOTx Registers (Miscellaneous)
64  */
65 #define CCM_MISC_ROOT0			0x8010
66 #define CCM_MISC_ROOTx_OFFSET		0x80
67 #define CCM_MISC_ROOTx(idx)		\
68 		(((idx) * CCM_MISC_ROOTx_OFFSET) + CCM_MISC_ROOT0)
69 #define CCM_MISC_ROOTx_SET(idx)		(CCM_MISC_ROOTx(idx) + 0x4)
70 #define CCM_MISC_ROOTx_CLR(idx)		(CCM_MISC_ROOTx(idx) + 0x8)
71 #define CCM_MISC_ROOTx_TOG(idx)		(CCM_MISC_ROOTx(idx) + 0xC)
72 
73 /*
74  * POST_ROOTx Registers (Post Divider)
75  */
76 #define CCM_POST_ROOT0			0x8020
77 #define CCM_POST_ROOTx_OFFSET		0x80
78 #define CCM_POST_ROOTx(idx)		\
79 		(((idx) * CCM_POST_ROOTx_OFFSET) + CCM_POST_ROOT0)
80 #define CCM_POST_ROOTx_SET(idx)		(CCM_POST_ROOTx(idx) + 0x4)
81 #define CCM_POST_ROOTx_CLR(idx)		(CCM_POST_ROOTx(idx) + 0x8)
82 #define CCM_POST_ROOTx_TOG(idx)		(CCM_POST_ROOTx(idx) + 0xC)
83 
84 /*
85  * PRE_ROOTx Registers (Pre Divider)
86  */
87 #define CCM_PRE_ROOT0			0x8030
88 #define CCM_PRE_ROOTx_OFFSET		0x80
89 #define CCM_PRE_ROOTx(idx)		\
90 		(((idx) * CCM_PRE_ROOTx_OFFSET) + CCM_PRE_ROOT0)
91 #define CCM_PRE_ROOTx_SET(idx)		(CCM_PRE_ROOTx(idx) + 0x4)
92 #define CCM_PRE_ROOTx_CLR(idx)		(CCM_PRE_ROOTx(idx) + 0x8)
93 #define CCM_PRE_ROOTx_TOG(idx)		(CCM_PRE_ROOTx(idx) + 0xC)
94 
95 /*
96  * ACCESS_CTRL_ROOTx Registers (Access Control)
97  */
98 #define CCM_ACCESS_CTRL_ROOT0		0x8030
99 #define CCM_ACCESS_CTRL_ROOTx_OFFSET	0x80
100 #define CCM_ACCESS_CTRL_ROOTx(idx)	\
101 		(((idx) * CCM_ACCESS_CTRL_ROOTx_OFFSET) + CCM_ACCESS_CTRL_ROOT0)
102 #define CCM_ACCESS_CTRL_ROOTx_SET(idx)	(CCM_ACCESS_CTRL_ROOTx(idx) + 0x4)
103 #define CCM_ACCESS_CTRL_ROOTx_CLR(idx)	(CCM_ACCESS_CTRL_ROOTx(idx) + 0x8)
104 #define CCM_ACCESS_CTRL_ROOTx_TOG(idx)	(CCM_ACCESS_CTRL_ROOTx(idx) + 0xC)
105 
106 /*
107  * Clock Domain ID
108  */
109 #define CCM_CLOCK_DOMAIN_OCOTP		35
110 #define CCM_CLOCK_DOMAIN_CAAM		36
111 
112 #endif /* __IMX7_CRM_H__ */
113