blob: e538f047b31099e78e9a0d6ae240e68f295fa854 [file] [log] [blame]
Peng Fan525c8762019-08-19 07:54:04 +00001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright 2019 NXP
4 * Peng Fan <peng.fan@nxp.com>
5 */
6
Peng Fan525c8762019-08-19 07:54:04 +00007#include <clk.h>
8#include <clk-uclass.h>
9#include <dm.h>
Simon Glass0f2af882020-05-10 11:40:05 -060010#include <log.h>
Peng Fan525c8762019-08-19 07:54:04 +000011#include <asm/arch/clock.h>
12#include <asm/arch/imx-regs.h>
13#include <dt-bindings/clock/imx8mm-clock.h>
14
15#include "clk.h"
16
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020017static const char * const pll_ref_sels[] = { "clock-osc-24m", "dummy", "dummy", "dummy", };
18static const char * const dram_pll_bypass_sels[] = {"dram_pll", "dram_pll_ref_sel", };
19static const char * const arm_pll_bypass_sels[] = {"arm_pll", "arm_pll_ref_sel", };
20static const char * const sys_pll1_bypass_sels[] = {"sys_pll1", "sys_pll1_ref_sel", };
21static const char * const sys_pll2_bypass_sels[] = {"sys_pll2", "sys_pll2_ref_sel", };
22static const char * const sys_pll3_bypass_sels[] = {"sys_pll3", "sys_pll3_ref_sel", };
Peng Fan525c8762019-08-19 07:54:04 +000023
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020024static const char * const imx8mm_a53_sels[] = {"clock-osc-24m", "arm_pll_out", "sys_pll2_500m",
25 "sys_pll2_1000m", "sys_pll1_800m", "sys_pll1_400m",
26 "audio_pll1_out", "sys_pll3_out", };
Peng Fan525c8762019-08-19 07:54:04 +000027
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020028static const char * const imx8mm_ahb_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_800m",
29 "sys_pll1_400m", "sys_pll2_125m", "sys_pll3_out",
30 "audio_pll1_out", "video_pll1_out", };
Peng Fan525c8762019-08-19 07:54:04 +000031
Fabio Estevam704aa872022-09-26 13:40:09 -030032#ifndef CONFIG_SPL_BUILD
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020033static const char * const imx8mm_enet_axi_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m",
34 "sys_pll2_250m", "sys_pll2_200m", "audio_pll1_out",
35 "video_pll1_out", "sys_pll3_out", };
Peng Fan525c8762019-08-19 07:54:04 +000036
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020037static const char * const imx8mm_enet_ref_sels[] = {"clock-osc-24m", "sys_pll2_125m", "sys_pll2_50m",
38 "sys_pll2_100m", "sys_pll1_160m", "audio_pll1_out",
39 "video_pll1_out", "clk_ext4", };
Peng Fanee5515d2019-10-22 03:29:48 +000040
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020041static const char * const imx8mm_enet_timer_sels[] = {"clock-osc-24m", "sys_pll2_100m", "audio_pll1_out",
42 "clk_ext1", "clk_ext2", "clk_ext3",
43 "clk_ext4", "video_pll1_out", };
Peng Fanee5515d2019-10-22 03:29:48 +000044
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020045static const char * const imx8mm_enet_phy_sels[] = {"clock-osc-24m", "sys_pll2_50m", "sys_pll2_125m",
46 "sys_pll2_200m", "sys_pll2_500m", "video_pll1_out",
47 "audio_pll2_out", };
Peng Fanee5515d2019-10-22 03:29:48 +000048#endif
49
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020050static const char * const imx8mm_nand_usdhc_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m",
51 "sys_pll2_200m", "sys_pll1_133m", "sys_pll3_out",
52 "sys_pll2_250m", "audio_pll1_out", };
Peng Fan525c8762019-08-19 07:54:04 +000053
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020054static const char * const imx8mm_usb_bus_sels[] = {"clock-osc-24m", "sys_pll2_500m", "sys_pll1_800m",
55 "sys_pll2_100m", "sys_pll2_200m", "clk_ext2",
56 "clk_ext4", "audio_pll2_out", };
Ye Li0321edb2020-04-19 02:22:09 -070057
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020058static const char * const imx8mm_usdhc1_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m",
59 "sys_pll2_500m", "sys_pll3_out", "sys_pll1_266m",
60 "audio_pll2_out", "sys_pll1_100m", };
Peng Fan525c8762019-08-19 07:54:04 +000061
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020062static const char * const imx8mm_usdhc2_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m",
63 "sys_pll2_500m", "sys_pll3_out", "sys_pll1_266m",
64 "audio_pll2_out", "sys_pll1_100m", };
Peng Fan525c8762019-08-19 07:54:04 +000065
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020066static const char * const imx8mm_i2c1_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m",
67 "sys_pll3_out", "audio_pll1_out", "video_pll1_out",
68 "audio_pll2_out", "sys_pll1_133m", };
Peng Fan525c8762019-08-19 07:54:04 +000069
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020070static const char * const imx8mm_i2c2_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m",
71 "sys_pll3_out", "audio_pll1_out", "video_pll1_out",
72 "audio_pll2_out", "sys_pll1_133m", };
Peng Fan525c8762019-08-19 07:54:04 +000073
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020074static const char * const imx8mm_i2c3_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m",
75 "sys_pll3_out", "audio_pll1_out", "video_pll1_out",
76 "audio_pll2_out", "sys_pll1_133m", };
Peng Fan525c8762019-08-19 07:54:04 +000077
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020078static const char * const imx8mm_i2c4_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m",
79 "sys_pll3_out", "audio_pll1_out", "video_pll1_out",
80 "audio_pll2_out", "sys_pll1_133m", };
Peng Fan525c8762019-08-19 07:54:04 +000081
Tim Harveyff465582024-04-19 08:29:00 -070082#if CONFIG_IS_ENABLED(PCIE_DW_IMX)
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020083static const char * const imx8mm_pcie1_ctrl_sels[] = {"clock-osc-24m", "sys_pll2_250m", "sys_pll2_200m",
84 "sys_pll1_266m", "sys_pll1_800m", "sys_pll2_500m",
85 "sys_pll2_333m", "sys_pll3_out", };
Tim Harveyff465582024-04-19 08:29:00 -070086
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020087static const char * const imx8mm_pcie1_phy_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll2_500m",
88 "clk_ext1", "clk_ext2", "clk_ext3",
89 "clk_ext4", "sys_pll1_400m", };
Tim Harveyff465582024-04-19 08:29:00 -070090
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020091static const char * const imx8mm_pcie1_aux_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll2_50m",
92 "sys_pll3_out", "sys_pll2_100m", "sys_pll1_80m",
93 "sys_pll1_160m", "sys_pll1_200m", };
Tim Harveyff465582024-04-19 08:29:00 -070094#endif
95
Fabio Estevam60896e02022-09-26 13:40:08 -030096#ifndef CONFIG_SPL_BUILD
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020097static const char * const imx8mm_pwm1_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m",
98 "sys_pll1_40m", "sys_pll3_out", "clk_ext1",
99 "sys_pll1_80m", "video_pll1_out", };
Tommaso Merciai4c1a7182022-03-26 12:19:04 +0100100
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200101static const char * const imx8mm_pwm2_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m",
102 "sys_pll1_40m", "sys_pll3_out", "clk_ext1",
103 "sys_pll1_80m", "video_pll1_out", };
Tommaso Merciai4c1a7182022-03-26 12:19:04 +0100104
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200105static const char * const imx8mm_pwm3_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m",
106 "sys_pll1_40m", "sys_pll3_out", "clk_ext2",
107 "sys_pll1_80m", "video_pll1_out", };
Tommaso Merciai4c1a7182022-03-26 12:19:04 +0100108
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200109static const char * const imx8mm_pwm4_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m",
110 "sys_pll1_40m", "sys_pll3_out", "clk_ext2",
111 "sys_pll1_80m", "video_pll1_out", };
Fabio Estevam60896e02022-09-26 13:40:08 -0300112#endif
Tommaso Merciai4c1a7182022-03-26 12:19:04 +0100113
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200114static const char * const imx8mm_wdog_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_160m",
115 "vpu_pll_out", "sys_pll2_125m", "sys_pll3_out",
116 "sys_pll1_80m", "sys_pll2_166m", };
Peng Fan525c8762019-08-19 07:54:04 +0000117
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200118static const char * const imx8mm_usdhc3_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m",
119 "sys_pll2_500m", "sys_pll3_out", "sys_pll1_266m",
120 "audio_pll2_clk", "sys_pll1_100m", };
Peng Fan525c8762019-08-19 07:54:04 +0000121
Fabio Estevam3e5255c2022-09-26 13:40:11 -0300122#if CONFIG_IS_ENABLED(NXP_FSPI)
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200123static const char * const imx8mm_qspi_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll2_333m",
124 "sys_pll2_500m", "audio_pll2_out", "sys_pll1_266m",
125 "sys_pll3_out", "sys_pll1_100m", };
Fabio Estevam3e5255c2022-09-26 13:40:11 -0300126#endif
Peng Fan2dff8792020-06-27 15:49:28 +0800127
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200128static const char * const imx8mm_usb_core_sels[] = {"clock-osc-24m", "sys_pll1_100m", "sys_pll1_40m",
129 "sys_pll2_100m", "sys_pll2_200m", "clk_ext2",
130 "clk_ext3", "audio_pll2_out", };
Ye Li0321edb2020-04-19 02:22:09 -0700131
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200132static const char * const imx8mm_usb_phy_sels[] = {"clock-osc-24m", "sys_pll1_100m", "sys_pll1_40m",
133 "sys_pll2_100m", "sys_pll2_200m", "clk_ext2",
134 "clk_ext3", "audio_pll2_out", };
Ye Li0321edb2020-04-19 02:22:09 -0700135
Fabio Estevam0b3fa1b2022-09-26 13:40:10 -0300136#if CONFIG_IS_ENABLED(DM_SPI)
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200137static const char * const imx8mm_ecspi1_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m",
138 "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out",
139 "sys_pll2_250m", "audio_pll2_out", };
Frieder Schrempf339beba2021-06-07 14:36:43 +0200140
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200141static const char * const imx8mm_ecspi2_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m",
142 "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out",
143 "sys_pll2_250m", "audio_pll2_out", };
Frieder Schrempf339beba2021-06-07 14:36:43 +0200144
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200145static const char * const imx8mm_ecspi3_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m",
146 "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out",
147 "sys_pll2_250m", "audio_pll2_out", };
Fabio Estevam0b3fa1b2022-09-26 13:40:10 -0300148#endif
Frieder Schrempf339beba2021-06-07 14:36:43 +0200149
Peng Fan525c8762019-08-19 07:54:04 +0000150static int imx8mm_clk_probe(struct udevice *dev)
151{
152 void __iomem *base;
153
154 base = (void *)ANATOP_BASE_ADDR;
155
156 clk_dm(IMX8MM_DRAM_PLL_REF_SEL,
157 imx_clk_mux("dram_pll_ref_sel", base + 0x50, 0, 2,
158 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
159 clk_dm(IMX8MM_ARM_PLL_REF_SEL,
160 imx_clk_mux("arm_pll_ref_sel", base + 0x84, 0, 2,
161 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
162 clk_dm(IMX8MM_SYS_PLL1_REF_SEL,
163 imx_clk_mux("sys_pll1_ref_sel", base + 0x94, 0, 2,
164 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
165 clk_dm(IMX8MM_SYS_PLL2_REF_SEL,
166 imx_clk_mux("sys_pll2_ref_sel", base + 0x104, 0, 2,
167 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
168 clk_dm(IMX8MM_SYS_PLL3_REF_SEL,
169 imx_clk_mux("sys_pll3_ref_sel", base + 0x114, 0, 2,
170 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
171
172 clk_dm(IMX8MM_DRAM_PLL,
173 imx_clk_pll14xx("dram_pll", "dram_pll_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700174 base + 0x50, &imx_1443x_dram_pll));
Peng Fan525c8762019-08-19 07:54:04 +0000175 clk_dm(IMX8MM_ARM_PLL,
176 imx_clk_pll14xx("arm_pll", "arm_pll_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700177 base + 0x84, &imx_1416x_pll));
Peng Fan525c8762019-08-19 07:54:04 +0000178 clk_dm(IMX8MM_SYS_PLL1,
179 imx_clk_pll14xx("sys_pll1", "sys_pll1_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700180 base + 0x94, &imx_1416x_pll));
Peng Fan525c8762019-08-19 07:54:04 +0000181 clk_dm(IMX8MM_SYS_PLL2,
182 imx_clk_pll14xx("sys_pll2", "sys_pll2_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700183 base + 0x104, &imx_1416x_pll));
Peng Fan525c8762019-08-19 07:54:04 +0000184 clk_dm(IMX8MM_SYS_PLL3,
185 imx_clk_pll14xx("sys_pll3", "sys_pll3_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700186 base + 0x114, &imx_1416x_pll));
Peng Fan525c8762019-08-19 07:54:04 +0000187
188 /* PLL bypass out */
189 clk_dm(IMX8MM_DRAM_PLL_BYPASS,
190 imx_clk_mux_flags("dram_pll_bypass", base + 0x50, 4, 1,
191 dram_pll_bypass_sels,
192 ARRAY_SIZE(dram_pll_bypass_sels),
193 CLK_SET_RATE_PARENT));
194 clk_dm(IMX8MM_ARM_PLL_BYPASS,
195 imx_clk_mux_flags("arm_pll_bypass", base + 0x84, 4, 1,
196 arm_pll_bypass_sels,
197 ARRAY_SIZE(arm_pll_bypass_sels),
198 CLK_SET_RATE_PARENT));
199 clk_dm(IMX8MM_SYS_PLL1_BYPASS,
200 imx_clk_mux_flags("sys_pll1_bypass", base + 0x94, 4, 1,
201 sys_pll1_bypass_sels,
202 ARRAY_SIZE(sys_pll1_bypass_sels),
203 CLK_SET_RATE_PARENT));
204 clk_dm(IMX8MM_SYS_PLL2_BYPASS,
205 imx_clk_mux_flags("sys_pll2_bypass", base + 0x104, 4, 1,
206 sys_pll2_bypass_sels,
207 ARRAY_SIZE(sys_pll2_bypass_sels),
208 CLK_SET_RATE_PARENT));
209 clk_dm(IMX8MM_SYS_PLL3_BYPASS,
210 imx_clk_mux_flags("sys_pll3_bypass", base + 0x114, 4, 1,
211 sys_pll3_bypass_sels,
212 ARRAY_SIZE(sys_pll3_bypass_sels),
213 CLK_SET_RATE_PARENT));
214
215 /* PLL out gate */
216 clk_dm(IMX8MM_DRAM_PLL_OUT,
217 imx_clk_gate("dram_pll_out", "dram_pll_bypass",
218 base + 0x50, 13));
219 clk_dm(IMX8MM_ARM_PLL_OUT,
220 imx_clk_gate("arm_pll_out", "arm_pll_bypass",
221 base + 0x84, 11));
222 clk_dm(IMX8MM_SYS_PLL1_OUT,
223 imx_clk_gate("sys_pll1_out", "sys_pll1_bypass",
224 base + 0x94, 11));
225 clk_dm(IMX8MM_SYS_PLL2_OUT,
226 imx_clk_gate("sys_pll2_out", "sys_pll2_bypass",
227 base + 0x104, 11));
228 clk_dm(IMX8MM_SYS_PLL3_OUT,
229 imx_clk_gate("sys_pll3_out", "sys_pll3_bypass",
230 base + 0x114, 11));
231
232 /* SYS PLL fixed output */
233 clk_dm(IMX8MM_SYS_PLL1_40M,
234 imx_clk_fixed_factor("sys_pll1_40m", "sys_pll1_out", 1, 20));
235 clk_dm(IMX8MM_SYS_PLL1_80M,
236 imx_clk_fixed_factor("sys_pll1_80m", "sys_pll1_out", 1, 10));
237 clk_dm(IMX8MM_SYS_PLL1_100M,
238 imx_clk_fixed_factor("sys_pll1_100m", "sys_pll1_out", 1, 8));
239 clk_dm(IMX8MM_SYS_PLL1_133M,
240 imx_clk_fixed_factor("sys_pll1_133m", "sys_pll1_out", 1, 6));
241 clk_dm(IMX8MM_SYS_PLL1_160M,
242 imx_clk_fixed_factor("sys_pll1_160m", "sys_pll1_out", 1, 5));
243 clk_dm(IMX8MM_SYS_PLL1_200M,
244 imx_clk_fixed_factor("sys_pll1_200m", "sys_pll1_out", 1, 4));
245 clk_dm(IMX8MM_SYS_PLL1_266M,
246 imx_clk_fixed_factor("sys_pll1_266m", "sys_pll1_out", 1, 3));
247 clk_dm(IMX8MM_SYS_PLL1_400M,
248 imx_clk_fixed_factor("sys_pll1_400m", "sys_pll1_out", 1, 2));
249 clk_dm(IMX8MM_SYS_PLL1_800M,
250 imx_clk_fixed_factor("sys_pll1_800m", "sys_pll1_out", 1, 1));
251
252 clk_dm(IMX8MM_SYS_PLL2_50M,
253 imx_clk_fixed_factor("sys_pll2_50m", "sys_pll2_out", 1, 20));
254 clk_dm(IMX8MM_SYS_PLL2_100M,
255 imx_clk_fixed_factor("sys_pll2_100m", "sys_pll2_out", 1, 10));
256 clk_dm(IMX8MM_SYS_PLL2_125M,
257 imx_clk_fixed_factor("sys_pll2_125m", "sys_pll2_out", 1, 8));
258 clk_dm(IMX8MM_SYS_PLL2_166M,
259 imx_clk_fixed_factor("sys_pll2_166m", "sys_pll2_out", 1, 6));
260 clk_dm(IMX8MM_SYS_PLL2_200M,
261 imx_clk_fixed_factor("sys_pll2_200m", "sys_pll2_out", 1, 5));
262 clk_dm(IMX8MM_SYS_PLL2_250M,
263 imx_clk_fixed_factor("sys_pll2_250m", "sys_pll2_out", 1, 4));
264 clk_dm(IMX8MM_SYS_PLL2_333M,
265 imx_clk_fixed_factor("sys_pll2_333m", "sys_pll2_out", 1, 3));
266 clk_dm(IMX8MM_SYS_PLL2_500M,
267 imx_clk_fixed_factor("sys_pll2_500m", "sys_pll2_out", 1, 2));
268 clk_dm(IMX8MM_SYS_PLL2_1000M,
269 imx_clk_fixed_factor("sys_pll2_1000m", "sys_pll2_out", 1, 1));
270
271 base = dev_read_addr_ptr(dev);
Sean Andersonb58106d2019-12-24 23:57:47 -0500272 if (!base)
Peng Fan525c8762019-08-19 07:54:04 +0000273 return -EINVAL;
274
275 clk_dm(IMX8MM_CLK_A53_SRC,
276 imx_clk_mux2("arm_a53_src", base + 0x8000, 24, 3,
277 imx8mm_a53_sels, ARRAY_SIZE(imx8mm_a53_sels)));
278 clk_dm(IMX8MM_CLK_A53_CG,
279 imx_clk_gate3("arm_a53_cg", "arm_a53_src", base + 0x8000, 28));
280 clk_dm(IMX8MM_CLK_A53_DIV,
281 imx_clk_divider2("arm_a53_div", "arm_a53_cg",
282 base + 0x8000, 0, 3));
283
284 clk_dm(IMX8MM_CLK_AHB,
285 imx8m_clk_composite_critical("ahb", imx8mm_ahb_sels,
286 base + 0x9000));
287 clk_dm(IMX8MM_CLK_IPG_ROOT,
288 imx_clk_divider2("ipg_root", "ahb", base + 0x9080, 0, 1));
289
Peng Fan525c8762019-08-19 07:54:04 +0000290 clk_dm(IMX8MM_CLK_NAND_USDHC_BUS,
291 imx8m_clk_composite_critical("nand_usdhc_bus",
292 imx8mm_nand_usdhc_sels,
293 base + 0x8900));
Ye Li0321edb2020-04-19 02:22:09 -0700294 clk_dm(IMX8MM_CLK_USB_BUS,
295 imx8m_clk_composite("usb_bus", imx8mm_usb_bus_sels, base + 0x8b80));
Peng Fan525c8762019-08-19 07:54:04 +0000296
297 /* IP */
Tim Harveyff465582024-04-19 08:29:00 -0700298#if CONFIG_IS_ENABLED(PCIE_DW_IMX)
299 clk_dm(IMX8MM_CLK_PCIE1_CTRL,
300 imx8m_clk_composite("pcie1_ctrl", imx8mm_pcie1_ctrl_sels,
301 base + 0xa300));
302 clk_dm(IMX8MM_CLK_PCIE1_PHY,
303 imx8m_clk_composite("pcie1_phy", imx8mm_pcie1_phy_sels,
304 base + 0xa380));
305 clk_dm(IMX8MM_CLK_PCIE1_AUX,
306 imx8m_clk_composite("pcie1_aux", imx8mm_pcie1_aux_sels,
307 base + 0xa400));
308#endif
Peng Fan525c8762019-08-19 07:54:04 +0000309 clk_dm(IMX8MM_CLK_USDHC1,
310 imx8m_clk_composite("usdhc1", imx8mm_usdhc1_sels,
311 base + 0xac00));
312 clk_dm(IMX8MM_CLK_USDHC2,
313 imx8m_clk_composite("usdhc2", imx8mm_usdhc2_sels,
314 base + 0xac80));
315 clk_dm(IMX8MM_CLK_I2C1,
316 imx8m_clk_composite("i2c1", imx8mm_i2c1_sels, base + 0xad00));
317 clk_dm(IMX8MM_CLK_I2C2,
318 imx8m_clk_composite("i2c2", imx8mm_i2c2_sels, base + 0xad80));
319 clk_dm(IMX8MM_CLK_I2C3,
320 imx8m_clk_composite("i2c3", imx8mm_i2c3_sels, base + 0xae00));
321 clk_dm(IMX8MM_CLK_I2C4,
322 imx8m_clk_composite("i2c4", imx8mm_i2c4_sels, base + 0xae80));
323 clk_dm(IMX8MM_CLK_WDOG,
324 imx8m_clk_composite("wdog", imx8mm_wdog_sels, base + 0xb900));
325 clk_dm(IMX8MM_CLK_USDHC3,
326 imx8m_clk_composite("usdhc3", imx8mm_usdhc3_sels,
327 base + 0xbc80));
Ye Li0321edb2020-04-19 02:22:09 -0700328 clk_dm(IMX8MM_CLK_USB_CORE_REF,
329 imx8m_clk_composite("usb_core_ref", imx8mm_usb_core_sels, base + 0xb100));
330 clk_dm(IMX8MM_CLK_USB_PHY_REF,
331 imx8m_clk_composite("usb_phy_ref", imx8mm_usb_phy_sels, base + 0xb180));
Peng Fan525c8762019-08-19 07:54:04 +0000332 clk_dm(IMX8MM_CLK_I2C1_ROOT,
333 imx_clk_gate4("i2c1_root_clk", "i2c1", base + 0x4170, 0));
334 clk_dm(IMX8MM_CLK_I2C2_ROOT,
335 imx_clk_gate4("i2c2_root_clk", "i2c2", base + 0x4180, 0));
336 clk_dm(IMX8MM_CLK_I2C3_ROOT,
337 imx_clk_gate4("i2c3_root_clk", "i2c3", base + 0x4190, 0));
338 clk_dm(IMX8MM_CLK_I2C4_ROOT,
339 imx_clk_gate4("i2c4_root_clk", "i2c4", base + 0x41a0, 0));
340 clk_dm(IMX8MM_CLK_OCOTP_ROOT,
341 imx_clk_gate4("ocotp_root_clk", "ipg_root", base + 0x4220, 0));
342 clk_dm(IMX8MM_CLK_USDHC1_ROOT,
343 imx_clk_gate4("usdhc1_root_clk", "usdhc1", base + 0x4510, 0));
344 clk_dm(IMX8MM_CLK_USDHC2_ROOT,
345 imx_clk_gate4("usdhc2_root_clk", "usdhc2", base + 0x4520, 0));
346 clk_dm(IMX8MM_CLK_WDOG1_ROOT,
347 imx_clk_gate4("wdog1_root_clk", "wdog", base + 0x4530, 0));
348 clk_dm(IMX8MM_CLK_WDOG2_ROOT,
349 imx_clk_gate4("wdog2_root_clk", "wdog", base + 0x4540, 0));
350 clk_dm(IMX8MM_CLK_WDOG3_ROOT,
351 imx_clk_gate4("wdog3_root_clk", "wdog", base + 0x4550, 0));
352 clk_dm(IMX8MM_CLK_USDHC3_ROOT,
353 imx_clk_gate4("usdhc3_root_clk", "usdhc3", base + 0x45e0, 0));
Ye Li0321edb2020-04-19 02:22:09 -0700354 clk_dm(IMX8MM_CLK_USB1_CTRL_ROOT,
355 imx_clk_gate4("usb1_ctrl_root_clk", "usb_bus", base + 0x44d0, 0));
Peng Fan525c8762019-08-19 07:54:04 +0000356
Peng Fanee5515d2019-10-22 03:29:48 +0000357 /* clks not needed in SPL stage */
358#ifndef CONFIG_SPL_BUILD
Fabio Estevam704aa872022-09-26 13:40:09 -0300359 clk_dm(IMX8MM_CLK_ENET_AXI,
360 imx8m_clk_composite("enet_axi", imx8mm_enet_axi_sels,
361 base + 0x8880));
Peng Fanee5515d2019-10-22 03:29:48 +0000362 clk_dm(IMX8MM_CLK_ENET_REF,
363 imx8m_clk_composite("enet_ref", imx8mm_enet_ref_sels,
364 base + 0xa980));
365 clk_dm(IMX8MM_CLK_ENET_TIMER,
366 imx8m_clk_composite("enet_timer", imx8mm_enet_timer_sels,
367 base + 0xaa00));
368 clk_dm(IMX8MM_CLK_ENET_PHY_REF,
369 imx8m_clk_composite("enet_phy", imx8mm_enet_phy_sels,
370 base + 0xaa80));
371 clk_dm(IMX8MM_CLK_ENET1_ROOT,
372 imx_clk_gate4("enet1_root_clk", "enet_axi",
373 base + 0x40a0, 0));
Fabio Estevam60896e02022-09-26 13:40:08 -0300374 clk_dm(IMX8MM_CLK_PWM1,
375 imx8m_clk_composite("pwm1", imx8mm_pwm1_sels, base + 0xb380));
376 clk_dm(IMX8MM_CLK_PWM2,
377 imx8m_clk_composite("pwm2", imx8mm_pwm2_sels, base + 0xb400));
378 clk_dm(IMX8MM_CLK_PWM3,
379 imx8m_clk_composite("pwm3", imx8mm_pwm3_sels, base + 0xb480));
380 clk_dm(IMX8MM_CLK_PWM4,
381 imx8m_clk_composite("pwm4", imx8mm_pwm4_sels, base + 0xb500));
382 clk_dm(IMX8MM_CLK_PWM1_ROOT,
383 imx_clk_gate4("pwm1_root_clk", "pwm1", base + 0x4280, 0));
384 clk_dm(IMX8MM_CLK_PWM2_ROOT,
385 imx_clk_gate4("pwm2_root_clk", "pwm2", base + 0x4290, 0));
386 clk_dm(IMX8MM_CLK_PWM3_ROOT,
387 imx_clk_gate4("pwm3_root_clk", "pwm3", base + 0x42a0, 0));
388 clk_dm(IMX8MM_CLK_PWM4_ROOT,
389 imx_clk_gate4("pwm4_root_clk", "pwm4", base + 0x42b0, 0));
Peng Fanee5515d2019-10-22 03:29:48 +0000390#endif
391
Tim Harveyff465582024-04-19 08:29:00 -0700392#if CONFIG_IS_ENABLED(PCIE_DW_IMX)
393 clk_dm(IMX8MM_CLK_PCIE1_ROOT,
394 imx_clk_gate4("pcie1_root_clk", "pcie1_ctrl", base + 0x4250, 0));
395#endif
396
Fabio Estevam0b3fa1b2022-09-26 13:40:10 -0300397#if CONFIG_IS_ENABLED(DM_SPI)
398 clk_dm(IMX8MM_CLK_ECSPI1,
399 imx8m_clk_composite("ecspi1", imx8mm_ecspi1_sels, base + 0xb280));
400 clk_dm(IMX8MM_CLK_ECSPI2,
401 imx8m_clk_composite("ecspi2", imx8mm_ecspi2_sels, base + 0xb300));
402 clk_dm(IMX8MM_CLK_ECSPI3,
403 imx8m_clk_composite("ecspi3", imx8mm_ecspi3_sels, base + 0xc180));
404
405 clk_dm(IMX8MM_CLK_ECSPI1_ROOT,
406 imx_clk_gate4("ecspi1_root_clk", "ecspi1", base + 0x4070, 0));
407 clk_dm(IMX8MM_CLK_ECSPI2_ROOT,
408 imx_clk_gate4("ecspi2_root_clk", "ecspi2", base + 0x4080, 0));
409 clk_dm(IMX8MM_CLK_ECSPI3_ROOT,
410 imx_clk_gate4("ecspi3_root_clk", "ecspi3", base + 0x4090, 0));
411#endif
412
Fabio Estevam3e5255c2022-09-26 13:40:11 -0300413#if CONFIG_IS_ENABLED(NXP_FSPI)
414 clk_dm(IMX8MM_CLK_QSPI,
415 imx8m_clk_composite("qspi", imx8mm_qspi_sels, base + 0xab80));
416 clk_dm(IMX8MM_CLK_QSPI_ROOT,
417 imx_clk_gate4("qspi_root_clk", "qspi", base + 0x42f0, 0));
418#endif
419
Peng Fan525c8762019-08-19 07:54:04 +0000420 return 0;
421}
422
423static const struct udevice_id imx8mm_clk_ids[] = {
424 { .compatible = "fsl,imx8mm-ccm" },
425 { },
426};
427
428U_BOOT_DRIVER(imx8mm_clk) = {
429 .name = "clk_imx8mm",
430 .id = UCLASS_CLK,
431 .of_match = imx8mm_clk_ids,
Sean Anderson35c84642022-03-20 16:34:46 -0400432 .ops = &ccf_clk_ops,
Peng Fan525c8762019-08-19 07:54:04 +0000433 .probe = imx8mm_clk_probe,
434 .flags = DM_FLAG_PRE_RELOC,
435};