blob: a91c6767fac5834ed0841aaf5ab1f8976c46ef5a [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
Hou Zhiqiang04a06432024-08-01 11:59:46 +080024static const char * const imx8mm_arm_core_sels[] = {"arm_a53_src", "arm_pll_out", };
25
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020026static const char * const imx8mm_a53_sels[] = {"clock-osc-24m", "arm_pll_out", "sys_pll2_500m",
27 "sys_pll2_1000m", "sys_pll1_800m", "sys_pll1_400m",
28 "audio_pll1_out", "sys_pll3_out", };
Peng Fan525c8762019-08-19 07:54:04 +000029
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020030static const char * const imx8mm_ahb_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_800m",
31 "sys_pll1_400m", "sys_pll2_125m", "sys_pll3_out",
32 "audio_pll1_out", "video_pll1_out", };
Peng Fan525c8762019-08-19 07:54:04 +000033
Fabio Estevam704aa872022-09-26 13:40:09 -030034#ifndef CONFIG_SPL_BUILD
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020035static const char * const imx8mm_enet_axi_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m",
36 "sys_pll2_250m", "sys_pll2_200m", "audio_pll1_out",
37 "video_pll1_out", "sys_pll3_out", };
Peng Fan525c8762019-08-19 07:54:04 +000038
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020039static const char * const imx8mm_enet_ref_sels[] = {"clock-osc-24m", "sys_pll2_125m", "sys_pll2_50m",
40 "sys_pll2_100m", "sys_pll1_160m", "audio_pll1_out",
41 "video_pll1_out", "clk_ext4", };
Peng Fanee5515d2019-10-22 03:29:48 +000042
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020043static const char * const imx8mm_enet_timer_sels[] = {"clock-osc-24m", "sys_pll2_100m", "audio_pll1_out",
44 "clk_ext1", "clk_ext2", "clk_ext3",
45 "clk_ext4", "video_pll1_out", };
Peng Fanee5515d2019-10-22 03:29:48 +000046
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020047static const char * const imx8mm_enet_phy_sels[] = {"clock-osc-24m", "sys_pll2_50m", "sys_pll2_125m",
48 "sys_pll2_200m", "sys_pll2_500m", "video_pll1_out",
49 "audio_pll2_out", };
Peng Fanee5515d2019-10-22 03:29:48 +000050#endif
51
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020052static const char * const imx8mm_nand_usdhc_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m",
53 "sys_pll2_200m", "sys_pll1_133m", "sys_pll3_out",
54 "sys_pll2_250m", "audio_pll1_out", };
Peng Fan525c8762019-08-19 07:54:04 +000055
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020056static const char * const imx8mm_usb_bus_sels[] = {"clock-osc-24m", "sys_pll2_500m", "sys_pll1_800m",
57 "sys_pll2_100m", "sys_pll2_200m", "clk_ext2",
58 "clk_ext4", "audio_pll2_out", };
Ye Li0321edb2020-04-19 02:22:09 -070059
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020060static const char * const imx8mm_usdhc1_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m",
61 "sys_pll2_500m", "sys_pll3_out", "sys_pll1_266m",
62 "audio_pll2_out", "sys_pll1_100m", };
Peng Fan525c8762019-08-19 07:54:04 +000063
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020064static const char * const imx8mm_usdhc2_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m",
65 "sys_pll2_500m", "sys_pll3_out", "sys_pll1_266m",
66 "audio_pll2_out", "sys_pll1_100m", };
Peng Fan525c8762019-08-19 07:54:04 +000067
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020068static const char * const imx8mm_i2c1_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m",
69 "sys_pll3_out", "audio_pll1_out", "video_pll1_out",
70 "audio_pll2_out", "sys_pll1_133m", };
Peng Fan525c8762019-08-19 07:54:04 +000071
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020072static const char * const imx8mm_i2c2_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m",
73 "sys_pll3_out", "audio_pll1_out", "video_pll1_out",
74 "audio_pll2_out", "sys_pll1_133m", };
Peng Fan525c8762019-08-19 07:54:04 +000075
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020076static const char * const imx8mm_i2c3_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m",
77 "sys_pll3_out", "audio_pll1_out", "video_pll1_out",
78 "audio_pll2_out", "sys_pll1_133m", };
Peng Fan525c8762019-08-19 07:54:04 +000079
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020080static const char * const imx8mm_i2c4_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m",
81 "sys_pll3_out", "audio_pll1_out", "video_pll1_out",
82 "audio_pll2_out", "sys_pll1_133m", };
Peng Fan525c8762019-08-19 07:54:04 +000083
Tim Harveyff465582024-04-19 08:29:00 -070084#if CONFIG_IS_ENABLED(PCIE_DW_IMX)
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020085static const char * const imx8mm_pcie1_ctrl_sels[] = {"clock-osc-24m", "sys_pll2_250m", "sys_pll2_200m",
86 "sys_pll1_266m", "sys_pll1_800m", "sys_pll2_500m",
87 "sys_pll2_333m", "sys_pll3_out", };
Tim Harveyff465582024-04-19 08:29:00 -070088
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020089static const char * const imx8mm_pcie1_phy_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll2_500m",
90 "clk_ext1", "clk_ext2", "clk_ext3",
91 "clk_ext4", "sys_pll1_400m", };
Tim Harveyff465582024-04-19 08:29:00 -070092
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020093static const char * const imx8mm_pcie1_aux_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll2_50m",
94 "sys_pll3_out", "sys_pll2_100m", "sys_pll1_80m",
95 "sys_pll1_160m", "sys_pll1_200m", };
Tim Harveyff465582024-04-19 08:29:00 -070096#endif
97
Fabio Estevam60896e02022-09-26 13:40:08 -030098#ifndef CONFIG_SPL_BUILD
Michael Trimarchi0e9e1692024-07-07 10:20:00 +020099static const char * const imx8mm_pwm1_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m",
100 "sys_pll1_40m", "sys_pll3_out", "clk_ext1",
101 "sys_pll1_80m", "video_pll1_out", };
Tommaso Merciai4c1a7182022-03-26 12:19:04 +0100102
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200103static const char * const imx8mm_pwm2_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m",
104 "sys_pll1_40m", "sys_pll3_out", "clk_ext1",
105 "sys_pll1_80m", "video_pll1_out", };
Tommaso Merciai4c1a7182022-03-26 12:19:04 +0100106
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200107static const char * const imx8mm_pwm3_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m",
108 "sys_pll1_40m", "sys_pll3_out", "clk_ext2",
109 "sys_pll1_80m", "video_pll1_out", };
Tommaso Merciai4c1a7182022-03-26 12:19:04 +0100110
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200111static const char * const imx8mm_pwm4_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m",
112 "sys_pll1_40m", "sys_pll3_out", "clk_ext2",
113 "sys_pll1_80m", "video_pll1_out", };
Fabio Estevam60896e02022-09-26 13:40:08 -0300114#endif
Tommaso Merciai4c1a7182022-03-26 12:19:04 +0100115
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200116static const char * const imx8mm_wdog_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_160m",
117 "vpu_pll_out", "sys_pll2_125m", "sys_pll3_out",
118 "sys_pll1_80m", "sys_pll2_166m", };
Peng Fan525c8762019-08-19 07:54:04 +0000119
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200120static const char * const imx8mm_usdhc3_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m",
121 "sys_pll2_500m", "sys_pll3_out", "sys_pll1_266m",
122 "audio_pll2_clk", "sys_pll1_100m", };
Peng Fan525c8762019-08-19 07:54:04 +0000123
Fabio Estevam3e5255c2022-09-26 13:40:11 -0300124#if CONFIG_IS_ENABLED(NXP_FSPI)
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200125static const char * const imx8mm_qspi_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll2_333m",
126 "sys_pll2_500m", "audio_pll2_out", "sys_pll1_266m",
127 "sys_pll3_out", "sys_pll1_100m", };
Fabio Estevam3e5255c2022-09-26 13:40:11 -0300128#endif
Peng Fan2dff8792020-06-27 15:49:28 +0800129
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200130static const char * const imx8mm_usb_core_sels[] = {"clock-osc-24m", "sys_pll1_100m", "sys_pll1_40m",
131 "sys_pll2_100m", "sys_pll2_200m", "clk_ext2",
132 "clk_ext3", "audio_pll2_out", };
Ye Li0321edb2020-04-19 02:22:09 -0700133
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200134static const char * const imx8mm_usb_phy_sels[] = {"clock-osc-24m", "sys_pll1_100m", "sys_pll1_40m",
135 "sys_pll2_100m", "sys_pll2_200m", "clk_ext2",
136 "clk_ext3", "audio_pll2_out", };
Ye Li0321edb2020-04-19 02:22:09 -0700137
Fabio Estevam0b3fa1b2022-09-26 13:40:10 -0300138#if CONFIG_IS_ENABLED(DM_SPI)
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200139static const char * const imx8mm_ecspi1_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m",
140 "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out",
141 "sys_pll2_250m", "audio_pll2_out", };
Frieder Schrempf339beba2021-06-07 14:36:43 +0200142
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200143static const char * const imx8mm_ecspi2_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m",
144 "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out",
145 "sys_pll2_250m", "audio_pll2_out", };
Frieder Schrempf339beba2021-06-07 14:36:43 +0200146
Michael Trimarchi0e9e1692024-07-07 10:20:00 +0200147static const char * const imx8mm_ecspi3_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m",
148 "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out",
149 "sys_pll2_250m", "audio_pll2_out", };
Fabio Estevam0b3fa1b2022-09-26 13:40:10 -0300150#endif
Frieder Schrempf339beba2021-06-07 14:36:43 +0200151
Peng Fan525c8762019-08-19 07:54:04 +0000152static int imx8mm_clk_probe(struct udevice *dev)
153{
154 void __iomem *base;
155
156 base = (void *)ANATOP_BASE_ADDR;
157
158 clk_dm(IMX8MM_DRAM_PLL_REF_SEL,
159 imx_clk_mux("dram_pll_ref_sel", base + 0x50, 0, 2,
160 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
161 clk_dm(IMX8MM_ARM_PLL_REF_SEL,
162 imx_clk_mux("arm_pll_ref_sel", base + 0x84, 0, 2,
163 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
164 clk_dm(IMX8MM_SYS_PLL1_REF_SEL,
165 imx_clk_mux("sys_pll1_ref_sel", base + 0x94, 0, 2,
166 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
167 clk_dm(IMX8MM_SYS_PLL2_REF_SEL,
168 imx_clk_mux("sys_pll2_ref_sel", base + 0x104, 0, 2,
169 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
170 clk_dm(IMX8MM_SYS_PLL3_REF_SEL,
171 imx_clk_mux("sys_pll3_ref_sel", base + 0x114, 0, 2,
172 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
173
174 clk_dm(IMX8MM_DRAM_PLL,
175 imx_clk_pll14xx("dram_pll", "dram_pll_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700176 base + 0x50, &imx_1443x_dram_pll));
Peng Fan525c8762019-08-19 07:54:04 +0000177 clk_dm(IMX8MM_ARM_PLL,
178 imx_clk_pll14xx("arm_pll", "arm_pll_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700179 base + 0x84, &imx_1416x_pll));
Peng Fan525c8762019-08-19 07:54:04 +0000180 clk_dm(IMX8MM_SYS_PLL1,
181 imx_clk_pll14xx("sys_pll1", "sys_pll1_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700182 base + 0x94, &imx_1416x_pll));
Peng Fan525c8762019-08-19 07:54:04 +0000183 clk_dm(IMX8MM_SYS_PLL2,
184 imx_clk_pll14xx("sys_pll2", "sys_pll2_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700185 base + 0x104, &imx_1416x_pll));
Peng Fan525c8762019-08-19 07:54:04 +0000186 clk_dm(IMX8MM_SYS_PLL3,
187 imx_clk_pll14xx("sys_pll3", "sys_pll3_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700188 base + 0x114, &imx_1416x_pll));
Peng Fan525c8762019-08-19 07:54:04 +0000189
190 /* PLL bypass out */
191 clk_dm(IMX8MM_DRAM_PLL_BYPASS,
192 imx_clk_mux_flags("dram_pll_bypass", base + 0x50, 4, 1,
193 dram_pll_bypass_sels,
194 ARRAY_SIZE(dram_pll_bypass_sels),
195 CLK_SET_RATE_PARENT));
196 clk_dm(IMX8MM_ARM_PLL_BYPASS,
197 imx_clk_mux_flags("arm_pll_bypass", base + 0x84, 4, 1,
198 arm_pll_bypass_sels,
199 ARRAY_SIZE(arm_pll_bypass_sels),
200 CLK_SET_RATE_PARENT));
201 clk_dm(IMX8MM_SYS_PLL1_BYPASS,
202 imx_clk_mux_flags("sys_pll1_bypass", base + 0x94, 4, 1,
203 sys_pll1_bypass_sels,
204 ARRAY_SIZE(sys_pll1_bypass_sels),
205 CLK_SET_RATE_PARENT));
206 clk_dm(IMX8MM_SYS_PLL2_BYPASS,
207 imx_clk_mux_flags("sys_pll2_bypass", base + 0x104, 4, 1,
208 sys_pll2_bypass_sels,
209 ARRAY_SIZE(sys_pll2_bypass_sels),
210 CLK_SET_RATE_PARENT));
211 clk_dm(IMX8MM_SYS_PLL3_BYPASS,
212 imx_clk_mux_flags("sys_pll3_bypass", base + 0x114, 4, 1,
213 sys_pll3_bypass_sels,
214 ARRAY_SIZE(sys_pll3_bypass_sels),
215 CLK_SET_RATE_PARENT));
216
217 /* PLL out gate */
218 clk_dm(IMX8MM_DRAM_PLL_OUT,
219 imx_clk_gate("dram_pll_out", "dram_pll_bypass",
220 base + 0x50, 13));
221 clk_dm(IMX8MM_ARM_PLL_OUT,
222 imx_clk_gate("arm_pll_out", "arm_pll_bypass",
223 base + 0x84, 11));
224 clk_dm(IMX8MM_SYS_PLL1_OUT,
225 imx_clk_gate("sys_pll1_out", "sys_pll1_bypass",
226 base + 0x94, 11));
227 clk_dm(IMX8MM_SYS_PLL2_OUT,
228 imx_clk_gate("sys_pll2_out", "sys_pll2_bypass",
229 base + 0x104, 11));
230 clk_dm(IMX8MM_SYS_PLL3_OUT,
231 imx_clk_gate("sys_pll3_out", "sys_pll3_bypass",
232 base + 0x114, 11));
233
234 /* SYS PLL fixed output */
235 clk_dm(IMX8MM_SYS_PLL1_40M,
236 imx_clk_fixed_factor("sys_pll1_40m", "sys_pll1_out", 1, 20));
237 clk_dm(IMX8MM_SYS_PLL1_80M,
238 imx_clk_fixed_factor("sys_pll1_80m", "sys_pll1_out", 1, 10));
239 clk_dm(IMX8MM_SYS_PLL1_100M,
240 imx_clk_fixed_factor("sys_pll1_100m", "sys_pll1_out", 1, 8));
241 clk_dm(IMX8MM_SYS_PLL1_133M,
242 imx_clk_fixed_factor("sys_pll1_133m", "sys_pll1_out", 1, 6));
243 clk_dm(IMX8MM_SYS_PLL1_160M,
244 imx_clk_fixed_factor("sys_pll1_160m", "sys_pll1_out", 1, 5));
245 clk_dm(IMX8MM_SYS_PLL1_200M,
246 imx_clk_fixed_factor("sys_pll1_200m", "sys_pll1_out", 1, 4));
247 clk_dm(IMX8MM_SYS_PLL1_266M,
248 imx_clk_fixed_factor("sys_pll1_266m", "sys_pll1_out", 1, 3));
249 clk_dm(IMX8MM_SYS_PLL1_400M,
250 imx_clk_fixed_factor("sys_pll1_400m", "sys_pll1_out", 1, 2));
251 clk_dm(IMX8MM_SYS_PLL1_800M,
252 imx_clk_fixed_factor("sys_pll1_800m", "sys_pll1_out", 1, 1));
253
254 clk_dm(IMX8MM_SYS_PLL2_50M,
255 imx_clk_fixed_factor("sys_pll2_50m", "sys_pll2_out", 1, 20));
256 clk_dm(IMX8MM_SYS_PLL2_100M,
257 imx_clk_fixed_factor("sys_pll2_100m", "sys_pll2_out", 1, 10));
258 clk_dm(IMX8MM_SYS_PLL2_125M,
259 imx_clk_fixed_factor("sys_pll2_125m", "sys_pll2_out", 1, 8));
260 clk_dm(IMX8MM_SYS_PLL2_166M,
261 imx_clk_fixed_factor("sys_pll2_166m", "sys_pll2_out", 1, 6));
262 clk_dm(IMX8MM_SYS_PLL2_200M,
263 imx_clk_fixed_factor("sys_pll2_200m", "sys_pll2_out", 1, 5));
264 clk_dm(IMX8MM_SYS_PLL2_250M,
265 imx_clk_fixed_factor("sys_pll2_250m", "sys_pll2_out", 1, 4));
266 clk_dm(IMX8MM_SYS_PLL2_333M,
267 imx_clk_fixed_factor("sys_pll2_333m", "sys_pll2_out", 1, 3));
268 clk_dm(IMX8MM_SYS_PLL2_500M,
269 imx_clk_fixed_factor("sys_pll2_500m", "sys_pll2_out", 1, 2));
270 clk_dm(IMX8MM_SYS_PLL2_1000M,
271 imx_clk_fixed_factor("sys_pll2_1000m", "sys_pll2_out", 1, 1));
272
273 base = dev_read_addr_ptr(dev);
Sean Andersonb58106d2019-12-24 23:57:47 -0500274 if (!base)
Peng Fan525c8762019-08-19 07:54:04 +0000275 return -EINVAL;
276
277 clk_dm(IMX8MM_CLK_A53_SRC,
278 imx_clk_mux2("arm_a53_src", base + 0x8000, 24, 3,
279 imx8mm_a53_sels, ARRAY_SIZE(imx8mm_a53_sels)));
280 clk_dm(IMX8MM_CLK_A53_CG,
281 imx_clk_gate3("arm_a53_cg", "arm_a53_src", base + 0x8000, 28));
282 clk_dm(IMX8MM_CLK_A53_DIV,
283 imx_clk_divider2("arm_a53_div", "arm_a53_cg",
284 base + 0x8000, 0, 3));
285
286 clk_dm(IMX8MM_CLK_AHB,
287 imx8m_clk_composite_critical("ahb", imx8mm_ahb_sels,
288 base + 0x9000));
289 clk_dm(IMX8MM_CLK_IPG_ROOT,
290 imx_clk_divider2("ipg_root", "ahb", base + 0x9080, 0, 1));
291
Peng Fan525c8762019-08-19 07:54:04 +0000292 clk_dm(IMX8MM_CLK_NAND_USDHC_BUS,
293 imx8m_clk_composite_critical("nand_usdhc_bus",
294 imx8mm_nand_usdhc_sels,
295 base + 0x8900));
Ye Li0321edb2020-04-19 02:22:09 -0700296 clk_dm(IMX8MM_CLK_USB_BUS,
297 imx8m_clk_composite("usb_bus", imx8mm_usb_bus_sels, base + 0x8b80));
Peng Fan525c8762019-08-19 07:54:04 +0000298
299 /* IP */
Tim Harveyff465582024-04-19 08:29:00 -0700300#if CONFIG_IS_ENABLED(PCIE_DW_IMX)
301 clk_dm(IMX8MM_CLK_PCIE1_CTRL,
302 imx8m_clk_composite("pcie1_ctrl", imx8mm_pcie1_ctrl_sels,
303 base + 0xa300));
304 clk_dm(IMX8MM_CLK_PCIE1_PHY,
305 imx8m_clk_composite("pcie1_phy", imx8mm_pcie1_phy_sels,
306 base + 0xa380));
307 clk_dm(IMX8MM_CLK_PCIE1_AUX,
308 imx8m_clk_composite("pcie1_aux", imx8mm_pcie1_aux_sels,
309 base + 0xa400));
310#endif
Peng Fan525c8762019-08-19 07:54:04 +0000311 clk_dm(IMX8MM_CLK_USDHC1,
312 imx8m_clk_composite("usdhc1", imx8mm_usdhc1_sels,
313 base + 0xac00));
314 clk_dm(IMX8MM_CLK_USDHC2,
315 imx8m_clk_composite("usdhc2", imx8mm_usdhc2_sels,
316 base + 0xac80));
317 clk_dm(IMX8MM_CLK_I2C1,
318 imx8m_clk_composite("i2c1", imx8mm_i2c1_sels, base + 0xad00));
319 clk_dm(IMX8MM_CLK_I2C2,
320 imx8m_clk_composite("i2c2", imx8mm_i2c2_sels, base + 0xad80));
321 clk_dm(IMX8MM_CLK_I2C3,
322 imx8m_clk_composite("i2c3", imx8mm_i2c3_sels, base + 0xae00));
323 clk_dm(IMX8MM_CLK_I2C4,
324 imx8m_clk_composite("i2c4", imx8mm_i2c4_sels, base + 0xae80));
325 clk_dm(IMX8MM_CLK_WDOG,
326 imx8m_clk_composite("wdog", imx8mm_wdog_sels, base + 0xb900));
327 clk_dm(IMX8MM_CLK_USDHC3,
328 imx8m_clk_composite("usdhc3", imx8mm_usdhc3_sels,
329 base + 0xbc80));
Ye Li0321edb2020-04-19 02:22:09 -0700330 clk_dm(IMX8MM_CLK_USB_CORE_REF,
331 imx8m_clk_composite("usb_core_ref", imx8mm_usb_core_sels, base + 0xb100));
332 clk_dm(IMX8MM_CLK_USB_PHY_REF,
333 imx8m_clk_composite("usb_phy_ref", imx8mm_usb_phy_sels, base + 0xb180));
Peng Fan525c8762019-08-19 07:54:04 +0000334 clk_dm(IMX8MM_CLK_I2C1_ROOT,
335 imx_clk_gate4("i2c1_root_clk", "i2c1", base + 0x4170, 0));
336 clk_dm(IMX8MM_CLK_I2C2_ROOT,
337 imx_clk_gate4("i2c2_root_clk", "i2c2", base + 0x4180, 0));
338 clk_dm(IMX8MM_CLK_I2C3_ROOT,
339 imx_clk_gate4("i2c3_root_clk", "i2c3", base + 0x4190, 0));
340 clk_dm(IMX8MM_CLK_I2C4_ROOT,
341 imx_clk_gate4("i2c4_root_clk", "i2c4", base + 0x41a0, 0));
342 clk_dm(IMX8MM_CLK_OCOTP_ROOT,
343 imx_clk_gate4("ocotp_root_clk", "ipg_root", base + 0x4220, 0));
344 clk_dm(IMX8MM_CLK_USDHC1_ROOT,
345 imx_clk_gate4("usdhc1_root_clk", "usdhc1", base + 0x4510, 0));
346 clk_dm(IMX8MM_CLK_USDHC2_ROOT,
347 imx_clk_gate4("usdhc2_root_clk", "usdhc2", base + 0x4520, 0));
348 clk_dm(IMX8MM_CLK_WDOG1_ROOT,
349 imx_clk_gate4("wdog1_root_clk", "wdog", base + 0x4530, 0));
350 clk_dm(IMX8MM_CLK_WDOG2_ROOT,
351 imx_clk_gate4("wdog2_root_clk", "wdog", base + 0x4540, 0));
352 clk_dm(IMX8MM_CLK_WDOG3_ROOT,
353 imx_clk_gate4("wdog3_root_clk", "wdog", base + 0x4550, 0));
354 clk_dm(IMX8MM_CLK_USDHC3_ROOT,
355 imx_clk_gate4("usdhc3_root_clk", "usdhc3", base + 0x45e0, 0));
Ye Li0321edb2020-04-19 02:22:09 -0700356 clk_dm(IMX8MM_CLK_USB1_CTRL_ROOT,
357 imx_clk_gate4("usb1_ctrl_root_clk", "usb_bus", base + 0x44d0, 0));
Peng Fan525c8762019-08-19 07:54:04 +0000358
Peng Fanee5515d2019-10-22 03:29:48 +0000359 /* clks not needed in SPL stage */
360#ifndef CONFIG_SPL_BUILD
Fabio Estevam704aa872022-09-26 13:40:09 -0300361 clk_dm(IMX8MM_CLK_ENET_AXI,
362 imx8m_clk_composite("enet_axi", imx8mm_enet_axi_sels,
363 base + 0x8880));
Peng Fanee5515d2019-10-22 03:29:48 +0000364 clk_dm(IMX8MM_CLK_ENET_REF,
365 imx8m_clk_composite("enet_ref", imx8mm_enet_ref_sels,
366 base + 0xa980));
367 clk_dm(IMX8MM_CLK_ENET_TIMER,
368 imx8m_clk_composite("enet_timer", imx8mm_enet_timer_sels,
369 base + 0xaa00));
370 clk_dm(IMX8MM_CLK_ENET_PHY_REF,
371 imx8m_clk_composite("enet_phy", imx8mm_enet_phy_sels,
372 base + 0xaa80));
373 clk_dm(IMX8MM_CLK_ENET1_ROOT,
374 imx_clk_gate4("enet1_root_clk", "enet_axi",
375 base + 0x40a0, 0));
Fabio Estevam60896e02022-09-26 13:40:08 -0300376 clk_dm(IMX8MM_CLK_PWM1,
377 imx8m_clk_composite("pwm1", imx8mm_pwm1_sels, base + 0xb380));
378 clk_dm(IMX8MM_CLK_PWM2,
379 imx8m_clk_composite("pwm2", imx8mm_pwm2_sels, base + 0xb400));
380 clk_dm(IMX8MM_CLK_PWM3,
381 imx8m_clk_composite("pwm3", imx8mm_pwm3_sels, base + 0xb480));
382 clk_dm(IMX8MM_CLK_PWM4,
383 imx8m_clk_composite("pwm4", imx8mm_pwm4_sels, base + 0xb500));
384 clk_dm(IMX8MM_CLK_PWM1_ROOT,
385 imx_clk_gate4("pwm1_root_clk", "pwm1", base + 0x4280, 0));
386 clk_dm(IMX8MM_CLK_PWM2_ROOT,
387 imx_clk_gate4("pwm2_root_clk", "pwm2", base + 0x4290, 0));
388 clk_dm(IMX8MM_CLK_PWM3_ROOT,
389 imx_clk_gate4("pwm3_root_clk", "pwm3", base + 0x42a0, 0));
390 clk_dm(IMX8MM_CLK_PWM4_ROOT,
391 imx_clk_gate4("pwm4_root_clk", "pwm4", base + 0x42b0, 0));
Peng Fanee5515d2019-10-22 03:29:48 +0000392#endif
393
Tim Harveyff465582024-04-19 08:29:00 -0700394#if CONFIG_IS_ENABLED(PCIE_DW_IMX)
395 clk_dm(IMX8MM_CLK_PCIE1_ROOT,
396 imx_clk_gate4("pcie1_root_clk", "pcie1_ctrl", base + 0x4250, 0));
397#endif
398
Fabio Estevam0b3fa1b2022-09-26 13:40:10 -0300399#if CONFIG_IS_ENABLED(DM_SPI)
400 clk_dm(IMX8MM_CLK_ECSPI1,
401 imx8m_clk_composite("ecspi1", imx8mm_ecspi1_sels, base + 0xb280));
402 clk_dm(IMX8MM_CLK_ECSPI2,
403 imx8m_clk_composite("ecspi2", imx8mm_ecspi2_sels, base + 0xb300));
404 clk_dm(IMX8MM_CLK_ECSPI3,
405 imx8m_clk_composite("ecspi3", imx8mm_ecspi3_sels, base + 0xc180));
406
407 clk_dm(IMX8MM_CLK_ECSPI1_ROOT,
408 imx_clk_gate4("ecspi1_root_clk", "ecspi1", base + 0x4070, 0));
409 clk_dm(IMX8MM_CLK_ECSPI2_ROOT,
410 imx_clk_gate4("ecspi2_root_clk", "ecspi2", base + 0x4080, 0));
411 clk_dm(IMX8MM_CLK_ECSPI3_ROOT,
412 imx_clk_gate4("ecspi3_root_clk", "ecspi3", base + 0x4090, 0));
413#endif
414
Fabio Estevam3e5255c2022-09-26 13:40:11 -0300415#if CONFIG_IS_ENABLED(NXP_FSPI)
416 clk_dm(IMX8MM_CLK_QSPI,
417 imx8m_clk_composite("qspi", imx8mm_qspi_sels, base + 0xab80));
418 clk_dm(IMX8MM_CLK_QSPI_ROOT,
419 imx_clk_gate4("qspi_root_clk", "qspi", base + 0x42f0, 0));
420#endif
421
Hou Zhiqiang04a06432024-08-01 11:59:46 +0800422 clk_dm(IMX8MM_CLK_ARM,
423 imx_clk_mux2_flags("arm_core", base + 0x9880, 24, 1,
424 imx8mm_arm_core_sels,
425 ARRAY_SIZE(imx8mm_arm_core_sels),
426 CLK_IS_CRITICAL));
427
Peng Fan525c8762019-08-19 07:54:04 +0000428 return 0;
429}
430
431static const struct udevice_id imx8mm_clk_ids[] = {
432 { .compatible = "fsl,imx8mm-ccm" },
433 { },
434};
435
436U_BOOT_DRIVER(imx8mm_clk) = {
437 .name = "clk_imx8mm",
438 .id = UCLASS_CLK,
439 .of_match = imx8mm_clk_ids,
Sean Anderson35c84642022-03-20 16:34:46 -0400440 .ops = &ccf_clk_ops,
Peng Fan525c8762019-08-19 07:54:04 +0000441 .probe = imx8mm_clk_probe,
442 .flags = DM_FLAG_PRE_RELOC,
443};