...
...
19
19
20
Tested on BananaPi-F3 board. With some out-of-tree drivers, I've
20
Tested on BananaPi-F3 board. With some out-of-tree drivers, I've
21
successfully brought up I2C, RTC, MMC and ethernet controllers. A clock
21
successfully brought up I2C, RTC, MMC and ethernet controllers. A clock
22
tree dump could be obtained here[1].
22
tree dump could be obtained here[1].
23
23
24
[1]: https://gist.github.com/heylenayy/4c88630454d5ad26c9336592673eb187
24
[1]: https://gist.github.com/heylenayy/73df0b6b075615a944990507112cfc5b
25
26
Changed from v5
27
- Correct "Spacemit" to "SpacemiT" in commit messages and code
28
- Always use space instead of TAB in comments for consistency
29
- dt-bindings
30
- Rename binding header to "spacemit,k1-syscon.h"
31
- apply review tags
32
- driver code
33
- remove "default" properties from Kconfig
34
- misc style and naming improvements
35
- make ccu_read() directly return the read value, drop ccu_poll() and
36
reorder the arguments to ccu_{read,update} macros
37
- drop ccu_common.reg_swcr2
38
- clock tree for K1
39
- define PLL3 with the correct offset of SWCR3 register
40
- synchronize PLL configuration entries with the vendor kernel
41
- reformat clocks definitions
42
- explain why PLLs require the MPMU syscon to function
43
- log a message when failing to register a clock
44
- simplify clock registration with ARRAY_SIZE()
45
- ddn
46
- correctly handle masks which doesn't start from BIT(0) when
47
calculating the best rate
48
- improve precision of frequency calculation
49
- derive _{den,num}_shift from corresponding masks with __ffs()
50
- mix
51
- match the full mask of gate in ccu_gate_is_enabled()
52
- add a note about "frequency change" bit and simplify FC-triggering
53
logic
54
- drop unnecessary local variables and initialization from clock
55
operations
56
- round to the closest rate in ccu_mix_calc_best_rate()
57
- change names of all mix subtypes to follow the order of mux ->
58
factor/div -> gate -> fc
59
- drop unused _flags argument from CCU_GATE_FACTOR_DEFINE()
60
- pll
61
- ensure PLLs are initialized to a known state
62
- drop extra check in ccu_pll_enable()
63
- round to the closest rate in ccu_pll_round_rate()
64
- TWSI8 support
65
- Split cleanly from the main driver commit
66
- devicetree
67
- drop extra "*-cells" and "ranges" properties
68
- Enable SpacemiT K1 CCU in RISC-V defconfig
69
- Link to v5: https://lore.kernel.org/all/20250306175750.22480-2-heylenay@4d2.org/
25
70
26
Changed from v4
71
Changed from v4
27
- bindings:
72
- bindings:
28
- Drop CLK_*_NUM macros from binding headers
73
- Drop CLK_*_NUM macros from binding headers
29
- Rename spacemit,k1-ccu.yaml to spacemit,k1-pll.yaml, change to
74
- Rename spacemit,k1-ccu.yaml to spacemit,k1-pll.yaml, change to
...
...
111
- document spacemit,k1-syscon
156
- document spacemit,k1-syscon
112
- implement all APBS, MPMU, APBC and APMU clocks
157
- implement all APBS, MPMU, APBC and APMU clocks
113
- code cleanup
158
- code cleanup
114
- Link to v1: https://lore.kernel.org/all/SEYPR01MB4221B3178F5233EAB5149E41D7902@SEYPR01MB4221.apcprd01.prod.exchangelabs.com/
159
- Link to v1: https://lore.kernel.org/all/SEYPR01MB4221B3178F5233EAB5149E41D7902@SEYPR01MB4221.apcprd01.prod.exchangelabs.com/
115
160
116
Haylen Chu (5):
161
Haylen Chu (6):
117
dt-bindings: soc: spacemit: Add spacemit,k1-syscon
162
dt-bindings: soc: spacemit: Add spacemit,k1-syscon
118
dt-bindings: clock: spacemit: Add spacemit,k1-pll
163
dt-bindings: clock: spacemit: Add spacemit,k1-pll
119
clk: spacemit: Add clock support for Spacemit K1 SoC
164
clk: spacemit: Add clock support for SpacemiT K1 SoC
120
clk: spacemit: k1: Add TWSI8 bus and function clocks
165
clk: spacemit: k1: Add TWSI8 bus and function clocks
121
riscv: dts: spacemit: Add clock tree for Spacemit K1
166
riscv: dts: spacemit: Add clock tree for SpacemiT K1
167
riscv: defconfig: enable clock controller unit support for SpacemiT K1
122
168
123
.../bindings/clock/spacemit,k1-pll.yaml | 50 +
169
.../bindings/clock/spacemit,k1-pll.yaml | 50 +
124
.../soc/spacemit/spacemit,k1-syscon.yaml | 80 +
170
.../soc/spacemit/spacemit,k1-syscon.yaml | 80 +
125
arch/riscv/boot/dts/spacemit/k1.dtsi | 79 +
171
arch/riscv/boot/dts/spacemit/k1.dtsi | 75 +
172
arch/riscv/configs/defconfig | 2 +
126
drivers/clk/Kconfig | 1 +
173
drivers/clk/Kconfig | 1 +
127
drivers/clk/Makefile | 1 +
174
drivers/clk/Makefile | 1 +
128
drivers/clk/spacemit/Kconfig | 20 +
175
drivers/clk/spacemit/Kconfig | 18 +
129
drivers/clk/spacemit/Makefile | 5 +
176
drivers/clk/spacemit/Makefile | 5 +
130
drivers/clk/spacemit/ccu-k1.c | 1720 +++++++++++++++++
177
drivers/clk/spacemit/apbc_clks | 100 ++
131
drivers/clk/spacemit/ccu_common.h | 47 +
178
drivers/clk/spacemit/ccu-k1.c | 1321 +++++++++++++++++
132
drivers/clk/spacemit/ccu_ddn.c | 80 +
179
drivers/clk/spacemit/ccu_common.h | 48 +
133
drivers/clk/spacemit/ccu_ddn.h | 48 +
180
drivers/clk/spacemit/ccu_ddn.c | 83 ++
134
drivers/clk/spacemit/ccu_mix.c | 284 +++
181
drivers/clk/spacemit/ccu_ddn.h | 47 +
135
drivers/clk/spacemit/ccu_mix.h | 246 +++
182
drivers/clk/spacemit/ccu_mix.c | 268 ++++
136
drivers/clk/spacemit/ccu_pll.c | 146 ++
183
drivers/clk/spacemit/ccu_mix.h | 218 +++
137
drivers/clk/spacemit/ccu_pll.h | 76 +
184
drivers/clk/spacemit/ccu_pll.c | 157 ++
138
include/dt-bindings/clock/spacemit,k1-ccu.h | 247 +++
185
drivers/clk/spacemit/ccu_pll.h | 86 ++
139
16 files changed, 3130 insertions(+)
186
.../dt-bindings/clock/spacemit,k1-syscon.h | 247 +++
187
18 files changed, 2807 insertions(+)
140
create mode 100644 Documentation/devicetree/bindings/clock/spacemit,k1-pll.yaml
188
create mode 100644 Documentation/devicetree/bindings/clock/spacemit,k1-pll.yaml
141
create mode 100644 Documentation/devicetree/bindings/soc/spacemit/spacemit,k1-syscon.yaml
189
create mode 100644 Documentation/devicetree/bindings/soc/spacemit/spacemit,k1-syscon.yaml
142
create mode 100644 drivers/clk/spacemit/Kconfig
190
create mode 100644 drivers/clk/spacemit/Kconfig
143
create mode 100644 drivers/clk/spacemit/Makefile
191
create mode 100644 drivers/clk/spacemit/Makefile
192
create mode 100644 drivers/clk/spacemit/apbc_clks
144
create mode 100644 drivers/clk/spacemit/ccu-k1.c
193
create mode 100644 drivers/clk/spacemit/ccu-k1.c
145
create mode 100644 drivers/clk/spacemit/ccu_common.h
194
create mode 100644 drivers/clk/spacemit/ccu_common.h
146
create mode 100644 drivers/clk/spacemit/ccu_ddn.c
195
create mode 100644 drivers/clk/spacemit/ccu_ddn.c
147
create mode 100644 drivers/clk/spacemit/ccu_ddn.h
196
create mode 100644 drivers/clk/spacemit/ccu_ddn.h
148
create mode 100644 drivers/clk/spacemit/ccu_mix.c
197
create mode 100644 drivers/clk/spacemit/ccu_mix.c
149
create mode 100644 drivers/clk/spacemit/ccu_mix.h
198
create mode 100644 drivers/clk/spacemit/ccu_mix.h
150
create mode 100644 drivers/clk/spacemit/ccu_pll.c
199
create mode 100644 drivers/clk/spacemit/ccu_pll.c
151
create mode 100644 drivers/clk/spacemit/ccu_pll.h
200
create mode 100644 drivers/clk/spacemit/ccu_pll.h
152
create mode 100644 include/dt-bindings/clock/spacemit,k1-ccu.h
201
create mode 100644 include/dt-bindings/clock/spacemit,k1-syscon.h
153
202
154
--
203
--
155
2.48.1
204
2.49.0
diff view generated by jsdifflib
1
Document APMU, MPMU and APBC syscons found on Spacemit K1 SoC, which are
1
Document APMU, MPMU and APBC syscons found on SpacemiT K1 SoC, which are
2
capable of generating clock and reset signals. Additionally, APMU and MPMU
2
capable of generating clock and reset signals. Additionally, APMU and MPMU
3
manage power domains.
3
manage power domains.
4
4
5
Signed-off-by: Haylen Chu <heylenay@4d2.org>
5
Signed-off-by: Haylen Chu <heylenay@4d2.org>
6
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
6
---
7
---
7
.../soc/spacemit/spacemit,k1-syscon.yaml | 80 +++++++
8
.../soc/spacemit/spacemit,k1-syscon.yaml | 80 +++++++
8
include/dt-bindings/clock/spacemit,k1-ccu.h | 210 ++++++++++++++++++
9
.../dt-bindings/clock/spacemit,k1-syscon.h | 210 ++++++++++++++++++
9
2 files changed, 290 insertions(+)
10
2 files changed, 290 insertions(+)
10
create mode 100644 Documentation/devicetree/bindings/soc/spacemit/spacemit,k1-syscon.yaml
11
create mode 100644 Documentation/devicetree/bindings/soc/spacemit/spacemit,k1-syscon.yaml
11
create mode 100644 include/dt-bindings/clock/spacemit,k1-ccu.h
12
create mode 100644 include/dt-bindings/clock/spacemit,k1-syscon.h
12
13
13
diff --git a/Documentation/devicetree/bindings/soc/spacemit/spacemit,k1-syscon.yaml b/Documentation/devicetree/bindings/soc/spacemit/spacemit,k1-syscon.yaml
14
diff --git a/Documentation/devicetree/bindings/soc/spacemit/spacemit,k1-syscon.yaml b/Documentation/devicetree/bindings/soc/spacemit/spacemit,k1-syscon.yaml
14
new file mode 100644
15
new file mode 100644
15
index XXXXXXX..XXXXXXX
16
index XXXXXXX..XXXXXXX
16
--- /dev/null
17
--- /dev/null
...
...
20
+%YAML 1.2
21
+%YAML 1.2
21
+---
22
+---
22
+$id: http://devicetree.org/schemas/soc/spacemit/spacemit,k1-syscon.yaml#
23
+$id: http://devicetree.org/schemas/soc/spacemit/spacemit,k1-syscon.yaml#
23
+$schema: http://devicetree.org/meta-schemas/core.yaml#
24
+$schema: http://devicetree.org/meta-schemas/core.yaml#
24
+
25
+
25
+title: Spacemit K1 SoC System Controller
26
+title: SpacemiT K1 SoC System Controller
26
+
27
+
27
+maintainers:
28
+maintainers:
28
+ - Haylen Chu <heylenay@4d2.org>
29
+ - Haylen Chu <heylenay@4d2.org>
29
+
30
+
30
+description:
31
+description:
31
+ System controllers found on Spacemit K1 SoC, which are capable of
32
+ System controllers found on SpacemiT K1 SoC, which are capable of
32
+ clock, reset and power-management functions.
33
+ clock, reset and power-management functions.
33
+
34
+
34
+properties:
35
+properties:
35
+ compatible:
36
+ compatible:
36
+ enum:
37
+ enum:
...
...
52
+ - const: vctcxo_24m
53
+ - const: vctcxo_24m
53
+
54
+
54
+ "#clock-cells":
55
+ "#clock-cells":
55
+ const: 1
56
+ const: 1
56
+ description:
57
+ description:
57
+ See <dt-bindings/clock/spacemit,k1-ccu.h> for valid indices.
58
+ See <dt-bindings/clock/spacemit,k1-syscon.h> for valid indices.
58
+
59
+
59
+ "#power-domain-cells":
60
+ "#power-domain-cells":
60
+ const: 1
61
+ const: 1
61
+
62
+
62
+ "#reset-cells":
63
+ "#reset-cells":
...
...
94
+ clock-names = "osc", "vctcxo_1m", "vctcxo_3m", "vctcxo_24m";
95
+ clock-names = "osc", "vctcxo_1m", "vctcxo_3m", "vctcxo_24m";
95
+ #clock-cells = <1>;
96
+ #clock-cells = <1>;
96
+ #power-domain-cells = <1>;
97
+ #power-domain-cells = <1>;
97
+ #reset-cells = <1>;
98
+ #reset-cells = <1>;
98
+ };
99
+ };
99
diff --git a/include/dt-bindings/clock/spacemit,k1-ccu.h b/include/dt-bindings/clock/spacemit,k1-ccu.h
100
diff --git a/include/dt-bindings/clock/spacemit,k1-syscon.h b/include/dt-bindings/clock/spacemit,k1-syscon.h
100
new file mode 100644
101
new file mode 100644
101
index XXXXXXX..XXXXXXX
102
index XXXXXXX..XXXXXXX
102
--- /dev/null
103
--- /dev/null
103
+++ b/include/dt-bindings/clock/spacemit,k1-ccu.h
104
+++ b/include/dt-bindings/clock/spacemit,k1-syscon.h
104
@@ -XXX,XX +XXX,XX @@
105
@@ -XXX,XX +XXX,XX @@
105
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
106
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
106
+/*
107
+/*
107
+ * Copyright (C) 2024 Haylen Chu <heylenay@outlook.com>
108
+ * Copyright (C) 2024 Haylen Chu <heylenay@outlook.com>
108
+ */
109
+ */
109
+
110
+
110
+#ifndef _DT_BINDINGS_SPACEMIT_CCU_H_
111
+#ifndef _DT_BINDINGS_SPACEMIT_CCU_H_
111
+#define _DT_BINDINGS_SPACEMIT_CCU_H_
112
+#define _DT_BINDINGS_SPACEMIT_CCU_H_
112
+
113
+
113
+/*    MPMU clocks    */
114
+/* MPMU clocks */
114
+#define CLK_PLL1_307P2        0
115
+#define CLK_PLL1_307P2        0
115
+#define CLK_PLL1_76P8        1
116
+#define CLK_PLL1_76P8        1
116
+#define CLK_PLL1_61P44        2
117
+#define CLK_PLL1_61P44        2
117
+#define CLK_PLL1_153P6        3
118
+#define CLK_PLL1_153P6        3
118
+#define CLK_PLL1_102P4        4
119
+#define CLK_PLL1_102P4        4
...
...
143
+#define CLK_I2S_SYSCLK        29
144
+#define CLK_I2S_SYSCLK        29
144
+#define CLK_I2S_BCLK        30
145
+#define CLK_I2S_BCLK        30
145
+#define CLK_APB            31
146
+#define CLK_APB            31
146
+#define CLK_WDT_BUS        32
147
+#define CLK_WDT_BUS        32
147
+
148
+
148
+/*    APBC clocks    */
149
+/* APBC clocks */
149
+#define CLK_UART0        0
150
+#define CLK_UART0        0
150
+#define CLK_UART2        1
151
+#define CLK_UART2        1
151
+#define CLK_UART3        2
152
+#define CLK_UART3        2
152
+#define CLK_UART4        3
153
+#define CLK_UART4        3
153
+#define CLK_UART5        4
154
+#define CLK_UART5        4
...
...
245
+#define CLK_SSPA0_BUS        96
246
+#define CLK_SSPA0_BUS        96
246
+#define CLK_SSPA1_BUS        97
247
+#define CLK_SSPA1_BUS        97
247
+#define CLK_TSEN_BUS        98
248
+#define CLK_TSEN_BUS        98
248
+#define CLK_IPC_AP2AUD_BUS    99
249
+#define CLK_IPC_AP2AUD_BUS    99
249
+
250
+
250
+/*    APMU clocks    */
251
+/* APMU clocks */
251
+#define CLK_CCI550        0
252
+#define CLK_CCI550        0
252
+#define CLK_CPU_C0_HI        1
253
+#define CLK_CPU_C0_HI        1
253
+#define CLK_CPU_C0_CORE        2
254
+#define CLK_CPU_C0_CORE        2
254
+#define CLK_CPU_C0_ACE        3
255
+#define CLK_CPU_C0_ACE        3
255
+#define CLK_CPU_C0_TCM        4
256
+#define CLK_CPU_C0_TCM        4
...
...
311
+#define CLK_V2D            60
312
+#define CLK_V2D            60
312
+#define CLK_EMMC_BUS        61
313
+#define CLK_EMMC_BUS        61
313
+
314
+
314
+#endif /* _DT_BINDINGS_SPACEMIT_CCU_H_ */
315
+#endif /* _DT_BINDINGS_SPACEMIT_CCU_H_ */
315
--
316
--
316
2.48.1
317
2.49.0
diff view generated by jsdifflib
1
Add definition for the PLL found on Spacemit K1 SoC, which takes the
1
Add definition for the PLL found on SpacemiT K1 SoC, which takes the
2
external 24MHz oscillator as input and generates clocks in various
2
external 24MHz oscillator as input and generates clocks in various
3
frequencies for the system.
3
frequencies for the system.
4
4
5
Signed-off-by: Haylen Chu <heylenay@4d2.org>
5
Signed-off-by: Haylen Chu <heylenay@4d2.org>
6
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
6
---
7
---
7
.../bindings/clock/spacemit,k1-pll.yaml | 50 +++++++++++++++++++
8
.../bindings/clock/spacemit,k1-pll.yaml | 50 +++++++++++++++++++
8
include/dt-bindings/clock/spacemit,k1-ccu.h | 37 ++++++++++++++
9
.../dt-bindings/clock/spacemit,k1-syscon.h | 37 ++++++++++++++
9
2 files changed, 87 insertions(+)
10
2 files changed, 87 insertions(+)
10
create mode 100644 Documentation/devicetree/bindings/clock/spacemit,k1-pll.yaml
11
create mode 100644 Documentation/devicetree/bindings/clock/spacemit,k1-pll.yaml
11
12
12
diff --git a/Documentation/devicetree/bindings/clock/spacemit,k1-pll.yaml b/Documentation/devicetree/bindings/clock/spacemit,k1-pll.yaml
13
diff --git a/Documentation/devicetree/bindings/clock/spacemit,k1-pll.yaml b/Documentation/devicetree/bindings/clock/spacemit,k1-pll.yaml
13
new file mode 100644
14
new file mode 100644
...
...
19
+%YAML 1.2
20
+%YAML 1.2
20
+---
21
+---
21
+$id: http://devicetree.org/schemas/clock/spacemit,k1-pll.yaml#
22
+$id: http://devicetree.org/schemas/clock/spacemit,k1-pll.yaml#
22
+$schema: http://devicetree.org/meta-schemas/core.yaml#
23
+$schema: http://devicetree.org/meta-schemas/core.yaml#
23
+
24
+
24
+title: Spacemit K1 PLL
25
+title: SpacemiT K1 PLL
25
+
26
+
26
+maintainers:
27
+maintainers:
27
+ - Haylen Chu <heylenay@4d2.org>
28
+ - Haylen Chu <heylenay@4d2.org>
28
+
29
+
29
+properties:
30
+properties:
...
...
43
+ lock status.
44
+ lock status.
44
+
45
+
45
+ "#clock-cells":
46
+ "#clock-cells":
46
+ const: 1
47
+ const: 1
47
+ description:
48
+ description:
48
+ See <dt-bindings/clock/spacemit,k1-ccu.h> for valid indices.
49
+ See <dt-bindings/clock/spacemit,k1-syscon.h> for valid indices.
49
+
50
+
50
+required:
51
+required:
51
+ - compatible
52
+ - compatible
52
+ - reg
53
+ - reg
53
+ - clocks
54
+ - clocks
...
...
63
+ reg = <0xd4090000 0x1000>;
64
+ reg = <0xd4090000 0x1000>;
64
+ clocks = <&vctcxo_24m>;
65
+ clocks = <&vctcxo_24m>;
65
+ spacemit,mpmu = <&sysctl_mpmu>;
66
+ spacemit,mpmu = <&sysctl_mpmu>;
66
+ #clock-cells = <1>;
67
+ #clock-cells = <1>;
67
+ };
68
+ };
68
diff --git a/include/dt-bindings/clock/spacemit,k1-ccu.h b/include/dt-bindings/clock/spacemit,k1-ccu.h
69
diff --git a/include/dt-bindings/clock/spacemit,k1-syscon.h b/include/dt-bindings/clock/spacemit,k1-syscon.h
69
index XXXXXXX..XXXXXXX 100644
70
index XXXXXXX..XXXXXXX 100644
70
--- a/include/dt-bindings/clock/spacemit,k1-ccu.h
71
--- a/include/dt-bindings/clock/spacemit,k1-syscon.h
71
+++ b/include/dt-bindings/clock/spacemit,k1-ccu.h
72
+++ b/include/dt-bindings/clock/spacemit,k1-syscon.h
72
@@ -XXX,XX +XXX,XX @@
73
@@ -XXX,XX +XXX,XX @@
73
#ifndef _DT_BINDINGS_SPACEMIT_CCU_H_
74
#ifndef _DT_BINDINGS_SPACEMIT_CCU_H_
74
#define _DT_BINDINGS_SPACEMIT_CCU_H_
75
#define _DT_BINDINGS_SPACEMIT_CCU_H_
75
76
76
+/*    APBS (PLL) clocks    */
77
+/*    APBS (PLL) clocks    */
...
...
108
+#define CLK_PLL3_D8        31
109
+#define CLK_PLL3_D8        31
109
+#define CLK_PLL3_80        32
110
+#define CLK_PLL3_80        32
110
+#define CLK_PLL3_40        33
111
+#define CLK_PLL3_40        33
111
+#define CLK_PLL3_20        34
112
+#define CLK_PLL3_20        34
112
+
113
+
113
/*    MPMU clocks    */
114
/* MPMU clocks */
114
#define CLK_PLL1_307P2        0
115
#define CLK_PLL1_307P2        0
115
#define CLK_PLL1_76P8        1
116
#define CLK_PLL1_76P8        1
116
--
117
--
117
2.48.1
118
2.49.0
diff view generated by jsdifflib
...
...
8
8
9
Signed-off-by: Haylen Chu <heylenay@4d2.org>
9
Signed-off-by: Haylen Chu <heylenay@4d2.org>
10
---
10
---
11
drivers/clk/Kconfig | 1 +
11
drivers/clk/Kconfig | 1 +
12
drivers/clk/Makefile | 1 +
12
drivers/clk/Makefile | 1 +
13
drivers/clk/spacemit/Kconfig | 20 +
13
drivers/clk/spacemit/Kconfig | 18 +
14
drivers/clk/spacemit/Makefile | 5 +
14
drivers/clk/spacemit/Makefile | 5 +
15
drivers/clk/spacemit/ccu-k1.c | 1714 +++++++++++++++++++++++++++++
15
drivers/clk/spacemit/apbc_clks | 100 +++
16
drivers/clk/spacemit/ccu_common.h | 47 +
16
drivers/clk/spacemit/ccu-k1.c | 1316 +++++++++++++++++++++++++++++
17
drivers/clk/spacemit/ccu_ddn.c | 80 ++
17
drivers/clk/spacemit/ccu_common.h | 48 ++
18
drivers/clk/spacemit/ccu_ddn.h | 48 +
18
drivers/clk/spacemit/ccu_ddn.c | 83 ++
19
drivers/clk/spacemit/ccu_mix.c | 284 +++++
19
drivers/clk/spacemit/ccu_ddn.h | 47 ++
20
drivers/clk/spacemit/ccu_mix.h | 246 +++++
20
drivers/clk/spacemit/ccu_mix.c | 268 ++++++
21
drivers/clk/spacemit/ccu_pll.c | 146 +++
21
drivers/clk/spacemit/ccu_mix.h | 218 +++++
22
drivers/clk/spacemit/ccu_pll.h | 76 ++
22
drivers/clk/spacemit/ccu_pll.c | 157 ++++
23
12 files changed, 2668 insertions(+)
23
drivers/clk/spacemit/ccu_pll.h | 86 ++
24
13 files changed, 2348 insertions(+)
24
create mode 100644 drivers/clk/spacemit/Kconfig
25
create mode 100644 drivers/clk/spacemit/Kconfig
25
create mode 100644 drivers/clk/spacemit/Makefile
26
create mode 100644 drivers/clk/spacemit/Makefile
27
create mode 100644 drivers/clk/spacemit/apbc_clks
26
create mode 100644 drivers/clk/spacemit/ccu-k1.c
28
create mode 100644 drivers/clk/spacemit/ccu-k1.c
27
create mode 100644 drivers/clk/spacemit/ccu_common.h
29
create mode 100644 drivers/clk/spacemit/ccu_common.h
28
create mode 100644 drivers/clk/spacemit/ccu_ddn.c
30
create mode 100644 drivers/clk/spacemit/ccu_ddn.c
29
create mode 100644 drivers/clk/spacemit/ccu_ddn.h
31
create mode 100644 drivers/clk/spacemit/ccu_ddn.h
30
create mode 100644 drivers/clk/spacemit/ccu_mix.c
32
create mode 100644 drivers/clk/spacemit/ccu_mix.c
...
...
63
+++ b/drivers/clk/spacemit/Kconfig
65
+++ b/drivers/clk/spacemit/Kconfig
64
@@ -XXX,XX +XXX,XX @@
66
@@ -XXX,XX +XXX,XX @@
65
+# SPDX-License-Identifier: GPL-2.0-only
67
+# SPDX-License-Identifier: GPL-2.0-only
66
+
68
+
67
+config SPACEMIT_CCU
69
+config SPACEMIT_CCU
68
+    tristate "Clock support for Spacemit SoCs"
70
+    tristate "Clock support for SpacemiT SoCs"
69
+    default y
70
+    depends on ARCH_SPACEMIT || COMPILE_TEST
71
+    depends on ARCH_SPACEMIT || COMPILE_TEST
71
+    select MFD_SYSCON
72
+    select MFD_SYSCON
72
+    help
73
+    help
73
+     Say Y to enable clock controller unit support for Spacemit SoCs.
74
+     Say Y to enable clock controller unit support for SpacemiT SoCs.
74
+
75
+
75
+if SPACEMIT_CCU
76
+if SPACEMIT_CCU
76
+
77
+
77
+config SPACEMIT_K1_CCU
78
+config SPACEMIT_K1_CCU
78
+    tristate "Support for Spacemit K1 SoC"
79
+    tristate "Support for SpacemiT K1 SoC"
79
+    default y
80
+    depends on ARCH_SPACEMIT || COMPILE_TEST
80
+    depends on ARCH_SPACEMIT || COMPILE_TEST
81
+    help
81
+    help
82
+     Support for clock controller unit in Spacemit K1 SoC.
82
+     Support for clock controller unit in SpacemiT K1 SoC.
83
+
83
+
84
+endif
84
+endif
85
diff --git a/drivers/clk/spacemit/Makefile b/drivers/clk/spacemit/Makefile
85
diff --git a/drivers/clk/spacemit/Makefile b/drivers/clk/spacemit/Makefile
86
new file mode 100644
86
new file mode 100644
87
index XXXXXXX..XXXXXXX
87
index XXXXXXX..XXXXXXX
...
...
91
+# SPDX-License-Identifier: GPL-2.0
91
+# SPDX-License-Identifier: GPL-2.0
92
+
92
+
93
+obj-$(CONFIG_SPACEMIT_K1_CCU)    = spacemit-ccu-k1.o
93
+obj-$(CONFIG_SPACEMIT_K1_CCU)    = spacemit-ccu-k1.o
94
+spacemit-ccu-k1-y        = ccu_pll.o ccu_mix.o ccu_ddn.o
94
+spacemit-ccu-k1-y        = ccu_pll.o ccu_mix.o ccu_ddn.o
95
+spacemit-ccu-k1-y        += ccu-k1.o
95
+spacemit-ccu-k1-y        += ccu-k1.o
96
diff --git a/drivers/clk/spacemit/apbc_clks b/drivers/clk/spacemit/apbc_clks
97
new file mode 100644
98
index XXXXXXX..XXXXXXX
99
--- /dev/null
100
+++ b/drivers/clk/spacemit/apbc_clks
101
@@ -XXX,XX +XXX,XX @@
102
+        [CLK_UART0]        = &uart0_clk.common.hw,
103
+        [CLK_UART2]        = &uart2_clk.common.hw,
104
+        [CLK_UART3]        = &uart3_clk.common.hw,
105
+        [CLK_UART4]        = &uart4_clk.common.hw,
106
+        [CLK_UART5]        = &uart5_clk.common.hw,
107
+        [CLK_UART6]        = &uart6_clk.common.hw,
108
+        [CLK_UART7]        = &uart7_clk.common.hw,
109
+        [CLK_UART8]        = &uart8_clk.common.hw,
110
+        [CLK_UART9]        = &uart9_clk.common.hw,
111
+        [CLK_GPIO]        = &gpio_clk.common.hw,
112
+        [CLK_PWM0]        = &pwm0_clk.common.hw,
113
+        [CLK_PWM1]        = &pwm1_clk.common.hw,
114
+        [CLK_PWM2]        = &pwm2_clk.common.hw,
115
+        [CLK_PWM3]        = &pwm3_clk.common.hw,
116
+        [CLK_PWM4]        = &pwm4_clk.common.hw,
117
+        [CLK_PWM5]        = &pwm5_clk.common.hw,
118
+        [CLK_PWM6]        = &pwm6_clk.common.hw,
119
+        [CLK_PWM7]        = &pwm7_clk.common.hw,
120
+        [CLK_PWM8]        = &pwm8_clk.common.hw,
121
+        [CLK_PWM9]        = &pwm9_clk.common.hw,
122
+        [CLK_PWM10]        = &pwm10_clk.common.hw,
123
+        [CLK_PWM11]        = &pwm11_clk.common.hw,
124
+        [CLK_PWM12]        = &pwm12_clk.common.hw,
125
+        [CLK_PWM13]        = &pwm13_clk.common.hw,
126
+        [CLK_PWM14]        = &pwm14_clk.common.hw,
127
+        [CLK_PWM15]        = &pwm15_clk.common.hw,
128
+        [CLK_PWM16]        = &pwm16_clk.common.hw,
129
+        [CLK_PWM17]        = &pwm17_clk.common.hw,
130
+        [CLK_PWM18]        = &pwm18_clk.common.hw,
131
+        [CLK_PWM19]        = &pwm19_clk.common.hw,
132
+        [CLK_SSP3]        = &ssp3_clk.common.hw,
133
+        [CLK_RTC]        = &rtc_clk.common.hw,
134
+        [CLK_TWSI0]        = &twsi0_clk.common.hw,
135
+        [CLK_TWSI1]        = &twsi1_clk.common.hw,
136
+        [CLK_TWSI2]        = &twsi2_clk.common.hw,
137
+        [CLK_TWSI4]        = &twsi4_clk.common.hw,
138
+        [CLK_TWSI5]        = &twsi5_clk.common.hw,
139
+        [CLK_TWSI6]        = &twsi6_clk.common.hw,
140
+        [CLK_TWSI7]        = &twsi7_clk.common.hw,
141
+        [CLK_TWSI8]        = &twsi8_clk.common.hw,
142
+        [CLK_TIMERS1]        = &timers1_clk.common.hw,
143
+        [CLK_TIMERS2]        = &timers2_clk.common.hw,
144
+        [CLK_AIB]        = &aib_clk.common.hw,
145
+        [CLK_ONEWIRE]        = &onewire_clk.common.hw,
146
+        [CLK_SSPA0]        = &sspa0_clk.common.hw,
147
+        [CLK_SSPA1]        = &sspa1_clk.common.hw,
148
+        [CLK_DRO]        = &dro_clk.common.hw,
149
+        [CLK_IR]        = &ir_clk.common.hw,
150
+        [CLK_TSEN]        = &tsen_clk.common.hw,
151
+        [CLK_IPC_AP2AUD]    = &ipc_ap2aud_clk.common.hw,
152
+        [CLK_CAN0]        = &can0_clk.common.hw,
153
+        [CLK_CAN0_BUS]        = &can0_bus_clk.common.hw,
154
+        [CLK_UART0_BUS]        = &uart0_bus_clk.common.hw,
155
+        [CLK_UART2_BUS]        = &uart2_bus_clk.common.hw,
156
+        [CLK_UART3_BUS]        = &uart3_bus_clk.common.hw,
157
+        [CLK_UART4_BUS]        = &uart4_bus_clk.common.hw,
158
+        [CLK_UART5_BUS]        = &uart5_bus_clk.common.hw,
159
+        [CLK_UART6_BUS]        = &uart6_bus_clk.common.hw,
160
+        [CLK_UART7_BUS]        = &uart7_bus_clk.common.hw,
161
+        [CLK_UART8_BUS]        = &uart8_bus_clk.common.hw,
162
+        [CLK_UART9_BUS]        = &uart9_bus_clk.common.hw,
163
+        [CLK_GPIO_BUS]        = &gpio_bus_clk.common.hw,
164
+        [CLK_PWM0_BUS]        = &pwm0_bus_clk.common.hw,
165
+        [CLK_PWM1_BUS]        = &pwm1_bus_clk.common.hw,
166
+        [CLK_PWM2_BUS]        = &pwm2_bus_clk.common.hw,
167
+        [CLK_PWM3_BUS]        = &pwm3_bus_clk.common.hw,
168
+        [CLK_PWM4_BUS]        = &pwm4_bus_clk.common.hw,
169
+        [CLK_PWM5_BUS]        = &pwm5_bus_clk.common.hw,
170
+        [CLK_PWM6_BUS]        = &pwm6_bus_clk.common.hw,
171
+        [CLK_PWM7_BUS]        = &pwm7_bus_clk.common.hw,
172
+        [CLK_PWM8_BUS]        = &pwm8_bus_clk.common.hw,
173
+        [CLK_PWM9_BUS]        = &pwm9_bus_clk.common.hw,
174
+        [CLK_PWM10_BUS]        = &pwm10_bus_clk.common.hw,
175
+        [CLK_PWM11_BUS]        = &pwm11_bus_clk.common.hw,
176
+        [CLK_PWM12_BUS]        = &pwm12_bus_clk.common.hw,
177
+        [CLK_PWM13_BUS]        = &pwm13_bus_clk.common.hw,
178
+        [CLK_PWM14_BUS]        = &pwm14_bus_clk.common.hw,
179
+        [CLK_PWM15_BUS]        = &pwm15_bus_clk.common.hw,
180
+        [CLK_PWM16_BUS]        = &pwm16_bus_clk.common.hw,
181
+        [CLK_PWM17_BUS]        = &pwm17_bus_clk.common.hw,
182
+        [CLK_PWM18_BUS]        = &pwm18_bus_clk.common.hw,
183
+        [CLK_PWM19_BUS]        = &pwm19_bus_clk.common.hw,
184
+        [CLK_SSP3_BUS]        = &ssp3_bus_clk.common.hw,
185
+        [CLK_RTC_BUS]        = &rtc_bus_clk.common.hw,
186
+        [CLK_TWSI0_BUS]        = &twsi0_bus_clk.common.hw,
187
+        [CLK_TWSI1_BUS]        = &twsi1_bus_clk.common.hw,
188
+        [CLK_TWSI2_BUS]        = &twsi2_bus_clk.common.hw,
189
+        [CLK_TWSI4_BUS]        = &twsi4_bus_clk.common.hw,
190
+        [CLK_TWSI5_BUS]        = &twsi5_bus_clk.common.hw,
191
+        [CLK_TWSI6_BUS]        = &twsi6_bus_clk.common.hw,
192
+        [CLK_TWSI7_BUS]        = &twsi7_bus_clk.common.hw,
193
+        [CLK_TWSI8_BUS]        = &twsi8_bus_clk.common.hw,
194
+        [CLK_TIMERS1_BUS]    = &timers1_bus_clk.common.hw,
195
+        [CLK_TIMERS2_BUS]    = &timers2_bus_clk.common.hw,
196
+        [CLK_AIB_BUS]        = &aib_bus_clk.common.hw,
197
+        [CLK_ONEWIRE_BUS]    = &onewire_bus_clk.common.hw,
198
+        [CLK_SSPA0_BUS]        = &sspa0_bus_clk.common.hw,
199
+        [CLK_SSPA1_BUS]        = &sspa1_bus_clk.common.hw,
200
+        [CLK_TSEN_BUS]        = &tsen_bus_clk.common.hw,
201
+        [CLK_IPC_AP2AUD_BUS]    = &ipc_ap2aud_bus_clk.common.hw,
96
diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
202
diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
97
new file mode 100644
203
new file mode 100644
98
index XXXXXXX..XXXXXXX
204
index XXXXXXX..XXXXXXX
99
--- /dev/null
205
--- /dev/null
100
+++ b/drivers/clk/spacemit/ccu-k1.c
206
+++ b/drivers/clk/spacemit/ccu-k1.c
...
...
103
+/*
209
+/*
104
+ * Copyright (c) 2024 SpacemiT Technology Co. Ltd
210
+ * Copyright (c) 2024 SpacemiT Technology Co. Ltd
105
+ * Copyright (c) 2024 Haylen Chu <heylenay@4d2.org>
211
+ * Copyright (c) 2024 Haylen Chu <heylenay@4d2.org>
106
+ */
212
+ */
107
+
213
+
214
+#include <linux/array_size.h>
108
+#include <linux/clk-provider.h>
215
+#include <linux/clk-provider.h>
109
+#include <linux/delay.h>
216
+#include <linux/delay.h>
110
+#include <linux/mfd/syscon.h>
217
+#include <linux/mfd/syscon.h>
111
+#include <linux/minmax.h>
218
+#include <linux/minmax.h>
112
+#include <linux/module.h>
219
+#include <linux/module.h>
...
...
115
+#include "ccu_common.h"
222
+#include "ccu_common.h"
116
+#include "ccu_pll.h"
223
+#include "ccu_pll.h"
117
+#include "ccu_mix.h"
224
+#include "ccu_mix.h"
118
+#include "ccu_ddn.h"
225
+#include "ccu_ddn.h"
119
+
226
+
120
+#include <dt-bindings/clock/spacemit,k1-ccu.h>
227
+#include <dt-bindings/clock/spacemit,k1-syscon.h>
121
+
228
+
122
+/*    APBS register offset    */
229
+/* APBS register offset */
123
+#define APBS_PLL1_SWCR1            0x100
230
+#define APBS_PLL1_SWCR1            0x100
124
+#define APBS_PLL1_SWCR2            0x104
231
+#define APBS_PLL1_SWCR2            0x104
125
+#define APBS_PLL1_SWCR3            0x108
232
+#define APBS_PLL1_SWCR3            0x108
126
+#define APBS_PLL2_SWCR1            0x118
233
+#define APBS_PLL2_SWCR1            0x118
127
+#define APBS_PLL2_SWCR2            0x11c
234
+#define APBS_PLL2_SWCR2            0x11c
128
+#define APBS_PLL2_SWCR3            0x120
235
+#define APBS_PLL2_SWCR3            0x120
129
+#define APBS_PLL3_SWCR1            0x124
236
+#define APBS_PLL3_SWCR1            0x124
130
+#define APBS_PLL3_SWCR2            0x128
237
+#define APBS_PLL3_SWCR2            0x128
131
+#define APBS_PLL3_SWCR3            0x12c
238
+#define APBS_PLL3_SWCR3            0x12c
132
+
239
+
133
+/* MPMU register offset */
240
+/* MPMU register offset */
134
+#define MPMU_POSR            0x10
241
+#define MPMU_POSR            0x0010
135
+#define POSR_PLL1_LOCK            BIT(27)
242
+#define POSR_PLL1_LOCK            BIT(27)
136
+#define POSR_PLL2_LOCK            BIT(28)
243
+#define POSR_PLL2_LOCK            BIT(28)
137
+#define POSR_PLL3_LOCK            BIT(29)
244
+#define POSR_PLL3_LOCK            BIT(29)
138
+
245
+#define MPMU_SUCCR            0x0014
139
+#define MPMU_WDTPCR            0x200
246
+#define MPMU_ISCCR            0x0044
140
+#define MPMU_RIPCCR            0x210
247
+#define MPMU_WDTPCR            0x0200
248
+#define MPMU_RIPCCR            0x0210
141
+#define MPMU_ACGR            0x1024
249
+#define MPMU_ACGR            0x1024
142
+#define MPMU_SUCCR            0x14
250
+#define MPMU_APBCSCR            0x1050
143
+#define MPMU_ISCCR            0x44
144
+#define MPMU_SUCCR_1            0x10b0
251
+#define MPMU_SUCCR_1            0x10b0
145
+#define MPMU_APBCSCR            0x1050
146
+
252
+
147
+/* APBC register offset */
253
+/* APBC register offset */
148
+#define APBC_UART1_CLK_RST        0x0
254
+#define APBC_UART1_CLK_RST        0x00
149
+#define APBC_UART2_CLK_RST        0x4
255
+#define APBC_UART2_CLK_RST        0x04
150
+#define APBC_GPIO_CLK_RST        0x8
256
+#define APBC_GPIO_CLK_RST        0x08
151
+#define APBC_PWM0_CLK_RST        0xc
257
+#define APBC_PWM0_CLK_RST        0x0c
152
+#define APBC_PWM1_CLK_RST        0x10
258
+#define APBC_PWM1_CLK_RST        0x10
153
+#define APBC_PWM2_CLK_RST        0x14
259
+#define APBC_PWM2_CLK_RST        0x14
154
+#define APBC_PWM3_CLK_RST        0x18
260
+#define APBC_PWM3_CLK_RST        0x18
155
+#define APBC_TWSI8_CLK_RST        0x20
261
+#define APBC_TWSI8_CLK_RST        0x20
156
+#define APBC_UART3_CLK_RST        0x24
262
+#define APBC_UART3_CLK_RST        0x24
...
...
197
+#define APBC_PWM17_CLK_RST        0xdc
303
+#define APBC_PWM17_CLK_RST        0xdc
198
+#define APBC_PWM18_CLK_RST        0xe0
304
+#define APBC_PWM18_CLK_RST        0xe0
199
+#define APBC_PWM19_CLK_RST        0xe4
305
+#define APBC_PWM19_CLK_RST        0xe4
200
+
306
+
201
+/* APMU register offset */
307
+/* APMU register offset */
202
+#define APMU_JPG_CLK_RES_CTRL        0x20
308
+#define APMU_JPG_CLK_RES_CTRL        0x020
203
+#define APMU_CSI_CCIC2_CLK_RES_CTRL    0x24
309
+#define APMU_CSI_CCIC2_CLK_RES_CTRL    0x024
204
+#define APMU_ISP_CLK_RES_CTRL        0x38
310
+#define APMU_ISP_CLK_RES_CTRL        0x038
205
+#define APMU_LCD_CLK_RES_CTRL1        0x44
311
+#define APMU_LCD_CLK_RES_CTRL1        0x044
206
+#define APMU_LCD_SPI_CLK_RES_CTRL    0x48
312
+#define APMU_LCD_SPI_CLK_RES_CTRL    0x048
207
+#define APMU_LCD_CLK_RES_CTRL2        0x4c
313
+#define APMU_LCD_CLK_RES_CTRL2        0x04c
208
+#define APMU_CCIC_CLK_RES_CTRL        0x50
314
+#define APMU_CCIC_CLK_RES_CTRL        0x050
209
+#define APMU_SDH0_CLK_RES_CTRL        0x54
315
+#define APMU_SDH0_CLK_RES_CTRL        0x054
210
+#define APMU_SDH1_CLK_RES_CTRL        0x58
316
+#define APMU_SDH1_CLK_RES_CTRL        0x058
211
+#define APMU_USB_CLK_RES_CTRL        0x5c
317
+#define APMU_USB_CLK_RES_CTRL        0x05c
212
+#define APMU_QSPI_CLK_RES_CTRL        0x60
318
+#define APMU_QSPI_CLK_RES_CTRL        0x060
213
+#define APMU_DMA_CLK_RES_CTRL        0x64
319
+#define APMU_DMA_CLK_RES_CTRL        0x064
214
+#define APMU_AES_CLK_RES_CTRL        0x68
320
+#define APMU_AES_CLK_RES_CTRL        0x068
215
+#define APMU_VPU_CLK_RES_CTRL        0xa4
321
+#define APMU_VPU_CLK_RES_CTRL        0x0a4
216
+#define APMU_GPU_CLK_RES_CTRL        0xcc
322
+#define APMU_GPU_CLK_RES_CTRL        0x0cc
217
+#define APMU_SDH2_CLK_RES_CTRL        0xe0
323
+#define APMU_SDH2_CLK_RES_CTRL        0x0e0
218
+#define APMU_PMUA_MC_CTRL        0xe8
324
+#define APMU_PMUA_MC_CTRL        0x0e8
219
+#define APMU_PMU_CC2_AP            0x100
325
+#define APMU_PMU_CC2_AP            0x100
220
+#define APMU_PMUA_EM_CLK_RES_CTRL    0x104
326
+#define APMU_PMUA_EM_CLK_RES_CTRL    0x104
221
+#define APMU_AUDIO_CLK_RES_CTRL        0x14c
327
+#define APMU_AUDIO_CLK_RES_CTRL        0x14c
222
+#define APMU_HDMI_CLK_RES_CTRL        0x1b8
328
+#define APMU_HDMI_CLK_RES_CTRL        0x1b8
223
+#define APMU_CCI550_CLK_CTRL        0x300
329
+#define APMU_CCI550_CLK_CTRL        0x300
...
...
228
+#define APMU_PCIE_CLK_RES_CTRL_1    0x3d4
334
+#define APMU_PCIE_CLK_RES_CTRL_1    0x3d4
229
+#define APMU_PCIE_CLK_RES_CTRL_2    0x3dc
335
+#define APMU_PCIE_CLK_RES_CTRL_2    0x3dc
230
+#define APMU_EMAC0_CLK_RES_CTRL        0x3e4
336
+#define APMU_EMAC0_CLK_RES_CTRL        0x3e4
231
+#define APMU_EMAC1_CLK_RES_CTRL        0x3ec
337
+#define APMU_EMAC1_CLK_RES_CTRL        0x3ec
232
+
338
+
233
+/*    APBS clocks start    */
339
+/* APBS clocks start, APBS region contains and only contains all PLL clocks */
234
+
340
+
235
+/* Frequency of pll{1,2} should not be updated at runtime */
341
+/* Frequency of pll{1,2} must not be updated at runtime */
236
+static const struct ccu_pll_rate_tbl pll1_rate_tbl[] = {
342
+static const struct ccu_pll_rate_tbl pll1_rate_tbl[] = {
237
+    CCU_PLL_RATE(2457600000UL, 0x0050dd64, 0x330ccccd),
343
+    CCU_PLL_RATE(2457600000UL, 0x0050dd64, 0x330ccccd),
238
+};
344
+};
239
+
345
+
240
+static const struct ccu_pll_rate_tbl pll2_rate_tbl[] = {
346
+static const struct ccu_pll_rate_tbl pll2_rate_tbl[] = {
347
+    CCU_PLL_RATE(2457600000UL, 0x0050dd64, 0x330ccccd),
348
+    CCU_PLL_RATE(2800000000UL, 0x0050dd66, 0x3a155555),
241
+    CCU_PLL_RATE(3000000000UL, 0x0050dd66, 0x3fe00000),
349
+    CCU_PLL_RATE(3000000000UL, 0x0050dd66, 0x3fe00000),
350
+    CCU_PLL_RATE(3200000000UL, 0x0050dd67, 0x43eaaaab),
242
+};
351
+};
243
+
352
+
244
+static const struct ccu_pll_rate_tbl pll3_rate_tbl[] = {
353
+static const struct ccu_pll_rate_tbl pll3_rate_tbl[] = {
354
+    CCU_PLL_RATE(1600000000UL, 0x0050cd61, 0x43eaaaab),
355
+    CCU_PLL_RATE(1800000000UL, 0x0050cd61, 0x4b000000),
356
+    CCU_PLL_RATE(2000000000UL, 0x0050dd62, 0x2aeaaaab),
245
+    CCU_PLL_RATE(2457600000UL, 0x0050dd64, 0x330ccccd),
357
+    CCU_PLL_RATE(2457600000UL, 0x0050dd64, 0x330ccccd),
246
+    CCU_PLL_RATE(3000000000UL, 0x0050dd66, 0x3fe00000),
358
+    CCU_PLL_RATE(3000000000UL, 0x0050dd66, 0x3fe00000),
247
+    CCU_PLL_RATE(3200000000UL, 0x0050dd67, 0x43eaaaab),
359
+    CCU_PLL_RATE(3200000000UL, 0x0050dd67, 0x43eaaaab),
248
+};
360
+};
249
+
361
+
250
+static CCU_PLL_DEFINE(pll1, pll1_rate_tbl,
362
+CCU_PLL_DEFINE(pll1, pll1_rate_tbl, APBS_PLL1_SWCR1, APBS_PLL1_SWCR3, MPMU_POSR,
251
+         APBS_PLL1_SWCR1, APBS_PLL1_SWCR3,
363
+     POSR_PLL1_LOCK, CLK_SET_RATE_GATE);
252
+         MPMU_POSR, POSR_PLL1_LOCK, CLK_SET_RATE_GATE);
364
+CCU_PLL_DEFINE(pll2, pll2_rate_tbl, APBS_PLL2_SWCR1, APBS_PLL2_SWCR3, MPMU_POSR,
253
+static CCU_PLL_DEFINE(pll2, pll2_rate_tbl,
365
+     POSR_PLL2_LOCK, CLK_SET_RATE_GATE);
254
+         APBS_PLL2_SWCR1, APBS_PLL2_SWCR3,
366
+CCU_PLL_DEFINE(pll3, pll3_rate_tbl, APBS_PLL3_SWCR1, APBS_PLL3_SWCR3, MPMU_POSR,
255
+         MPMU_POSR, POSR_PLL2_LOCK, CLK_SET_RATE_GATE);
367
+     POSR_PLL3_LOCK, CLK_SET_RATE_GATE);
256
+static CCU_PLL_DEFINE(pll3, pll3_rate_tbl,
368
+
257
+         APBS_PLL3_SWCR1, APBS_PLL2_SWCR3,
369
+CCU_FACTOR_GATE_DEFINE(pll1_d2, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT(1), 2,
258
+         MPMU_POSR, POSR_PLL3_LOCK, CLK_SET_RATE_GATE);
370
+         1);
259
+
371
+CCU_FACTOR_GATE_DEFINE(pll1_d3, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT(2), 3,
260
+static CCU_GATE_FACTOR_DEFINE(pll1_d2, CCU_PARENT_HW(pll1),
372
+         1);
261
+             APBS_PLL1_SWCR2,
373
+CCU_FACTOR_GATE_DEFINE(pll1_d4, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT(3), 4,
262
+             BIT(1), 2, 1, 0);
374
+         1);
263
+static CCU_GATE_FACTOR_DEFINE(pll1_d3, CCU_PARENT_HW(pll1),
375
+CCU_FACTOR_GATE_DEFINE(pll1_d5, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT(4), 5,
264
+             APBS_PLL1_SWCR2,
376
+         1);
265
+             BIT(2), 3, 1, 0);
377
+CCU_FACTOR_GATE_DEFINE(pll1_d6, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT(5), 6,
266
+static CCU_GATE_FACTOR_DEFINE(pll1_d4, CCU_PARENT_HW(pll1),
378
+         1);
267
+             APBS_PLL1_SWCR2,
379
+CCU_FACTOR_GATE_DEFINE(pll1_d7, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT(6), 7,
268
+             BIT(3), 4, 1, 0);
380
+         1);
269
+static CCU_GATE_FACTOR_DEFINE(pll1_d5, CCU_PARENT_HW(pll1),
381
+CCU_FACTOR_GATE_DEFINE(pll1_d8, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT(7), 8,
270
+             APBS_PLL1_SWCR2,
382
+         1);
271
+             BIT(4), 5, 1, 0);
383
+CCU_FACTOR_GATE_DEFINE(pll1_d11_223p4, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2,
272
+static CCU_GATE_FACTOR_DEFINE(pll1_d6, CCU_PARENT_HW(pll1),
384
+         BIT(15), 11, 1);
273
+             APBS_PLL1_SWCR2,
385
+CCU_FACTOR_GATE_DEFINE(pll1_d13_189, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2,
274
+             BIT(5), 6, 1, 0);
386
+         BIT(16), 13, 1);
275
+static CCU_GATE_FACTOR_DEFINE(pll1_d7, CCU_PARENT_HW(pll1),
387
+CCU_FACTOR_GATE_DEFINE(pll1_d23_106p8, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2,
276
+             APBS_PLL1_SWCR2,
388
+         BIT(20), 23, 1);
277
+             BIT(6), 7, 1, 0);
389
+CCU_FACTOR_GATE_DEFINE(pll1_d64_38p4, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2,
278
+static CCU_GATE_FACTOR_DEFINE(pll1_d8, CCU_PARENT_HW(pll1),
390
+         BIT(0), 64, 1);
279
+             APBS_PLL1_SWCR2,
391
+CCU_FACTOR_GATE_DEFINE(pll1_aud_245p7, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2,
280
+             BIT(7), 8, 1, 0);
392
+         BIT(10), 10, 1);
281
+static CCU_GATE_FACTOR_DEFINE(pll1_d11_223p4, CCU_PARENT_HW(pll1),
393
+CCU_FACTOR_GATE_DEFINE(pll1_aud_24p5, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2,
282
+             APBS_PLL1_SWCR2,
394
+         BIT(11), 100, 1);
283
+             BIT(15), 11, 1, 0);
395
+
284
+static CCU_GATE_FACTOR_DEFINE(pll1_d13_189, CCU_PARENT_HW(pll1),
396
+CCU_FACTOR_GATE_DEFINE(pll2_d1, CCU_PARENT_HW(pll2), APBS_PLL2_SWCR2, BIT(0), 1,
285
+             APBS_PLL1_SWCR2,
397
+         1);
286
+             BIT(16), 13, 1, 0);
398
+CCU_FACTOR_GATE_DEFINE(pll2_d2, CCU_PARENT_HW(pll2), APBS_PLL2_SWCR2, BIT(1), 2,
287
+static CCU_GATE_FACTOR_DEFINE(pll1_d23_106p8, CCU_PARENT_HW(pll1),
399
+         1);
288
+             APBS_PLL1_SWCR2,
400
+CCU_FACTOR_GATE_DEFINE(pll2_d3, CCU_PARENT_HW(pll2), APBS_PLL2_SWCR2, BIT(2), 3,
289
+             BIT(20), 23, 1, 0);
401
+         1);
290
+static CCU_GATE_FACTOR_DEFINE(pll1_d64_38p4, CCU_PARENT_HW(pll1),
402
+CCU_FACTOR_GATE_DEFINE(pll2_d4, CCU_PARENT_HW(pll2), APBS_PLL2_SWCR2, BIT(3), 4,
291
+             APBS_PLL1_SWCR2,
403
+         1);
292
+             BIT(0), 64, 1, 0);
404
+CCU_FACTOR_GATE_DEFINE(pll2_d5, CCU_PARENT_HW(pll2), APBS_PLL2_SWCR2, BIT(4), 5,
293
+static CCU_GATE_FACTOR_DEFINE(pll1_aud_245p7, CCU_PARENT_HW(pll1),
405
+         1);
294
+             APBS_PLL1_SWCR2,
406
+CCU_FACTOR_GATE_DEFINE(pll2_d6, CCU_PARENT_HW(pll2), APBS_PLL2_SWCR2, BIT(5), 6,
295
+             BIT(10), 10, 1, 0);
407
+         1);
296
+static CCU_GATE_FACTOR_DEFINE(pll1_aud_24p5, CCU_PARENT_HW(pll1),
408
+CCU_FACTOR_GATE_DEFINE(pll2_d7, CCU_PARENT_HW(pll2), APBS_PLL2_SWCR2, BIT(6), 7,
297
+             APBS_PLL1_SWCR2,
409
+         1);
298
+             BIT(11), 100, 1, 0);
410
+CCU_FACTOR_GATE_DEFINE(pll2_d8, CCU_PARENT_HW(pll2), APBS_PLL2_SWCR2, BIT(7), 8,
299
+
411
+         1);
300
+static CCU_GATE_FACTOR_DEFINE(pll2_d1, CCU_PARENT_HW(pll2),
412
+
301
+             APBS_PLL2_SWCR2,
413
+CCU_FACTOR_GATE_DEFINE(pll3_d1, CCU_PARENT_HW(pll3), APBS_PLL3_SWCR2, BIT(0), 1,
302
+             BIT(0), 1, 1, 0);
414
+         1);
303
+static CCU_GATE_FACTOR_DEFINE(pll2_d2, CCU_PARENT_HW(pll2),
415
+CCU_FACTOR_GATE_DEFINE(pll3_d2, CCU_PARENT_HW(pll3), APBS_PLL3_SWCR2, BIT(1), 2,
304
+             APBS_PLL2_SWCR2,
416
+         1);
305
+             BIT(1), 2, 1, 0);
417
+CCU_FACTOR_GATE_DEFINE(pll3_d3, CCU_PARENT_HW(pll3), APBS_PLL3_SWCR2, BIT(2), 3,
306
+static CCU_GATE_FACTOR_DEFINE(pll2_d3, CCU_PARENT_HW(pll2),
418
+         1);
307
+             APBS_PLL2_SWCR2,
419
+CCU_FACTOR_GATE_DEFINE(pll3_d4, CCU_PARENT_HW(pll3), APBS_PLL3_SWCR2, BIT(3), 4,
308
+             BIT(2), 3, 1, 0);
420
+         1);
309
+static CCU_GATE_FACTOR_DEFINE(pll2_d4, CCU_PARENT_HW(pll2),
421
+CCU_FACTOR_GATE_DEFINE(pll3_d5, CCU_PARENT_HW(pll3), APBS_PLL3_SWCR2, BIT(4), 5,
310
+             APBS_PLL2_SWCR2,
422
+         1);
311
+             BIT(3), 4, 1, 0);
423
+CCU_FACTOR_GATE_DEFINE(pll3_d6, CCU_PARENT_HW(pll3), APBS_PLL3_SWCR2, BIT(5), 6,
312
+static CCU_GATE_FACTOR_DEFINE(pll2_d5, CCU_PARENT_HW(pll2),
424
+         1);
313
+             APBS_PLL2_SWCR2,
425
+CCU_FACTOR_GATE_DEFINE(pll3_d7, CCU_PARENT_HW(pll3), APBS_PLL3_SWCR2, BIT(6), 7,
314
+             BIT(4), 5, 1, 0);
426
+         1);
315
+static CCU_GATE_FACTOR_DEFINE(pll2_d6, CCU_PARENT_HW(pll2),
427
+CCU_FACTOR_GATE_DEFINE(pll3_d8, CCU_PARENT_HW(pll3), APBS_PLL3_SWCR2, BIT(7), 8,
316
+             APBS_PLL2_SWCR2,
428
+         1);
317
+             BIT(5), 6, 1, 0);
429
+
318
+static CCU_GATE_FACTOR_DEFINE(pll2_d7, CCU_PARENT_HW(pll2),
430
+CCU_FACTOR_DEFINE(pll3_20, CCU_PARENT_HW(pll3_d8), 20, 1);
319
+             APBS_PLL2_SWCR2,
431
+CCU_FACTOR_DEFINE(pll3_40, CCU_PARENT_HW(pll3_d8), 10, 1);
320
+             BIT(6), 7, 1, 0);
432
+CCU_FACTOR_DEFINE(pll3_80, CCU_PARENT_HW(pll3_d8), 5, 1);
321
+static CCU_GATE_FACTOR_DEFINE(pll2_d8, CCU_PARENT_HW(pll2),
433
+
322
+             APBS_PLL2_SWCR2,
434
+/* APBS clocks end */
323
+             BIT(7), 8, 1, 0);
435
+
324
+
436
+/* MPMU clocks start */
325
+static CCU_GATE_FACTOR_DEFINE(pll3_d1, CCU_PARENT_HW(pll3),
437
+CCU_GATE_DEFINE(pll1_d8_307p2, CCU_PARENT_HW(pll1_d8), MPMU_ACGR, BIT(13), 0);
326
+             APBS_PLL3_SWCR2,
438
+
327
+             BIT(0), 1, 1, 0);
439
+CCU_FACTOR_DEFINE(pll1_d32_76p8, CCU_PARENT_HW(pll1_d8_307p2), 4, 1);
328
+static CCU_GATE_FACTOR_DEFINE(pll3_d2, CCU_PARENT_HW(pll3),
440
+
329
+             APBS_PLL3_SWCR2,
441
+CCU_FACTOR_DEFINE(pll1_d40_61p44, CCU_PARENT_HW(pll1_d8_307p2), 5, 1);
330
+             BIT(1), 2, 1, 0);
442
+
331
+static CCU_GATE_FACTOR_DEFINE(pll3_d3, CCU_PARENT_HW(pll3),
443
+CCU_FACTOR_DEFINE(pll1_d16_153p6, CCU_PARENT_HW(pll1_d8), 2, 1);
332
+             APBS_PLL3_SWCR2,
444
+CCU_FACTOR_GATE_DEFINE(pll1_d24_102p4, CCU_PARENT_HW(pll1_d8), MPMU_ACGR,
333
+             BIT(2), 3, 1, 0);
445
+         BIT(12), 3, 1);
334
+static CCU_GATE_FACTOR_DEFINE(pll3_d4, CCU_PARENT_HW(pll3),
446
+CCU_FACTOR_GATE_DEFINE(pll1_d48_51p2, CCU_PARENT_HW(pll1_d8), MPMU_ACGR, BIT(7),
335
+             APBS_PLL3_SWCR2,
447
+         6, 1);
336
+             BIT(3), 4, 1, 0);
448
+CCU_FACTOR_GATE_DEFINE(pll1_d48_51p2_ap, CCU_PARENT_HW(pll1_d8), MPMU_ACGR,
337
+static CCU_GATE_FACTOR_DEFINE(pll3_d5, CCU_PARENT_HW(pll3),
449
+         BIT(11), 6, 1);
338
+             APBS_PLL3_SWCR2,
450
+CCU_FACTOR_GATE_DEFINE(pll1_m3d128_57p6, CCU_PARENT_HW(pll1_d8), MPMU_ACGR,
339
+             BIT(4), 5, 1, 0);
451
+         BIT(8), 16, 3);
340
+static CCU_GATE_FACTOR_DEFINE(pll3_d6, CCU_PARENT_HW(pll3),
452
+CCU_FACTOR_GATE_DEFINE(pll1_d96_25p6, CCU_PARENT_HW(pll1_d8), MPMU_ACGR, BIT(4),
341
+             APBS_PLL3_SWCR2,
453
+         12, 1);
342
+             BIT(5), 6, 1, 0);
454
+CCU_FACTOR_GATE_DEFINE(pll1_d192_12p8, CCU_PARENT_HW(pll1_d8), MPMU_ACGR,
343
+static CCU_GATE_FACTOR_DEFINE(pll3_d7, CCU_PARENT_HW(pll3),
455
+         BIT(3), 24, 1);
344
+             APBS_PLL3_SWCR2,
456
+CCU_FACTOR_GATE_DEFINE(pll1_d192_12p8_wdt, CCU_PARENT_HW(pll1_d8), MPMU_ACGR,
345
+             BIT(6), 7, 1, 0);
457
+         BIT(19), 24, 1);
346
+static CCU_GATE_FACTOR_DEFINE(pll3_d8, CCU_PARENT_HW(pll3),
458
+CCU_FACTOR_GATE_DEFINE(pll1_d384_6p4, CCU_PARENT_HW(pll1_d8), MPMU_ACGR,
347
+             APBS_PLL3_SWCR2,
459
+         BIT(2), 48, 1);
348
+             BIT(7), 8, 1, 0);
460
+
349
+
461
+CCU_FACTOR_DEFINE(pll1_d768_3p2, CCU_PARENT_HW(pll1_d384_6p4), 2, 1);
350
+static CCU_FACTOR_DEFINE(pll3_20, CCU_PARENT_HW(pll3_d8), 20, 1);
462
+CCU_FACTOR_DEFINE(pll1_d1536_1p6, CCU_PARENT_HW(pll1_d384_6p4), 4, 1);
351
+static CCU_FACTOR_DEFINE(pll3_40, CCU_PARENT_HW(pll3_d8), 10, 1);
463
+CCU_FACTOR_DEFINE(pll1_d3072_0p8, CCU_PARENT_HW(pll1_d384_6p4), 8, 1);
352
+static CCU_FACTOR_DEFINE(pll3_80, CCU_PARENT_HW(pll3_d8), 5, 1);
464
+
353
+
465
+CCU_GATE_DEFINE(pll1_d6_409p6, CCU_PARENT_HW(pll1_d6), MPMU_ACGR, BIT(0), 0);
354
+/*    APBS clocks end        */
466
+CCU_FACTOR_GATE_DEFINE(pll1_d12_204p8, CCU_PARENT_HW(pll1_d6), MPMU_ACGR,
355
+
467
+         BIT(5), 2, 1);
356
+/*    MPMU clocks start    */
468
+
357
+static CCU_GATE_DEFINE(pll1_d8_307p2, CCU_PARENT_HW(pll1_d8),
469
+CCU_GATE_DEFINE(pll1_d5_491p52, CCU_PARENT_HW(pll1_d5), MPMU_ACGR, BIT(21), 0);
358
+         MPMU_ACGR,
470
+CCU_FACTOR_GATE_DEFINE(pll1_d10_245p76, CCU_PARENT_HW(pll1_d5), MPMU_ACGR,
359
+         BIT(13), 0);
471
+         BIT(18), 2, 1);
360
+static CCU_FACTOR_DEFINE(pll1_d32_76p8, CCU_PARENT_HW(pll1_d8_307p2),
472
+
361
+             4, 1);
473
+CCU_GATE_DEFINE(pll1_d4_614p4, CCU_PARENT_HW(pll1_d4), MPMU_ACGR,
362
+static CCU_FACTOR_DEFINE(pll1_d40_61p44, CCU_PARENT_HW(pll1_d8_307p2),
474
+        BIT(15), 0);
363
+             5, 1);
475
+CCU_FACTOR_GATE_DEFINE(pll1_d52_47p26, CCU_PARENT_HW(pll1_d4), MPMU_ACGR,
364
+static CCU_FACTOR_DEFINE(pll1_d16_153p6, CCU_PARENT_HW(pll1_d8),
476
+         BIT(10), 13, 1);
365
+             2, 1);
477
+CCU_FACTOR_GATE_DEFINE(pll1_d78_31p5, CCU_PARENT_HW(pll1_d4), MPMU_ACGR,
366
+static CCU_GATE_FACTOR_DEFINE(pll1_d24_102p4, CCU_PARENT_HW(pll1_d8),
478
+         BIT(6), 39, 2);
367
+             MPMU_ACGR,
479
+
368
+             BIT(12), 3, 1, 0);
480
+CCU_GATE_DEFINE(pll1_d3_819p2, CCU_PARENT_HW(pll1_d3), MPMU_ACGR, BIT(14), 0);
369
+static CCU_GATE_FACTOR_DEFINE(pll1_d48_51p2, CCU_PARENT_HW(pll1_d8),
481
+
370
+             MPMU_ACGR,
482
+CCU_GATE_DEFINE(pll1_d2_1228p8, CCU_PARENT_HW(pll1_d2), MPMU_ACGR, BIT(16), 0);
371
+             BIT(7), 6, 1, 0);
483
+
372
+static CCU_GATE_FACTOR_DEFINE(pll1_d48_51p2_ap, CCU_PARENT_HW(pll1_d8),
484
+CCU_GATE_DEFINE(slow_uart, CCU_PARENT_NAME(osc), MPMU_ACGR, BIT(1),
373
+             MPMU_ACGR,
485
+        CLK_IGNORE_UNUSED);
374
+             BIT(11), 6, 1, 0);
486
+CCU_DDN_DEFINE(slow_uart1_14p74, pll1_d16_153p6, MPMU_SUCCR, GENMASK(28, 16),
375
+static CCU_GATE_FACTOR_DEFINE(pll1_m3d128_57p6, CCU_PARENT_HW(pll1_d8),
487
+     GENMASK(12, 0), 0);
376
+             MPMU_ACGR,
488
+CCU_DDN_DEFINE(slow_uart2_48, pll1_d4_614p4, MPMU_SUCCR_1, GENMASK(28, 16),
377
+             BIT(8), 16, 3, 0);
489
+     GENMASK(12, 0), 0);
378
+static CCU_GATE_FACTOR_DEFINE(pll1_d96_25p6, CCU_PARENT_HW(pll1_d8),
490
+
379
+             MPMU_ACGR,
491
+CCU_GATE_DEFINE(wdt_clk, CCU_PARENT_HW(pll1_d96_25p6), MPMU_WDTPCR, BIT(1), 0);
380
+             BIT(4), 12, 1, 0);
492
+
381
+static CCU_GATE_FACTOR_DEFINE(pll1_d192_12p8, CCU_PARENT_HW(pll1_d8),
493
+CCU_FACTOR_GATE_DEFINE(i2s_sysclk, CCU_PARENT_HW(pll1_d16_153p6), MPMU_ISCCR,
382
+             MPMU_ACGR,
494
+         BIT(31), 50, 1);
383
+             BIT(3), 24, 1, 0);
495
+CCU_FACTOR_GATE_DEFINE(i2s_bclk, CCU_PARENT_HW(i2s_sysclk), MPMU_ISCCR, BIT(29),
384
+static CCU_GATE_FACTOR_DEFINE(pll1_d192_12p8_wdt, CCU_PARENT_HW(pll1_d8),
496
+         1, 1);
385
+             MPMU_ACGR,
386
+             BIT(19), 24, 1, 0);
387
+static CCU_GATE_FACTOR_DEFINE(pll1_d384_6p4, CCU_PARENT_HW(pll1_d8),
388
+             MPMU_ACGR,
389
+             BIT(2), 48, 1, 0);
390
+static CCU_FACTOR_DEFINE(pll1_d768_3p2, CCU_PARENT_HW(pll1_d384_6p4),
391
+             2, 1);
392
+static CCU_FACTOR_DEFINE(pll1_d1536_1p6, CCU_PARENT_HW(pll1_d384_6p4),
393
+             4, 1);
394
+static CCU_FACTOR_DEFINE(pll1_d3072_0p8, CCU_PARENT_HW(pll1_d384_6p4),
395
+             8, 1);
396
+
397
+static CCU_GATE_DEFINE(pll1_d6_409p6, CCU_PARENT_HW(pll1_d6),
398
+         MPMU_ACGR,
399
+         BIT(0), 0);
400
+static CCU_GATE_FACTOR_DEFINE(pll1_d12_204p8, CCU_PARENT_HW(pll1_d6),
401
+             MPMU_ACGR,
402
+             BIT(5), 2, 1, 0);
403
+
404
+static CCU_GATE_DEFINE(pll1_d5_491p52, CCU_PARENT_HW(pll1_d5),
405
+         MPMU_ACGR,
406
+         BIT(21), 0);
407
+static CCU_GATE_FACTOR_DEFINE(pll1_d10_245p76, CCU_PARENT_HW(pll1_d5),
408
+             MPMU_ACGR,
409
+             BIT(18), 2, 1, 0);
410
+
411
+static CCU_GATE_DEFINE(pll1_d4_614p4, CCU_PARENT_HW(pll1_d4),
412
+         MPMU_ACGR,
413
+         BIT(15), 0);
414
+static CCU_GATE_FACTOR_DEFINE(pll1_d52_47p26, CCU_PARENT_HW(pll1_d4),
415
+             MPMU_ACGR,
416
+             BIT(10), 13, 1, 0);
417
+static CCU_GATE_FACTOR_DEFINE(pll1_d78_31p5, CCU_PARENT_HW(pll1_d4),
418
+             MPMU_ACGR,
419
+             BIT(6), 39, 2, 0);
420
+
421
+static CCU_GATE_DEFINE(pll1_d3_819p2, CCU_PARENT_HW(pll1_d3),
422
+         MPMU_ACGR,
423
+         BIT(14), 0);
424
+
425
+static CCU_GATE_DEFINE(pll1_d2_1228p8, CCU_PARENT_HW(pll1_d2),
426
+         MPMU_ACGR,
427
+         BIT(16), 0);
428
+
429
+static CCU_GATE_DEFINE(slow_uart, CCU_PARENT_NAME(osc),
430
+         MPMU_ACGR,
431
+         BIT(1), CLK_IGNORE_UNUSED);
432
+static CCU_DDN_DEFINE(slow_uart1_14p74, pll1_d16_153p6,
433
+         MPMU_SUCCR,
434
+         GENMASK(28, 16), 16, GENMASK(12, 0), 0,
435
+         0);
436
+static CCU_DDN_DEFINE(slow_uart2_48, pll1_d4_614p4,
437
+         MPMU_SUCCR_1,
438
+         GENMASK(28, 16), 16, GENMASK(12, 0), 0,
439
+         0);
440
+
441
+static CCU_GATE_DEFINE(wdt_clk, CCU_PARENT_HW(pll1_d96_25p6),
442
+         MPMU_WDTPCR,
443
+         BIT(1),
444
+         0);
445
+
446
+static CCU_GATE_FACTOR_DEFINE(i2s_sysclk, CCU_PARENT_HW(pll1_d16_153p6),
447
+             MPMU_ISCCR,
448
+             BIT(31), 50, 1,
449
+             0);
450
+static CCU_GATE_FACTOR_DEFINE(i2s_bclk, CCU_PARENT_HW(i2s_sysclk),
451
+             MPMU_ISCCR,
452
+             BIT(29), 1, 1,
453
+             0);
454
+
497
+
455
+static const struct clk_parent_data apb_parents[] = {
498
+static const struct clk_parent_data apb_parents[] = {
456
+    CCU_PARENT_HW(pll1_d96_25p6),
499
+    CCU_PARENT_HW(pll1_d96_25p6),
457
+    CCU_PARENT_HW(pll1_d48_51p2),
500
+    CCU_PARENT_HW(pll1_d48_51p2),
458
+    CCU_PARENT_HW(pll1_d96_25p6),
501
+    CCU_PARENT_HW(pll1_d96_25p6),
459
+    CCU_PARENT_HW(pll1_d24_102p4),
502
+    CCU_PARENT_HW(pll1_d24_102p4),
460
+};
503
+};
461
+static CCU_MUX_DEFINE(apb_clk, apb_parents,
504
+CCU_MUX_DEFINE(apb_clk, apb_parents, MPMU_APBCSCR, 0, 2, 0);
462
+         MPMU_APBCSCR,
505
+
463
+         0, 2,
506
+CCU_GATE_DEFINE(wdt_bus_clk, CCU_PARENT_HW(apb_clk), MPMU_WDTPCR, BIT(0), 0);
464
+         0);
507
+
465
+
508
+CCU_GATE_DEFINE(ripc_clk, CCU_PARENT_HW(apb_clk), MPMU_RIPCCR, 0x1, 0);
466
+static CCU_GATE_DEFINE(wdt_bus_clk, CCU_PARENT_HW(apb_clk),
509
+/* MPMU clocks end */
467
+         MPMU_WDTPCR,
510
+
468
+         BIT(0),
511
+/* APBC clocks start */
469
+         0);
470
+
471
+static CCU_GATE_DEFINE(ripc_clk, CCU_PARENT_HW(apb_clk),
472
+         MPMU_RIPCCR,
473
+         0x1,
474
+         0);
475
+/*    MPMU clocks end        */
476
+
477
+/*    APBC clocks start    */
478
+static const struct clk_parent_data uart_clk_parents[] = {
512
+static const struct clk_parent_data uart_clk_parents[] = {
479
+    CCU_PARENT_HW(pll1_m3d128_57p6),
513
+    CCU_PARENT_HW(pll1_m3d128_57p6),
480
+    CCU_PARENT_HW(slow_uart1_14p74),
514
+    CCU_PARENT_HW(slow_uart1_14p74),
481
+    CCU_PARENT_HW(slow_uart2_48),
515
+    CCU_PARENT_HW(slow_uart2_48),
482
+};
516
+};
483
+static CCU_MUX_GATE_DEFINE(uart0_clk, uart_clk_parents,
517
+CCU_MUX_GATE_DEFINE(uart0_clk, uart_clk_parents, APBC_UART1_CLK_RST, 4, 3,
484
+             APBC_UART1_CLK_RST,
518
+         BIT(1), CLK_IS_CRITICAL);
485
+             4, 3, BIT(1),
519
+CCU_MUX_GATE_DEFINE(uart2_clk, uart_clk_parents, APBC_UART2_CLK_RST, 4, 3,
486
+             CLK_IS_CRITICAL);
520
+         BIT(1), 0);
487
+static CCU_MUX_GATE_DEFINE(uart2_clk, uart_clk_parents,
521
+CCU_MUX_GATE_DEFINE(uart3_clk, uart_clk_parents, APBC_UART3_CLK_RST, 4, 3,
488
+             APBC_UART2_CLK_RST,
522
+         BIT(1), 0);
489
+             4, 3, BIT(1),
523
+CCU_MUX_GATE_DEFINE(uart4_clk, uart_clk_parents, APBC_UART4_CLK_RST, 4, 3,
490
+             0);
524
+         BIT(1), 0);
491
+static CCU_MUX_GATE_DEFINE(uart3_clk, uart_clk_parents,
525
+CCU_MUX_GATE_DEFINE(uart5_clk, uart_clk_parents, APBC_UART5_CLK_RST, 4, 3,
492
+             APBC_UART3_CLK_RST,
526
+         BIT(1), 0);
493
+             4, 3, BIT(1),
527
+CCU_MUX_GATE_DEFINE(uart6_clk, uart_clk_parents, APBC_UART6_CLK_RST, 4, 3,
494
+             0);
528
+         BIT(1), 0);
495
+static CCU_MUX_GATE_DEFINE(uart4_clk, uart_clk_parents,
529
+CCU_MUX_GATE_DEFINE(uart7_clk, uart_clk_parents, APBC_UART7_CLK_RST, 4, 3,
496
+             APBC_UART4_CLK_RST,
530
+         BIT(1), 0);
497
+             4, 3, BIT(1),
531
+CCU_MUX_GATE_DEFINE(uart8_clk, uart_clk_parents, APBC_UART8_CLK_RST, 4, 3,
498
+             0);
532
+         BIT(1), 0);
499
+static CCU_MUX_GATE_DEFINE(uart5_clk, uart_clk_parents,
533
+CCU_MUX_GATE_DEFINE(uart9_clk, uart_clk_parents, APBC_UART9_CLK_RST, 4, 3,
500
+             APBC_UART5_CLK_RST,
534
+         BIT(1), 0);
501
+             4, 3, BIT(1),
535
+
502
+             0);
536
+CCU_GATE_DEFINE(gpio_clk, CCU_PARENT_NAME(vctcxo_24m), APBC_GPIO_CLK_RST,
503
+static CCU_MUX_GATE_DEFINE(uart6_clk, uart_clk_parents,
537
+        BIT(1), 0);
504
+             APBC_UART6_CLK_RST,
505
+             4, 3, BIT(1),
506
+             0);
507
+static CCU_MUX_GATE_DEFINE(uart7_clk, uart_clk_parents,
508
+             APBC_UART7_CLK_RST,
509
+             4, 3, BIT(1),
510
+             0);
511
+static CCU_MUX_GATE_DEFINE(uart8_clk, uart_clk_parents,
512
+             APBC_UART8_CLK_RST,
513
+             4, 3, BIT(1),
514
+             0);
515
+static CCU_MUX_GATE_DEFINE(uart9_clk, uart_clk_parents,
516
+             APBC_UART9_CLK_RST,
517
+             4, 3, BIT(1),
518
+             0);
519
+
520
+static CCU_GATE_DEFINE(gpio_clk, CCU_PARENT_NAME(vctcxo_24m),
521
+         APBC_GPIO_CLK_RST,
522
+         BIT(1),
523
+         0);
524
+
538
+
525
+static const struct clk_parent_data pwm_parents[] = {
539
+static const struct clk_parent_data pwm_parents[] = {
526
+    CCU_PARENT_HW(pll1_d192_12p8),
540
+    CCU_PARENT_HW(pll1_d192_12p8),
527
+    CCU_PARENT_NAME(osc),
541
+    CCU_PARENT_NAME(osc),
528
+};
542
+};
529
+static CCU_MUX_GATE_DEFINE(pwm0_clk, pwm_parents,
543
+CCU_MUX_GATE_DEFINE(pwm0_clk, pwm_parents, APBC_PWM0_CLK_RST, 4, 3, BIT(1), 0);
530
+             APBC_PWM0_CLK_RST,
544
+CCU_MUX_GATE_DEFINE(pwm1_clk, pwm_parents, APBC_PWM1_CLK_RST, 4, 3, BIT(1), 0);
531
+             4, 3, BIT(1),
545
+CCU_MUX_GATE_DEFINE(pwm2_clk, pwm_parents, APBC_PWM2_CLK_RST, 4, 3, BIT(1), 0);
532
+             0);
546
+CCU_MUX_GATE_DEFINE(pwm3_clk, pwm_parents, APBC_PWM3_CLK_RST, 4, 3, BIT(1), 0);
533
+static CCU_MUX_GATE_DEFINE(pwm1_clk, pwm_parents,
547
+CCU_MUX_GATE_DEFINE(pwm4_clk, pwm_parents, APBC_PWM4_CLK_RST, 4, 3, BIT(1), 0);
534
+             APBC_PWM1_CLK_RST,
548
+CCU_MUX_GATE_DEFINE(pwm5_clk, pwm_parents, APBC_PWM5_CLK_RST, 4, 3, BIT(1), 0);
535
+             4, 3, BIT(1),
549
+CCU_MUX_GATE_DEFINE(pwm6_clk, pwm_parents, APBC_PWM6_CLK_RST, 4, 3, BIT(1), 0);
536
+             0);
550
+CCU_MUX_GATE_DEFINE(pwm7_clk, pwm_parents, APBC_PWM7_CLK_RST, 4, 3, BIT(1), 0);
537
+static CCU_MUX_GATE_DEFINE(pwm2_clk, pwm_parents,
551
+CCU_MUX_GATE_DEFINE(pwm8_clk, pwm_parents, APBC_PWM8_CLK_RST, 4, 3, BIT(1), 0);
538
+             APBC_PWM2_CLK_RST,
552
+CCU_MUX_GATE_DEFINE(pwm9_clk, pwm_parents, APBC_PWM9_CLK_RST, 4, 3, BIT(1), 0);
539
+             4, 3, BIT(1),
553
+CCU_MUX_GATE_DEFINE(pwm10_clk, pwm_parents, APBC_PWM10_CLK_RST, 4, 3, BIT(1),
540
+             0);
554
+         0);
541
+static CCU_MUX_GATE_DEFINE(pwm3_clk, pwm_parents,
555
+CCU_MUX_GATE_DEFINE(pwm11_clk, pwm_parents, APBC_PWM11_CLK_RST, 4, 3, BIT(1),
542
+             APBC_PWM3_CLK_RST,
556
+         0);
543
+             4, 3, BIT(1),
557
+CCU_MUX_GATE_DEFINE(pwm12_clk, pwm_parents, APBC_PWM12_CLK_RST, 4, 3, BIT(1),
544
+             0);
558
+         0);
545
+static CCU_MUX_GATE_DEFINE(pwm4_clk, pwm_parents,
559
+CCU_MUX_GATE_DEFINE(pwm13_clk, pwm_parents, APBC_PWM13_CLK_RST, 4, 3, BIT(1),
546
+             APBC_PWM4_CLK_RST,
560
+         0);
547
+             4, 3, BIT(1),
561
+CCU_MUX_GATE_DEFINE(pwm14_clk, pwm_parents, APBC_PWM14_CLK_RST, 4, 3, BIT(1),
548
+             0);
562
+         0);
549
+static CCU_MUX_GATE_DEFINE(pwm5_clk, pwm_parents,
563
+CCU_MUX_GATE_DEFINE(pwm15_clk, pwm_parents, APBC_PWM15_CLK_RST, 4, 3, BIT(1),
550
+             APBC_PWM5_CLK_RST,
564
+         0);
551
+             4, 3, BIT(1),
565
+CCU_MUX_GATE_DEFINE(pwm16_clk, pwm_parents, APBC_PWM16_CLK_RST, 4, 3, BIT(1),
552
+             0);
566
+         0);
553
+static CCU_MUX_GATE_DEFINE(pwm6_clk, pwm_parents,
567
+CCU_MUX_GATE_DEFINE(pwm17_clk, pwm_parents, APBC_PWM17_CLK_RST, 4, 3, BIT(1),
554
+             APBC_PWM6_CLK_RST,
568
+         0);
555
+             4, 3, BIT(1),
569
+CCU_MUX_GATE_DEFINE(pwm18_clk, pwm_parents, APBC_PWM18_CLK_RST, 4, 3, BIT(1),
556
+             0);
570
+         0);
557
+static CCU_MUX_GATE_DEFINE(pwm7_clk, pwm_parents,
571
+CCU_MUX_GATE_DEFINE(pwm19_clk, pwm_parents, APBC_PWM19_CLK_RST, 4, 3, BIT(1),
558
+             APBC_PWM7_CLK_RST,
572
+         0);
559
+             4, 3, BIT(1),
560
+             0);
561
+static CCU_MUX_GATE_DEFINE(pwm8_clk, pwm_parents,
562
+             APBC_PWM8_CLK_RST,
563
+             4, 3, BIT(1),
564
+             0);
565
+static CCU_MUX_GATE_DEFINE(pwm9_clk, pwm_parents,
566
+             APBC_PWM9_CLK_RST,
567
+             4, 3, BIT(1),
568
+             0);
569
+static CCU_MUX_GATE_DEFINE(pwm10_clk, pwm_parents,
570
+             APBC_PWM10_CLK_RST,
571
+             4, 3, BIT(1),
572
+             0);
573
+static CCU_MUX_GATE_DEFINE(pwm11_clk, pwm_parents,
574
+             APBC_PWM11_CLK_RST,
575
+             4, 3, BIT(1),
576
+             0);
577
+static CCU_MUX_GATE_DEFINE(pwm12_clk, pwm_parents,
578
+             APBC_PWM12_CLK_RST,
579
+             4, 3, BIT(1),
580
+             0);
581
+static CCU_MUX_GATE_DEFINE(pwm13_clk, pwm_parents,
582
+             APBC_PWM13_CLK_RST,
583
+             4, 3, BIT(1),
584
+             0);
585
+static CCU_MUX_GATE_DEFINE(pwm14_clk, pwm_parents,
586
+             APBC_PWM14_CLK_RST,
587
+             4, 3, BIT(1),
588
+             0);
589
+static CCU_MUX_GATE_DEFINE(pwm15_clk, pwm_parents,
590
+             APBC_PWM15_CLK_RST,
591
+             4, 3, BIT(1),
592
+             0);
593
+static CCU_MUX_GATE_DEFINE(pwm16_clk, pwm_parents,
594
+             APBC_PWM16_CLK_RST,
595
+             4, 3, BIT(1),
596
+             0);
597
+static CCU_MUX_GATE_DEFINE(pwm17_clk, pwm_parents,
598
+             APBC_PWM17_CLK_RST,
599
+             4, 3, BIT(1),
600
+             0);
601
+static CCU_MUX_GATE_DEFINE(pwm18_clk, pwm_parents,
602
+             APBC_PWM18_CLK_RST,
603
+             4, 3, BIT(1),
604
+             0);
605
+static CCU_MUX_GATE_DEFINE(pwm19_clk, pwm_parents,
606
+             APBC_PWM19_CLK_RST,
607
+             4, 3, BIT(1),
608
+             0);
609
+
573
+
610
+static const struct clk_parent_data ssp_parents[] = {
574
+static const struct clk_parent_data ssp_parents[] = {
611
+    CCU_PARENT_HW(pll1_d384_6p4),
575
+    CCU_PARENT_HW(pll1_d384_6p4),
612
+    CCU_PARENT_HW(pll1_d192_12p8),
576
+    CCU_PARENT_HW(pll1_d192_12p8),
613
+    CCU_PARENT_HW(pll1_d96_25p6),
577
+    CCU_PARENT_HW(pll1_d96_25p6),
614
+    CCU_PARENT_HW(pll1_d48_51p2),
578
+    CCU_PARENT_HW(pll1_d48_51p2),
615
+    CCU_PARENT_HW(pll1_d768_3p2),
579
+    CCU_PARENT_HW(pll1_d768_3p2),
616
+    CCU_PARENT_HW(pll1_d1536_1p6),
580
+    CCU_PARENT_HW(pll1_d1536_1p6),
617
+    CCU_PARENT_HW(pll1_d3072_0p8),
581
+    CCU_PARENT_HW(pll1_d3072_0p8),
618
+};
582
+};
619
+static CCU_MUX_GATE_DEFINE(ssp3_clk, ssp_parents,
583
+CCU_MUX_GATE_DEFINE(ssp3_clk, ssp_parents, APBC_SSP3_CLK_RST, 4, 3, BIT(1), 0);
620
+             APBC_SSP3_CLK_RST,
584
+
621
+             4, 3, BIT(1),
585
+CCU_GATE_DEFINE(rtc_clk, CCU_PARENT_NAME(osc), APBC_RTC_CLK_RST,
622
+             0);
586
+        BIT(7) | BIT(1), 0);
623
+
624
+static CCU_GATE_DEFINE(rtc_clk, CCU_PARENT_NAME(osc),
625
+         APBC_RTC_CLK_RST,
626
+         BIT(7) | BIT(1),
627
+         0);
628
+
587
+
629
+static const struct clk_parent_data twsi_parents[] = {
588
+static const struct clk_parent_data twsi_parents[] = {
630
+    CCU_PARENT_HW(pll1_d78_31p5),
589
+    CCU_PARENT_HW(pll1_d78_31p5),
631
+    CCU_PARENT_HW(pll1_d48_51p2),
590
+    CCU_PARENT_HW(pll1_d48_51p2),
632
+    CCU_PARENT_HW(pll1_d40_61p44),
591
+    CCU_PARENT_HW(pll1_d40_61p44),
633
+};
592
+};
634
+static CCU_MUX_GATE_DEFINE(twsi0_clk, twsi_parents,
593
+CCU_MUX_GATE_DEFINE(twsi0_clk, twsi_parents, APBC_TWSI0_CLK_RST, 4, 3, BIT(1),
635
+             APBC_TWSI0_CLK_RST,
594
+         0);
636
+             4, 3, BIT(1),
595
+CCU_MUX_GATE_DEFINE(twsi1_clk, twsi_parents, APBC_TWSI1_CLK_RST, 4, 3, BIT(1),
637
+             0);
596
+         0);
638
+static CCU_MUX_GATE_DEFINE(twsi1_clk, twsi_parents,
597
+CCU_MUX_GATE_DEFINE(twsi2_clk, twsi_parents, APBC_TWSI2_CLK_RST, 4, 3, BIT(1),
639
+             APBC_TWSI1_CLK_RST,
598
+         0);
640
+             4, 3, BIT(1),
599
+CCU_MUX_GATE_DEFINE(twsi4_clk, twsi_parents, APBC_TWSI4_CLK_RST, 4, 3, BIT(1),
641
+             0);
600
+         0);
642
+static CCU_MUX_GATE_DEFINE(twsi2_clk, twsi_parents,
601
+CCU_MUX_GATE_DEFINE(twsi5_clk, twsi_parents, APBC_TWSI5_CLK_RST, 4, 3, BIT(1),
643
+             APBC_TWSI2_CLK_RST,
602
+         0);
644
+             4, 3, BIT(1),
603
+CCU_MUX_GATE_DEFINE(twsi6_clk, twsi_parents, APBC_TWSI6_CLK_RST, 4, 3, BIT(1),
645
+             0);
604
+         0);
646
+static CCU_MUX_GATE_DEFINE(twsi4_clk, twsi_parents,
605
+CCU_MUX_GATE_DEFINE(twsi7_clk, twsi_parents, APBC_TWSI7_CLK_RST, 4, 3, BIT(1),
647
+             APBC_TWSI4_CLK_RST,
606
+         0);
648
+             4, 3, BIT(1),
649
+             0);
650
+static CCU_MUX_GATE_DEFINE(twsi5_clk, twsi_parents,
651
+             APBC_TWSI5_CLK_RST,
652
+             4, 3, BIT(1),
653
+             0);
654
+static CCU_MUX_GATE_DEFINE(twsi6_clk, twsi_parents,
655
+             APBC_TWSI6_CLK_RST,
656
+             4, 3, BIT(1),
657
+             0);
658
+static CCU_MUX_GATE_DEFINE(twsi7_clk, twsi_parents,
659
+             APBC_TWSI7_CLK_RST,
660
+             4, 3, BIT(1),
661
+             0);
662
+
607
+
663
+static const struct clk_parent_data timer_parents[] = {
608
+static const struct clk_parent_data timer_parents[] = {
664
+    CCU_PARENT_HW(pll1_d192_12p8),
609
+    CCU_PARENT_HW(pll1_d192_12p8),
665
+    CCU_PARENT_NAME(osc),
610
+    CCU_PARENT_NAME(osc),
666
+    CCU_PARENT_HW(pll1_d384_6p4),
611
+    CCU_PARENT_HW(pll1_d384_6p4),
667
+    CCU_PARENT_NAME(vctcxo_3m),
612
+    CCU_PARENT_NAME(vctcxo_3m),
668
+    CCU_PARENT_NAME(vctcxo_1m),
613
+    CCU_PARENT_NAME(vctcxo_1m),
669
+};
614
+};
670
+static CCU_MUX_GATE_DEFINE(timers1_clk, timer_parents,
615
+CCU_MUX_GATE_DEFINE(timers1_clk, timer_parents, APBC_TIMERS1_CLK_RST, 4, 3,
671
+             APBC_TIMERS1_CLK_RST,
616
+         BIT(1), 0);
672
+             4, 3, BIT(1),
617
+CCU_MUX_GATE_DEFINE(timers2_clk, timer_parents, APBC_TIMERS2_CLK_RST, 4, 3,
673
+             0);
618
+         BIT(1), 0);
674
+static CCU_MUX_GATE_DEFINE(timers2_clk, timer_parents,
619
+
675
+             APBC_TIMERS2_CLK_RST,
620
+CCU_GATE_DEFINE(aib_clk, CCU_PARENT_NAME(vctcxo_24m), APBC_AIB_CLK_RST, BIT(1),
676
+             4, 3, BIT(1),
621
+        0);
677
+             0);
622
+
678
+
623
+CCU_GATE_DEFINE(onewire_clk, CCU_PARENT_NAME(vctcxo_24m), APBC_ONEWIRE_CLK_RST,
679
+static CCU_GATE_DEFINE(aib_clk, CCU_PARENT_NAME(vctcxo_24m),
624
+        BIT(1), 0);
680
+         APBC_AIB_CLK_RST,
681
+         BIT(1),
682
+         0);
683
+
684
+static CCU_GATE_DEFINE(onewire_clk, CCU_PARENT_NAME(vctcxo_24m),
685
+         APBC_ONEWIRE_CLK_RST,
686
+         BIT(1),
687
+         0);
688
+
625
+
689
+static const struct clk_parent_data sspa_parents[] = {
626
+static const struct clk_parent_data sspa_parents[] = {
690
+    CCU_PARENT_HW(pll1_d384_6p4),
627
+    CCU_PARENT_HW(pll1_d384_6p4),
691
+    CCU_PARENT_HW(pll1_d192_12p8),
628
+    CCU_PARENT_HW(pll1_d192_12p8),
692
+    CCU_PARENT_HW(pll1_d96_25p6),
629
+    CCU_PARENT_HW(pll1_d96_25p6),
693
+    CCU_PARENT_HW(pll1_d48_51p2),
630
+    CCU_PARENT_HW(pll1_d48_51p2),
694
+    CCU_PARENT_HW(pll1_d768_3p2),
631
+    CCU_PARENT_HW(pll1_d768_3p2),
695
+    CCU_PARENT_HW(pll1_d1536_1p6),
632
+    CCU_PARENT_HW(pll1_d1536_1p6),
696
+    CCU_PARENT_HW(pll1_d3072_0p8),
633
+    CCU_PARENT_HW(pll1_d3072_0p8),
697
+    CCU_PARENT_HW(i2s_bclk),
634
+    CCU_PARENT_HW(i2s_bclk),
698
+};
635
+};
699
+static CCU_MUX_GATE_DEFINE(sspa0_clk, sspa_parents,
636
+CCU_MUX_GATE_DEFINE(sspa0_clk, sspa_parents, APBC_SSPA0_CLK_RST, 4, 3, BIT(1),
700
+             APBC_SSPA0_CLK_RST,
637
+         0);
701
+             4, 3, BIT(1),
638
+CCU_MUX_GATE_DEFINE(sspa1_clk, sspa_parents, APBC_SSPA1_CLK_RST, 4, 3, BIT(1),
702
+             0);
639
+         0);
703
+static CCU_MUX_GATE_DEFINE(sspa1_clk, sspa_parents,
640
+CCU_GATE_DEFINE(dro_clk, CCU_PARENT_HW(apb_clk), APBC_DRO_CLK_RST, BIT(1), 0);
704
+             APBC_SSPA1_CLK_RST,
641
+CCU_GATE_DEFINE(ir_clk, CCU_PARENT_HW(apb_clk), APBC_IR_CLK_RST, BIT(1), 0);
705
+             4, 3, BIT(1),
642
+CCU_GATE_DEFINE(tsen_clk, CCU_PARENT_HW(apb_clk), APBC_TSEN_CLK_RST, BIT(1), 0);
706
+             0);
643
+CCU_GATE_DEFINE(ipc_ap2aud_clk, CCU_PARENT_HW(apb_clk), APBC_IPC_AP2AUD_CLK_RST,
707
+static CCU_GATE_DEFINE(dro_clk, CCU_PARENT_HW(apb_clk),
644
+        BIT(1), 0);
708
+         APBC_DRO_CLK_RST,
709
+         BIT(1),
710
+         0);
711
+static CCU_GATE_DEFINE(ir_clk, CCU_PARENT_HW(apb_clk),
712
+         APBC_IR_CLK_RST,
713
+         BIT(1),
714
+         0);
715
+static CCU_GATE_DEFINE(tsen_clk, CCU_PARENT_HW(apb_clk),
716
+         APBC_TSEN_CLK_RST,
717
+         BIT(1),
718
+         0);
719
+static CCU_GATE_DEFINE(ipc_ap2aud_clk, CCU_PARENT_HW(apb_clk),
720
+         APBC_IPC_AP2AUD_CLK_RST,
721
+         BIT(1),
722
+         0);
723
+
645
+
724
+static const struct clk_parent_data can_parents[] = {
646
+static const struct clk_parent_data can_parents[] = {
725
+    CCU_PARENT_HW(pll3_20),
647
+    CCU_PARENT_HW(pll3_20),
726
+    CCU_PARENT_HW(pll3_40),
648
+    CCU_PARENT_HW(pll3_40),
727
+    CCU_PARENT_HW(pll3_80),
649
+    CCU_PARENT_HW(pll3_80),
728
+};
650
+};
729
+static CCU_MUX_GATE_DEFINE(can0_clk, can_parents,
651
+CCU_MUX_GATE_DEFINE(can0_clk, can_parents, APBC_CAN0_CLK_RST, 4, 3, BIT(1), 0);
730
+             APBC_CAN0_CLK_RST,
652
+CCU_GATE_DEFINE(can0_bus_clk, CCU_PARENT_NAME(vctcxo_24m), APBC_CAN0_CLK_RST,
731
+             4, 3, BIT(1),
653
+        BIT(0), 0);
732
+             0);
654
+
733
+static CCU_GATE_DEFINE(can0_bus_clk, CCU_PARENT_NAME(vctcxo_24m),
655
+CCU_GATE_DEFINE(uart0_bus_clk, CCU_PARENT_HW(apb_clk), APBC_UART1_CLK_RST,
734
+         APBC_CAN0_CLK_RST,
656
+        BIT(0), CLK_IS_CRITICAL);
735
+         BIT(0),
657
+CCU_GATE_DEFINE(uart2_bus_clk, CCU_PARENT_HW(apb_clk), APBC_UART2_CLK_RST,
736
+         0);
658
+        BIT(0), 0);
737
+
659
+CCU_GATE_DEFINE(uart3_bus_clk, CCU_PARENT_HW(apb_clk), APBC_UART3_CLK_RST,
738
+static CCU_GATE_DEFINE(uart0_bus_clk, CCU_PARENT_HW(apb_clk),
660
+        BIT(0), 0);
739
+         APBC_UART1_CLK_RST,
661
+CCU_GATE_DEFINE(uart4_bus_clk, CCU_PARENT_HW(apb_clk), APBC_UART4_CLK_RST,
740
+         BIT(0),
662
+        BIT(0), 0);
741
+         CLK_IS_CRITICAL);
663
+CCU_GATE_DEFINE(uart5_bus_clk, CCU_PARENT_HW(apb_clk), APBC_UART5_CLK_RST,
742
+static CCU_GATE_DEFINE(uart2_bus_clk, CCU_PARENT_HW(apb_clk),
664
+        BIT(0), 0);
743
+         APBC_UART2_CLK_RST,
665
+CCU_GATE_DEFINE(uart6_bus_clk, CCU_PARENT_HW(apb_clk), APBC_UART6_CLK_RST,
744
+         BIT(0),
666
+        BIT(0), 0);
745
+         0);
667
+CCU_GATE_DEFINE(uart7_bus_clk, CCU_PARENT_HW(apb_clk), APBC_UART7_CLK_RST,
746
+static CCU_GATE_DEFINE(uart3_bus_clk, CCU_PARENT_HW(apb_clk),
668
+        BIT(0), 0);
747
+         APBC_UART3_CLK_RST,
669
+CCU_GATE_DEFINE(uart8_bus_clk, CCU_PARENT_HW(apb_clk), APBC_UART8_CLK_RST,
748
+         BIT(0),
670
+        BIT(0), 0);
749
+         0);
671
+CCU_GATE_DEFINE(uart9_bus_clk, CCU_PARENT_HW(apb_clk), APBC_UART9_CLK_RST,
750
+static CCU_GATE_DEFINE(uart4_bus_clk, CCU_PARENT_HW(apb_clk),
672
+        BIT(0), 0);
751
+         APBC_UART4_CLK_RST,
673
+
752
+         BIT(0),
674
+CCU_GATE_DEFINE(gpio_bus_clk, CCU_PARENT_HW(apb_clk), APBC_GPIO_CLK_RST, BIT(0),
753
+         0);
675
+        0);
754
+static CCU_GATE_DEFINE(uart5_bus_clk, CCU_PARENT_HW(apb_clk),
676
+
755
+         APBC_UART5_CLK_RST,
677
+CCU_GATE_DEFINE(pwm0_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM0_CLK_RST, BIT(0),
756
+         BIT(0),
678
+        0);
757
+         0);
679
+CCU_GATE_DEFINE(pwm1_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM1_CLK_RST, BIT(0),
758
+static CCU_GATE_DEFINE(uart6_bus_clk, CCU_PARENT_HW(apb_clk),
680
+        0);
759
+         APBC_UART6_CLK_RST,
681
+CCU_GATE_DEFINE(pwm2_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM2_CLK_RST, BIT(0),
760
+         BIT(0),
682
+        0);
761
+         0);
683
+CCU_GATE_DEFINE(pwm3_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM3_CLK_RST, BIT(0),
762
+static CCU_GATE_DEFINE(uart7_bus_clk, CCU_PARENT_HW(apb_clk),
684
+        0);
763
+         APBC_UART7_CLK_RST,
685
+CCU_GATE_DEFINE(pwm4_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM4_CLK_RST, BIT(0),
764
+         BIT(0),
686
+        0);
765
+         0);
687
+CCU_GATE_DEFINE(pwm5_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM5_CLK_RST, BIT(0),
766
+static CCU_GATE_DEFINE(uart8_bus_clk, CCU_PARENT_HW(apb_clk),
688
+        0);
767
+         APBC_UART8_CLK_RST,
689
+CCU_GATE_DEFINE(pwm6_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM6_CLK_RST, BIT(0),
768
+         BIT(0),
690
+        0);
769
+         0);
691
+CCU_GATE_DEFINE(pwm7_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM7_CLK_RST, BIT(0),
770
+static CCU_GATE_DEFINE(uart9_bus_clk, CCU_PARENT_HW(apb_clk),
692
+        0);
771
+         APBC_UART9_CLK_RST,
693
+CCU_GATE_DEFINE(pwm8_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM8_CLK_RST, BIT(0),
772
+         BIT(0),
694
+        0);
773
+         0);
695
+CCU_GATE_DEFINE(pwm9_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM9_CLK_RST, BIT(0),
774
+
696
+        0);
775
+static CCU_GATE_DEFINE(gpio_bus_clk, CCU_PARENT_HW(apb_clk),
697
+CCU_GATE_DEFINE(pwm10_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM10_CLK_RST,
776
+         APBC_GPIO_CLK_RST,
698
+        BIT(0), 0);
777
+         BIT(0),
699
+CCU_GATE_DEFINE(pwm11_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM11_CLK_RST,
778
+         0);
700
+        BIT(0), 0);
779
+
701
+CCU_GATE_DEFINE(pwm12_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM12_CLK_RST,
780
+static CCU_GATE_DEFINE(pwm0_bus_clk, CCU_PARENT_HW(apb_clk),
702
+        BIT(0), 0);
781
+         APBC_PWM0_CLK_RST,
703
+CCU_GATE_DEFINE(pwm13_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM13_CLK_RST,
782
+         BIT(0),
704
+        BIT(0), 0);
783
+         0);
705
+CCU_GATE_DEFINE(pwm14_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM14_CLK_RST,
784
+static CCU_GATE_DEFINE(pwm1_bus_clk, CCU_PARENT_HW(apb_clk),
706
+        BIT(0), 0);
785
+         APBC_PWM1_CLK_RST,
707
+CCU_GATE_DEFINE(pwm15_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM15_CLK_RST,
786
+         BIT(0),
708
+        BIT(0), 0);
787
+         0);
709
+CCU_GATE_DEFINE(pwm16_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM16_CLK_RST,
788
+static CCU_GATE_DEFINE(pwm2_bus_clk, CCU_PARENT_HW(apb_clk),
710
+        BIT(0), 0);
789
+         APBC_PWM2_CLK_RST,
711
+CCU_GATE_DEFINE(pwm17_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM17_CLK_RST,
790
+         BIT(0),
712
+        BIT(0), 0);
791
+         0);
713
+CCU_GATE_DEFINE(pwm18_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM18_CLK_RST,
792
+static CCU_GATE_DEFINE(pwm3_bus_clk, CCU_PARENT_HW(apb_clk),
714
+        BIT(0), 0);
793
+         APBC_PWM3_CLK_RST,
715
+CCU_GATE_DEFINE(pwm19_bus_clk, CCU_PARENT_HW(apb_clk), APBC_PWM19_CLK_RST,
794
+         BIT(0),
716
+        BIT(0), 0);
795
+         0);
717
+
796
+static CCU_GATE_DEFINE(pwm4_bus_clk, CCU_PARENT_HW(apb_clk),
718
+CCU_GATE_DEFINE(ssp3_bus_clk, CCU_PARENT_HW(apb_clk), APBC_SSP3_CLK_RST, BIT(0),
797
+         APBC_PWM4_CLK_RST,
719
+        0);
798
+         BIT(0),
720
+
799
+         0);
721
+CCU_GATE_DEFINE(rtc_bus_clk, CCU_PARENT_HW(apb_clk), APBC_RTC_CLK_RST, BIT(0),
800
+static CCU_GATE_DEFINE(pwm5_bus_clk, CCU_PARENT_HW(apb_clk),
722
+        0);
801
+         APBC_PWM5_CLK_RST,
723
+
802
+         BIT(0),
724
+CCU_GATE_DEFINE(twsi0_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TWSI0_CLK_RST,
803
+         0);
725
+        BIT(0), 0);
804
+static CCU_GATE_DEFINE(pwm6_bus_clk, CCU_PARENT_HW(apb_clk),
726
+CCU_GATE_DEFINE(twsi1_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TWSI1_CLK_RST,
805
+         APBC_PWM6_CLK_RST,
727
+        BIT(0), 0);
806
+         BIT(0),
728
+CCU_GATE_DEFINE(twsi2_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TWSI2_CLK_RST,
807
+         0);
729
+        BIT(0), 0);
808
+static CCU_GATE_DEFINE(pwm7_bus_clk, CCU_PARENT_HW(apb_clk),
730
+CCU_GATE_DEFINE(twsi4_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TWSI4_CLK_RST,
809
+         APBC_PWM7_CLK_RST,
731
+        BIT(0), 0);
810
+         BIT(0),
732
+CCU_GATE_DEFINE(twsi5_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TWSI5_CLK_RST,
811
+         0);
733
+        BIT(0), 0);
812
+static CCU_GATE_DEFINE(pwm8_bus_clk, CCU_PARENT_HW(apb_clk),
734
+CCU_GATE_DEFINE(twsi6_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TWSI6_CLK_RST,
813
+         APBC_PWM8_CLK_RST,
735
+        BIT(0), 0);
814
+         BIT(0),
736
+CCU_GATE_DEFINE(twsi7_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TWSI7_CLK_RST,
815
+         0);
737
+        BIT(0), 0);
816
+static CCU_GATE_DEFINE(pwm9_bus_clk, CCU_PARENT_HW(apb_clk),
738
+
817
+         APBC_PWM9_CLK_RST,
739
+CCU_GATE_DEFINE(timers1_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TIMERS1_CLK_RST,
818
+         BIT(0),
740
+        BIT(0), 0);
819
+         0);
741
+CCU_GATE_DEFINE(timers2_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TIMERS2_CLK_RST,
820
+static CCU_GATE_DEFINE(pwm10_bus_clk, CCU_PARENT_HW(apb_clk),
742
+        BIT(0), 0);
821
+         APBC_PWM10_CLK_RST,
743
+
822
+         BIT(0),
744
+CCU_GATE_DEFINE(aib_bus_clk, CCU_PARENT_HW(apb_clk), APBC_AIB_CLK_RST, BIT(0),
823
+         0);
745
+        0);
824
+static CCU_GATE_DEFINE(pwm11_bus_clk, CCU_PARENT_HW(apb_clk),
746
+
825
+         APBC_PWM11_CLK_RST,
747
+CCU_GATE_DEFINE(onewire_bus_clk, CCU_PARENT_HW(apb_clk), APBC_ONEWIRE_CLK_RST,
826
+         BIT(0),
748
+        BIT(0), 0);
827
+         0);
749
+
828
+static CCU_GATE_DEFINE(pwm12_bus_clk, CCU_PARENT_HW(apb_clk),
750
+CCU_GATE_DEFINE(sspa0_bus_clk, CCU_PARENT_HW(apb_clk), APBC_SSPA0_CLK_RST,
829
+         APBC_PWM12_CLK_RST,
751
+        BIT(0), 0);
830
+         BIT(0),
752
+CCU_GATE_DEFINE(sspa1_bus_clk, CCU_PARENT_HW(apb_clk), APBC_SSPA1_CLK_RST,
831
+         0);
753
+        BIT(0), 0);
832
+static CCU_GATE_DEFINE(pwm13_bus_clk, CCU_PARENT_HW(apb_clk),
754
+
833
+         APBC_PWM13_CLK_RST,
755
+CCU_GATE_DEFINE(tsen_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TSEN_CLK_RST, BIT(0),
834
+         BIT(0),
756
+        0);
835
+         0);
757
+
836
+static CCU_GATE_DEFINE(pwm14_bus_clk, CCU_PARENT_HW(apb_clk),
758
+CCU_GATE_DEFINE(ipc_ap2aud_bus_clk, CCU_PARENT_HW(apb_clk),
837
+         APBC_PWM14_CLK_RST,
759
+        APBC_IPC_AP2AUD_CLK_RST, BIT(0), 0);
838
+         BIT(0),
760
+/* APBC clocks end */
839
+         0);
761
+
840
+static CCU_GATE_DEFINE(pwm15_bus_clk, CCU_PARENT_HW(apb_clk),
762
+/* APMU clocks start */
841
+         APBC_PWM15_CLK_RST,
842
+         BIT(0),
843
+         0);
844
+static CCU_GATE_DEFINE(pwm16_bus_clk, CCU_PARENT_HW(apb_clk),
845
+         APBC_PWM16_CLK_RST,
846
+         BIT(0),
847
+         0);
848
+static CCU_GATE_DEFINE(pwm17_bus_clk, CCU_PARENT_HW(apb_clk),
849
+         APBC_PWM17_CLK_RST,
850
+         BIT(0),
851
+         0);
852
+static CCU_GATE_DEFINE(pwm18_bus_clk, CCU_PARENT_HW(apb_clk),
853
+         APBC_PWM18_CLK_RST,
854
+         BIT(0),
855
+         0);
856
+static CCU_GATE_DEFINE(pwm19_bus_clk, CCU_PARENT_HW(apb_clk),
857
+         APBC_PWM19_CLK_RST,
858
+         BIT(0),
859
+         0);
860
+
861
+static CCU_GATE_DEFINE(ssp3_bus_clk, CCU_PARENT_HW(apb_clk),
862
+         APBC_SSP3_CLK_RST,
863
+         BIT(0),
864
+         0);
865
+
866
+static CCU_GATE_DEFINE(rtc_bus_clk, CCU_PARENT_HW(apb_clk),
867
+         APBC_RTC_CLK_RST,
868
+         BIT(0),
869
+         0);
870
+
871
+static CCU_GATE_DEFINE(twsi0_bus_clk, CCU_PARENT_HW(apb_clk),
872
+         APBC_TWSI0_CLK_RST,
873
+         BIT(0),
874
+         0);
875
+static CCU_GATE_DEFINE(twsi1_bus_clk, CCU_PARENT_HW(apb_clk),
876
+         APBC_TWSI1_CLK_RST,
877
+         BIT(0),
878
+         0);
879
+static CCU_GATE_DEFINE(twsi2_bus_clk, CCU_PARENT_HW(apb_clk),
880
+         APBC_TWSI2_CLK_RST,
881
+         BIT(0),
882
+         0);
883
+static CCU_GATE_DEFINE(twsi4_bus_clk, CCU_PARENT_HW(apb_clk),
884
+         APBC_TWSI4_CLK_RST,
885
+         BIT(0),
886
+         0);
887
+static CCU_GATE_DEFINE(twsi5_bus_clk, CCU_PARENT_HW(apb_clk),
888
+         APBC_TWSI5_CLK_RST,
889
+         BIT(0),
890
+         0);
891
+static CCU_GATE_DEFINE(twsi6_bus_clk, CCU_PARENT_HW(apb_clk),
892
+         APBC_TWSI6_CLK_RST,
893
+         BIT(0),
894
+         0);
895
+static CCU_GATE_DEFINE(twsi7_bus_clk, CCU_PARENT_HW(apb_clk),
896
+         APBC_TWSI7_CLK_RST,
897
+         BIT(0),
898
+         0);
899
+
900
+static CCU_GATE_DEFINE(timers1_bus_clk, CCU_PARENT_HW(apb_clk),
901
+         APBC_TIMERS1_CLK_RST,
902
+         BIT(0),
903
+         0);
904
+static CCU_GATE_DEFINE(timers2_bus_clk, CCU_PARENT_HW(apb_clk),
905
+         APBC_TIMERS2_CLK_RST,
906
+         BIT(0),
907
+         0);
908
+
909
+static CCU_GATE_DEFINE(aib_bus_clk, CCU_PARENT_HW(apb_clk),
910
+         APBC_AIB_CLK_RST,
911
+         BIT(0),
912
+         0);
913
+
914
+static CCU_GATE_DEFINE(onewire_bus_clk, CCU_PARENT_HW(apb_clk),
915
+         APBC_ONEWIRE_CLK_RST,
916
+         BIT(0),
917
+         0);
918
+
919
+static CCU_GATE_DEFINE(sspa0_bus_clk, CCU_PARENT_HW(apb_clk),
920
+         APBC_SSPA0_CLK_RST,
921
+         BIT(0),
922
+         0);
923
+static CCU_GATE_DEFINE(sspa1_bus_clk, CCU_PARENT_HW(apb_clk),
924
+         APBC_SSPA1_CLK_RST,
925
+         BIT(0),
926
+         0);
927
+
928
+static CCU_GATE_DEFINE(tsen_bus_clk, CCU_PARENT_HW(apb_clk),
929
+         APBC_TSEN_CLK_RST,
930
+         BIT(0),
931
+         0);
932
+
933
+static CCU_GATE_DEFINE(ipc_ap2aud_bus_clk, CCU_PARENT_HW(apb_clk),
934
+         APBC_IPC_AP2AUD_CLK_RST,
935
+         BIT(0),
936
+         0);
937
+/*    APBC clocks end        */
938
+
939
+/*    APMU clocks start    */
940
+static const struct clk_parent_data pmua_aclk_parents[] = {
763
+static const struct clk_parent_data pmua_aclk_parents[] = {
941
+    CCU_PARENT_HW(pll1_d10_245p76),
764
+    CCU_PARENT_HW(pll1_d10_245p76),
942
+    CCU_PARENT_HW(pll1_d8_307p2),
765
+    CCU_PARENT_HW(pll1_d8_307p2),
943
+};
766
+};
944
+static CCU_DIV_FC_MUX_DEFINE(pmua_aclk, pmua_aclk_parents,
767
+CCU_MUX_DIV_FC_DEFINE(pmua_aclk, pmua_aclk_parents, APMU_ACLK_CLK_CTRL, 1, 2,
945
+             APMU_ACLK_CLK_CTRL,
768
+         BIT(4), 0, 1, 0);
946
+             1, 2, BIT(4),
947
+             0, 1,
948
+             0);
949
+
769
+
950
+static const struct clk_parent_data cci550_clk_parents[] = {
770
+static const struct clk_parent_data cci550_clk_parents[] = {
951
+    CCU_PARENT_HW(pll1_d5_491p52),
771
+    CCU_PARENT_HW(pll1_d5_491p52),
952
+    CCU_PARENT_HW(pll1_d4_614p4),
772
+    CCU_PARENT_HW(pll1_d4_614p4),
953
+    CCU_PARENT_HW(pll1_d3_819p2),
773
+    CCU_PARENT_HW(pll1_d3_819p2),
954
+    CCU_PARENT_HW(pll2_d3),
774
+    CCU_PARENT_HW(pll2_d3),
955
+};
775
+};
956
+static CCU_DIV_FC_MUX_DEFINE(cci550_clk, cci550_clk_parents,
776
+CCU_MUX_DIV_FC_DEFINE(cci550_clk, cci550_clk_parents, APMU_CCI550_CLK_CTRL, 8,
957
+             APMU_CCI550_CLK_CTRL,
777
+         3, BIT(12), 0, 2, CLK_IS_CRITICAL);
958
+             8, 3, BIT(12), 0, 2, CLK_IS_CRITICAL);
959
+
778
+
960
+static const struct clk_parent_data cpu_c0_hi_clk_parents[] = {
779
+static const struct clk_parent_data cpu_c0_hi_clk_parents[] = {
961
+    CCU_PARENT_HW(pll3_d2),
780
+    CCU_PARENT_HW(pll3_d2),
962
+    CCU_PARENT_HW(pll3_d1),
781
+    CCU_PARENT_HW(pll3_d1),
963
+};
782
+};
964
+static CCU_MUX_DEFINE(cpu_c0_hi_clk, cpu_c0_hi_clk_parents,
783
+CCU_MUX_DEFINE(cpu_c0_hi_clk, cpu_c0_hi_clk_parents, APMU_CPU_C0_CLK_CTRL, 13,
965
+         APMU_CPU_C0_CLK_CTRL,
784
+     1, 0);
966
+         13, 1, 0);
967
+static const struct clk_parent_data cpu_c0_clk_parents[] = {
785
+static const struct clk_parent_data cpu_c0_clk_parents[] = {
968
+    CCU_PARENT_HW(pll1_d4_614p4),
786
+    CCU_PARENT_HW(pll1_d4_614p4),
969
+    CCU_PARENT_HW(pll1_d3_819p2),
787
+    CCU_PARENT_HW(pll1_d3_819p2),
970
+    CCU_PARENT_HW(pll1_d6_409p6),
788
+    CCU_PARENT_HW(pll1_d6_409p6),
971
+    CCU_PARENT_HW(pll1_d5_491p52),
789
+    CCU_PARENT_HW(pll1_d5_491p52),
972
+    CCU_PARENT_HW(pll1_d2_1228p8),
790
+    CCU_PARENT_HW(pll1_d2_1228p8),
973
+    CCU_PARENT_HW(pll3_d3),
791
+    CCU_PARENT_HW(pll3_d3),
974
+    CCU_PARENT_HW(pll2_d3),
792
+    CCU_PARENT_HW(pll2_d3),
975
+    CCU_PARENT_HW(cpu_c0_hi_clk),
793
+    CCU_PARENT_HW(cpu_c0_hi_clk),
976
+};
794
+};
977
+static CCU_MUX_FC_DEFINE(cpu_c0_core_clk, cpu_c0_clk_parents,
795
+CCU_MUX_FC_DEFINE(cpu_c0_core_clk, cpu_c0_clk_parents, APMU_CPU_C0_CLK_CTRL,
978
+             APMU_CPU_C0_CLK_CTRL,
796
+         BIT(12), 0, 3, CLK_IS_CRITICAL);
979
+             BIT(12), 0, 3, CLK_IS_CRITICAL);
797
+CCU_DIV_DEFINE(cpu_c0_ace_clk, CCU_PARENT_HW(cpu_c0_core_clk),
980
+static CCU_DIV_DEFINE(cpu_c0_ace_clk, CCU_PARENT_HW(cpu_c0_core_clk),
798
+     APMU_CPU_C0_CLK_CTRL, 6, 3, CLK_IS_CRITICAL);
981
+         APMU_CPU_C0_CLK_CTRL,
799
+CCU_DIV_DEFINE(cpu_c0_tcm_clk, CCU_PARENT_HW(cpu_c0_core_clk),
982
+         6, 3, CLK_IS_CRITICAL);
800
+     APMU_CPU_C0_CLK_CTRL, 9, 3, CLK_IS_CRITICAL);
983
+static CCU_DIV_DEFINE(cpu_c0_tcm_clk, CCU_PARENT_HW(cpu_c0_core_clk),
984
+         APMU_CPU_C0_CLK_CTRL, 9, 3, CLK_IS_CRITICAL);
985
+
801
+
986
+static const struct clk_parent_data cpu_c1_hi_clk_parents[] = {
802
+static const struct clk_parent_data cpu_c1_hi_clk_parents[] = {
987
+    CCU_PARENT_HW(pll3_d2),
803
+    CCU_PARENT_HW(pll3_d2),
988
+    CCU_PARENT_HW(pll3_d1),
804
+    CCU_PARENT_HW(pll3_d1),
989
+};
805
+};
990
+static CCU_MUX_DEFINE(cpu_c1_hi_clk, cpu_c1_hi_clk_parents,
806
+CCU_MUX_DEFINE(cpu_c1_hi_clk, cpu_c1_hi_clk_parents, APMU_CPU_C1_CLK_CTRL, 13,
991
+         APMU_CPU_C1_CLK_CTRL,
807
+     1, CLK_IS_CRITICAL);
992
+         13, 1, CLK_IS_CRITICAL);
993
+static const struct clk_parent_data cpu_c1_clk_parents[] = {
808
+static const struct clk_parent_data cpu_c1_clk_parents[] = {
994
+    CCU_PARENT_HW(pll1_d4_614p4),
809
+    CCU_PARENT_HW(pll1_d4_614p4),
995
+    CCU_PARENT_HW(pll1_d3_819p2),
810
+    CCU_PARENT_HW(pll1_d3_819p2),
996
+    CCU_PARENT_HW(pll1_d6_409p6),
811
+    CCU_PARENT_HW(pll1_d6_409p6),
997
+    CCU_PARENT_HW(pll1_d5_491p52),
812
+    CCU_PARENT_HW(pll1_d5_491p52),
998
+    CCU_PARENT_HW(pll1_d2_1228p8),
813
+    CCU_PARENT_HW(pll1_d2_1228p8),
999
+    CCU_PARENT_HW(pll3_d3),
814
+    CCU_PARENT_HW(pll3_d3),
1000
+    CCU_PARENT_HW(pll2_d3),
815
+    CCU_PARENT_HW(pll2_d3),
1001
+    CCU_PARENT_HW(cpu_c1_hi_clk),
816
+    CCU_PARENT_HW(cpu_c1_hi_clk),
1002
+};
817
+};
1003
+static CCU_MUX_FC_DEFINE(cpu_c1_core_clk, cpu_c1_clk_parents,
818
+CCU_MUX_FC_DEFINE(cpu_c1_core_clk, cpu_c1_clk_parents, APMU_CPU_C1_CLK_CTRL,
1004
+             APMU_CPU_C1_CLK_CTRL,
819
+         BIT(12), 0, 3, CLK_IS_CRITICAL);
1005
+             BIT(12), 0, 3, CLK_IS_CRITICAL);
820
+CCU_DIV_DEFINE(cpu_c1_ace_clk, CCU_PARENT_HW(cpu_c1_core_clk),
1006
+static CCU_DIV_DEFINE(cpu_c1_ace_clk, CCU_PARENT_HW(cpu_c1_core_clk),
821
+     APMU_CPU_C1_CLK_CTRL, 6, 3, CLK_IS_CRITICAL);
1007
+         APMU_CPU_C1_CLK_CTRL,
1008
+         6, 3, CLK_IS_CRITICAL);
1009
+
822
+
1010
+static const struct clk_parent_data jpg_parents[] = {
823
+static const struct clk_parent_data jpg_parents[] = {
1011
+    CCU_PARENT_HW(pll1_d4_614p4),
824
+    CCU_PARENT_HW(pll1_d4_614p4),
1012
+    CCU_PARENT_HW(pll1_d6_409p6),
825
+    CCU_PARENT_HW(pll1_d6_409p6),
1013
+    CCU_PARENT_HW(pll1_d5_491p52),
826
+    CCU_PARENT_HW(pll1_d5_491p52),
1014
+    CCU_PARENT_HW(pll1_d3_819p2),
827
+    CCU_PARENT_HW(pll1_d3_819p2),
1015
+    CCU_PARENT_HW(pll1_d2_1228p8),
828
+    CCU_PARENT_HW(pll1_d2_1228p8),
1016
+    CCU_PARENT_HW(pll2_d4),
829
+    CCU_PARENT_HW(pll2_d4),
1017
+    CCU_PARENT_HW(pll2_d3),
830
+    CCU_PARENT_HW(pll2_d3),
1018
+};
831
+};
1019
+static CCU_DIV_FC_MUX_GATE_DEFINE(jpg_clk, jpg_parents,
832
+CCU_MUX_DIV_GATE_FC_DEFINE(jpg_clk, jpg_parents, APMU_JPG_CLK_RES_CTRL, 5, 3,
1020
+                 APMU_JPG_CLK_RES_CTRL,
833
+             BIT(15), 2, 3, BIT(1), 0);
1021
+                 5, 3, BIT(15),
1022
+                 2, 3, BIT(1),
1023
+                 0);
1024
+
834
+
1025
+static const struct clk_parent_data ccic2phy_parents[] = {
835
+static const struct clk_parent_data ccic2phy_parents[] = {
1026
+    CCU_PARENT_HW(pll1_d24_102p4),
836
+    CCU_PARENT_HW(pll1_d24_102p4),
1027
+    CCU_PARENT_HW(pll1_d48_51p2_ap),
837
+    CCU_PARENT_HW(pll1_d48_51p2_ap),
1028
+};
838
+};
1029
+static CCU_MUX_GATE_DEFINE(ccic2phy_clk, ccic2phy_parents,
839
+CCU_MUX_GATE_DEFINE(ccic2phy_clk, ccic2phy_parents, APMU_CSI_CCIC2_CLK_RES_CTRL,
1030
+             APMU_CSI_CCIC2_CLK_RES_CTRL,
840
+         7, 1, BIT(5), 0);
1031
+             7, 1, BIT(5),
1032
+             0);
1033
+
841
+
1034
+static const struct clk_parent_data ccic3phy_parents[] = {
842
+static const struct clk_parent_data ccic3phy_parents[] = {
1035
+    CCU_PARENT_HW(pll1_d24_102p4),
843
+    CCU_PARENT_HW(pll1_d24_102p4),
1036
+    CCU_PARENT_HW(pll1_d48_51p2_ap),
844
+    CCU_PARENT_HW(pll1_d48_51p2_ap),
1037
+};
845
+};
1038
+static CCU_MUX_GATE_DEFINE(ccic3phy_clk, ccic3phy_parents,
846
+CCU_MUX_GATE_DEFINE(ccic3phy_clk, ccic3phy_parents, APMU_CSI_CCIC2_CLK_RES_CTRL,
1039
+             APMU_CSI_CCIC2_CLK_RES_CTRL,
847
+         31, 1, BIT(30), 0);
1040
+             31, 1, BIT(30),
1041
+             0);
1042
+
848
+
1043
+static const struct clk_parent_data csi_parents[] = {
849
+static const struct clk_parent_data csi_parents[] = {
1044
+    CCU_PARENT_HW(pll1_d5_491p52),
850
+    CCU_PARENT_HW(pll1_d5_491p52),
1045
+    CCU_PARENT_HW(pll1_d6_409p6),
851
+    CCU_PARENT_HW(pll1_d6_409p6),
1046
+    CCU_PARENT_HW(pll1_d4_614p4),
852
+    CCU_PARENT_HW(pll1_d4_614p4),
1047
+    CCU_PARENT_HW(pll1_d3_819p2),
853
+    CCU_PARENT_HW(pll1_d3_819p2),
1048
+    CCU_PARENT_HW(pll2_d2),
854
+    CCU_PARENT_HW(pll2_d2),
1049
+    CCU_PARENT_HW(pll2_d3),
855
+    CCU_PARENT_HW(pll2_d3),
1050
+    CCU_PARENT_HW(pll2_d4),
856
+    CCU_PARENT_HW(pll2_d4),
1051
+    CCU_PARENT_HW(pll1_d2_1228p8),
857
+    CCU_PARENT_HW(pll1_d2_1228p8),
1052
+};
858
+};
1053
+static CCU_DIV_FC_MUX_GATE_DEFINE(csi_clk, csi_parents,
859
+CCU_MUX_DIV_GATE_FC_DEFINE(csi_clk, csi_parents, APMU_CSI_CCIC2_CLK_RES_CTRL,
1054
+                 APMU_CSI_CCIC2_CLK_RES_CTRL,
860
+             20, 3, BIT(15), 16, 3, BIT(4), 0);
1055
+                 20, 3, BIT(15),
1056
+                 16, 3, BIT(4),
1057
+                 0);
1058
+
861
+
1059
+static const struct clk_parent_data camm_parents[] = {
862
+static const struct clk_parent_data camm_parents[] = {
1060
+    CCU_PARENT_HW(pll1_d8_307p2),
863
+    CCU_PARENT_HW(pll1_d8_307p2),
1061
+    CCU_PARENT_HW(pll2_d5),
864
+    CCU_PARENT_HW(pll2_d5),
1062
+    CCU_PARENT_HW(pll1_d6_409p6),
865
+    CCU_PARENT_HW(pll1_d6_409p6),
1063
+    CCU_PARENT_NAME(vctcxo_24m),
866
+    CCU_PARENT_NAME(vctcxo_24m),
1064
+};
867
+};
1065
+static CCU_DIV_MUX_GATE_DEFINE(camm0_clk, camm_parents,
868
+CCU_MUX_DIV_GATE_DEFINE(camm0_clk, camm_parents, APMU_CSI_CCIC2_CLK_RES_CTRL,
1066
+             APMU_CSI_CCIC2_CLK_RES_CTRL,
869
+            23, 4, 8, 2, BIT(28), 0);
1067
+             23, 4, 8, 2,
870
+CCU_MUX_DIV_GATE_DEFINE(camm1_clk, camm_parents, APMU_CSI_CCIC2_CLK_RES_CTRL,
1068
+             BIT(28),
871
+            23, 4, 8, 2, BIT(6), 0);
1069
+             0);
872
+CCU_MUX_DIV_GATE_DEFINE(camm2_clk, camm_parents, APMU_CSI_CCIC2_CLK_RES_CTRL,
1070
+static CCU_DIV_MUX_GATE_DEFINE(camm1_clk, camm_parents,
873
+            23, 4, 8, 2, BIT(3), 0);
1071
+             APMU_CSI_CCIC2_CLK_RES_CTRL,
1072
+             23, 4, 8, 2, BIT(6),
1073
+             0);
1074
+static CCU_DIV_MUX_GATE_DEFINE(camm2_clk, camm_parents,
1075
+             APMU_CSI_CCIC2_CLK_RES_CTRL,
1076
+             23, 4, 8, 2, BIT(3),
1077
+             0);
1078
+
874
+
1079
+static const struct clk_parent_data isp_cpp_parents[] = {
875
+static const struct clk_parent_data isp_cpp_parents[] = {
1080
+    CCU_PARENT_HW(pll1_d8_307p2),
876
+    CCU_PARENT_HW(pll1_d8_307p2),
1081
+    CCU_PARENT_HW(pll1_d6_409p6),
877
+    CCU_PARENT_HW(pll1_d6_409p6),
1082
+};
878
+};
1083
+static CCU_DIV_MUX_GATE_DEFINE(isp_cpp_clk, isp_cpp_parents,
879
+CCU_MUX_DIV_GATE_DEFINE(isp_cpp_clk, isp_cpp_parents, APMU_ISP_CLK_RES_CTRL, 24,
1084
+             APMU_ISP_CLK_RES_CTRL,
880
+            2, 26, 1, BIT(28), 0);
1085
+             24, 2, 26, 1, BIT(28),
1086
+             0);
1087
+static const struct clk_parent_data isp_bus_parents[] = {
881
+static const struct clk_parent_data isp_bus_parents[] = {
1088
+    CCU_PARENT_HW(pll1_d6_409p6),
882
+    CCU_PARENT_HW(pll1_d6_409p6),
1089
+    CCU_PARENT_HW(pll1_d5_491p52),
883
+    CCU_PARENT_HW(pll1_d5_491p52),
1090
+    CCU_PARENT_HW(pll1_d8_307p2),
884
+    CCU_PARENT_HW(pll1_d8_307p2),
1091
+    CCU_PARENT_HW(pll1_d10_245p76),
885
+    CCU_PARENT_HW(pll1_d10_245p76),
1092
+};
886
+};
1093
+static CCU_DIV_FC_MUX_GATE_DEFINE(isp_bus_clk, isp_bus_parents,
887
+CCU_MUX_DIV_GATE_FC_DEFINE(isp_bus_clk, isp_bus_parents, APMU_ISP_CLK_RES_CTRL,
1094
+                 APMU_ISP_CLK_RES_CTRL,
888
+             18, 3, BIT(23), 21, 2, BIT(17), 0);
1095
+                 18, 3, BIT(23),
1096
+                 21, 2, BIT(17),
1097
+                 0);
1098
+static const struct clk_parent_data isp_parents[] = {
889
+static const struct clk_parent_data isp_parents[] = {
1099
+    CCU_PARENT_HW(pll1_d6_409p6),
890
+    CCU_PARENT_HW(pll1_d6_409p6),
1100
+    CCU_PARENT_HW(pll1_d5_491p52),
891
+    CCU_PARENT_HW(pll1_d5_491p52),
1101
+    CCU_PARENT_HW(pll1_d4_614p4),
892
+    CCU_PARENT_HW(pll1_d4_614p4),
1102
+    CCU_PARENT_HW(pll1_d8_307p2),
893
+    CCU_PARENT_HW(pll1_d8_307p2),
1103
+};
894
+};
1104
+static CCU_DIV_FC_MUX_GATE_DEFINE(isp_clk, isp_parents,
895
+CCU_MUX_DIV_GATE_FC_DEFINE(isp_clk, isp_parents, APMU_ISP_CLK_RES_CTRL, 4, 3,
1105
+                 APMU_ISP_CLK_RES_CTRL,
896
+             BIT(7), 8, 2, BIT(1), 0);
1106
+                 4, 3, BIT(7),
1107
+                 8, 2, BIT(1),
1108
+                 0);
1109
+
897
+
1110
+static const struct clk_parent_data dpumclk_parents[] = {
898
+static const struct clk_parent_data dpumclk_parents[] = {
1111
+    CCU_PARENT_HW(pll1_d6_409p6),
899
+    CCU_PARENT_HW(pll1_d6_409p6),
1112
+    CCU_PARENT_HW(pll1_d5_491p52),
900
+    CCU_PARENT_HW(pll1_d5_491p52),
1113
+    CCU_PARENT_HW(pll1_d4_614p4),
901
+    CCU_PARENT_HW(pll1_d4_614p4),
1114
+    CCU_PARENT_HW(pll1_d8_307p2),
902
+    CCU_PARENT_HW(pll1_d8_307p2),
1115
+};
903
+};
1116
+static CCU_DIV_SPLIT_FC_MUX_GATE_DEFINE(dpu_mclk, dpumclk_parents,
904
+CCU_MUX_DIV_GATE_SPLIT_FC_DEFINE(dpu_mclk, dpumclk_parents,
1117
+                    APMU_LCD_CLK_RES_CTRL2,
905
+                 APMU_LCD_CLK_RES_CTRL2, APMU_LCD_CLK_RES_CTRL1,
1118
+                    APMU_LCD_CLK_RES_CTRL1,
906
+                 1, 4, BIT(29), 5, 3, BIT(0), 0);
1119
+                    1, 4, BIT(29),
1120
+                    5, 3, BIT(0),
1121
+                    0);
1122
+
907
+
1123
+static const struct clk_parent_data dpuesc_parents[] = {
908
+static const struct clk_parent_data dpuesc_parents[] = {
1124
+    CCU_PARENT_HW(pll1_d48_51p2_ap),
909
+    CCU_PARENT_HW(pll1_d48_51p2_ap),
1125
+    CCU_PARENT_HW(pll1_d52_47p26),
910
+    CCU_PARENT_HW(pll1_d52_47p26),
1126
+    CCU_PARENT_HW(pll1_d96_25p6),
911
+    CCU_PARENT_HW(pll1_d96_25p6),
1127
+    CCU_PARENT_HW(pll1_d32_76p8),
912
+    CCU_PARENT_HW(pll1_d32_76p8),
1128
+};
913
+};
1129
+static CCU_MUX_GATE_DEFINE(dpu_esc_clk, dpuesc_parents,
914
+CCU_MUX_GATE_DEFINE(dpu_esc_clk, dpuesc_parents, APMU_LCD_CLK_RES_CTRL1, 0, 2,
1130
+             APMU_LCD_CLK_RES_CTRL1,
915
+         BIT(2), 0);
1131
+             0, 2, BIT(2),
1132
+             0);
1133
+
916
+
1134
+static const struct clk_parent_data dpubit_parents[] = {
917
+static const struct clk_parent_data dpubit_parents[] = {
1135
+    CCU_PARENT_HW(pll1_d3_819p2),
918
+    CCU_PARENT_HW(pll1_d3_819p2),
1136
+    CCU_PARENT_HW(pll2_d2),
919
+    CCU_PARENT_HW(pll2_d2),
1137
+    CCU_PARENT_HW(pll2_d3),
920
+    CCU_PARENT_HW(pll2_d3),
1138
+    CCU_PARENT_HW(pll1_d2_1228p8),
921
+    CCU_PARENT_HW(pll1_d2_1228p8),
1139
+    CCU_PARENT_HW(pll2_d4),
922
+    CCU_PARENT_HW(pll2_d4),
1140
+    CCU_PARENT_HW(pll2_d5),
923
+    CCU_PARENT_HW(pll2_d5),
1141
+    CCU_PARENT_HW(pll2_d7),
924
+    CCU_PARENT_HW(pll2_d7),
1142
+    CCU_PARENT_HW(pll2_d8),
925
+    CCU_PARENT_HW(pll2_d8),
1143
+};
926
+};
1144
+static CCU_DIV_FC_MUX_GATE_DEFINE(dpu_bit_clk, dpubit_parents,
927
+CCU_MUX_DIV_GATE_FC_DEFINE(dpu_bit_clk, dpubit_parents, APMU_LCD_CLK_RES_CTRL1,
1145
+                 APMU_LCD_CLK_RES_CTRL1,
928
+             17, 3, BIT(31), 20, 3, BIT(16), 0);
1146
+                 17, 3, BIT(31),
1147
+                 20, 3, BIT(16),
1148
+                 0);
1149
+
929
+
1150
+static const struct clk_parent_data dpupx_parents[] = {
930
+static const struct clk_parent_data dpupx_parents[] = {
1151
+    CCU_PARENT_HW(pll1_d6_409p6),
931
+    CCU_PARENT_HW(pll1_d6_409p6),
1152
+    CCU_PARENT_HW(pll1_d5_491p52),
932
+    CCU_PARENT_HW(pll1_d5_491p52),
1153
+    CCU_PARENT_HW(pll1_d4_614p4),
933
+    CCU_PARENT_HW(pll1_d4_614p4),
1154
+    CCU_PARENT_HW(pll1_d8_307p2),
934
+    CCU_PARENT_HW(pll1_d8_307p2),
1155
+    CCU_PARENT_HW(pll2_d7),
935
+    CCU_PARENT_HW(pll2_d7),
1156
+    CCU_PARENT_HW(pll2_d8),
936
+    CCU_PARENT_HW(pll2_d8),
1157
+};
937
+};
1158
+static CCU_DIV_SPLIT_FC_MUX_GATE_DEFINE(dpu_pxclk, dpupx_parents,
938
+CCU_MUX_DIV_GATE_SPLIT_FC_DEFINE(dpu_pxclk, dpupx_parents,
1159
+                    APMU_LCD_CLK_RES_CTRL2,
939
+                 APMU_LCD_CLK_RES_CTRL2, APMU_LCD_CLK_RES_CTRL1,
1160
+                    APMU_LCD_CLK_RES_CTRL1,
940
+                 17, 4, BIT(30), 21, 3, BIT(16), 0);
1161
+                    17, 4, BIT(30),
941
+
1162
+                    21, 3, BIT(16),
942
+CCU_GATE_DEFINE(dpu_hclk, CCU_PARENT_HW(pmua_aclk), APMU_LCD_CLK_RES_CTRL1,
1163
+                    0);
943
+        BIT(5), 0);
1164
+
1165
+static CCU_GATE_DEFINE(dpu_hclk, CCU_PARENT_HW(pmua_aclk),
1166
+         APMU_LCD_CLK_RES_CTRL1,
1167
+         BIT(5),
1168
+         0);
1169
+
944
+
1170
+static const struct clk_parent_data dpu_spi_parents[] = {
945
+static const struct clk_parent_data dpu_spi_parents[] = {
1171
+    CCU_PARENT_HW(pll1_d8_307p2),
946
+    CCU_PARENT_HW(pll1_d8_307p2),
1172
+    CCU_PARENT_HW(pll1_d6_409p6),
947
+    CCU_PARENT_HW(pll1_d6_409p6),
1173
+    CCU_PARENT_HW(pll1_d10_245p76),
948
+    CCU_PARENT_HW(pll1_d10_245p76),
1174
+    CCU_PARENT_HW(pll1_d11_223p4),
949
+    CCU_PARENT_HW(pll1_d11_223p4),
1175
+    CCU_PARENT_HW(pll1_d13_189),
950
+    CCU_PARENT_HW(pll1_d13_189),
1176
+    CCU_PARENT_HW(pll1_d23_106p8),
951
+    CCU_PARENT_HW(pll1_d23_106p8),
1177
+    CCU_PARENT_HW(pll2_d3),
952
+    CCU_PARENT_HW(pll2_d3),
1178
+    CCU_PARENT_HW(pll2_d5),
953
+    CCU_PARENT_HW(pll2_d5),
1179
+};
954
+};
1180
+static CCU_DIV_FC_MUX_GATE_DEFINE(dpu_spi_clk, dpu_spi_parents,
955
+CCU_MUX_DIV_GATE_FC_DEFINE(dpu_spi_clk, dpu_spi_parents,
1181
+                 APMU_LCD_SPI_CLK_RES_CTRL,
956
+             APMU_LCD_SPI_CLK_RES_CTRL, 8, 3, BIT(7), 12, 3,
1182
+                 8, 3, BIT(7),
957
+             BIT(1), 0);
1183
+                 12, 3, BIT(1),
958
+CCU_GATE_DEFINE(dpu_spi_hbus_clk, CCU_PARENT_HW(pmua_aclk),
1184
+                 0);
959
+        APMU_LCD_SPI_CLK_RES_CTRL, BIT(3), 0);
1185
+static CCU_GATE_DEFINE(dpu_spi_hbus_clk, CCU_PARENT_HW(pmua_aclk),
960
+CCU_GATE_DEFINE(dpu_spi_bus_clk, CCU_PARENT_HW(pmua_aclk),
1186
+         APMU_LCD_SPI_CLK_RES_CTRL,
961
+        APMU_LCD_SPI_CLK_RES_CTRL, BIT(5), 0);
1187
+         BIT(3),
962
+CCU_GATE_DEFINE(dpu_spi_aclk, CCU_PARENT_HW(pmua_aclk),
1188
+         0);
963
+        APMU_LCD_SPI_CLK_RES_CTRL, BIT(6), 0);
1189
+static CCU_GATE_DEFINE(dpu_spi_bus_clk, CCU_PARENT_HW(pmua_aclk),
1190
+         APMU_LCD_SPI_CLK_RES_CTRL,
1191
+         BIT(5),
1192
+         0);
1193
+static CCU_GATE_DEFINE(dpu_spi_aclk, CCU_PARENT_HW(pmua_aclk),
1194
+         APMU_LCD_SPI_CLK_RES_CTRL,
1195
+         BIT(6),
1196
+         0);
1197
+
964
+
1198
+static const struct clk_parent_data v2d_parents[] = {
965
+static const struct clk_parent_data v2d_parents[] = {
1199
+    CCU_PARENT_HW(pll1_d5_491p52),
966
+    CCU_PARENT_HW(pll1_d5_491p52),
1200
+    CCU_PARENT_HW(pll1_d6_409p6),
967
+    CCU_PARENT_HW(pll1_d6_409p6),
1201
+    CCU_PARENT_HW(pll1_d8_307p2),
968
+    CCU_PARENT_HW(pll1_d8_307p2),
1202
+    CCU_PARENT_HW(pll1_d4_614p4),
969
+    CCU_PARENT_HW(pll1_d4_614p4),
1203
+};
970
+};
1204
+static CCU_DIV_FC_MUX_GATE_DEFINE(v2d_clk, v2d_parents,
971
+CCU_MUX_DIV_GATE_FC_DEFINE(v2d_clk, v2d_parents, APMU_LCD_CLK_RES_CTRL1, 9, 3,
1205
+                 APMU_LCD_CLK_RES_CTRL1,
972
+             BIT(28), 12, 2, BIT(8), 0);
1206
+                 9, 3, BIT(28),
1207
+                 12, 2, BIT(8),
1208
+                 0);
1209
+
973
+
1210
+static const struct clk_parent_data ccic_4x_parents[] = {
974
+static const struct clk_parent_data ccic_4x_parents[] = {
1211
+    CCU_PARENT_HW(pll1_d5_491p52),
975
+    CCU_PARENT_HW(pll1_d5_491p52),
1212
+    CCU_PARENT_HW(pll1_d6_409p6),
976
+    CCU_PARENT_HW(pll1_d6_409p6),
1213
+    CCU_PARENT_HW(pll1_d4_614p4),
977
+    CCU_PARENT_HW(pll1_d4_614p4),
1214
+    CCU_PARENT_HW(pll1_d3_819p2),
978
+    CCU_PARENT_HW(pll1_d3_819p2),
1215
+    CCU_PARENT_HW(pll2_d2),
979
+    CCU_PARENT_HW(pll2_d2),
1216
+    CCU_PARENT_HW(pll2_d3),
980
+    CCU_PARENT_HW(pll2_d3),
1217
+    CCU_PARENT_HW(pll2_d4),
981
+    CCU_PARENT_HW(pll2_d4),
1218
+    CCU_PARENT_HW(pll1_d2_1228p8),
982
+    CCU_PARENT_HW(pll1_d2_1228p8),
1219
+};
983
+};
1220
+static CCU_DIV_FC_MUX_GATE_DEFINE(ccic_4x_clk, ccic_4x_parents,
984
+CCU_MUX_DIV_GATE_FC_DEFINE(ccic_4x_clk, ccic_4x_parents, APMU_CCIC_CLK_RES_CTRL,
1221
+                 APMU_CCIC_CLK_RES_CTRL,
985
+             18, 3, BIT(15), 23, 2, BIT(4), 0);
1222
+                 18, 3, BIT(15),
1223
+                 23, 2, BIT(4),
1224
+                 0);
1225
+
986
+
1226
+static const struct clk_parent_data ccic1phy_parents[] = {
987
+static const struct clk_parent_data ccic1phy_parents[] = {
1227
+    CCU_PARENT_HW(pll1_d24_102p4),
988
+    CCU_PARENT_HW(pll1_d24_102p4),
1228
+    CCU_PARENT_HW(pll1_d48_51p2_ap),
989
+    CCU_PARENT_HW(pll1_d48_51p2_ap),
1229
+};
990
+};
1230
+static CCU_MUX_GATE_DEFINE(ccic1phy_clk, ccic1phy_parents,
991
+CCU_MUX_GATE_DEFINE(ccic1phy_clk, ccic1phy_parents, APMU_CCIC_CLK_RES_CTRL, 7,
1231
+             APMU_CCIC_CLK_RES_CTRL,
992
+         1, BIT(5), 0);
1232
+             7, 1, BIT(5),
993
+
1233
+             0);
994
+CCU_GATE_DEFINE(sdh_axi_aclk, CCU_PARENT_HW(pmua_aclk), APMU_SDH0_CLK_RES_CTRL,
1234
+
995
+        BIT(3), 0);
1235
+static CCU_GATE_DEFINE(sdh_axi_aclk, CCU_PARENT_HW(pmua_aclk),
1236
+         APMU_SDH0_CLK_RES_CTRL,
1237
+         BIT(3),
1238
+         0);
1239
+static const struct clk_parent_data sdh01_parents[] = {
996
+static const struct clk_parent_data sdh01_parents[] = {
1240
+    CCU_PARENT_HW(pll1_d6_409p6),
997
+    CCU_PARENT_HW(pll1_d6_409p6),
1241
+    CCU_PARENT_HW(pll1_d4_614p4),
998
+    CCU_PARENT_HW(pll1_d4_614p4),
1242
+    CCU_PARENT_HW(pll2_d8),
999
+    CCU_PARENT_HW(pll2_d8),
1243
+    CCU_PARENT_HW(pll2_d5),
1000
+    CCU_PARENT_HW(pll2_d5),
1244
+    CCU_PARENT_HW(pll1_d11_223p4),
1001
+    CCU_PARENT_HW(pll1_d11_223p4),
1245
+    CCU_PARENT_HW(pll1_d13_189),
1002
+    CCU_PARENT_HW(pll1_d13_189),
1246
+    CCU_PARENT_HW(pll1_d23_106p8),
1003
+    CCU_PARENT_HW(pll1_d23_106p8),
1247
+};
1004
+};
1248
+static CCU_DIV_FC_MUX_GATE_DEFINE(sdh0_clk, sdh01_parents,
1005
+CCU_MUX_DIV_GATE_FC_DEFINE(sdh0_clk, sdh01_parents, APMU_SDH0_CLK_RES_CTRL, 8,
1249
+                 APMU_SDH0_CLK_RES_CTRL,
1006
+             3, BIT(11), 5, 3, BIT(4), 0);
1250
+                 8, 3, BIT(11),
1007
+CCU_MUX_DIV_GATE_FC_DEFINE(sdh1_clk, sdh01_parents, APMU_SDH1_CLK_RES_CTRL, 8,
1251
+                 5, 3, BIT(4),
1008
+             3, BIT(11), 5, 3, BIT(4), 0);
1252
+                 0);
1253
+static CCU_DIV_FC_MUX_GATE_DEFINE(sdh1_clk, sdh01_parents,
1254
+                 APMU_SDH1_CLK_RES_CTRL,
1255
+                 8, 3, BIT(11),
1256
+                 5, 3, BIT(4),
1257
+                 0);
1258
+static const struct clk_parent_data sdh2_parents[] = {
1009
+static const struct clk_parent_data sdh2_parents[] = {
1259
+    CCU_PARENT_HW(pll1_d6_409p6),
1010
+    CCU_PARENT_HW(pll1_d6_409p6),
1260
+    CCU_PARENT_HW(pll1_d4_614p4),
1011
+    CCU_PARENT_HW(pll1_d4_614p4),
1261
+    CCU_PARENT_HW(pll2_d8),
1012
+    CCU_PARENT_HW(pll2_d8),
1262
+    CCU_PARENT_HW(pll1_d3_819p2),
1013
+    CCU_PARENT_HW(pll1_d3_819p2),
1263
+    CCU_PARENT_HW(pll1_d11_223p4),
1014
+    CCU_PARENT_HW(pll1_d11_223p4),
1264
+    CCU_PARENT_HW(pll1_d13_189),
1015
+    CCU_PARENT_HW(pll1_d13_189),
1265
+    CCU_PARENT_HW(pll1_d23_106p8),
1016
+    CCU_PARENT_HW(pll1_d23_106p8),
1266
+};
1017
+};
1267
+static CCU_DIV_FC_MUX_GATE_DEFINE(sdh2_clk, sdh2_parents,
1018
+CCU_MUX_DIV_GATE_FC_DEFINE(sdh2_clk, sdh2_parents, APMU_SDH2_CLK_RES_CTRL, 8, 3,
1268
+                 APMU_SDH2_CLK_RES_CTRL,
1019
+             BIT(11), 5, 3, BIT(4), 0);
1269
+                 8, 3, BIT(11),
1020
+
1270
+                 5, 3, BIT(4),
1021
+CCU_GATE_DEFINE(usb_axi_clk, CCU_PARENT_HW(pmua_aclk), APMU_USB_CLK_RES_CTRL,
1271
+                 0);
1022
+        BIT(1), 0);
1272
+
1023
+CCU_GATE_DEFINE(usb_p1_aclk, CCU_PARENT_HW(pmua_aclk), APMU_USB_CLK_RES_CTRL,
1273
+static CCU_GATE_DEFINE(usb_axi_clk, CCU_PARENT_HW(pmua_aclk),
1024
+        BIT(5), 0);
1274
+         APMU_USB_CLK_RES_CTRL,
1025
+CCU_GATE_DEFINE(usb30_clk, CCU_PARENT_HW(pmua_aclk), APMU_USB_CLK_RES_CTRL,
1275
+         BIT(1),
1026
+        BIT(8), 0);
1276
+         0);
1277
+static CCU_GATE_DEFINE(usb_p1_aclk, CCU_PARENT_HW(pmua_aclk),
1278
+         APMU_USB_CLK_RES_CTRL,
1279
+         BIT(5),
1280
+         0);
1281
+static CCU_GATE_DEFINE(usb30_clk, CCU_PARENT_HW(pmua_aclk),
1282
+         APMU_USB_CLK_RES_CTRL,
1283
+         BIT(8),
1284
+         0);
1285
+
1027
+
1286
+static const struct clk_parent_data qspi_parents[] = {
1028
+static const struct clk_parent_data qspi_parents[] = {
1287
+    CCU_PARENT_HW(pll1_d6_409p6),
1029
+    CCU_PARENT_HW(pll1_d6_409p6),
1288
+    CCU_PARENT_HW(pll2_d8),
1030
+    CCU_PARENT_HW(pll2_d8),
1289
+    CCU_PARENT_HW(pll1_d8_307p2),
1031
+    CCU_PARENT_HW(pll1_d8_307p2),
1290
+    CCU_PARENT_HW(pll1_d10_245p76),
1032
+    CCU_PARENT_HW(pll1_d10_245p76),
1291
+    CCU_PARENT_HW(pll1_d11_223p4),
1033
+    CCU_PARENT_HW(pll1_d11_223p4),
1292
+    CCU_PARENT_HW(pll1_d23_106p8),
1034
+    CCU_PARENT_HW(pll1_d23_106p8),
1293
+    CCU_PARENT_HW(pll1_d5_491p52),
1035
+    CCU_PARENT_HW(pll1_d5_491p52),
1294
+    CCU_PARENT_HW(pll1_d13_189),
1036
+    CCU_PARENT_HW(pll1_d13_189),
1295
+};
1037
+};
1296
+static CCU_DIV_FC_MUX_GATE_DEFINE(qspi_clk, qspi_parents,
1038
+CCU_MUX_DIV_GATE_FC_DEFINE(qspi_clk, qspi_parents, APMU_QSPI_CLK_RES_CTRL, 9, 3,
1297
+                 APMU_QSPI_CLK_RES_CTRL,
1039
+             BIT(12), 6, 3, BIT(4), 0);
1298
+                 9, 3, BIT(12),
1040
+CCU_GATE_DEFINE(qspi_bus_clk, CCU_PARENT_HW(pmua_aclk), APMU_QSPI_CLK_RES_CTRL,
1299
+                 6, 3, BIT(4),
1041
+        BIT(3), 0);
1300
+                 0);
1042
+CCU_GATE_DEFINE(dma_clk, CCU_PARENT_HW(pmua_aclk), APMU_DMA_CLK_RES_CTRL,
1301
+static CCU_GATE_DEFINE(qspi_bus_clk, CCU_PARENT_HW(pmua_aclk),
1043
+        BIT(3), 0);
1302
+         APMU_QSPI_CLK_RES_CTRL,
1303
+         BIT(3),
1304
+         0);
1305
+static CCU_GATE_DEFINE(dma_clk, CCU_PARENT_HW(pmua_aclk),
1306
+         APMU_DMA_CLK_RES_CTRL,
1307
+         BIT(3),
1308
+         0);
1309
+
1044
+
1310
+static const struct clk_parent_data aes_parents[] = {
1045
+static const struct clk_parent_data aes_parents[] = {
1311
+    CCU_PARENT_HW(pll1_d12_204p8),
1046
+    CCU_PARENT_HW(pll1_d12_204p8),
1312
+    CCU_PARENT_HW(pll1_d24_102p4),
1047
+    CCU_PARENT_HW(pll1_d24_102p4),
1313
+};
1048
+};
1314
+static CCU_MUX_GATE_DEFINE(aes_clk, aes_parents,
1049
+CCU_MUX_GATE_DEFINE(aes_clk, aes_parents, APMU_AES_CLK_RES_CTRL, 6, 1, BIT(5),
1315
+             APMU_AES_CLK_RES_CTRL,
1050
+         0);
1316
+             6, 1, BIT(5),
1317
+             0);
1318
+
1051
+
1319
+static const struct clk_parent_data vpu_parents[] = {
1052
+static const struct clk_parent_data vpu_parents[] = {
1320
+    CCU_PARENT_HW(pll1_d4_614p4),
1053
+    CCU_PARENT_HW(pll1_d4_614p4),
1321
+    CCU_PARENT_HW(pll1_d5_491p52),
1054
+    CCU_PARENT_HW(pll1_d5_491p52),
1322
+    CCU_PARENT_HW(pll1_d3_819p2),
1055
+    CCU_PARENT_HW(pll1_d3_819p2),
1323
+    CCU_PARENT_HW(pll1_d6_409p6),
1056
+    CCU_PARENT_HW(pll1_d6_409p6),
1324
+    CCU_PARENT_HW(pll3_d6),
1057
+    CCU_PARENT_HW(pll3_d6),
1325
+    CCU_PARENT_HW(pll2_d3),
1058
+    CCU_PARENT_HW(pll2_d3),
1326
+    CCU_PARENT_HW(pll2_d4),
1059
+    CCU_PARENT_HW(pll2_d4),
1327
+    CCU_PARENT_HW(pll2_d5),
1060
+    CCU_PARENT_HW(pll2_d5),
1328
+};
1061
+};
1329
+static CCU_DIV_FC_MUX_GATE_DEFINE(vpu_clk, vpu_parents,
1062
+CCU_MUX_DIV_GATE_FC_DEFINE(vpu_clk, vpu_parents, APMU_VPU_CLK_RES_CTRL, 13, 3,
1330
+                 APMU_VPU_CLK_RES_CTRL,
1063
+             BIT(21), 10, 3, BIT(3), 0);
1331
+                 13, 3, BIT(21),
1332
+                 10, 3,
1333
+                 BIT(3),
1334
+                 0);
1335
+
1064
+
1336
+static const struct clk_parent_data gpu_parents[] = {
1065
+static const struct clk_parent_data gpu_parents[] = {
1337
+    CCU_PARENT_HW(pll1_d4_614p4),
1066
+    CCU_PARENT_HW(pll1_d4_614p4),
1338
+    CCU_PARENT_HW(pll1_d5_491p52),
1067
+    CCU_PARENT_HW(pll1_d5_491p52),
1339
+    CCU_PARENT_HW(pll1_d3_819p2),
1068
+    CCU_PARENT_HW(pll1_d3_819p2),
1340
+    CCU_PARENT_HW(pll1_d6_409p6),
1069
+    CCU_PARENT_HW(pll1_d6_409p6),
1341
+    CCU_PARENT_HW(pll3_d6),
1070
+    CCU_PARENT_HW(pll3_d6),
1342
+    CCU_PARENT_HW(pll2_d3),
1071
+    CCU_PARENT_HW(pll2_d3),
1343
+    CCU_PARENT_HW(pll2_d4),
1072
+    CCU_PARENT_HW(pll2_d4),
1344
+    CCU_PARENT_HW(pll2_d5),
1073
+    CCU_PARENT_HW(pll2_d5),
1345
+};
1074
+};
1346
+static CCU_DIV_FC_MUX_GATE_DEFINE(gpu_clk, gpu_parents,
1075
+CCU_MUX_DIV_GATE_FC_DEFINE(gpu_clk, gpu_parents, APMU_GPU_CLK_RES_CTRL, 12, 3,
1347
+                 APMU_GPU_CLK_RES_CTRL,
1076
+             BIT(15), 18, 3, BIT(4), 0);
1348
+                 12, 3, BIT(15),
1349
+                 18, 3,
1350
+                 BIT(4),
1351
+                 0);
1352
+
1077
+
1353
+static const struct clk_parent_data emmc_parents[] = {
1078
+static const struct clk_parent_data emmc_parents[] = {
1354
+    CCU_PARENT_HW(pll1_d6_409p6),
1079
+    CCU_PARENT_HW(pll1_d6_409p6),
1355
+    CCU_PARENT_HW(pll1_d4_614p4),
1080
+    CCU_PARENT_HW(pll1_d4_614p4),
1356
+    CCU_PARENT_HW(pll1_d52_47p26),
1081
+    CCU_PARENT_HW(pll1_d52_47p26),
1357
+    CCU_PARENT_HW(pll1_d3_819p2),
1082
+    CCU_PARENT_HW(pll1_d3_819p2),
1358
+};
1083
+};
1359
+static CCU_DIV_FC_MUX_GATE_DEFINE(emmc_clk, emmc_parents,
1084
+CCU_MUX_DIV_GATE_FC_DEFINE(emmc_clk, emmc_parents, APMU_PMUA_EM_CLK_RES_CTRL,
1360
+                 APMU_PMUA_EM_CLK_RES_CTRL,
1085
+             8, 3, BIT(11), 6, 2, BIT(4), 0);
1361
+                 8, 3, BIT(11),
1086
+CCU_DIV_GATE_DEFINE(emmc_x_clk, CCU_PARENT_HW(pll1_d2_1228p8),
1362
+                 6, 2,
1087
+         APMU_PMUA_EM_CLK_RES_CTRL, 12, 3, BIT(15), 0);
1363
+                 BIT(4),
1364
+                 0);
1365
+static CCU_DIV_GATE_DEFINE(emmc_x_clk, CCU_PARENT_HW(pll1_d2_1228p8),
1366
+             APMU_PMUA_EM_CLK_RES_CTRL,
1367
+             12, 3, BIT(15),
1368
+             0);
1369
+
1088
+
1370
+static const struct clk_parent_data audio_parents[] = {
1089
+static const struct clk_parent_data audio_parents[] = {
1371
+    CCU_PARENT_HW(pll1_aud_245p7),
1090
+    CCU_PARENT_HW(pll1_aud_245p7),
1372
+    CCU_PARENT_HW(pll1_d8_307p2),
1091
+    CCU_PARENT_HW(pll1_d8_307p2),
1373
+    CCU_PARENT_HW(pll1_d6_409p6),
1092
+    CCU_PARENT_HW(pll1_d6_409p6),
1374
+};
1093
+};
1375
+static CCU_DIV_FC_MUX_GATE_DEFINE(audio_clk, audio_parents,
1094
+CCU_MUX_DIV_GATE_FC_DEFINE(audio_clk, audio_parents, APMU_AUDIO_CLK_RES_CTRL, 4,
1376
+                 APMU_AUDIO_CLK_RES_CTRL,
1095
+             3, BIT(15), 7, 3, BIT(12), 0);
1377
+                 4, 3, BIT(15),
1378
+                 7, 3,
1379
+                 BIT(12),
1380
+                 0);
1381
+
1096
+
1382
+static const struct clk_parent_data hdmi_parents[] = {
1097
+static const struct clk_parent_data hdmi_parents[] = {
1383
+    CCU_PARENT_HW(pll1_d6_409p6),
1098
+    CCU_PARENT_HW(pll1_d6_409p6),
1384
+    CCU_PARENT_HW(pll1_d5_491p52),
1099
+    CCU_PARENT_HW(pll1_d5_491p52),
1385
+    CCU_PARENT_HW(pll1_d4_614p4),
1100
+    CCU_PARENT_HW(pll1_d4_614p4),
1386
+    CCU_PARENT_HW(pll1_d8_307p2),
1101
+    CCU_PARENT_HW(pll1_d8_307p2),
1387
+};
1102
+};
1388
+static CCU_DIV_FC_MUX_GATE_DEFINE(hdmi_mclk, hdmi_parents,
1103
+CCU_MUX_DIV_GATE_FC_DEFINE(hdmi_mclk, hdmi_parents, APMU_HDMI_CLK_RES_CTRL, 1,
1389
+                 APMU_HDMI_CLK_RES_CTRL,
1104
+             4, BIT(29), 5, 3, BIT(0), 0);
1390
+                 1, 4, BIT(29),
1105
+
1391
+                 5, 3,
1106
+CCU_GATE_DEFINE(pcie0_master_clk, CCU_PARENT_HW(pmua_aclk),
1392
+                 BIT(0),
1107
+        APMU_PCIE_CLK_RES_CTRL_0, BIT(2), 0);
1393
+                 0);
1108
+CCU_GATE_DEFINE(pcie0_slave_clk, CCU_PARENT_HW(pmua_aclk),
1394
+
1109
+        APMU_PCIE_CLK_RES_CTRL_0, BIT(1), 0);
1395
+static CCU_GATE_DEFINE(pcie0_master_clk, CCU_PARENT_HW(pmua_aclk),
1110
+CCU_GATE_DEFINE(pcie0_dbi_clk, CCU_PARENT_HW(pmua_aclk),
1396
+         APMU_PCIE_CLK_RES_CTRL_0,
1111
+        APMU_PCIE_CLK_RES_CTRL_0, BIT(0), 0);
1397
+         BIT(2),
1112
+
1398
+         0);
1113
+CCU_GATE_DEFINE(pcie1_master_clk, CCU_PARENT_HW(pmua_aclk),
1399
+static CCU_GATE_DEFINE(pcie0_slave_clk, CCU_PARENT_HW(pmua_aclk),
1114
+        APMU_PCIE_CLK_RES_CTRL_1, BIT(2), 0);
1400
+         APMU_PCIE_CLK_RES_CTRL_0,
1115
+CCU_GATE_DEFINE(pcie1_slave_clk, CCU_PARENT_HW(pmua_aclk),
1401
+         BIT(1),
1116
+        APMU_PCIE_CLK_RES_CTRL_1, BIT(1), 0);
1402
+         0);
1117
+CCU_GATE_DEFINE(pcie1_dbi_clk, CCU_PARENT_HW(pmua_aclk),
1403
+static CCU_GATE_DEFINE(pcie0_dbi_clk, CCU_PARENT_HW(pmua_aclk),
1118
+        APMU_PCIE_CLK_RES_CTRL_1, BIT(0), 0);
1404
+         APMU_PCIE_CLK_RES_CTRL_0,
1119
+
1405
+         BIT(0),
1120
+CCU_GATE_DEFINE(pcie2_master_clk, CCU_PARENT_HW(pmua_aclk),
1406
+         0);
1121
+        APMU_PCIE_CLK_RES_CTRL_2, BIT(2), 0);
1407
+
1122
+CCU_GATE_DEFINE(pcie2_slave_clk, CCU_PARENT_HW(pmua_aclk),
1408
+static CCU_GATE_DEFINE(pcie1_master_clk, CCU_PARENT_HW(pmua_aclk),
1123
+        APMU_PCIE_CLK_RES_CTRL_2, BIT(1), 0);
1409
+         APMU_PCIE_CLK_RES_CTRL_1,
1124
+CCU_GATE_DEFINE(pcie2_dbi_clk, CCU_PARENT_HW(pmua_aclk),
1410
+         BIT(2),
1125
+        APMU_PCIE_CLK_RES_CTRL_2, BIT(0), 0);
1411
+         0);
1126
+
1412
+static CCU_GATE_DEFINE(pcie1_slave_clk, CCU_PARENT_HW(pmua_aclk),
1127
+CCU_GATE_DEFINE(emac0_bus_clk, CCU_PARENT_HW(pmua_aclk),
1413
+         APMU_PCIE_CLK_RES_CTRL_1,
1128
+        APMU_EMAC0_CLK_RES_CTRL, BIT(0), 0);
1414
+         BIT(1),
1129
+CCU_GATE_DEFINE(emac0_ptp_clk, CCU_PARENT_HW(pll2_d6),
1415
+         0);
1130
+        APMU_EMAC0_CLK_RES_CTRL, BIT(15), 0);
1416
+static CCU_GATE_DEFINE(pcie1_dbi_clk, CCU_PARENT_HW(pmua_aclk),
1131
+CCU_GATE_DEFINE(emac1_bus_clk, CCU_PARENT_HW(pmua_aclk),
1417
+         APMU_PCIE_CLK_RES_CTRL_1,
1132
+        APMU_EMAC1_CLK_RES_CTRL, BIT(0), 0);
1418
+         BIT(0),
1133
+CCU_GATE_DEFINE(emac1_ptp_clk, CCU_PARENT_HW(pll2_d6), APMU_EMAC1_CLK_RES_CTRL,
1419
+         0);
1134
+        BIT(15), 0);
1420
+
1135
+
1421
+static CCU_GATE_DEFINE(pcie2_master_clk, CCU_PARENT_HW(pmua_aclk),
1136
+CCU_GATE_DEFINE(emmc_bus_clk, CCU_PARENT_HW(pmua_aclk),
1422
+         APMU_PCIE_CLK_RES_CTRL_2,
1137
+        APMU_PMUA_EM_CLK_RES_CTRL, BIT(3), 0);
1423
+         BIT(2),
1138
+/* APMU clocks end */
1424
+         0);
1139
+
1425
+static CCU_GATE_DEFINE(pcie2_slave_clk, CCU_PARENT_HW(pmua_aclk),
1140
+struct spacemit_ccu_data {
1426
+         APMU_PCIE_CLK_RES_CTRL_2,
1141
+    struct clk_hw **hws;
1427
+         BIT(1),
1142
+    size_t num;
1428
+         0);
1143
+};
1429
+static CCU_GATE_DEFINE(pcie2_dbi_clk, CCU_PARENT_HW(pmua_aclk),
1144
+
1430
+         APMU_PCIE_CLK_RES_CTRL_2,
1145
+static struct clk_hw *k1_ccu_pll_hws[] = {
1431
+         BIT(0),
1146
+    [CLK_PLL1]        = &pll1.common.hw,
1432
+         0);
1147
+    [CLK_PLL2]        = &pll2.common.hw,
1433
+
1148
+    [CLK_PLL3]        = &pll3.common.hw,
1434
+static CCU_GATE_DEFINE(emac0_bus_clk, CCU_PARENT_HW(pmua_aclk),
1149
+    [CLK_PLL1_D2]        = &pll1_d2.common.hw,
1435
+         APMU_EMAC0_CLK_RES_CTRL,
1150
+    [CLK_PLL1_D3]        = &pll1_d3.common.hw,
1436
+         BIT(0),
1151
+    [CLK_PLL1_D4]        = &pll1_d4.common.hw,
1437
+         0);
1152
+    [CLK_PLL1_D5]        = &pll1_d5.common.hw,
1438
+static CCU_GATE_DEFINE(emac0_ptp_clk, CCU_PARENT_HW(pll2_d6),
1153
+    [CLK_PLL1_D6]        = &pll1_d6.common.hw,
1439
+         APMU_EMAC0_CLK_RES_CTRL,
1154
+    [CLK_PLL1_D7]        = &pll1_d7.common.hw,
1440
+         BIT(15),
1155
+    [CLK_PLL1_D8]        = &pll1_d8.common.hw,
1441
+         0);
1156
+    [CLK_PLL1_D11]        = &pll1_d11_223p4.common.hw,
1442
+static CCU_GATE_DEFINE(emac1_bus_clk, CCU_PARENT_HW(pmua_aclk),
1157
+    [CLK_PLL1_D13]        = &pll1_d13_189.common.hw,
1443
+         APMU_EMAC1_CLK_RES_CTRL,
1158
+    [CLK_PLL1_D23]        = &pll1_d23_106p8.common.hw,
1444
+         BIT(0),
1159
+    [CLK_PLL1_D64]        = &pll1_d64_38p4.common.hw,
1445
+         0);
1160
+    [CLK_PLL1_D10_AUD]    = &pll1_aud_245p7.common.hw,
1446
+static CCU_GATE_DEFINE(emac1_ptp_clk, CCU_PARENT_HW(pll2_d6),
1161
+    [CLK_PLL1_D100_AUD]    = &pll1_aud_24p5.common.hw,
1447
+         APMU_EMAC1_CLK_RES_CTRL,
1162
+    [CLK_PLL2_D1]        = &pll2_d1.common.hw,
1448
+         BIT(15),
1163
+    [CLK_PLL2_D2]        = &pll2_d2.common.hw,
1449
+         0);
1164
+    [CLK_PLL2_D3]        = &pll2_d3.common.hw,
1450
+
1165
+    [CLK_PLL2_D4]        = &pll2_d4.common.hw,
1451
+static CCU_GATE_DEFINE(emmc_bus_clk, CCU_PARENT_HW(pmua_aclk),
1166
+    [CLK_PLL2_D5]        = &pll2_d5.common.hw,
1452
+         APMU_PMUA_EM_CLK_RES_CTRL,
1167
+    [CLK_PLL2_D6]        = &pll2_d6.common.hw,
1453
+         BIT(3),
1168
+    [CLK_PLL2_D7]        = &pll2_d7.common.hw,
1454
+         0);
1169
+    [CLK_PLL2_D8]        = &pll2_d8.common.hw,
1455
+/*    APMU clocks end        */
1170
+    [CLK_PLL3_D1]        = &pll3_d1.common.hw,
1456
+
1171
+    [CLK_PLL3_D2]        = &pll3_d2.common.hw,
1457
+struct spacemit_ccu_clk {
1172
+    [CLK_PLL3_D3]        = &pll3_d3.common.hw,
1458
+    int id;
1173
+    [CLK_PLL3_D4]        = &pll3_d4.common.hw,
1459
+    struct clk_hw *hw;
1174
+    [CLK_PLL3_D5]        = &pll3_d5.common.hw,
1460
+};
1175
+    [CLK_PLL3_D6]        = &pll3_d6.common.hw,
1461
+
1176
+    [CLK_PLL3_D7]        = &pll3_d7.common.hw,
1462
+static struct spacemit_ccu_clk k1_ccu_apbs_clks[] = {
1177
+    [CLK_PLL3_D8]        = &pll3_d8.common.hw,
1463
+    { CLK_PLL1,        &pll1.common.hw },
1178
+    [CLK_PLL3_80]        = &pll3_80.common.hw,
1464
+    { CLK_PLL2,        &pll2.common.hw },
1179
+    [CLK_PLL3_40]        = &pll3_40.common.hw,
1465
+    { CLK_PLL3,        &pll3.common.hw },
1180
+    [CLK_PLL3_20]        = &pll3_20.common.hw,
1466
+    { CLK_PLL1_D2,        &pll1_d2.common.hw },
1181
+};
1467
+    { CLK_PLL1_D3,        &pll1_d3.common.hw },
1182
+
1468
+    { CLK_PLL1_D4,        &pll1_d4.common.hw },
1183
+static const struct spacemit_ccu_data k1_ccu_pll_data = {
1469
+    { CLK_PLL1_D5,        &pll1_d5.common.hw },
1184
+    .hws    = k1_ccu_pll_hws,
1470
+    { CLK_PLL1_D6,        &pll1_d6.common.hw },
1185
+    .num    = ARRAY_SIZE(k1_ccu_pll_hws),
1471
+    { CLK_PLL1_D7,        &pll1_d7.common.hw },
1186
+};
1472
+    { CLK_PLL1_D8,        &pll1_d8.common.hw },
1187
+
1473
+    { CLK_PLL1_D11,        &pll1_d11_223p4.common.hw },
1188
+static struct clk_hw *k1_ccu_mpmu_hws[] = {
1474
+    { CLK_PLL1_D13,        &pll1_d13_189.common.hw },
1189
+    [CLK_PLL1_307P2]    = &pll1_d8_307p2.common.hw,
1475
+    { CLK_PLL1_D23,        &pll1_d23_106p8.common.hw },
1190
+    [CLK_PLL1_76P8]        = &pll1_d32_76p8.common.hw,
1476
+    { CLK_PLL1_D64,        &pll1_d64_38p4.common.hw },
1191
+    [CLK_PLL1_61P44]    = &pll1_d40_61p44.common.hw,
1477
+    { CLK_PLL1_D10_AUD,    &pll1_aud_245p7.common.hw },
1192
+    [CLK_PLL1_153P6]    = &pll1_d16_153p6.common.hw,
1478
+    { CLK_PLL1_D100_AUD,    &pll1_aud_24p5.common.hw },
1193
+    [CLK_PLL1_102P4]    = &pll1_d24_102p4.common.hw,
1479
+    { CLK_PLL2_D1,        &pll2_d1.common.hw },
1194
+    [CLK_PLL1_51P2]        = &pll1_d48_51p2.common.hw,
1480
+    { CLK_PLL2_D2,        &pll2_d2.common.hw },
1195
+    [CLK_PLL1_51P2_AP]    = &pll1_d48_51p2_ap.common.hw,
1481
+    { CLK_PLL2_D3,        &pll2_d3.common.hw },
1196
+    [CLK_PLL1_57P6]        = &pll1_m3d128_57p6.common.hw,
1482
+    { CLK_PLL2_D4,        &pll2_d4.common.hw },
1197
+    [CLK_PLL1_25P6]        = &pll1_d96_25p6.common.hw,
1483
+    { CLK_PLL2_D5,        &pll2_d5.common.hw },
1198
+    [CLK_PLL1_12P8]        = &pll1_d192_12p8.common.hw,
1484
+    { CLK_PLL2_D6,        &pll2_d6.common.hw },
1199
+    [CLK_PLL1_12P8_WDT]    = &pll1_d192_12p8_wdt.common.hw,
1485
+    { CLK_PLL2_D7,        &pll2_d7.common.hw },
1200
+    [CLK_PLL1_6P4]        = &pll1_d384_6p4.common.hw,
1486
+    { CLK_PLL2_D8,        &pll2_d8.common.hw },
1201
+    [CLK_PLL1_3P2]        = &pll1_d768_3p2.common.hw,
1487
+    { CLK_PLL3_D1,        &pll3_d1.common.hw },
1202
+    [CLK_PLL1_1P6]        = &pll1_d1536_1p6.common.hw,
1488
+    { CLK_PLL3_D2,        &pll3_d2.common.hw },
1203
+    [CLK_PLL1_0P8]        = &pll1_d3072_0p8.common.hw,
1489
+    { CLK_PLL3_D3,        &pll3_d3.common.hw },
1204
+    [CLK_PLL1_409P6]    = &pll1_d6_409p6.common.hw,
1490
+    { CLK_PLL3_D4,        &pll3_d4.common.hw },
1205
+    [CLK_PLL1_204P8]    = &pll1_d12_204p8.common.hw,
1491
+    { CLK_PLL3_D5,        &pll3_d5.common.hw },
1206
+    [CLK_PLL1_491]        = &pll1_d5_491p52.common.hw,
1492
+    { CLK_PLL3_D6,        &pll3_d6.common.hw },
1207
+    [CLK_PLL1_245P76]    = &pll1_d10_245p76.common.hw,
1493
+    { CLK_PLL3_D7,        &pll3_d7.common.hw },
1208
+    [CLK_PLL1_614]        = &pll1_d4_614p4.common.hw,
1494
+    { CLK_PLL3_D8,        &pll3_d8.common.hw },
1209
+    [CLK_PLL1_47P26]    = &pll1_d52_47p26.common.hw,
1495
+    { CLK_PLL3_80,        &pll3_80.common.hw },
1210
+    [CLK_PLL1_31P5]        = &pll1_d78_31p5.common.hw,
1496
+    { CLK_PLL3_40,        &pll3_40.common.hw },
1211
+    [CLK_PLL1_819]        = &pll1_d3_819p2.common.hw,
1497
+    { CLK_PLL3_20,        &pll3_20.common.hw },
1212
+    [CLK_PLL1_1228]        = &pll1_d2_1228p8.common.hw,
1498
+    { 0,            NULL },
1213
+    [CLK_SLOW_UART]        = &slow_uart.common.hw,
1499
+};
1214
+    [CLK_SLOW_UART1]    = &slow_uart1_14p74.common.hw,
1500
+
1215
+    [CLK_SLOW_UART2]    = &slow_uart2_48.common.hw,
1501
+static struct spacemit_ccu_clk k1_ccu_mpmu_clks[] = {
1216
+    [CLK_WDT]        = &wdt_clk.common.hw,
1502
+    { CLK_PLL1_307P2,    &pll1_d8_307p2.common.hw },
1217
+    [CLK_RIPC]        = &ripc_clk.common.hw,
1503
+    { CLK_PLL1_76P8,    &pll1_d32_76p8.common.hw },
1218
+    [CLK_I2S_SYSCLK]    = &i2s_sysclk.common.hw,
1504
+    { CLK_PLL1_61P44,    &pll1_d40_61p44.common.hw },
1219
+    [CLK_I2S_BCLK]        = &i2s_bclk.common.hw,
1505
+    { CLK_PLL1_153P6,    &pll1_d16_153p6.common.hw },
1220
+    [CLK_APB]        = &apb_clk.common.hw,
1506
+    { CLK_PLL1_102P4,    &pll1_d24_102p4.common.hw },
1221
+    [CLK_WDT_BUS]        = &wdt_bus_clk.common.hw,
1507
+    { CLK_PLL1_51P2,    &pll1_d48_51p2.common.hw },
1222
+};
1508
+    { CLK_PLL1_51P2_AP,    &pll1_d48_51p2_ap.common.hw },
1223
+
1509
+    { CLK_PLL1_57P6,    &pll1_m3d128_57p6.common.hw },
1224
+static const struct spacemit_ccu_data k1_ccu_mpmu_data = {
1510
+    { CLK_PLL1_25P6,    &pll1_d96_25p6.common.hw },
1225
+    .hws    = k1_ccu_mpmu_hws,
1511
+    { CLK_PLL1_12P8,    &pll1_d192_12p8.common.hw },
1226
+    .num    = ARRAY_SIZE(k1_ccu_mpmu_hws),
1512
+    { CLK_PLL1_12P8_WDT,    &pll1_d192_12p8_wdt.common.hw },
1227
+};
1513
+    { CLK_PLL1_6P4,        &pll1_d384_6p4.common.hw },
1228
+
1514
+    { CLK_PLL1_3P2,        &pll1_d768_3p2.common.hw },
1229
+static struct clk_hw *k1_ccu_apbc_hws[] = {
1515
+    { CLK_PLL1_1P6,        &pll1_d1536_1p6.common.hw },
1230
+    [CLK_UART0]        = &uart0_clk.common.hw,
1516
+    { CLK_PLL1_0P8,        &pll1_d3072_0p8.common.hw },
1231
+    [CLK_UART2]        = &uart2_clk.common.hw,
1517
+    { CLK_PLL1_409P6,    &pll1_d6_409p6.common.hw },
1232
+    [CLK_UART3]        = &uart3_clk.common.hw,
1518
+    { CLK_PLL1_204P8,    &pll1_d12_204p8.common.hw },
1233
+    [CLK_UART4]        = &uart4_clk.common.hw,
1519
+    { CLK_PLL1_491,        &pll1_d5_491p52.common.hw },
1234
+    [CLK_UART5]        = &uart5_clk.common.hw,
1520
+    { CLK_PLL1_245P76,    &pll1_d10_245p76.common.hw },
1235
+    [CLK_UART6]        = &uart6_clk.common.hw,
1521
+    { CLK_PLL1_614,        &pll1_d4_614p4.common.hw },
1236
+    [CLK_UART7]        = &uart7_clk.common.hw,
1522
+    { CLK_PLL1_47P26,    &pll1_d52_47p26.common.hw },
1237
+    [CLK_UART8]        = &uart8_clk.common.hw,
1523
+    { CLK_PLL1_31P5,    &pll1_d78_31p5.common.hw },
1238
+    [CLK_UART9]        = &uart9_clk.common.hw,
1524
+    { CLK_PLL1_819,        &pll1_d3_819p2.common.hw },
1239
+    [CLK_GPIO]        = &gpio_clk.common.hw,
1525
+    { CLK_PLL1_1228,    &pll1_d2_1228p8.common.hw },
1240
+    [CLK_PWM0]        = &pwm0_clk.common.hw,
1526
+    { CLK_SLOW_UART,    &slow_uart.common.hw },
1241
+    [CLK_PWM1]        = &pwm1_clk.common.hw,
1527
+    { CLK_SLOW_UART1,    &slow_uart1_14p74.common.hw },
1242
+    [CLK_PWM2]        = &pwm2_clk.common.hw,
1528
+    { CLK_SLOW_UART2,    &slow_uart2_48.common.hw },
1243
+    [CLK_PWM3]        = &pwm3_clk.common.hw,
1529
+    { CLK_WDT,        &wdt_clk.common.hw },
1244
+    [CLK_PWM4]        = &pwm4_clk.common.hw,
1530
+    { CLK_RIPC,        &ripc_clk.common.hw },
1245
+    [CLK_PWM5]        = &pwm5_clk.common.hw,
1531
+    { CLK_I2S_SYSCLK,    &i2s_sysclk.common.hw },
1246
+    [CLK_PWM6]        = &pwm6_clk.common.hw,
1532
+    { CLK_I2S_BCLK,        &i2s_bclk.common.hw },
1247
+    [CLK_PWM7]        = &pwm7_clk.common.hw,
1533
+    { CLK_APB,        &apb_clk.common.hw },
1248
+    [CLK_PWM8]        = &pwm8_clk.common.hw,
1534
+    { CLK_WDT_BUS,        &wdt_bus_clk.common.hw },
1249
+    [CLK_PWM9]        = &pwm9_clk.common.hw,
1535
+    { 0,            NULL },
1250
+    [CLK_PWM10]        = &pwm10_clk.common.hw,
1536
+};
1251
+    [CLK_PWM11]        = &pwm11_clk.common.hw,
1537
+
1252
+    [CLK_PWM12]        = &pwm12_clk.common.hw,
1538
+static struct spacemit_ccu_clk k1_ccu_apbc_clks[] = {
1253
+    [CLK_PWM13]        = &pwm13_clk.common.hw,
1539
+    { CLK_UART0,        &uart0_clk.common.hw },
1254
+    [CLK_PWM14]        = &pwm14_clk.common.hw,
1540
+    { CLK_UART2,        &uart2_clk.common.hw },
1255
+    [CLK_PWM15]        = &pwm15_clk.common.hw,
1541
+    { CLK_UART3,        &uart3_clk.common.hw },
1256
+    [CLK_PWM16]        = &pwm16_clk.common.hw,
1542
+    { CLK_UART4,        &uart4_clk.common.hw },
1257
+    [CLK_PWM17]        = &pwm17_clk.common.hw,
1543
+    { CLK_UART5,        &uart5_clk.common.hw },
1258
+    [CLK_PWM18]        = &pwm18_clk.common.hw,
1544
+    { CLK_UART6,        &uart6_clk.common.hw },
1259
+    [CLK_PWM19]        = &pwm19_clk.common.hw,
1545
+    { CLK_UART7,        &uart7_clk.common.hw },
1260
+    [CLK_SSP3]        = &ssp3_clk.common.hw,
1546
+    { CLK_UART8,        &uart8_clk.common.hw },
1261
+    [CLK_RTC]        = &rtc_clk.common.hw,
1547
+    { CLK_UART9,        &uart9_clk.common.hw },
1262
+    [CLK_TWSI0]        = &twsi0_clk.common.hw,
1548
+    { CLK_GPIO,        &gpio_clk.common.hw },
1263
+    [CLK_TWSI1]        = &twsi1_clk.common.hw,
1549
+    { CLK_PWM0,        &pwm0_clk.common.hw },
1264
+    [CLK_TWSI2]        = &twsi2_clk.common.hw,
1550
+    { CLK_PWM1,        &pwm1_clk.common.hw },
1265
+    [CLK_TWSI4]        = &twsi4_clk.common.hw,
1551
+    { CLK_PWM2,        &pwm2_clk.common.hw },
1266
+    [CLK_TWSI5]        = &twsi5_clk.common.hw,
1552
+    { CLK_PWM3,        &pwm3_clk.common.hw },
1267
+    [CLK_TWSI6]        = &twsi6_clk.common.hw,
1553
+    { CLK_PWM4,        &pwm4_clk.common.hw },
1268
+    [CLK_TWSI7]        = &twsi7_clk.common.hw,
1554
+    { CLK_PWM5,        &pwm5_clk.common.hw },
1269
+    [CLK_TIMERS1]        = &timers1_clk.common.hw,
1555
+    { CLK_PWM6,        &pwm6_clk.common.hw },
1270
+    [CLK_TIMERS2]        = &timers2_clk.common.hw,
1556
+    { CLK_PWM7,        &pwm7_clk.common.hw },
1271
+    [CLK_AIB]        = &aib_clk.common.hw,
1557
+    { CLK_PWM8,        &pwm8_clk.common.hw },
1272
+    [CLK_ONEWIRE]        = &onewire_clk.common.hw,
1558
+    { CLK_PWM9,        &pwm9_clk.common.hw },
1273
+    [CLK_SSPA0]        = &sspa0_clk.common.hw,
1559
+    { CLK_PWM10,        &pwm10_clk.common.hw },
1274
+    [CLK_SSPA1]        = &sspa1_clk.common.hw,
1560
+    { CLK_PWM11,        &pwm11_clk.common.hw },
1275
+    [CLK_DRO]        = &dro_clk.common.hw,
1561
+    { CLK_PWM12,        &pwm12_clk.common.hw },
1276
+    [CLK_IR]        = &ir_clk.common.hw,
1562
+    { CLK_PWM13,        &pwm13_clk.common.hw },
1277
+    [CLK_TSEN]        = &tsen_clk.common.hw,
1563
+    { CLK_PWM14,        &pwm14_clk.common.hw },
1278
+    [CLK_IPC_AP2AUD]    = &ipc_ap2aud_clk.common.hw,
1564
+    { CLK_PWM15,        &pwm15_clk.common.hw },
1279
+    [CLK_CAN0]        = &can0_clk.common.hw,
1565
+    { CLK_PWM16,        &pwm16_clk.common.hw },
1280
+    [CLK_CAN0_BUS]        = &can0_bus_clk.common.hw,
1566
+    { CLK_PWM17,        &pwm17_clk.common.hw },
1281
+    [CLK_UART0_BUS]        = &uart0_bus_clk.common.hw,
1567
+    { CLK_PWM18,        &pwm18_clk.common.hw },
1282
+    [CLK_UART2_BUS]        = &uart2_bus_clk.common.hw,
1568
+    { CLK_PWM19,        &pwm19_clk.common.hw },
1283
+    [CLK_UART3_BUS]        = &uart3_bus_clk.common.hw,
1569
+    { CLK_SSP3,        &ssp3_clk.common.hw },
1284
+    [CLK_UART4_BUS]        = &uart4_bus_clk.common.hw,
1570
+    { CLK_RTC,        &rtc_clk.common.hw },
1285
+    [CLK_UART5_BUS]        = &uart5_bus_clk.common.hw,
1571
+    { CLK_TWSI0,        &twsi0_clk.common.hw },
1286
+    [CLK_UART6_BUS]        = &uart6_bus_clk.common.hw,
1572
+    { CLK_TWSI1,        &twsi1_clk.common.hw },
1287
+    [CLK_UART7_BUS]        = &uart7_bus_clk.common.hw,
1573
+    { CLK_TWSI2,        &twsi2_clk.common.hw },
1288
+    [CLK_UART8_BUS]        = &uart8_bus_clk.common.hw,
1574
+    { CLK_TWSI4,        &twsi4_clk.common.hw },
1289
+    [CLK_UART9_BUS]        = &uart9_bus_clk.common.hw,
1575
+    { CLK_TWSI5,        &twsi5_clk.common.hw },
1290
+    [CLK_GPIO_BUS]        = &gpio_bus_clk.common.hw,
1576
+    { CLK_TWSI6,        &twsi6_clk.common.hw },
1291
+    [CLK_PWM0_BUS]        = &pwm0_bus_clk.common.hw,
1577
+    { CLK_TWSI7,        &twsi7_clk.common.hw },
1292
+    [CLK_PWM1_BUS]        = &pwm1_bus_clk.common.hw,
1578
+    { CLK_TWSI8,        &twsi8_clk.common.hw },
1293
+    [CLK_PWM2_BUS]        = &pwm2_bus_clk.common.hw,
1579
+    { CLK_TIMERS1,        &timers1_clk.common.hw },
1294
+    [CLK_PWM3_BUS]        = &pwm3_bus_clk.common.hw,
1580
+    { CLK_TIMERS2,        &timers2_clk.common.hw },
1295
+    [CLK_PWM4_BUS]        = &pwm4_bus_clk.common.hw,
1581
+    { CLK_AIB,        &aib_clk.common.hw },
1296
+    [CLK_PWM5_BUS]        = &pwm5_bus_clk.common.hw,
1582
+    { CLK_ONEWIRE,        &onewire_clk.common.hw },
1297
+    [CLK_PWM6_BUS]        = &pwm6_bus_clk.common.hw,
1583
+    { CLK_SSPA0,        &sspa0_clk.common.hw },
1298
+    [CLK_PWM7_BUS]        = &pwm7_bus_clk.common.hw,
1584
+    { CLK_SSPA1,        &sspa1_clk.common.hw },
1299
+    [CLK_PWM8_BUS]        = &pwm8_bus_clk.common.hw,
1585
+    { CLK_DRO,        &dro_clk.common.hw },
1300
+    [CLK_PWM9_BUS]        = &pwm9_bus_clk.common.hw,
1586
+    { CLK_IR,        &ir_clk.common.hw },
1301
+    [CLK_PWM10_BUS]        = &pwm10_bus_clk.common.hw,
1587
+    { CLK_TSEN,        &tsen_clk.common.hw },
1302
+    [CLK_PWM11_BUS]        = &pwm11_bus_clk.common.hw,
1588
+    { CLK_IPC_AP2AUD,    &ipc_ap2aud_clk.common.hw },
1303
+    [CLK_PWM12_BUS]        = &pwm12_bus_clk.common.hw,
1589
+    { CLK_CAN0,        &can0_clk.common.hw },
1304
+    [CLK_PWM13_BUS]        = &pwm13_bus_clk.common.hw,
1590
+    { CLK_CAN0_BUS,        &can0_bus_clk.common.hw },
1305
+    [CLK_PWM14_BUS]        = &pwm14_bus_clk.common.hw,
1591
+    { CLK_UART0_BUS,    &uart0_bus_clk.common.hw },
1306
+    [CLK_PWM15_BUS]        = &pwm15_bus_clk.common.hw,
1592
+    { CLK_UART2_BUS,    &uart2_bus_clk.common.hw },
1307
+    [CLK_PWM16_BUS]        = &pwm16_bus_clk.common.hw,
1593
+    { CLK_UART3_BUS,    &uart3_bus_clk.common.hw },
1308
+    [CLK_PWM17_BUS]        = &pwm17_bus_clk.common.hw,
1594
+    { CLK_UART4_BUS,    &uart4_bus_clk.common.hw },
1309
+    [CLK_PWM18_BUS]        = &pwm18_bus_clk.common.hw,
1595
+    { CLK_UART5_BUS,    &uart5_bus_clk.common.hw },
1310
+    [CLK_PWM19_BUS]        = &pwm19_bus_clk.common.hw,
1596
+    { CLK_UART6_BUS,    &uart6_bus_clk.common.hw },
1311
+    [CLK_SSP3_BUS]        = &ssp3_bus_clk.common.hw,
1597
+    { CLK_UART7_BUS,    &uart7_bus_clk.common.hw },
1312
+    [CLK_RTC_BUS]        = &rtc_bus_clk.common.hw,
1598
+    { CLK_UART8_BUS,    &uart8_bus_clk.common.hw },
1313
+    [CLK_TWSI0_BUS]        = &twsi0_bus_clk.common.hw,
1599
+    { CLK_UART9_BUS,    &uart9_bus_clk.common.hw },
1314
+    [CLK_TWSI1_BUS]        = &twsi1_bus_clk.common.hw,
1600
+    { CLK_GPIO_BUS,        &gpio_bus_clk.common.hw },
1315
+    [CLK_TWSI2_BUS]        = &twsi2_bus_clk.common.hw,
1601
+    { CLK_PWM0_BUS,        &pwm0_bus_clk.common.hw },
1316
+    [CLK_TWSI4_BUS]        = &twsi4_bus_clk.common.hw,
1602
+    { CLK_PWM1_BUS,        &pwm1_bus_clk.common.hw },
1317
+    [CLK_TWSI5_BUS]        = &twsi5_bus_clk.common.hw,
1603
+    { CLK_PWM2_BUS,        &pwm2_bus_clk.common.hw },
1318
+    [CLK_TWSI6_BUS]        = &twsi6_bus_clk.common.hw,
1604
+    { CLK_PWM3_BUS,        &pwm3_bus_clk.common.hw },
1319
+    [CLK_TWSI7_BUS]        = &twsi7_bus_clk.common.hw,
1605
+    { CLK_PWM4_BUS,        &pwm4_bus_clk.common.hw },
1320
+    [CLK_TIMERS1_BUS]    = &timers1_bus_clk.common.hw,
1606
+    { CLK_PWM5_BUS,        &pwm5_bus_clk.common.hw },
1321
+    [CLK_TIMERS2_BUS]    = &timers2_bus_clk.common.hw,
1607
+    { CLK_PWM6_BUS,        &pwm6_bus_clk.common.hw },
1322
+    [CLK_AIB_BUS]        = &aib_bus_clk.common.hw,
1608
+    { CLK_PWM7_BUS,        &pwm7_bus_clk.common.hw },
1323
+    [CLK_ONEWIRE_BUS]    = &onewire_bus_clk.common.hw,
1609
+    { CLK_PWM8_BUS,        &pwm8_bus_clk.common.hw },
1324
+    [CLK_SSPA0_BUS]        = &sspa0_bus_clk.common.hw,
1610
+    { CLK_PWM9_BUS,        &pwm9_bus_clk.common.hw },
1325
+    [CLK_SSPA1_BUS]        = &sspa1_bus_clk.common.hw,
1611
+    { CLK_PWM10_BUS,    &pwm10_bus_clk.common.hw },
1326
+    [CLK_TSEN_BUS]        = &tsen_bus_clk.common.hw,
1612
+    { CLK_PWM11_BUS,    &pwm11_bus_clk.common.hw },
1327
+    [CLK_IPC_AP2AUD_BUS]    = &ipc_ap2aud_bus_clk.common.hw,
1613
+    { CLK_PWM12_BUS,    &pwm12_bus_clk.common.hw },
1328
+};
1614
+    { CLK_PWM13_BUS,    &pwm13_bus_clk.common.hw },
1329
+
1615
+    { CLK_PWM14_BUS,    &pwm14_bus_clk.common.hw },
1330
+static const struct spacemit_ccu_data k1_ccu_apbc_data = {
1616
+    { CLK_PWM15_BUS,    &pwm15_bus_clk.common.hw },
1331
+    .hws    = k1_ccu_apbc_hws,
1617
+    { CLK_PWM16_BUS,    &pwm16_bus_clk.common.hw },
1332
+    .num    = ARRAY_SIZE(k1_ccu_apbc_hws),
1618
+    { CLK_PWM17_BUS,    &pwm17_bus_clk.common.hw },
1333
+};
1619
+    { CLK_PWM18_BUS,    &pwm18_bus_clk.common.hw },
1334
+
1620
+    { CLK_PWM19_BUS,    &pwm19_bus_clk.common.hw },
1335
+static struct clk_hw *k1_ccu_apmu_hws[] = {
1621
+    { CLK_SSP3_BUS,        &ssp3_bus_clk.common.hw },
1336
+    [CLK_CCI550]        = &cci550_clk.common.hw,
1622
+    { CLK_RTC_BUS,        &rtc_bus_clk.common.hw },
1337
+    [CLK_CPU_C0_HI]        = &cpu_c0_hi_clk.common.hw,
1623
+    { CLK_TWSI0_BUS,    &twsi0_bus_clk.common.hw },
1338
+    [CLK_CPU_C0_CORE]    = &cpu_c0_core_clk.common.hw,
1624
+    { CLK_TWSI1_BUS,    &twsi1_bus_clk.common.hw },
1339
+    [CLK_CPU_C0_ACE]    = &cpu_c0_ace_clk.common.hw,
1625
+    { CLK_TWSI2_BUS,    &twsi2_bus_clk.common.hw },
1340
+    [CLK_CPU_C0_TCM]    = &cpu_c0_tcm_clk.common.hw,
1626
+    { CLK_TWSI4_BUS,    &twsi4_bus_clk.common.hw },
1341
+    [CLK_CPU_C1_HI]        = &cpu_c1_hi_clk.common.hw,
1627
+    { CLK_TWSI5_BUS,    &twsi5_bus_clk.common.hw },
1342
+    [CLK_CPU_C1_CORE]    = &cpu_c1_core_clk.common.hw,
1628
+    { CLK_TWSI6_BUS,    &twsi6_bus_clk.common.hw },
1343
+    [CLK_CPU_C1_ACE]    = &cpu_c1_ace_clk.common.hw,
1629
+    { CLK_TWSI7_BUS,    &twsi7_bus_clk.common.hw },
1344
+    [CLK_CCIC_4X]        = &ccic_4x_clk.common.hw,
1630
+    { CLK_TWSI8_BUS,    &twsi8_bus_clk.common.hw },
1345
+    [CLK_CCIC1PHY]        = &ccic1phy_clk.common.hw,
1631
+    { CLK_TIMERS1_BUS,    &timers1_bus_clk.common.hw },
1346
+    [CLK_SDH_AXI]        = &sdh_axi_aclk.common.hw,
1632
+    { CLK_TIMERS2_BUS,    &timers2_bus_clk.common.hw },
1347
+    [CLK_SDH0]        = &sdh0_clk.common.hw,
1633
+    { CLK_AIB_BUS,        &aib_bus_clk.common.hw },
1348
+    [CLK_SDH1]        = &sdh1_clk.common.hw,
1634
+    { CLK_ONEWIRE_BUS,    &onewire_bus_clk.common.hw },
1349
+    [CLK_SDH2]        = &sdh2_clk.common.hw,
1635
+    { CLK_SSPA0_BUS,    &sspa0_bus_clk.common.hw },
1350
+    [CLK_USB_P1]        = &usb_p1_aclk.common.hw,
1636
+    { CLK_SSPA1_BUS,    &sspa1_bus_clk.common.hw },
1351
+    [CLK_USB_AXI]        = &usb_axi_clk.common.hw,
1637
+    { CLK_TSEN_BUS,        &tsen_bus_clk.common.hw },
1352
+    [CLK_USB30]        = &usb30_clk.common.hw,
1638
+    { CLK_IPC_AP2AUD_BUS,    &ipc_ap2aud_bus_clk.common.hw },
1353
+    [CLK_QSPI]        = &qspi_clk.common.hw,
1639
+    { 0,            NULL },
1354
+    [CLK_QSPI_BUS]        = &qspi_bus_clk.common.hw,
1640
+};
1355
+    [CLK_DMA]        = &dma_clk.common.hw,
1641
+
1356
+    [CLK_AES]        = &aes_clk.common.hw,
1642
+static struct spacemit_ccu_clk k1_ccu_apmu_clks[] = {
1357
+    [CLK_VPU]        = &vpu_clk.common.hw,
1643
+    { CLK_CCI550,        &cci550_clk.common.hw },
1358
+    [CLK_GPU]        = &gpu_clk.common.hw,
1644
+    { CLK_CPU_C0_HI,    &cpu_c0_hi_clk.common.hw },
1359
+    [CLK_EMMC]        = &emmc_clk.common.hw,
1645
+    { CLK_CPU_C0_CORE,    &cpu_c0_core_clk.common.hw },
1360
+    [CLK_EMMC_X]        = &emmc_x_clk.common.hw,
1646
+    { CLK_CPU_C0_ACE,    &cpu_c0_ace_clk.common.hw },
1361
+    [CLK_AUDIO]        = &audio_clk.common.hw,
1647
+    { CLK_CPU_C0_TCM,    &cpu_c0_tcm_clk.common.hw },
1362
+    [CLK_HDMI]        = &hdmi_mclk.common.hw,
1648
+    { CLK_CPU_C1_HI,    &cpu_c1_hi_clk.common.hw },
1363
+    [CLK_PMUA_ACLK]        = &pmua_aclk.common.hw,
1649
+    { CLK_CPU_C1_CORE,    &cpu_c1_core_clk.common.hw },
1364
+    [CLK_PCIE0_MASTER]    = &pcie0_master_clk.common.hw,
1650
+    { CLK_CPU_C1_ACE,    &cpu_c1_ace_clk.common.hw },
1365
+    [CLK_PCIE0_SLAVE]    = &pcie0_slave_clk.common.hw,
1651
+    { CLK_CCIC_4X,        &ccic_4x_clk.common.hw },
1366
+    [CLK_PCIE0_DBI]        = &pcie0_dbi_clk.common.hw,
1652
+    { CLK_CCIC1PHY,        &ccic1phy_clk.common.hw },
1367
+    [CLK_PCIE1_MASTER]    = &pcie1_master_clk.common.hw,
1653
+    { CLK_SDH_AXI,        &sdh_axi_aclk.common.hw },
1368
+    [CLK_PCIE1_SLAVE]    = &pcie1_slave_clk.common.hw,
1654
+    { CLK_SDH0,        &sdh0_clk.common.hw },
1369
+    [CLK_PCIE1_DBI]        = &pcie1_dbi_clk.common.hw,
1655
+    { CLK_SDH1,        &sdh1_clk.common.hw },
1370
+    [CLK_PCIE2_MASTER]    = &pcie2_master_clk.common.hw,
1656
+    { CLK_SDH2,        &sdh2_clk.common.hw },
1371
+    [CLK_PCIE2_SLAVE]    = &pcie2_slave_clk.common.hw,
1657
+    { CLK_USB_P1,        &usb_p1_aclk.common.hw },
1372
+    [CLK_PCIE2_DBI]        = &pcie2_dbi_clk.common.hw,
1658
+    { CLK_USB_AXI,        &usb_axi_clk.common.hw },
1373
+    [CLK_EMAC0_BUS]        = &emac0_bus_clk.common.hw,
1659
+    { CLK_USB30,        &usb30_clk.common.hw },
1374
+    [CLK_EMAC0_PTP]        = &emac0_ptp_clk.common.hw,
1660
+    { CLK_QSPI,        &qspi_clk.common.hw },
1375
+    [CLK_EMAC1_BUS]        = &emac1_bus_clk.common.hw,
1661
+    { CLK_QSPI_BUS,        &qspi_bus_clk.common.hw },
1376
+    [CLK_EMAC1_PTP]        = &emac1_ptp_clk.common.hw,
1662
+    { CLK_DMA,        &dma_clk.common.hw },
1377
+    [CLK_JPG]        = &jpg_clk.common.hw,
1663
+    { CLK_AES,        &aes_clk.common.hw },
1378
+    [CLK_CCIC2PHY]        = &ccic2phy_clk.common.hw,
1664
+    { CLK_VPU,        &vpu_clk.common.hw },
1379
+    [CLK_CCIC3PHY]        = &ccic3phy_clk.common.hw,
1665
+    { CLK_GPU,        &gpu_clk.common.hw },
1380
+    [CLK_CSI]        = &csi_clk.common.hw,
1666
+    { CLK_EMMC,        &emmc_clk.common.hw },
1381
+    [CLK_CAMM0]        = &camm0_clk.common.hw,
1667
+    { CLK_EMMC_X,        &emmc_x_clk.common.hw },
1382
+    [CLK_CAMM1]        = &camm1_clk.common.hw,
1668
+    { CLK_AUDIO,        &audio_clk.common.hw },
1383
+    [CLK_CAMM2]        = &camm2_clk.common.hw,
1669
+    { CLK_HDMI,        &hdmi_mclk.common.hw },
1384
+    [CLK_ISP_CPP]        = &isp_cpp_clk.common.hw,
1670
+    { CLK_PMUA_ACLK,    &pmua_aclk.common.hw },
1385
+    [CLK_ISP_BUS]        = &isp_bus_clk.common.hw,
1671
+    { CLK_PCIE0_MASTER,    &pcie0_master_clk.common.hw },
1386
+    [CLK_ISP]        = &isp_clk.common.hw,
1672
+    { CLK_PCIE0_SLAVE,    &pcie0_slave_clk.common.hw },
1387
+    [CLK_DPU_MCLK]        = &dpu_mclk.common.hw,
1673
+    { CLK_PCIE0_DBI,    &pcie0_dbi_clk.common.hw },
1388
+    [CLK_DPU_ESC]        = &dpu_esc_clk.common.hw,
1674
+    { CLK_PCIE1_MASTER,    &pcie1_master_clk.common.hw },
1389
+    [CLK_DPU_BIT]        = &dpu_bit_clk.common.hw,
1675
+    { CLK_PCIE1_SLAVE,    &pcie1_slave_clk.common.hw },
1390
+    [CLK_DPU_PXCLK]        = &dpu_pxclk.common.hw,
1676
+    { CLK_PCIE1_DBI,    &pcie1_dbi_clk.common.hw },
1391
+    [CLK_DPU_HCLK]        = &dpu_hclk.common.hw,
1677
+    { CLK_PCIE2_MASTER,    &pcie2_master_clk.common.hw },
1392
+    [CLK_DPU_SPI]        = &dpu_spi_clk.common.hw,
1678
+    { CLK_PCIE2_SLAVE,    &pcie2_slave_clk.common.hw },
1393
+    [CLK_DPU_SPI_HBUS]    = &dpu_spi_hbus_clk.common.hw,
1679
+    { CLK_PCIE2_DBI,    &pcie2_dbi_clk.common.hw },
1394
+    [CLK_DPU_SPIBUS]    = &dpu_spi_bus_clk.common.hw,
1680
+    { CLK_EMAC0_BUS,    &emac0_bus_clk.common.hw },
1395
+    [CLK_DPU_SPI_ACLK]    = &dpu_spi_aclk.common.hw,
1681
+    { CLK_EMAC0_PTP,    &emac0_ptp_clk.common.hw },
1396
+    [CLK_V2D]        = &v2d_clk.common.hw,
1682
+    { CLK_EMAC1_BUS,    &emac1_bus_clk.common.hw },
1397
+    [CLK_EMMC_BUS]        = &emmc_bus_clk.common.hw,
1683
+    { CLK_EMAC1_PTP,    &emac1_ptp_clk.common.hw },
1398
+};
1684
+    { CLK_JPG,        &jpg_clk.common.hw },
1399
+
1685
+    { CLK_CCIC2PHY,        &ccic2phy_clk.common.hw },
1400
+static const struct spacemit_ccu_data k1_ccu_apmu_data = {
1686
+    { CLK_CCIC3PHY,        &ccic3phy_clk.common.hw },
1401
+    .hws    = k1_ccu_apmu_hws,
1687
+    { CLK_CSI,        &csi_clk.common.hw },
1402
+    .num    = ARRAY_SIZE(k1_ccu_apmu_hws),
1688
+    { CLK_CAMM0,        &camm0_clk.common.hw },
1689
+    { CLK_CAMM1,        &camm1_clk.common.hw },
1690
+    { CLK_CAMM2,        &camm2_clk.common.hw },
1691
+    { CLK_ISP_CPP,        &isp_cpp_clk.common.hw },
1692
+    { CLK_ISP_BUS,        &isp_bus_clk.common.hw },
1693
+    { CLK_ISP,        &isp_clk.common.hw },
1694
+    { CLK_DPU_MCLK,        &dpu_mclk.common.hw },
1695
+    { CLK_DPU_ESC,        &dpu_esc_clk.common.hw },
1696
+    { CLK_DPU_BIT,        &dpu_bit_clk.common.hw },
1697
+    { CLK_DPU_PXCLK,    &dpu_pxclk.common.hw },
1698
+    { CLK_DPU_HCLK,        &dpu_hclk.common.hw },
1699
+    { CLK_DPU_SPI,        &dpu_spi_clk.common.hw },
1700
+    { CLK_DPU_SPI_HBUS,    &dpu_spi_hbus_clk.common.hw },
1701
+    { CLK_DPU_SPIBUS,    &dpu_spi_bus_clk.common.hw },
1702
+    { CLK_DPU_SPI_ACLK,    &dpu_spi_aclk.common.hw },
1703
+    { CLK_V2D,        &v2d_clk.common.hw },
1704
+    { CLK_EMMC_BUS,        &emmc_bus_clk.common.hw },
1705
+    { 0,            NULL },
1706
+};
1403
+};
1707
+
1404
+
1708
+static int spacemit_ccu_register(struct device *dev,
1405
+static int spacemit_ccu_register(struct device *dev,
1709
+                 struct regmap *regmap, struct regmap *lock_regmap,
1406
+                 struct regmap *regmap, struct regmap *lock_regmap,
1710
+                 const struct spacemit_ccu_clk *clks)
1407
+                 const struct spacemit_ccu_data *data)
1711
+{
1408
+{
1712
+    const struct spacemit_ccu_clk *clk;
1713
+    int i, ret, max_id = 0;
1714
+
1715
+    for (clk = clks; clk->hw; clk++)
1716
+        max_id = max(max_id, clk->id);
1717
+
1718
+    struct clk_hw_onecell_data *clk_data;
1409
+    struct clk_hw_onecell_data *clk_data;
1719
+
1410
+    int i, ret;
1720
+    clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, max_id + 1), GFP_KERNEL);
1411
+
1412
+    clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, data->num),
1413
+                GFP_KERNEL);
1721
+    if (!clk_data)
1414
+    if (!clk_data)
1722
+        return -ENOMEM;
1415
+        return -ENOMEM;
1723
+
1416
+
1724
+    for (i = 0; i <= max_id; i++)
1417
+    for (i = 0; i < data->num; i++) {
1725
+        clk_data->hws[i] = ERR_PTR(-ENOENT);
1418
+        struct clk_hw *hw = data->hws[i];
1726
+
1419
+        struct ccu_common *common;
1727
+    for (clk = clks; clk->hw; clk++) {
1420
+        const char *name;
1728
+        struct ccu_common *common = hw_to_ccu_common(clk->hw);
1421
+
1729
+        const char *name = clk->hw->init->name;
1422
+        if (!hw) {
1730
+
1423
+            clk_data->hws[i] = ERR_PTR(-ENOENT);
1424
+            continue;
1425
+        }
1426
+
1427
+        name = hw->init->name;
1428
+
1429
+        common = hw_to_ccu_common(hw);
1731
+        common->regmap        = regmap;
1430
+        common->regmap        = regmap;
1732
+        common->lock_regmap    = lock_regmap;
1431
+        common->lock_regmap    = lock_regmap;
1733
+
1432
+
1734
+        ret = devm_clk_hw_register(dev, clk->hw);
1433
+        ret = devm_clk_hw_register(dev, hw);
1735
+        if (ret) {
1434
+        if (ret) {
1736
+            dev_err(dev, "Cannot register clock %d - %s\n",
1435
+            dev_err(dev, "Cannot register clock %d - %s\n",
1737
+                i, name);
1436
+                i, name);
1738
+            return ret;
1437
+            return ret;
1739
+        }
1438
+        }
1740
+
1439
+
1741
+        clk_data->hws[clk->id] = clk->hw;
1440
+        clk_data->hws[i] = hw;
1742
+    }
1441
+    }
1743
+
1442
+
1744
+    clk_data->num = max_id + 1;
1443
+    clk_data->num = data->num;
1745
+
1444
+
1746
+    return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
1445
+    ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
1446
+    if (ret)
1447
+        dev_err(dev, "failed to add clock hardware provider (%d)\n", ret);
1448
+
1449
+    return ret;
1747
+}
1450
+}
1748
+
1451
+
1749
+static int k1_ccu_probe(struct platform_device *pdev)
1452
+static int k1_ccu_probe(struct platform_device *pdev)
1750
+{
1453
+{
1751
+    struct regmap *base_regmap, *lock_regmap = NULL;
1454
+    struct regmap *base_regmap, *lock_regmap = NULL;
...
...
1755
+    base_regmap = device_node_to_regmap(dev->of_node);
1458
+    base_regmap = device_node_to_regmap(dev->of_node);
1756
+    if (IS_ERR(base_regmap))
1459
+    if (IS_ERR(base_regmap))
1757
+        return dev_err_probe(dev, PTR_ERR(base_regmap),
1460
+        return dev_err_probe(dev, PTR_ERR(base_regmap),
1758
+                 "failed to get regmap\n");
1461
+                 "failed to get regmap\n");
1759
+
1462
+
1463
+    /*
1464
+     * The lock status of PLLs locate in MPMU region, while PLLs themselves
1465
+     * are in APBS region. Reference to MPMU syscon is required to check PLL
1466
+     * status.
1467
+     */
1760
+    if (of_device_is_compatible(dev->of_node, "spacemit,k1-pll")) {
1468
+    if (of_device_is_compatible(dev->of_node, "spacemit,k1-pll")) {
1761
+        struct device_node *mpmu = of_parse_phandle(dev->of_node,
1469
+        struct device_node *mpmu = of_parse_phandle(dev->of_node,
1762
+                             "spacemit,mpmu", 0);
1470
+                             "spacemit,mpmu", 0);
1763
+        if (!mpmu)
1471
+        if (!mpmu)
1764
+            return dev_err_probe(dev, -ENODEV,
1472
+            return dev_err_probe(dev, -ENODEV,
...
...
1781
+}
1489
+}
1782
+
1490
+
1783
+static const struct of_device_id of_k1_ccu_match[] = {
1491
+static const struct of_device_id of_k1_ccu_match[] = {
1784
+    {
1492
+    {
1785
+        .compatible    = "spacemit,k1-pll",
1493
+        .compatible    = "spacemit,k1-pll",
1786
+        .data        = k1_ccu_apbs_clks,
1494
+        .data        = &k1_ccu_pll_data,
1787
+    },
1495
+    },
1788
+    {
1496
+    {
1789
+        .compatible    = "spacemit,k1-syscon-mpmu",
1497
+        .compatible    = "spacemit,k1-syscon-mpmu",
1790
+        .data        = k1_ccu_mpmu_clks,
1498
+        .data        = &k1_ccu_mpmu_data,
1791
+    },
1499
+    },
1792
+    {
1500
+    {
1793
+        .compatible    = "spacemit,k1-syscon-apbc",
1501
+        .compatible    = "spacemit,k1-syscon-apbc",
1794
+        .data        = k1_ccu_apbc_clks,
1502
+        .data        = &k1_ccu_apbc_data,
1795
+    },
1503
+    },
1796
+    {
1504
+    {
1797
+        .compatible    = "spacemit,k1-syscon-apmu",
1505
+        .compatible    = "spacemit,k1-syscon-apmu",
1798
+        .data        = k1_ccu_apmu_clks,
1506
+        .data        = &k1_ccu_apmu_data,
1799
+    },
1507
+    },
1800
+    { }
1508
+    { }
1801
+};
1509
+};
1802
+MODULE_DEVICE_TABLE(of, of_k1_ccu_match);
1510
+MODULE_DEVICE_TABLE(of, of_k1_ccu_match);
1803
+
1511
+
...
...
1808
+    },
1516
+    },
1809
+    .probe    = k1_ccu_probe,
1517
+    .probe    = k1_ccu_probe,
1810
+};
1518
+};
1811
+module_platform_driver(k1_ccu_driver);
1519
+module_platform_driver(k1_ccu_driver);
1812
+
1520
+
1813
+MODULE_DESCRIPTION("Spacemit K1 CCU driver");
1521
+MODULE_DESCRIPTION("SpacemiT K1 CCU driver");
1814
+MODULE_AUTHOR("Haylen Chu <heylenay@4d2.org>");
1522
+MODULE_AUTHOR("Haylen Chu <heylenay@4d2.org>");
1815
+MODULE_LICENSE("GPL");
1523
+MODULE_LICENSE("GPL");
1816
diff --git a/drivers/clk/spacemit/ccu_common.h b/drivers/clk/spacemit/ccu_common.h
1524
diff --git a/drivers/clk/spacemit/ccu_common.h b/drivers/clk/spacemit/ccu_common.h
1817
new file mode 100644
1525
new file mode 100644
1818
index XXXXXXX..XXXXXXX
1526
index XXXXXXX..XXXXXXX
...
...
1837
+    union {
1545
+    union {
1838
+        /* For DDN and MIX */
1546
+        /* For DDN and MIX */
1839
+        struct {
1547
+        struct {
1840
+            u32 reg_ctrl;
1548
+            u32 reg_ctrl;
1841
+            u32 reg_fc;
1549
+            u32 reg_fc;
1842
+            u32 fc;
1550
+            u32 mask_fc;
1843
+        };
1551
+        };
1844
+
1552
+
1845
+        /* For PLL */
1553
+        /* For PLL */
1846
+        struct {
1554
+        struct {
1847
+            u32 reg_swcr1;
1555
+            u32 reg_swcr1;
1848
+            u32 reg_swcr2;
1849
+            u32 reg_swcr3;
1556
+            u32 reg_swcr3;
1850
+        };
1557
+        };
1851
+    };
1558
+    };
1852
+
1559
+
1853
+    struct clk_hw hw;
1560
+    struct clk_hw hw;
...
...
1856
+static inline struct ccu_common *hw_to_ccu_common(struct clk_hw *hw)
1563
+static inline struct ccu_common *hw_to_ccu_common(struct clk_hw *hw)
1857
+{
1564
+{
1858
+    return container_of(hw, struct ccu_common, hw);
1565
+    return container_of(hw, struct ccu_common, hw);
1859
+}
1566
+}
1860
+
1567
+
1861
+#define ccu_read(reg, c, val)    regmap_read((c)->regmap, (c)->reg_##reg, val)
1568
+#define ccu_read(c, reg)                        \
1862
+#define ccu_update(reg, c, mask, val) \
1569
+    ({                                \
1570
+        u32 tmp;                        \
1571
+        regmap_read((c)->regmap, (c)->reg_##reg, &tmp);        \
1572
+        tmp;                            \
1573
+     })
1574
+#define ccu_update(c, reg, mask, val) \
1863
+    regmap_update_bits((c)->regmap, (c)->reg_##reg, mask, val)
1575
+    regmap_update_bits((c)->regmap, (c)->reg_##reg, mask, val)
1864
+#define ccu_poll(reg, c, tmp, cond, sleep, timeout) \
1865
+    regmap_read_poll_timeout_atomic((c)->regmap, (c)->reg_##reg,    \
1866
+                    tmp, cond, sleep, timeout)
1867
+
1576
+
1868
+#endif /* _CCU_COMMON_H_ */
1577
+#endif /* _CCU_COMMON_H_ */
1869
diff --git a/drivers/clk/spacemit/ccu_ddn.c b/drivers/clk/spacemit/ccu_ddn.c
1578
diff --git a/drivers/clk/spacemit/ccu_ddn.c b/drivers/clk/spacemit/ccu_ddn.c
1870
new file mode 100644
1579
new file mode 100644
1871
index XXXXXXX..XXXXXXX
1580
index XXXXXXX..XXXXXXX
1872
--- /dev/null
1581
--- /dev/null
1873
+++ b/drivers/clk/spacemit/ccu_ddn.c
1582
+++ b/drivers/clk/spacemit/ccu_ddn.c
1874
@@ -XXX,XX +XXX,XX @@
1583
@@ -XXX,XX +XXX,XX @@
1875
+// SPDX-License-Identifier: GPL-2.0-only
1584
+// SPDX-License-Identifier: GPL-2.0-only
1876
+/*
1585
+/*
1877
+ * Spacemit clock type ddn
1878
+ *
1879
+ * Copyright (c) 2024 SpacemiT Technology Co. Ltd
1586
+ * Copyright (c) 2024 SpacemiT Technology Co. Ltd
1880
+ * Copyright (c) 2024 Haylen Chu <heylenay@4d2.org>
1587
+ * Copyright (c) 2024 Haylen Chu <heylenay@4d2.org>
1881
+ */
1588
+ *
1882
+
1883
+#include <linux/clk-provider.h>
1884
+#include <linux/rational.h>
1885
+
1886
+#include "ccu_ddn.h"
1887
+
1888
+/*
1889
+ * DDN stands for "Divider Denominator Numerator", it's M/N clock with a
1589
+ * DDN stands for "Divider Denominator Numerator", it's M/N clock with a
1890
+ * constant x2 factor. This clock hardware follows the equation below,
1590
+ * constant x2 factor. This clock hardware follows the equation below,
1891
+ *
1591
+ *
1892
+ *     numerator Fin
1592
+ *     numerator Fin
1893
+ *    2 * ------------- = -------
1593
+ *    2 * ------------- = -------
...
...
1898
+ *        Fin    denominator
1598
+ *        Fin    denominator
1899
+ *    Fout = ----- * -------------
1599
+ *    Fout = ----- * -------------
1900
+ *         2     numerator
1600
+ *         2     numerator
1901
+ */
1601
+ */
1902
+
1602
+
1903
+static unsigned long clk_ddn_calc_best_rate(struct ccu_ddn *ddn,
1603
+#include <linux/clk-provider.h>
1604
+#include <linux/rational.h>
1605
+
1606
+#include "ccu_ddn.h"
1607
+
1608
+static unsigned long ccu_ddn_calc_rate(unsigned long prate,
1609
+                 unsigned long num, unsigned long den)
1610
+{
1611
+    return prate * den / 2 / num;
1612
+}
1613
+
1614
+static unsigned long ccu_ddn_calc_best_rate(struct ccu_ddn *ddn,
1904
+                     unsigned long rate, unsigned long prate,
1615
+                     unsigned long rate, unsigned long prate,
1905
+                     unsigned long *num, unsigned long *den)
1616
+                     unsigned long *num, unsigned long *den)
1906
+{
1617
+{
1907
+    rational_best_approximation(rate, prate / 2,
1618
+    rational_best_approximation(rate, prate / 2,
1908
+                 ddn->den_mask, ddn->num_mask,
1619
+                 ddn->den_mask >> ddn->den_shift,
1620
+                 ddn->num_mask >> ddn->num_shift,
1909
+                 den, num);
1621
+                 den, num);
1910
+    return prate / 2 * *den / *num;
1622
+    return ccu_ddn_calc_rate(prate, *num, *den);
1911
+}
1623
+}
1912
+
1624
+
1913
+static long clk_ddn_round_rate(struct clk_hw *hw, unsigned long rate,
1625
+static long ccu_ddn_round_rate(struct clk_hw *hw, unsigned long rate,
1914
+             unsigned long *prate)
1626
+             unsigned long *prate)
1915
+{
1627
+{
1916
+    struct ccu_ddn *ddn = hw_to_ccu_ddn(hw);
1628
+    struct ccu_ddn *ddn = hw_to_ccu_ddn(hw);
1917
+    unsigned long num = 0, den = 0;
1629
+    unsigned long num, den;
1918
+
1630
+
1919
+    return clk_ddn_calc_best_rate(ddn, rate, *prate, &num, &den);
1631
+    return ccu_ddn_calc_best_rate(ddn, rate, *prate, &num, &den);
1920
+}
1632
+}
1921
+
1633
+
1922
+static unsigned long clk_ddn_recalc_rate(struct clk_hw *hw, unsigned long prate)
1634
+static unsigned long ccu_ddn_recalc_rate(struct clk_hw *hw, unsigned long prate)
1923
+{
1635
+{
1924
+    struct ccu_ddn *ddn = hw_to_ccu_ddn(hw);
1636
+    struct ccu_ddn *ddn = hw_to_ccu_ddn(hw);
1925
+    unsigned int val, num, den;
1637
+    unsigned int val, num, den;
1926
+
1638
+
1927
+    ccu_read(ctrl, &ddn->common, &val);
1639
+    val = ccu_read(&ddn->common, ctrl);
1928
+
1640
+
1929
+    num = (val & ddn->num_mask) >> ddn->num_shift;
1641
+    num = (val & ddn->num_mask) >> ddn->num_shift;
1930
+    den = (val & ddn->den_mask) >> ddn->den_shift;
1642
+    den = (val & ddn->den_mask) >> ddn->den_shift;
1931
+
1643
+
1932
+    return prate / 2 * den / num;
1644
+    return ccu_ddn_calc_rate(prate, num, den);
1933
+}
1645
+}
1934
+
1646
+
1935
+static int clk_ddn_set_rate(struct clk_hw *hw, unsigned long rate,
1647
+static int ccu_ddn_set_rate(struct clk_hw *hw, unsigned long rate,
1936
+             unsigned long prate)
1648
+             unsigned long prate)
1937
+{
1649
+{
1938
+    struct ccu_ddn *ddn = hw_to_ccu_ddn(hw);
1650
+    struct ccu_ddn *ddn = hw_to_ccu_ddn(hw);
1939
+    unsigned long num, den;
1651
+    unsigned long num, den;
1940
+
1652
+
1941
+    clk_ddn_calc_best_rate(ddn, rate, prate, &num, &den);
1653
+    ccu_ddn_calc_best_rate(ddn, rate, prate, &num, &den);
1942
+
1654
+
1943
+    ccu_update(ctrl, &ddn->common,
1655
+    ccu_update(&ddn->common, ctrl,
1944
+         ddn->num_mask | ddn->den_mask,
1656
+         ddn->num_mask | ddn->den_mask,
1945
+         (num << ddn->num_shift) | (den << ddn->den_shift));
1657
+         (num << ddn->num_shift) | (den << ddn->den_shift));
1946
+
1658
+
1947
+    return 0;
1659
+    return 0;
1948
+}
1660
+}
1949
+
1661
+
1950
+const struct clk_ops spacemit_ccu_ddn_ops = {
1662
+const struct clk_ops spacemit_ccu_ddn_ops = {
1951
+    .recalc_rate    = clk_ddn_recalc_rate,
1663
+    .recalc_rate    = ccu_ddn_recalc_rate,
1952
+    .round_rate    = clk_ddn_round_rate,
1664
+    .round_rate    = ccu_ddn_round_rate,
1953
+    .set_rate    = clk_ddn_set_rate,
1665
+    .set_rate    = ccu_ddn_set_rate,
1954
+};
1666
+};
1955
diff --git a/drivers/clk/spacemit/ccu_ddn.h b/drivers/clk/spacemit/ccu_ddn.h
1667
diff --git a/drivers/clk/spacemit/ccu_ddn.h b/drivers/clk/spacemit/ccu_ddn.h
1956
new file mode 100644
1668
new file mode 100644
1957
index XXXXXXX..XXXXXXX
1669
index XXXXXXX..XXXXXXX
1958
--- /dev/null
1670
--- /dev/null
...
...
1965
+ */
1677
+ */
1966
+
1678
+
1967
+#ifndef _CCU_DDN_H_
1679
+#ifndef _CCU_DDN_H_
1968
+#define _CCU_DDN_H_
1680
+#define _CCU_DDN_H_
1969
+
1681
+
1682
+#include <linux/bitops.h>
1970
+#include <linux/clk-provider.h>
1683
+#include <linux/clk-provider.h>
1971
+
1684
+
1972
+#include "ccu_common.h"
1685
+#include "ccu_common.h"
1973
+
1686
+
1974
+struct ccu_ddn {
1687
+struct ccu_ddn {
...
...
1980
+};
1693
+};
1981
+
1694
+
1982
+#define CCU_DDN_INIT(_name, _parent, _flags) \
1695
+#define CCU_DDN_INIT(_name, _parent, _flags) \
1983
+    CLK_HW_INIT_HW(#_name, &_parent.common.hw, &spacemit_ccu_ddn_ops, _flags)
1696
+    CLK_HW_INIT_HW(#_name, &_parent.common.hw, &spacemit_ccu_ddn_ops, _flags)
1984
+
1697
+
1985
+#define CCU_DDN_DEFINE(_name, _parent, _reg_ctrl,                \
1698
+#define CCU_DDN_DEFINE(_name, _parent, _reg_ctrl, _num_mask, _den_mask, _flags)    \
1986
+         _num_mask, _num_shift, _den_mask, _den_shift,        \
1699
+static struct ccu_ddn _name = {                            \
1987
+         _flags)                            \
1700
+    .common = {                                \
1988
+    struct ccu_ddn _name = {                        \
1701
+        .reg_ctrl    = _reg_ctrl,                    \
1989
+        .common = {                            \
1702
+        .hw.init    = CCU_DDN_INIT(_name, _parent, _flags),        \
1990
+            .reg_ctrl = _reg_ctrl,                    \
1703
+    },                                    \
1991
+            .hw.init = CCU_DDN_INIT(_name, _parent, _flags),    \
1704
+    .num_mask    = _num_mask,                        \
1992
+        },                                \
1705
+    .num_shift    = __ffs(_num_mask),                    \
1993
+        .num_mask = _num_mask,                        \
1706
+    .den_mask    = _den_mask,                        \
1994
+        .num_shift = _num_shift,                    \
1707
+    .den_shift    = __ffs(_den_mask),                    \
1995
+        .den_mask = _den_mask,                        \
1708
+}
1996
+        .den_shift = _den_shift,                    \
1997
+    }
1998
+
1709
+
1999
+static inline struct ccu_ddn *hw_to_ccu_ddn(struct clk_hw *hw)
1710
+static inline struct ccu_ddn *hw_to_ccu_ddn(struct clk_hw *hw)
2000
+{
1711
+{
2001
+    struct ccu_common *common = hw_to_ccu_common(hw);
1712
+    struct ccu_common *common = hw_to_ccu_common(hw);
2002
+
1713
+
...
...
2012
--- /dev/null
1723
--- /dev/null
2013
+++ b/drivers/clk/spacemit/ccu_mix.c
1724
+++ b/drivers/clk/spacemit/ccu_mix.c
2014
@@ -XXX,XX +XXX,XX @@
1725
@@ -XXX,XX +XXX,XX @@
2015
+// SPDX-License-Identifier: GPL-2.0-only
1726
+// SPDX-License-Identifier: GPL-2.0-only
2016
+/*
1727
+/*
2017
+ * Spacemit clock type mix(div/mux/gate/factor)
2018
+ *
2019
+ * Copyright (c) 2024 SpacemiT Technology Co. Ltd
1728
+ * Copyright (c) 2024 SpacemiT Technology Co. Ltd
2020
+ * Copyright (c) 2024 Haylen Chu <heylenay@4d2.org>
1729
+ * Copyright (c) 2024 Haylen Chu <heylenay@4d2.org>
1730
+ *
1731
+ * MIX clock type is the combination of mux, factor or divider, and gate
2021
+ */
1732
+ */
2022
+
1733
+
2023
+#include <linux/clk-provider.h>
1734
+#include <linux/clk-provider.h>
2024
+
1735
+
2025
+#include "ccu_mix.h"
1736
+#include "ccu_mix.h"
2026
+
1737
+
2027
+#define MIX_TIMEOUT    10000
1738
+#define MIX_FC_TIMEOUT_US    10000
1739
+#define MIX_FC_DELAY_US        5
2028
+
1740
+
2029
+static void ccu_gate_disable(struct clk_hw *hw)
1741
+static void ccu_gate_disable(struct clk_hw *hw)
2030
+{
1742
+{
2031
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
1743
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
2032
+    struct ccu_common *common = &mix->common;
1744
+
2033
+
1745
+    ccu_update(&mix->common, ctrl, mix->gate.mask, 0);
2034
+    ccu_update(ctrl, common, mix->gate.mask, 0);
2035
+}
1746
+}
2036
+
1747
+
2037
+static int ccu_gate_enable(struct clk_hw *hw)
1748
+static int ccu_gate_enable(struct clk_hw *hw)
2038
+{
1749
+{
2039
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
1750
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
2040
+    struct ccu_common *common = &mix->common;
2041
+    struct ccu_gate_config *gate = &mix->gate;
1751
+    struct ccu_gate_config *gate = &mix->gate;
2042
+
1752
+
2043
+    ccu_update(ctrl, common, gate->mask, gate->mask);
1753
+    ccu_update(&mix->common, ctrl, gate->mask, gate->mask);
2044
+
1754
+
2045
+    return 0;
1755
+    return 0;
2046
+}
1756
+}
2047
+
1757
+
2048
+static int ccu_gate_is_enabled(struct clk_hw *hw)
1758
+static int ccu_gate_is_enabled(struct clk_hw *hw)
2049
+{
1759
+{
2050
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
1760
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
2051
+    struct ccu_common *common = &mix->common;
1761
+    struct ccu_gate_config *gate = &mix->gate;
2052
+    u32 tmp;
1762
+
2053
+
1763
+    return (ccu_read(&mix->common, ctrl) & gate->mask) == gate->mask;
2054
+    ccu_read(ctrl, common, &tmp);
2055
+
2056
+    return !!(tmp & mix->gate.mask);
2057
+}
1764
+}
2058
+
1765
+
2059
+static unsigned long ccu_factor_recalc_rate(struct clk_hw *hw,
1766
+static unsigned long ccu_factor_recalc_rate(struct clk_hw *hw,
2060
+                     unsigned long parent_rate)
1767
+                     unsigned long parent_rate)
2061
+{
1768
+{
...
...
2066
+
1773
+
2067
+static unsigned long ccu_div_recalc_rate(struct clk_hw *hw,
1774
+static unsigned long ccu_div_recalc_rate(struct clk_hw *hw,
2068
+                     unsigned long parent_rate)
1775
+                     unsigned long parent_rate)
2069
+{
1776
+{
2070
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
1777
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
2071
+    struct ccu_common *common = &mix->common;
2072
+    struct ccu_div_config *div = &mix->div;
1778
+    struct ccu_div_config *div = &mix->div;
2073
+    unsigned long val;
1779
+    unsigned long val;
2074
+    u32 reg;
1780
+
2075
+
1781
+    val = ccu_read(&mix->common, ctrl) >> div->shift;
2076
+    ccu_read(ctrl, common, &reg);
2077
+
2078
+    val = reg >> div->shift;
2079
+    val &= (1 << div->width) - 1;
1782
+    val &= (1 << div->width) - 1;
2080
+
1783
+
2081
+    val = divider_recalc_rate(hw, parent_rate, val, NULL, 0, div->width);
1784
+    return divider_recalc_rate(hw, parent_rate, val, NULL, 0, div->width);
2082
+
1785
+}
2083
+    return val;
1786
+
2084
+}
1787
+/*
2085
+
1788
+ * Some clocks require a "FC" (frequency change) bit to be set after changing
1789
+ * their rates or reparenting. This bit will be automatically cleared by
1790
+ * hardware in MIX_FC_TIMEOUT_US, which indicates the operation is completed.
1791
+ */
2086
+static int ccu_mix_trigger_fc(struct clk_hw *hw)
1792
+static int ccu_mix_trigger_fc(struct clk_hw *hw)
2087
+{
1793
+{
2088
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
1794
+    struct ccu_common *common = hw_to_ccu_common(hw);
2089
+    struct ccu_common *common = &mix->common;
1795
+    unsigned int val;
2090
+    unsigned int val = 0;
1796
+
2091
+
1797
+    if (common->reg_fc)
2092
+    ccu_update(fc, common, common->fc, common->fc);
1798
+        return 0;
2093
+
1799
+
2094
+    return ccu_poll(fc, common, val, !(val & common->fc),
1800
+    ccu_update(common, fc, common->mask_fc, common->mask_fc);
2095
+            5, MIX_TIMEOUT);
1801
+
1802
+    return regmap_read_poll_timeout_atomic(common->regmap, common->reg_fc,
1803
+                     val, !(val & common->mask_fc),
1804
+                     MIX_FC_DELAY_US,
1805
+                     MIX_FC_TIMEOUT_US);
2096
+}
1806
+}
2097
+
1807
+
2098
+static long ccu_factor_round_rate(struct clk_hw *hw, unsigned long rate,
1808
+static long ccu_factor_round_rate(struct clk_hw *hw, unsigned long rate,
2099
+                 unsigned long *prate)
1809
+                 unsigned long *prate)
2100
+{
1810
+{
...
...
2127
+            continue;
1837
+            continue;
2128
+
1838
+
2129
+        parent_rate = clk_hw_get_rate(parent);
1839
+        parent_rate = clk_hw_get_rate(parent);
2130
+
1840
+
2131
+        for (int j = 1; j <= div_max; j++) {
1841
+        for (int j = 1; j <= div_max; j++) {
2132
+            unsigned long tmp = DIV_ROUND_UP_ULL(parent_rate, j);
1842
+            unsigned long tmp = DIV_ROUND_CLOSEST_ULL(parent_rate, j);
2133
+
1843
+
2134
+            if (abs(tmp - rate) < abs(best_rate - rate)) {
1844
+            if (abs(tmp - rate) < abs(best_rate - rate)) {
2135
+                best_rate = tmp;
1845
+                best_rate = tmp;
2136
+
1846
+
2137
+                if (div_val)
1847
+                if (div_val)
...
...
2162
+             unsigned long parent_rate)
1872
+             unsigned long parent_rate)
2163
+{
1873
+{
2164
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
1874
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
2165
+    struct ccu_common *common = &mix->common;
1875
+    struct ccu_common *common = &mix->common;
2166
+    struct ccu_div_config *div = &mix->div;
1876
+    struct ccu_div_config *div = &mix->div;
2167
+    int ret = 0, tmp = 0;
1877
+    u32 current_div, target_div, mask;
2168
+    u32 current_div, target_div;
2169
+
1878
+
2170
+    ccu_mix_calc_best_rate(hw, rate, NULL, NULL, &target_div);
1879
+    ccu_mix_calc_best_rate(hw, rate, NULL, NULL, &target_div);
2171
+
1880
+
2172
+    ccu_read(ctrl, common, &tmp);
1881
+    current_div = ccu_read(common, ctrl) >> div->shift;
2173
+
2174
+    current_div = tmp >> div->shift;
2175
+    current_div &= (1 << div->width) - 1;
1882
+    current_div &= (1 << div->width) - 1;
2176
+
1883
+
2177
+    if (current_div == target_div)
1884
+    if (current_div == target_div)
2178
+        return 0;
1885
+        return 0;
2179
+
1886
+
2180
+    tmp = GENMASK(div->width + div->shift - 1, div->shift);
1887
+    mask = GENMASK(div->width + div->shift - 1, div->shift);
2181
+
1888
+
2182
+    ccu_update(ctrl, common, tmp, target_div << div->shift);
1889
+    ccu_update(common, ctrl, mask, target_div << div->shift);
2183
+
1890
+
2184
+    if (common->reg_fc)
1891
+    return ccu_mix_trigger_fc(hw);
2185
+        ret = ccu_mix_trigger_fc(hw);
2186
+
2187
+    return ret;
2188
+}
1892
+}
2189
+
1893
+
2190
+static u8 ccu_mux_get_parent(struct clk_hw *hw)
1894
+static u8 ccu_mux_get_parent(struct clk_hw *hw)
2191
+{
1895
+{
2192
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
1896
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
2193
+    struct ccu_common *common = &mix->common;
2194
+    struct ccu_mux_config *mux = &mix->mux;
1897
+    struct ccu_mux_config *mux = &mix->mux;
2195
+    u32 reg;
2196
+    u8 parent;
1898
+    u8 parent;
2197
+
1899
+
2198
+    ccu_read(ctrl, common, &reg);
1900
+    parent = ccu_read(&mix->common, ctrl) >> mux->shift;
2199
+
2200
+    parent = reg >> mux->shift;
2201
+    parent &= (1 << mux->width) - 1;
1901
+    parent &= (1 << mux->width) - 1;
2202
+
1902
+
2203
+    return parent;
1903
+    return parent;
2204
+}
1904
+}
2205
+
1905
+
2206
+static int ccu_mux_set_parent(struct clk_hw *hw, u8 index)
1906
+static int ccu_mux_set_parent(struct clk_hw *hw, u8 index)
2207
+{
1907
+{
2208
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
1908
+    struct ccu_mix *mix = hw_to_ccu_mix(hw);
2209
+    struct ccu_common *common = &mix->common;
2210
+    struct ccu_mux_config *mux = &mix->mux;
1909
+    struct ccu_mux_config *mux = &mix->mux;
2211
+    int ret = 0;
2212
+    u32 mask;
1910
+    u32 mask;
2213
+
1911
+
2214
+    mask = GENMASK(mux->width + mux->shift - 1, mux->shift);
1912
+    mask = GENMASK(mux->width + mux->shift - 1, mux->shift);
2215
+
1913
+
2216
+    ccu_update(ctrl, common, mask, index << mux->shift);
1914
+    ccu_update(&mix->common, ctrl, mask, index << mux->shift);
2217
+
1915
+
2218
+    if (common->reg_fc)
1916
+    return ccu_mix_trigger_fc(hw);
2219
+        ret = ccu_mix_trigger_fc(hw);
2220
+
2221
+    return ret;
2222
+}
1917
+}
2223
+
1918
+
2224
+const struct clk_ops spacemit_ccu_gate_ops = {
1919
+const struct clk_ops spacemit_ccu_gate_ops = {
2225
+    .disable    = ccu_gate_disable,
1920
+    .disable    = ccu_gate_disable,
2226
+    .enable        = ccu_gate_enable,
1921
+    .enable        = ccu_gate_enable,
...
...
2243
+    .determine_rate = ccu_mix_determine_rate,
1938
+    .determine_rate = ccu_mix_determine_rate,
2244
+    .recalc_rate    = ccu_div_recalc_rate,
1939
+    .recalc_rate    = ccu_div_recalc_rate,
2245
+    .set_rate    = ccu_mix_set_rate,
1940
+    .set_rate    = ccu_mix_set_rate,
2246
+};
1941
+};
2247
+
1942
+
2248
+const struct clk_ops spacemit_ccu_gate_factor_ops = {
1943
+const struct clk_ops spacemit_ccu_factor_gate_ops = {
2249
+    .disable    = ccu_gate_disable,
1944
+    .disable    = ccu_gate_disable,
2250
+    .enable        = ccu_gate_enable,
1945
+    .enable        = ccu_gate_enable,
2251
+    .is_enabled    = ccu_gate_is_enabled,
1946
+    .is_enabled    = ccu_gate_is_enabled,
2252
+
1947
+
2253
+    .round_rate    = ccu_factor_round_rate,
1948
+    .round_rate    = ccu_factor_round_rate,
...
...
2273
+    .determine_rate = ccu_mix_determine_rate,
1968
+    .determine_rate = ccu_mix_determine_rate,
2274
+    .recalc_rate    = ccu_div_recalc_rate,
1969
+    .recalc_rate    = ccu_div_recalc_rate,
2275
+    .set_rate    = ccu_mix_set_rate,
1970
+    .set_rate    = ccu_mix_set_rate,
2276
+};
1971
+};
2277
+
1972
+
2278
+const struct clk_ops spacemit_ccu_div_mux_gate_ops = {
1973
+const struct clk_ops spacemit_ccu_mux_div_gate_ops = {
2279
+    .disable    = ccu_gate_disable,
1974
+    .disable    = ccu_gate_disable,
2280
+    .enable        = ccu_gate_enable,
1975
+    .enable        = ccu_gate_enable,
2281
+    .is_enabled    = ccu_gate_is_enabled,
1976
+    .is_enabled    = ccu_gate_is_enabled,
2282
+
1977
+
2283
+    .get_parent    = ccu_mux_get_parent,
1978
+    .get_parent    = ccu_mux_get_parent,
...
...
2286
+    .determine_rate = ccu_mix_determine_rate,
1981
+    .determine_rate = ccu_mix_determine_rate,
2287
+    .recalc_rate    = ccu_div_recalc_rate,
1982
+    .recalc_rate    = ccu_div_recalc_rate,
2288
+    .set_rate    = ccu_mix_set_rate,
1983
+    .set_rate    = ccu_mix_set_rate,
2289
+};
1984
+};
2290
+
1985
+
2291
+const struct clk_ops spacemit_ccu_div_mux_ops = {
1986
+const struct clk_ops spacemit_ccu_mux_div_ops = {
2292
+    .get_parent    = ccu_mux_get_parent,
1987
+    .get_parent    = ccu_mux_get_parent,
2293
+    .set_parent    = ccu_mux_set_parent,
1988
+    .set_parent    = ccu_mux_set_parent,
2294
+
1989
+
2295
+    .determine_rate = ccu_mix_determine_rate,
1990
+    .determine_rate = ccu_mix_determine_rate,
2296
+    .recalc_rate    = ccu_div_recalc_rate,
1991
+    .recalc_rate    = ccu_div_recalc_rate,
...
...
2313
+
2008
+
2314
+#include <linux/clk-provider.h>
2009
+#include <linux/clk-provider.h>
2315
+
2010
+
2316
+#include "ccu_common.h"
2011
+#include "ccu_common.h"
2317
+
2012
+
2013
+/**
2014
+ * struct ccu_gate_config - Gate configuration
2015
+ *
2016
+ * @mask:    Mask to enable the gate. Some clocks may have more than one bit
2017
+ *        set in this field.
2018
+ */
2318
+struct ccu_gate_config {
2019
+struct ccu_gate_config {
2319
+    u32 mask;
2020
+    u32 mask;
2320
+};
2021
+};
2321
+
2022
+
2322
+struct ccu_factor_config {
2023
+struct ccu_factor_config {
...
...
2340
+    struct ccu_div_config div;
2041
+    struct ccu_div_config div;
2341
+    struct ccu_mux_config mux;
2042
+    struct ccu_mux_config mux;
2342
+    struct ccu_common common;
2043
+    struct ccu_common common;
2343
+};
2044
+};
2344
+
2045
+
2345
+#define CCU_GATE_INIT(_mask) { .mask = _mask }
2046
+#define CCU_GATE_INIT(_mask)        { .mask = _mask }
2346
+#define CCU_FACTOR_INIT(_div, _mul) { .div = _div, .mul = _mul }
2047
+#define CCU_FACTOR_INIT(_div, _mul)    { .div = _div, .mul = _mul }
2347
+#define CCU_MUX_INIT(_shift, _width) { .shift = _shift, .width = _width }
2048
+#define CCU_MUX_INIT(_shift, _width)    { .shift = _shift, .width = _width }
2348
+#define CCU_DIV_INIT(_shift, _width) { .shift = _shift, .width = _width }
2049
+#define CCU_DIV_INIT(_shift, _width)    { .shift = _shift, .width = _width }
2349
+
2050
+
2350
+#define CCU_PARENT_HW(_parent)        { .hw = &_parent.common.hw }
2051
+#define CCU_PARENT_HW(_parent)        { .hw = &_parent.common.hw }
2351
+#define CCU_PARENT_NAME(_name)        { .fw_name = #_name }
2052
+#define CCU_PARENT_NAME(_name)        { .fw_name = #_name }
2352
+
2053
+
2353
+#define CCU_MIX_INITHW(_name, _parent, _ops, _flags)            \
2054
+#define CCU_MIX_INITHW(_name, _parent, _ops, _flags)            \
2354
+    (&(struct clk_init_data) {                    \
2055
+    .hw.init = &(struct clk_init_data) {                \
2355
+        .flags        = _flags,                \
2056
+        .flags        = _flags,                \
2356
+        .name        = #_name,                \
2057
+        .name        = #_name,                \
2357
+        .parent_data    = (const struct clk_parent_data[])    \
2058
+        .parent_data    = (const struct clk_parent_data[])    \
2358
+                    { _parent },            \
2059
+                    { _parent },            \
2359
+        .num_parents    = 1,                    \
2060
+        .num_parents    = 1,                    \
2360
+        .ops        = &_ops,                \
2061
+        .ops        = &_ops,                \
2361
+    })
2062
+    }
2362
+
2063
+
2363
+#define CCU_MIX_INITHW_PARENTS(_name, _parents, _ops, _flags)        \
2064
+#define CCU_MIX_INITHW_PARENTS(_name, _parents, _ops, _flags)        \
2364
+    CLK_HW_INIT_PARENTS_DATA(#_name, _parents, &_ops, _flags)
2065
+    .hw.init = CLK_HW_INIT_PARENTS_DATA(#_name, _parents, &_ops, _flags)
2365
+
2066
+
2366
+#define CCU_GATE_DEFINE(_name, _parent, _reg, _gate_mask, _flags)        \
2067
+#define CCU_GATE_DEFINE(_name, _parent, _reg_ctrl, _mask_gate, _flags)        \
2367
+struct ccu_mix _name = {                            \
2068
+static struct ccu_mix _name = {                            \
2368
+    .gate    = CCU_GATE_INIT(_gate_mask),                    \
2069
+    .gate    = CCU_GATE_INIT(_mask_gate),                    \
2369
+    .common    = {                                \
2070
+    .common    = {                                \
2370
+        .reg_ctrl    = _reg,                        \
2071
+        .reg_ctrl    = _reg_ctrl,                    \
2371
+        .hw.init = CCU_MIX_INITHW(_name, _parent,            \
2072
+        CCU_MIX_INITHW(_name, _parent, spacemit_ccu_gate_ops, _flags),    \
2372
+                     spacemit_ccu_gate_ops, _flags),    \
2373
+    }                                    \
2073
+    }                                    \
2374
+}
2074
+}
2375
+
2075
+
2376
+#define CCU_FACTOR_DEFINE(_name, _parent, _div, _mul)                \
2076
+#define CCU_FACTOR_DEFINE(_name, _parent, _div, _mul)                \
2377
+struct ccu_mix _name = {                            \
2077
+static struct ccu_mix _name = {                            \
2378
+    .factor    = CCU_FACTOR_INIT(_div, _mul),                    \
2078
+    .factor    = CCU_FACTOR_INIT(_div, _mul),                    \
2379
+    .common = {                                \
2079
+    .common = {                                \
2380
+        .hw.init = CCU_MIX_INITHW(_name, _parent,            \
2080
+        CCU_MIX_INITHW(_name, _parent, spacemit_ccu_factor_ops, 0),    \
2381
+                     spacemit_ccu_factor_ops, 0),        \
2382
+    }                                    \
2081
+    }                                    \
2383
+}
2082
+}
2384
+
2083
+
2385
+#define CCU_MUX_DEFINE(_name, _parents, _reg, _shift, _width, _flags)        \
2084
+#define CCU_MUX_DEFINE(_name, _parents, _reg_ctrl, _shift, _width, _flags)    \
2386
+struct ccu_mix _name = {                            \
2085
+static struct ccu_mix _name = {                            \
2387
+    .mux    = CCU_MUX_INIT(_shift, _width),                    \
2086
+    .mux    = CCU_MUX_INIT(_shift, _width),                    \
2388
+    .common = {                                \
2087
+    .common = {                                \
2389
+        .reg_ctrl    = _reg,                        \
2088
+        .reg_ctrl    = _reg_ctrl,                    \
2390
+        .hw.init = CCU_MIX_INITHW_PARENTS(_name, _parents,        \
2089
+        CCU_MIX_INITHW_PARENTS(_name, _parents, spacemit_ccu_mux_ops,    \
2391
+                         spacemit_ccu_mux_ops,    _flags),\
2090
+                 _flags),                    \
2392
+    }                                    \
2091
+    }                                    \
2393
+}
2092
+}
2394
+
2093
+
2395
+#define CCU_DIV_DEFINE(_name, _parent, _reg, _shift, _width, _flags)        \
2094
+#define CCU_DIV_DEFINE(_name, _parent, _reg_ctrl, _shift, _width, _flags)    \
2396
+struct ccu_mix _name = {                            \
2095
+static struct ccu_mix _name = {                            \
2397
+    .div    = CCU_DIV_INIT(_shift, _width),                    \
2096
+    .div    = CCU_DIV_INIT(_shift, _width),                    \
2398
+    .common = {                                \
2097
+    .common = {                                \
2399
+        .reg_ctrl    = _reg,                        \
2098
+        .reg_ctrl    = _reg_ctrl,                    \
2400
+        .hw.init = CCU_MIX_INITHW(_name, _parent,            \
2099
+        CCU_MIX_INITHW(_name, _parent, spacemit_ccu_div_ops, _flags)    \
2401
+                     spacemit_ccu_div_ops, _flags)        \
2402
+    }                                    \
2100
+    }                                    \
2403
+}
2101
+}
2404
+
2102
+
2405
+#define CCU_GATE_FACTOR_DEFINE(_name, _parent,                    \
2103
+#define CCU_FACTOR_GATE_DEFINE(_name, _parent, _reg_ctrl, _mask_gate, _div,    \
2406
+             _reg,                        \
2104
+             _mul)                        \
2407
+             _gate_mask,                    \
2105
+static struct ccu_mix _name = {                            \
2408
+             _div, _mul,                    \
2106
+    .gate    = CCU_GATE_INIT(_mask_gate),                    \
2409
+             _flags)                        \
2410
+struct ccu_mix _name = {                            \
2411
+    .gate    = CCU_GATE_INIT(_gate_mask),                    \
2412
+    .factor    = CCU_FACTOR_INIT(_div, _mul),                    \
2107
+    .factor    = CCU_FACTOR_INIT(_div, _mul),                    \
2413
+    .common = {                                \
2108
+    .common = {                                \
2414
+        .reg_ctrl    = _reg,                        \
2109
+        .reg_ctrl    = _reg_ctrl,                    \
2415
+        .hw.init = CCU_MIX_INITHW(_name, _parent,            \
2110
+        CCU_MIX_INITHW(_name, _parent, spacemit_ccu_factor_gate_ops, 0)    \
2416
+                     spacemit_ccu_gate_factor_ops, _flags)    \
2417
+    }                                    \
2111
+    }                                    \
2418
+}
2112
+}
2419
+
2113
+
2420
+#define CCU_MUX_GATE_DEFINE(_name, _parents,                    \
2114
+#define CCU_MUX_GATE_DEFINE(_name, _parents, _reg_ctrl, _shift, _width,        \
2421
+             _reg,                        \
2115
+             _mask_gate, _flags)                    \
2422
+             _shift, _width,                    \
2116
+static struct ccu_mix _name = {                            \
2423
+             _gate_mask,                        \
2117
+    .gate    = CCU_GATE_INIT(_mask_gate),                    \
2424
+             _flags)                        \
2425
+struct ccu_mix _name = {                            \
2426
+    .gate    = CCU_GATE_INIT(_gate_mask),                    \
2427
+    .mux    = CCU_MUX_INIT(_shift, _width),                    \
2118
+    .mux    = CCU_MUX_INIT(_shift, _width),                    \
2428
+    .common = {                                \
2119
+    .common = {                                \
2429
+        .reg_ctrl    = _reg,                        \
2120
+        .reg_ctrl    = _reg_ctrl,                    \
2430
+        .hw.init = CCU_MIX_INITHW_PARENTS(_name, _parents,        \
2121
+        CCU_MIX_INITHW_PARENTS(_name, _parents,                \
2431
+                         spacemit_ccu_mux_gate_ops,    \
2122
+                 spacemit_ccu_mux_gate_ops, _flags),    \
2432
+                         _flags),            \
2433
+    }                                    \
2123
+    }                                    \
2434
+}
2124
+}
2435
+
2125
+
2436
+#define CCU_DIV_GATE_DEFINE(_name, _parent,                    \
2126
+#define CCU_DIV_GATE_DEFINE(_name, _parent, _reg_ctrl, _shift, _width,        \
2437
+             _reg,                        \
2127
+             _mask_gate,    _flags)                    \
2438
+             _shift, _width,                    \
2128
+static struct ccu_mix _name = {                            \
2439
+             _gate_mask,                        \
2129
+    .gate    = CCU_GATE_INIT(_mask_gate),                    \
2440
+             _flags)                        \
2441
+struct ccu_mix _name = {                            \
2442
+    .gate    = CCU_GATE_INIT(_gate_mask),                    \
2443
+    .div    = CCU_DIV_INIT(_shift, _width),                    \
2130
+    .div    = CCU_DIV_INIT(_shift, _width),                    \
2444
+    .common = {                                \
2131
+    .common = {                                \
2445
+        .reg_ctrl    = _reg,                        \
2132
+        .reg_ctrl    = _reg_ctrl,                    \
2446
+        .hw.init = CCU_MIX_INITHW(_name, _parent,            \
2133
+        CCU_MIX_INITHW(_name, _parent, spacemit_ccu_div_gate_ops,    \
2447
+                     spacemit_ccu_div_gate_ops, _flags),    \
2134
+             _flags),                        \
2448
+    }                                    \
2135
+    }                                    \
2449
+}
2136
+}
2450
+
2137
+
2451
+#define CCU_DIV_MUX_GATE_DEFINE(_name, _parents,                \
2138
+#define CCU_MUX_DIV_GATE_DEFINE(_name, _parents, _reg_ctrl, _mshift, _mwidth,    \
2452
+                _reg_ctrl,                    \
2139
+                 _muxshift, _muxwidth, _mask_gate, _flags)    \
2453
+                _mshift, _mwidth, _muxshift, _muxwidth,        \
2140
+static struct ccu_mix _name = {                            \
2454
+                _gate_mask,                    \
2141
+    .gate    = CCU_GATE_INIT(_mask_gate),                    \
2455
+                _flags)                        \
2456
+struct ccu_mix _name = {                            \
2457
+    .gate    = CCU_GATE_INIT(_gate_mask),                    \
2458
+    .div    = CCU_DIV_INIT(_mshift, _mwidth),                \
2142
+    .div    = CCU_DIV_INIT(_mshift, _mwidth),                \
2459
+    .mux    = CCU_MUX_INIT(_muxshift, _muxwidth),                \
2143
+    .mux    = CCU_MUX_INIT(_muxshift, _muxwidth),                \
2460
+    .common    = {                                \
2144
+    .common    = {                                \
2461
+        .reg_ctrl    = _reg_ctrl,                    \
2145
+        .reg_ctrl    = _reg_ctrl,                    \
2462
+        .hw.init = CCU_MIX_INITHW_PARENTS(_name, _parents,        \
2146
+        CCU_MIX_INITHW_PARENTS(_name, _parents,                \
2463
+                         spacemit_ccu_div_mux_gate_ops,\
2147
+                 spacemit_ccu_mux_div_gate_ops, _flags),    \
2464
+                         _flags),            \
2465
+    },                                    \
2148
+    },                                    \
2466
+}
2149
+}
2467
+
2150
+
2468
+#define CCU_DIV_SPLIT_FC_MUX_GATE_DEFINE(_name, _parents,            \
2151
+#define CCU_MUX_DIV_GATE_SPLIT_FC_DEFINE(_name, _parents, _reg_ctrl, _reg_fc,    \
2469
+                     _reg_ctrl, _reg_fc,            \
2152
+                     _mshift, _mwidth, _mask_fc, _muxshift,    \
2470
+                     _mshift, _mwidth,            \
2153
+                     _muxwidth, _mask_gate, _flags)        \
2471
+                     _fc,                    \
2154
+static struct ccu_mix _name = {                            \
2472
+                     _muxshift, _muxwidth,            \
2155
+    .gate    = CCU_GATE_INIT(_mask_gate),                    \
2473
+                     _gate_mask,                \
2474
+                     _flags)                \
2475
+struct ccu_mix _name = {                            \
2476
+    .gate    = CCU_GATE_INIT(_gate_mask),                    \
2477
+    .div    = CCU_DIV_INIT(_mshift, _mwidth),                \
2156
+    .div    = CCU_DIV_INIT(_mshift, _mwidth),                \
2478
+    .mux    = CCU_MUX_INIT(_muxshift, _muxwidth),                \
2157
+    .mux    = CCU_MUX_INIT(_muxshift, _muxwidth),                \
2479
+    .common = {                                \
2158
+    .common = {                                \
2480
+        .reg_ctrl    = _reg_ctrl,                    \
2159
+        .reg_ctrl    = _reg_ctrl,                    \
2481
+        .reg_fc        = _reg_fc,                    \
2160
+        .reg_fc        = _reg_fc,                    \
2482
+        .fc        = _fc,                        \
2161
+        .mask_fc    = _mask_fc,                    \
2483
+        .hw.init = CCU_MIX_INITHW_PARENTS(_name, _parents,        \
2162
+        CCU_MIX_INITHW_PARENTS(_name, _parents,                \
2484
+                         spacemit_ccu_div_mux_gate_ops,\
2163
+                 spacemit_ccu_mux_div_gate_ops, _flags),    \
2485
+                         _flags),            \
2486
+    },                                    \
2164
+    },                                    \
2487
+}
2165
+}
2488
+
2166
+
2489
+#define CCU_DIV_FC_MUX_GATE_DEFINE(_name, _parents,                \
2167
+#define CCU_MUX_DIV_GATE_FC_DEFINE(_name, _parents, _reg_ctrl, _mshift, _mwidth,\
2490
+                 _reg_ctrl,                    \
2168
+                 _mask_fc, _muxshift, _muxwidth, _mask_gate,    \
2491
+                 _mshift, _mwidth,                \
2169
+                 _flags)                    \
2492
+                 _fc,                        \
2170
+CCU_MUX_DIV_GATE_SPLIT_FC_DEFINE(_name, _parents, _reg_ctrl, _reg_ctrl, _mshift,\
2493
+                 _muxshift, _muxwidth,            \
2171
+                 _mwidth, _mask_fc, _muxshift, _muxwidth,    \
2494
+                 _gate_mask, _flags)        \
2172
+                 _mask_gate, _flags)
2495
+CCU_DIV_SPLIT_FC_MUX_GATE_DEFINE(_name, _parents, _reg_ctrl, _reg_ctrl,        \
2173
+
2496
+                 _mshift, _mwidth, _fc, _muxshift, _muxwidth,        \
2174
+#define CCU_MUX_DIV_FC_DEFINE(_name, _parents, _reg_ctrl, _mshift, _mwidth,    \
2497
+                 _gate_mask, _flags)
2175
+             _mask_fc, _muxshift, _muxwidth, _flags)        \
2498
+
2176
+static struct ccu_mix _name = {                            \
2499
+#define CCU_DIV_FC_MUX_DEFINE(_name, _parents,                    \
2500
+             _reg_ctrl,                    \
2501
+             _mshift, _mwidth,                    \
2502
+             _fc,                        \
2503
+             _muxshift, _muxwidth,                \
2504
+             _flags)                        \
2505
+struct ccu_mix _name = {                            \
2506
+    .div    = CCU_DIV_INIT(_mshift, _mwidth),                \
2177
+    .div    = CCU_DIV_INIT(_mshift, _mwidth),                \
2507
+    .mux    = CCU_MUX_INIT(_muxshift, _muxwidth),                \
2178
+    .mux    = CCU_MUX_INIT(_muxshift, _muxwidth),                \
2508
+    .common = {                                \
2179
+    .common = {                                \
2509
+        .reg_ctrl    = _reg_ctrl,                    \
2180
+        .reg_ctrl    = _reg_ctrl,                    \
2510
+        .reg_fc        = _reg_ctrl,                    \
2181
+        .reg_fc        = _reg_ctrl,                    \
2511
+        .fc        = _fc,                        \
2182
+        .mask_fc    = _mask_fc,                    \
2512
+        .hw.init = CCU_MIX_INITHW_PARENTS(_name, _parents,        \
2183
+        CCU_MIX_INITHW_PARENTS(_name, _parents,                \
2513
+                         spacemit_ccu_div_mux_ops,    \
2184
+                 spacemit_ccu_mux_div_ops, _flags),    \
2514
+                         _flags),            \
2515
+    },                                    \
2185
+    },                                    \
2516
+}
2186
+}
2517
+
2187
+
2518
+#define CCU_MUX_FC_DEFINE(_name, _parents,                    \
2188
+#define CCU_MUX_FC_DEFINE(_name, _parents, _reg_ctrl, _mask_fc,    _muxshift,    \
2519
+             _reg_ctrl,                        \
2189
+             _muxwidth, _flags)                    \
2520
+             _fc,                            \
2190
+static struct ccu_mix _name = {                            \
2521
+             _muxshift, _muxwidth,                    \
2522
+             _flags)                        \
2523
+struct ccu_mix _name = {                            \
2524
+    .mux    = CCU_MUX_INIT(_muxshift, _muxwidth),                \
2191
+    .mux    = CCU_MUX_INIT(_muxshift, _muxwidth),                \
2525
+    .common = {                                \
2192
+    .common = {                                \
2526
+        .reg_ctrl    = _reg_ctrl,                    \
2193
+        .reg_ctrl    = _reg_ctrl,                    \
2527
+        .reg_fc        = _reg_ctrl,                    \
2194
+        .reg_fc        = _reg_ctrl,                    \
2528
+        .fc        = _fc,                        \
2195
+        .mask_fc    = _mask_fc,                    \
2529
+        .hw.init = CCU_MIX_INITHW_PARENTS(_name, _parents,        \
2196
+        CCU_MIX_INITHW_PARENTS(_name, _parents, spacemit_ccu_mux_ops,    \
2530
+                         spacemit_ccu_mux_ops,    _flags)    \
2197
+                 _flags)                    \
2531
+    },                                    \
2198
+    },                                    \
2532
+}
2199
+}
2533
+
2200
+
2534
+static inline struct ccu_mix *hw_to_ccu_mix(struct clk_hw *hw)
2201
+static inline struct ccu_mix *hw_to_ccu_mix(struct clk_hw *hw)
2535
+{
2202
+{
2536
+    struct ccu_common *common = hw_to_ccu_common(hw);
2203
+    struct ccu_common *common = hw_to_ccu_common(hw);
2537
+
2204
+
2538
+    return container_of(common, struct ccu_mix, common);
2205
+    return container_of(common, struct ccu_mix, common);
2539
+}
2206
+}
2540
+
2207
+
2541
+extern const struct clk_ops spacemit_ccu_gate_ops, spacemit_ccu_factor_ops;
2208
+extern const struct clk_ops spacemit_ccu_gate_ops;
2542
+extern const struct clk_ops spacemit_ccu_mux_ops, spacemit_ccu_div_ops;
2209
+extern const struct clk_ops spacemit_ccu_factor_ops;
2543
+
2210
+extern const struct clk_ops spacemit_ccu_mux_ops;
2544
+extern const struct clk_ops spacemit_ccu_gate_factor_ops;
2211
+extern const struct clk_ops spacemit_ccu_div_ops;
2212
+extern const struct clk_ops spacemit_ccu_factor_gate_ops;
2545
+extern const struct clk_ops spacemit_ccu_div_gate_ops;
2213
+extern const struct clk_ops spacemit_ccu_div_gate_ops;
2546
+extern const struct clk_ops spacemit_ccu_mux_gate_ops;
2214
+extern const struct clk_ops spacemit_ccu_mux_gate_ops;
2547
+extern const struct clk_ops spacemit_ccu_div_mux_ops;
2215
+extern const struct clk_ops spacemit_ccu_mux_div_ops;
2548
+
2216
+extern const struct clk_ops spacemit_ccu_mux_div_gate_ops;
2549
+extern const struct clk_ops spacemit_ccu_div_mux_gate_ops;
2550
+#endif /* _CCU_DIV_H_ */
2217
+#endif /* _CCU_DIV_H_ */
2551
diff --git a/drivers/clk/spacemit/ccu_pll.c b/drivers/clk/spacemit/ccu_pll.c
2218
diff --git a/drivers/clk/spacemit/ccu_pll.c b/drivers/clk/spacemit/ccu_pll.c
2552
new file mode 100644
2219
new file mode 100644
2553
index XXXXXXX..XXXXXXX
2220
index XXXXXXX..XXXXXXX
2554
--- /dev/null
2221
--- /dev/null
2555
+++ b/drivers/clk/spacemit/ccu_pll.c
2222
+++ b/drivers/clk/spacemit/ccu_pll.c
2556
@@ -XXX,XX +XXX,XX @@
2223
@@ -XXX,XX +XXX,XX @@
2557
+// SPDX-License-Identifier: GPL-2.0-only
2224
+// SPDX-License-Identifier: GPL-2.0-only
2558
+/*
2225
+/*
2559
+ * Spacemit clock type pll
2560
+ *
2561
+ * Copyright (c) 2024 SpacemiT Technology Co. Ltd
2226
+ * Copyright (c) 2024 SpacemiT Technology Co. Ltd
2562
+ * Copyright (c) 2024 Haylen Chu <heylenay@4d2.org>
2227
+ * Copyright (c) 2024 Haylen Chu <heylenay@4d2.org>
2563
+ */
2228
+ */
2564
+
2229
+
2565
+#include <linux/clk-provider.h>
2230
+#include <linux/clk-provider.h>
2231
+#include <linux/math.h>
2566
+#include <linux/regmap.h>
2232
+#include <linux/regmap.h>
2567
+
2233
+
2568
+#include "ccu_common.h"
2234
+#include "ccu_common.h"
2569
+#include "ccu_pll.h"
2235
+#include "ccu_pll.h"
2570
+
2236
+
2571
+#define PLL_DELAY_TIME    3000
2237
+#define PLL_TIMEOUT_US        3000
2572
+
2238
+#define PLL_DELAY_US        5
2573
+#define PLL_SWCR3_EN    BIT(31)
2239
+
2240
+#define PLL_SWCR3_EN        ((u32)BIT(31))
2241
+#define PLL_SWCR3_MASK        GENMASK(30, 0)
2242
+
2243
+static const struct ccu_pll_rate_tbl *ccu_pll_lookup_best_rate(struct ccu_pll *pll,
2244
+                             unsigned long rate)
2245
+{
2246
+    struct ccu_pll_config *config = &pll->config;
2247
+    const struct ccu_pll_rate_tbl *best_entry;
2248
+    unsigned long best_delta = ULONG_MAX;
2249
+    int i;
2250
+
2251
+    for (i = 0; i < config->tbl_num; i++) {
2252
+        const struct ccu_pll_rate_tbl *entry = &config->rate_tbl[i];
2253
+        unsigned long delta = abs_diff(entry->rate, rate);
2254
+
2255
+        if (delta < best_delta) {
2256
+            best_delta = delta;
2257
+            best_entry = entry;
2258
+        }
2259
+    }
2260
+
2261
+    return best_entry;
2262
+}
2263
+
2264
+static const struct ccu_pll_rate_tbl *ccu_pll_lookup_matched_entry(struct ccu_pll *pll)
2265
+{
2266
+    struct ccu_pll_config *config = &pll->config;
2267
+    u32 swcr1, swcr3;
2268
+    int i;
2269
+
2270
+    swcr1 = ccu_read(&pll->common, swcr1);
2271
+    swcr3 = ccu_read(&pll->common, swcr3);
2272
+    swcr3 &= PLL_SWCR3_MASK;
2273
+
2274
+    for (i = 0; i < config->tbl_num; i++) {
2275
+        const struct ccu_pll_rate_tbl *entry = &config->rate_tbl[i];
2276
+
2277
+        if (swcr1 == entry->swcr1 && swcr3 == entry->swcr3)
2278
+            return entry;
2279
+    }
2280
+
2281
+    return NULL;
2282
+}
2283
+
2284
+static void ccu_pll_update_param(struct ccu_pll *pll, const struct ccu_pll_rate_tbl *entry)
2285
+{
2286
+    struct ccu_common *common = &pll->common;
2287
+
2288
+    regmap_write(common->regmap, common->reg_swcr1, entry->swcr1);
2289
+    ccu_update(common, swcr3, PLL_SWCR3_MASK, entry->swcr3);
2290
+}
2574
+
2291
+
2575
+static int ccu_pll_is_enabled(struct clk_hw *hw)
2292
+static int ccu_pll_is_enabled(struct clk_hw *hw)
2576
+{
2293
+{
2577
+    struct ccu_pll *p = hw_to_ccu_pll(hw);
2294
+    struct ccu_common *common = hw_to_ccu_common(hw);
2578
+    u32 tmp;
2295
+
2579
+
2296
+    return ccu_read(common, swcr3) & PLL_SWCR3_EN;
2580
+    ccu_read(swcr3, &p->common, &tmp);
2581
+
2582
+    return tmp & PLL_SWCR3_EN;
2583
+}
2584
+
2585
+/* frequency unit Mhz, return pll vco freq */
2586
+static unsigned long ccu_pll_get_vco_freq(struct clk_hw *hw)
2587
+{
2588
+    const struct ccu_pll_rate_tbl *pll_rate_table;
2589
+    struct ccu_pll *p = hw_to_ccu_pll(hw);
2590
+    struct ccu_common *common = &p->common;
2591
+    u32 swcr1, swcr3, size;
2592
+    int i;
2593
+
2594
+    ccu_read(swcr1, common, &swcr1);
2595
+    ccu_read(swcr3, common, &swcr3);
2596
+    swcr3 &= ~PLL_SWCR3_EN;
2597
+
2598
+    pll_rate_table = p->pll.rate_tbl;
2599
+    size = p->pll.tbl_size;
2600
+
2601
+    for (i = 0; i < size; i++) {
2602
+        if (pll_rate_table[i].swcr1 == swcr1 &&
2603
+         pll_rate_table[i].swcr3 == swcr3)
2604
+            return pll_rate_table[i].rate;
2605
+    }
2606
+
2607
+    WARN_ON_ONCE(1);
2608
+
2609
+    return 0;
2610
+}
2297
+}
2611
+
2298
+
2612
+static int ccu_pll_enable(struct clk_hw *hw)
2299
+static int ccu_pll_enable(struct clk_hw *hw)
2613
+{
2300
+{
2614
+    struct ccu_pll *p = hw_to_ccu_pll(hw);
2301
+    struct ccu_pll *pll = hw_to_ccu_pll(hw);
2615
+    struct ccu_common *common = &p->common;
2302
+    struct ccu_common *common = &pll->common;
2616
+    unsigned int tmp;
2303
+    unsigned int tmp;
2617
+    int ret;
2304
+
2618
+
2305
+    ccu_update(common, swcr3, PLL_SWCR3_EN, PLL_SWCR3_EN);
2619
+    if (ccu_pll_is_enabled(hw))
2620
+        return 0;
2621
+
2622
+    ccu_update(swcr3, common, PLL_SWCR3_EN, PLL_SWCR3_EN);
2623
+
2306
+
2624
+    /* check lock status */
2307
+    /* check lock status */
2625
+    ret = regmap_read_poll_timeout_atomic(common->lock_regmap,
2308
+    return regmap_read_poll_timeout_atomic(common->lock_regmap,
2626
+                     p->pll.reg_lock,
2309
+                     pll->config.reg_lock,
2627
+                     tmp,
2310
+                     tmp,
2628
+                     tmp & p->pll.lock_enable_bit,
2311
+                     tmp & pll->config.mask_lock,
2629
+                     5, PLL_DELAY_TIME);
2312
+                     PLL_DELAY_US, PLL_TIMEOUT_US);
2630
+
2631
+    return ret;
2632
+}
2313
+}
2633
+
2314
+
2634
+static void ccu_pll_disable(struct clk_hw *hw)
2315
+static void ccu_pll_disable(struct clk_hw *hw)
2635
+{
2316
+{
2636
+    struct ccu_pll *p = hw_to_ccu_pll(hw);
2317
+    struct ccu_common *common = hw_to_ccu_common(hw);
2637
+    struct ccu_common *common = &p->common;
2318
+
2638
+
2319
+    ccu_update(common, swcr3, PLL_SWCR3_EN, 0);
2639
+    ccu_update(swcr3, common, PLL_SWCR3_EN, 0);
2640
+}
2320
+}
2641
+
2321
+
2642
+/*
2322
+/*
2643
+ * PLLs must be gated before changing rate, which is ensured by
2323
+ * PLLs must be gated before changing rate, which is ensured by
2644
+ * flag CLK_SET_RATE_GATE.
2324
+ * flag CLK_SET_RATE_GATE.
2645
+ */
2325
+ */
2646
+static int ccu_pll_set_rate(struct clk_hw *hw, unsigned long rate,
2326
+static int ccu_pll_set_rate(struct clk_hw *hw, unsigned long rate,
2647
+             unsigned long parent_rate)
2327
+             unsigned long parent_rate)
2648
+{
2328
+{
2649
+    struct ccu_pll *p = hw_to_ccu_pll(hw);
2329
+    struct ccu_pll *pll = hw_to_ccu_pll(hw);
2650
+    struct ccu_common *common = &p->common;
2330
+    const struct ccu_pll_rate_tbl *entry;
2651
+    struct ccu_pll_config *params = &p->pll;
2331
+
2652
+    const struct ccu_pll_rate_tbl *entry = NULL;
2332
+    entry = ccu_pll_lookup_best_rate(pll, rate);
2653
+    int i;
2333
+    ccu_pll_update_param(pll, entry);
2654
+
2655
+    for (i = 0; i < params->tbl_size; i++) {
2656
+        if (rate == params->rate_tbl[i].rate) {
2657
+            entry = &params->rate_tbl[i];
2658
+            break;
2659
+        }
2660
+    }
2661
+
2662
+    if (WARN_ON_ONCE(!entry))
2663
+        return -EINVAL;
2664
+
2665
+    ccu_update(swcr1, common, entry->swcr1, entry->swcr1);
2666
+    ccu_update(swcr3, common, (u32)~PLL_SWCR3_EN, entry->swcr3);
2667
+
2334
+
2668
+    return 0;
2335
+    return 0;
2669
+}
2336
+}
2670
+
2337
+
2671
+static unsigned long ccu_pll_recalc_rate(struct clk_hw *hw,
2338
+static unsigned long ccu_pll_recalc_rate(struct clk_hw *hw,
2672
+                     unsigned long parent_rate)
2339
+                     unsigned long parent_rate)
2673
+{
2340
+{
2674
+    return ccu_pll_get_vco_freq(hw);
2341
+    struct ccu_pll *pll = hw_to_ccu_pll(hw);
2342
+    const struct ccu_pll_rate_tbl *entry;
2343
+
2344
+    entry = ccu_pll_lookup_matched_entry(pll);
2345
+
2346
+    WARN_ON_ONCE(!entry);
2347
+
2348
+    return entry ? entry->rate : -EINVAL;
2675
+}
2349
+}
2676
+
2350
+
2677
+static long ccu_pll_round_rate(struct clk_hw *hw, unsigned long rate,
2351
+static long ccu_pll_round_rate(struct clk_hw *hw, unsigned long rate,
2678
+             unsigned long *prate)
2352
+             unsigned long *prate)
2679
+{
2353
+{
2680
+    struct ccu_pll *p = hw_to_ccu_pll(hw);
2354
+    struct ccu_pll *pll = hw_to_ccu_pll(hw);
2681
+    struct ccu_pll_config *params = &p->pll;
2355
+
2682
+    unsigned int i;
2356
+    return ccu_pll_lookup_best_rate(pll, rate)->rate;
2683
+
2357
+}
2684
+    for (i = 0; i < params->tbl_size; i++) {
2358
+
2685
+        if (params->rate_tbl[i].rate > rate) {
2359
+static int ccu_pll_init(struct clk_hw *hw)
2686
+            i--;
2360
+{
2687
+            break;
2361
+    struct ccu_pll *pll = hw_to_ccu_pll(hw);
2688
+        }
2362
+
2689
+    }
2363
+    if (ccu_pll_lookup_matched_entry(pll))
2690
+
2364
+        return 0;
2691
+    return rate;
2365
+
2366
+    ccu_pll_disable(hw);
2367
+    ccu_pll_update_param(pll, &pll->config.rate_tbl[0]);
2368
+
2369
+    return 0;
2692
+}
2370
+}
2693
+
2371
+
2694
+const struct clk_ops spacemit_ccu_pll_ops = {
2372
+const struct clk_ops spacemit_ccu_pll_ops = {
2373
+    .init        = ccu_pll_init,
2695
+    .enable        = ccu_pll_enable,
2374
+    .enable        = ccu_pll_enable,
2696
+    .disable    = ccu_pll_disable,
2375
+    .disable    = ccu_pll_disable,
2697
+    .set_rate    = ccu_pll_set_rate,
2376
+    .set_rate    = ccu_pll_set_rate,
2698
+    .recalc_rate    = ccu_pll_recalc_rate,
2377
+    .recalc_rate    = ccu_pll_recalc_rate,
2699
+    .round_rate    = ccu_pll_round_rate,
2378
+    .round_rate    = ccu_pll_round_rate,
2700
+    .is_enabled    = ccu_pll_is_enabled,
2379
+    .is_enabled    = ccu_pll_is_enabled,
2701
+};
2380
+};
2702
+
2703
diff --git a/drivers/clk/spacemit/ccu_pll.h b/drivers/clk/spacemit/ccu_pll.h
2381
diff --git a/drivers/clk/spacemit/ccu_pll.h b/drivers/clk/spacemit/ccu_pll.h
2704
new file mode 100644
2382
new file mode 100644
2705
index XXXXXXX..XXXXXXX
2383
index XXXXXXX..XXXXXXX
2706
--- /dev/null
2384
--- /dev/null
2707
+++ b/drivers/clk/spacemit/ccu_pll.h
2385
+++ b/drivers/clk/spacemit/ccu_pll.h
...
...
2717
+
2395
+
2718
+#include <linux/clk-provider.h>
2396
+#include <linux/clk-provider.h>
2719
+
2397
+
2720
+#include "ccu_common.h"
2398
+#include "ccu_common.h"
2721
+
2399
+
2400
+/**
2401
+ * struct ccu_pll_rate_tbl - Structure mapping between PLL rate and register
2402
+ * configuration.
2403
+ *
2404
+ * @rate:    PLL rate
2405
+ * @swcr1:    Register value of PLLX_SW1_CTRL (PLLx_SWCR1).
2406
+ * @swcr3:    Register value of the PLLx_SW3_CTRL's lowest 31 bits of
2407
+ *        PLLx_SW3_CTRL (PLLx_SWCR3). This highest bit is for enabling
2408
+ *        the PLL and not contained in this field.
2409
+ */
2722
+struct ccu_pll_rate_tbl {
2410
+struct ccu_pll_rate_tbl {
2723
+    unsigned long rate;
2411
+    unsigned long rate;
2724
+    u32 swcr1;
2412
+    u32 swcr1;
2725
+    u32 swcr3;
2413
+    u32 swcr3;
2726
+};
2414
+};
2727
+
2415
+
2728
+struct ccu_pll_config {
2416
+struct ccu_pll_config {
2729
+    const struct ccu_pll_rate_tbl *rate_tbl;
2417
+    const struct ccu_pll_rate_tbl *rate_tbl;
2730
+    u32 tbl_size;
2418
+    u32 tbl_num;
2731
+    u32 reg_lock;
2419
+    u32 reg_lock;
2732
+    u32 lock_enable_bit;
2420
+    u32 mask_lock;
2733
+};
2421
+};
2734
+
2422
+
2735
+#define CCU_PLL_RATE(_rate, _swcr1, _swcr3) \
2423
+#define CCU_PLL_RATE(_rate, _swcr1, _swcr3) \
2736
+    {                                    \
2424
+    {                                    \
2737
+        .rate    = _rate,                            \
2425
+        .rate    = _rate,                            \
2738
+        .swcr1    = _swcr1,                        \
2426
+        .swcr1    = _swcr1,                        \
2739
+        .swcr3    = _swcr3,                        \
2427
+        .swcr3    = _swcr3,                        \
2740
+    }
2428
+    }
2741
+
2429
+
2742
+struct ccu_pll {
2430
+struct ccu_pll {
2743
+    struct ccu_pll_config    pll;
2744
+    struct ccu_common    common;
2431
+    struct ccu_common    common;
2745
+};
2432
+    struct ccu_pll_config    config;
2746
+
2433
+};
2747
+#define CCU_PLL_CONFIG(_table, _reg_lock, _lock_enable_bit) \
2434
+
2435
+#define CCU_PLL_CONFIG(_table, _reg_lock, _mask_lock) \
2748
+    {                                    \
2436
+    {                                    \
2749
+        .rate_tbl     = _table,                    \
2437
+        .rate_tbl    = _table,                    \
2750
+        .tbl_size     = ARRAY_SIZE(_table),                \
2438
+        .tbl_num    = ARRAY_SIZE(_table),                \
2751
+        .reg_lock     = (_reg_lock),                    \
2439
+        .reg_lock    = (_reg_lock),                    \
2752
+        .lock_enable_bit = (_lock_enable_bit),                \
2440
+        .mask_lock    = (_mask_lock),                    \
2753
+    }
2441
+    }
2754
+
2442
+
2755
+#define CCU_PLL_HWINIT(_name, _flags)                        \
2443
+#define CCU_PLL_HWINIT(_name, _flags)                        \
2756
+    (&(struct clk_init_data) {                        \
2444
+    (&(struct clk_init_data) {                        \
2757
+        .name        = #_name,                    \
2445
+        .name        = #_name,                    \
2758
+        .ops        = &spacemit_ccu_pll_ops,            \
2446
+        .ops        = &spacemit_ccu_pll_ops,            \
2759
+        .parent_data    = &(struct clk_parent_data) { .index = 0 },    \
2447
+        .parent_data    = &(struct clk_parent_data) { .index = 0 },    \
2760
+        .num_parents    = 1,                        \
2448
+        .num_parents    = 1,                        \
2761
+        .flags        = _flags,                    \
2449
+        .flags        = _flags,                    \
2762
+    })
2450
+    })
2763
+
2451
+
2764
+#define CCU_PLL_DEFINE(_name, _table, _reg_swcr1, _reg_swcr3,            \
2452
+#define CCU_PLL_DEFINE(_name, _table, _reg_swcr1, _reg_swcr3, _reg_lock,    \
2765
+         _reg_lock, _lock_enable_bit, _flags)            \
2453
+         _mask_lock, _flags)                    \
2766
+    struct ccu_pll _name = {                        \
2454
+static struct ccu_pll _name = {                            \
2767
+        .pll    = CCU_PLL_CONFIG(_table, _reg_lock, _lock_enable_bit),    \
2455
+    .config    = CCU_PLL_CONFIG(_table, _reg_lock, _mask_lock),        \
2768
+        .common = {                            \
2456
+    .common = {                                \
2769
+            .reg_swcr1    = _reg_swcr1,                \
2457
+        .reg_swcr1    = _reg_swcr1,                    \
2770
+            .reg_swcr3    = _reg_swcr3,                \
2458
+        .reg_swcr3    = _reg_swcr3,                    \
2771
+            .hw.init    = CCU_PLL_HWINIT(_name, _flags)        \
2459
+        .hw.init    = CCU_PLL_HWINIT(_name, _flags)            \
2772
+        }                                \
2460
+    }                                    \
2773
+    }
2461
+}
2774
+
2462
+
2775
+static inline struct ccu_pll *hw_to_ccu_pll(struct clk_hw *hw)
2463
+static inline struct ccu_pll *hw_to_ccu_pll(struct clk_hw *hw)
2776
+{
2464
+{
2777
+    struct ccu_common *common = hw_to_ccu_common(hw);
2465
+    struct ccu_common *common = hw_to_ccu_common(hw);
2778
+
2466
+
...
...
2781
+
2469
+
2782
+extern const struct clk_ops spacemit_ccu_pll_ops;
2470
+extern const struct clk_ops spacemit_ccu_pll_ops;
2783
+
2471
+
2784
+#endif
2472
+#endif
2785
--
2473
--
2786
2.48.1
2474
2.49.0
diff view generated by jsdifflib
...
...
12
controller could be brought up, which is essential for boards attaching
12
controller could be brought up, which is essential for boards attaching
13
power-management chips to it.
13
power-management chips to it.
14
14
15
Signed-off-by: Haylen Chu <heylenay@4d2.org>
15
Signed-off-by: Haylen Chu <heylenay@4d2.org>
16
---
16
---
17
drivers/clk/spacemit/ccu-k1.c | 6 ++++++
17
drivers/clk/spacemit/ccu-k1.c | 5 +++++
18
1 file changed, 6 insertions(+)
18
1 file changed, 5 insertions(+)
19
19
20
diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
20
diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
21
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
22
--- a/drivers/clk/spacemit/ccu-k1.c
22
--- a/drivers/clk/spacemit/ccu-k1.c
23
+++ b/drivers/clk/spacemit/ccu-k1.c
23
+++ b/drivers/clk/spacemit/ccu-k1.c
24
@@ -XXX,XX +XXX,XX @@ static CCU_MUX_GATE_DEFINE(twsi7_clk, twsi_parents,
24
@@ -XXX,XX +XXX,XX @@ CCU_MUX_GATE_DEFINE(twsi6_clk, twsi_parents, APBC_TWSI6_CLK_RST, 4, 3, BIT(1),
25
             APBC_TWSI7_CLK_RST,
25
         0);
26
             4, 3, BIT(1),
26
CCU_MUX_GATE_DEFINE(twsi7_clk, twsi_parents, APBC_TWSI7_CLK_RST, 4, 3, BIT(1),
27
             0);
27
         0);
28
+static CCU_GATE_DEFINE(twsi8_clk, CCU_PARENT_HW(pll1_d78_31p5),
28
+CCU_GATE_DEFINE(twsi8_clk, CCU_PARENT_HW(pll1_d78_31p5), APBC_TWSI8_CLK_RST,
29
+         APBC_TWSI8_CLK_RST,
29
+        BIT(1) | BIT(0), 0);
30
+         BIT(1) | BIT(0),
31
+         0);
32
30
33
static const struct clk_parent_data timer_parents[] = {
31
static const struct clk_parent_data timer_parents[] = {
34
    CCU_PARENT_HW(pll1_d192_12p8),
32
    CCU_PARENT_HW(pll1_d192_12p8),
35
@@ -XXX,XX +XXX,XX @@ static CCU_GATE_DEFINE(twsi7_bus_clk, CCU_PARENT_HW(apb_clk),
33
@@ -XXX,XX +XXX,XX @@ CCU_GATE_DEFINE(twsi6_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TWSI6_CLK_RST,
36
         APBC_TWSI7_CLK_RST,
34
        BIT(0), 0);
37
         BIT(0),
35
CCU_GATE_DEFINE(twsi7_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TWSI7_CLK_RST,
38
         0);
36
        BIT(0), 0);
39
+static CCU_FACTOR_DEFINE(twsi8_bus_clk, CCU_PARENT_HW(apb_clk),
37
+CCU_FACTOR_DEFINE(twsi8_bus_clk, CCU_PARENT_HW(apb_clk), 1, 1);
40
+             1, 1);
38
41
39
CCU_GATE_DEFINE(timers1_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TIMERS1_CLK_RST,
42
static CCU_GATE_DEFINE(timers1_bus_clk, CCU_PARENT_HW(apb_clk),
40
        BIT(0), 0);
43
         APBC_TIMERS1_CLK_RST,
41
@@ -XXX,XX +XXX,XX @@ static struct clk_hw *k1_ccu_apbc_hws[] = {
42
    [CLK_TWSI5]        = &twsi5_clk.common.hw,
43
    [CLK_TWSI6]        = &twsi6_clk.common.hw,
44
    [CLK_TWSI7]        = &twsi7_clk.common.hw,
45
+    [CLK_TWSI8]        = &twsi8_clk.common.hw,
46
    [CLK_TIMERS1]        = &timers1_clk.common.hw,
47
    [CLK_TIMERS2]        = &timers2_clk.common.hw,
48
    [CLK_AIB]        = &aib_clk.common.hw,
49
@@ -XXX,XX +XXX,XX @@ static struct clk_hw *k1_ccu_apbc_hws[] = {
50
    [CLK_TWSI5_BUS]        = &twsi5_bus_clk.common.hw,
51
    [CLK_TWSI6_BUS]        = &twsi6_bus_clk.common.hw,
52
    [CLK_TWSI7_BUS]        = &twsi7_bus_clk.common.hw,
53
+    [CLK_TWSI8_BUS]        = &twsi8_bus_clk.common.hw,
54
    [CLK_TIMERS1_BUS]    = &timers1_bus_clk.common.hw,
55
    [CLK_TIMERS2_BUS]    = &timers2_bus_clk.common.hw,
56
    [CLK_AIB_BUS]        = &aib_bus_clk.common.hw,
44
--
57
--
45
2.48.1
58
2.49.0
diff view generated by jsdifflib
1
Describe the PLL and system controllers that're capable of generating
1
Describe the PLL and system controllers that're capable of generating
2
clock signals in the devicetree.
2
clock signals in the devicetree.
3
3
4
Signed-off-by: Haylen Chu <heylenay@4d2.org>
4
Signed-off-by: Haylen Chu <heylenay@4d2.org>
5
---
5
---
6
arch/riscv/boot/dts/spacemit/k1.dtsi | 79 ++++++++++++++++++++++++++++
6
arch/riscv/boot/dts/spacemit/k1.dtsi | 75 ++++++++++++++++++++++++++++
7
1 file changed, 79 insertions(+)
7
1 file changed, 75 insertions(+)
8
8
9
diff --git a/arch/riscv/boot/dts/spacemit/k1.dtsi b/arch/riscv/boot/dts/spacemit/k1.dtsi
9
diff --git a/arch/riscv/boot/dts/spacemit/k1.dtsi b/arch/riscv/boot/dts/spacemit/k1.dtsi
10
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
11
--- a/arch/riscv/boot/dts/spacemit/k1.dtsi
11
--- a/arch/riscv/boot/dts/spacemit/k1.dtsi
12
+++ b/arch/riscv/boot/dts/spacemit/k1.dtsi
12
+++ b/arch/riscv/boot/dts/spacemit/k1.dtsi
13
@@ -XXX,XX +XXX,XX @@
13
@@ -XXX,XX +XXX,XX @@
14
* Copyright (C) 2024 Yangyu Chen <cyy@cyyself.name>
14
* Copyright (C) 2024 Yangyu Chen <cyy@cyyself.name>
15
*/
15
*/
16
16
17
+#include <dt-bindings/clock/spacemit,k1-ccu.h>
17
+#include <dt-bindings/clock/spacemit,k1-syscon.h>
18
+
18
+
19
/dts-v1/;
19
/dts-v1/;
20
/ {
20
/ {
21
    #address-cells = <2>;
21
    #address-cells = <2>;
22
@@ -XXX,XX +XXX,XX @@ cluster1_l2_cache: l2-cache1 {
22
@@ -XXX,XX +XXX,XX @@ cluster1_l2_cache: l2-cache1 {
23
        };
23
        };
24
    };
24
    };
25
25
26
+    clocks {
26
+    clocks {
27
+        #address-cells = <0x2>;
28
+        #size-cells = <0x2>;
29
+        ranges;
30
+
31
+        vctcxo_1m: clock-1m {
27
+        vctcxo_1m: clock-1m {
32
+            compatible = "fixed-clock";
28
+            compatible = "fixed-clock";
33
+            clock-frequency = <1000000>;
29
+            clock-frequency = <1000000>;
34
+            clock-output-names = "vctcxo_1m";
30
+            clock-output-names = "vctcxo_1m";
35
+            #clock-cells = <0>;
31
+            #clock-cells = <0>;
...
...
116
+
112
+
117
        plic: interrupt-controller@e0000000 {
113
        plic: interrupt-controller@e0000000 {
118
            compatible = "spacemit,k1-plic", "sifive,plic-1.0.0";
114
            compatible = "spacemit,k1-plic", "sifive,plic-1.0.0";
119
            reg = <0x0 0xe0000000 0x0 0x4000000>;
115
            reg = <0x0 0xe0000000 0x0 0x4000000>;
120
--
116
--
121
2.48.1
117
2.49.0
diff view generated by jsdifflib
New patch
1
Clock controller unit, or CCU, generates various clocks frequency for
2
peripherals integrated in SpacemiT K1 SoC and is essential for normal
3
operation. Let's enable it in defconfig.
1
4
5
Signed-off-by: Haylen Chu <heylenay@4d2.org>
6
---
7
arch/riscv/configs/defconfig | 2 ++
8
1 file changed, 2 insertions(+)
9
10
diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig
11
index XXXXXXX..XXXXXXX 100644
12
--- a/arch/riscv/configs/defconfig
13
+++ b/arch/riscv/configs/defconfig
14
@@ -XXX,XX +XXX,XX @@ CONFIG_CLK_SOPHGO_CV1800=y
15
CONFIG_CLK_SOPHGO_SG2042_PLL=y
16
CONFIG_CLK_SOPHGO_SG2042_CLKGEN=y
17
CONFIG_CLK_SOPHGO_SG2042_RPGATE=y
18
+CONFIG_SPACEMIT_CCU=y
19
+CONFIG_SPACEMIT_K1_CCU=y
20
CONFIG_SUN8I_DE2_CCU=m
21
CONFIG_SUN50I_IOMMU=y
22
CONFIG_RPMSG_CHAR=y
23
--
24
2.49.0
diff view generated by jsdifflib