blob: 8911e342f18bd6dfe8b10a8afad313f64c3f5301 [file] [log] [blame]
Peng Fane2f674d2019-09-16 03:09:47 +00001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright 2019 NXP
4 * Peng Fan <peng.fan@nxp.com>
5 */
6
Peng Fane2f674d2019-09-16 03:09:47 +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 Fane2f674d2019-09-16 03:09:47 +000011#include <asm/arch/clock.h>
12#include <asm/arch/imx-regs.h>
13#include <dt-bindings/clock/imx8mn-clock.h>
14
15#include "clk.h"
16
Michael Trimarchi252e54e2022-08-30 16:45:20 +020017static u32 share_count_nand;
18
Michael Trimarchia5e83042024-07-07 10:19:59 +020019static const char * const pll_ref_sels[] = { "clock-osc-24m", "dummy", "dummy", "dummy", };
20static const char * const dram_pll_bypass_sels[] = {"dram_pll", "dram_pll_ref_sel", };
21static const char * const arm_pll_bypass_sels[] = {"arm_pll", "arm_pll_ref_sel", };
22static const char * const sys_pll1_bypass_sels[] = {"sys_pll1", "sys_pll1_ref_sel", };
23static const char * const sys_pll2_bypass_sels[] = {"sys_pll2", "sys_pll2_ref_sel", };
24static const char * const sys_pll3_bypass_sels[] = {"sys_pll3", "sys_pll3_ref_sel", };
Peng Fane2f674d2019-09-16 03:09:47 +000025
Michael Trimarchia5e83042024-07-07 10:19:59 +020026static const char * const imx8mn_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 Fane2f674d2019-09-16 03:09:47 +000029
Michael Trimarchia5e83042024-07-07 10:19:59 +020030static const char * const imx8mn_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_pll_out", };
Peng Fane2f674d2019-09-16 03:09:47 +000033
Michael Trimarchia5e83042024-07-07 10:19:59 +020034static const char * const imx8mn_enet_axi_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m",
35 "sys_pll2_250m", "sys_pll2_200m", "audio_pll1_out",
36 "video_pll_out", "sys_pll3_out", };
Peng Fane2f674d2019-09-16 03:09:47 +000037
Ye Li418c1fc2020-04-18 08:19:12 -070038#ifndef CONFIG_SPL_BUILD
Michael Trimarchia5e83042024-07-07 10:19:59 +020039static const char * const imx8mn_enet_ref_sels[] = {"clock-osc-24m", "sys_pll2_125m", "sys_pll2_50m",
40 "sys_pll2_100m", "sys_pll1_160m", "audio_pll1_out",
41 "video_pll_out", "clk_ext4", };
Ye Li418c1fc2020-04-18 08:19:12 -070042
Michael Trimarchia5e83042024-07-07 10:19:59 +020043static const char * const imx8mn_enet_timer_sels[] = {"clock-osc-24m", "sys_pll2_100m", "audio_pll1_out",
44 "clk_ext1", "clk_ext2", "clk_ext3",
45 "clk_ext4", "video_pll_out", };
Ye Li418c1fc2020-04-18 08:19:12 -070046
Michael Trimarchia5e83042024-07-07 10:19:59 +020047static const char * const imx8mn_enet_phy_sels[] = {"clock-osc-24m", "sys_pll2_50m", "sys_pll2_125m",
48 "sys_pll2_200m", "sys_pll2_500m", "audio_pll1_out",
49 "video_pll_out", "audio_pll2_out", };
Ye Li418c1fc2020-04-18 08:19:12 -070050#endif
51
Michael Trimarchia5e83042024-07-07 10:19:59 +020052static const char * const imx8mn_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 Fane2f674d2019-09-16 03:09:47 +000055
Ye Li0321edb2020-04-19 02:22:09 -070056static const char * const imx8mn_usb_bus_sels[] = {"clock-osc-24m", "sys_pll2_500m", "sys_pll1_800m",
Michael Trimarchia5e83042024-07-07 10:19:59 +020057 "sys_pll2_100m", "sys_pll2_200m", "clk_ext2",
58 "clk_ext4", "audio_pll2_out", };
Ye Li0321edb2020-04-19 02:22:09 -070059
Michael Trimarchia5e83042024-07-07 10:19:59 +020060static const char * const imx8mn_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 Fane2f674d2019-09-16 03:09:47 +000063
Michael Trimarchia5e83042024-07-07 10:19:59 +020064static const char * const imx8mn_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 Fane2f674d2019-09-16 03:09:47 +000067
Marek Vasutb1a8bb02021-01-19 00:58:31 +010068#if CONFIG_IS_ENABLED(DM_SPI)
Michael Trimarchia5e83042024-07-07 10:19:59 +020069static const char * const imx8mn_ecspi1_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m",
70 "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out",
71 "sys_pll2_250m", "audio_pll2_out", };
Marek Vasutb1a8bb02021-01-19 00:58:31 +010072
Michael Trimarchia5e83042024-07-07 10:19:59 +020073static const char * const imx8mn_ecspi2_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m",
74 "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out",
75 "sys_pll2_250m", "audio_pll2_out", };
Marek Vasutb1a8bb02021-01-19 00:58:31 +010076
Michael Trimarchia5e83042024-07-07 10:19:59 +020077static const char * const imx8mn_ecspi3_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m",
78 "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out",
79 "sys_pll2_250m", "audio_pll2_out", };
Marek Vasutb1a8bb02021-01-19 00:58:31 +010080#endif
81
Michael Trimarchia5e83042024-07-07 10:19:59 +020082static const char * const imx8mn_i2c1_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m",
83 "sys_pll3_out", "audio_pll1_out", "video_pll_out",
84 "audio_pll2_out", "sys_pll1_133m", };
Peng Fane2f674d2019-09-16 03:09:47 +000085
Michael Trimarchia5e83042024-07-07 10:19:59 +020086static const char * const imx8mn_i2c2_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m",
87 "sys_pll3_out", "audio_pll1_out", "video_pll_out",
88 "audio_pll2_out", "sys_pll1_133m", };
Peng Fane2f674d2019-09-16 03:09:47 +000089
Michael Trimarchia5e83042024-07-07 10:19:59 +020090static const char * const imx8mn_i2c3_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m",
91 "sys_pll3_out", "audio_pll1_out", "video_pll_out",
92 "audio_pll2_out", "sys_pll1_133m", };
Peng Fane2f674d2019-09-16 03:09:47 +000093
Michael Trimarchia5e83042024-07-07 10:19:59 +020094static const char * const imx8mn_i2c4_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m",
95 "sys_pll3_out", "audio_pll1_out", "video_pll_out",
96 "audio_pll2_out", "sys_pll1_133m", };
Peng Fane2f674d2019-09-16 03:09:47 +000097
Nicolas Heemerycke5e85232023-12-11 11:06:13 +010098#ifndef CONFIG_SPL_BUILD
Michael Trimarchia5e83042024-07-07 10:19:59 +020099static const char * const imx8mn_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_pll_out", };
Nicolas Heemerycke5e85232023-12-11 11:06:13 +0100102
Michael Trimarchia5e83042024-07-07 10:19:59 +0200103static const char * const imx8mn_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_pll_out", };
Nicolas Heemerycke5e85232023-12-11 11:06:13 +0100106
Michael Trimarchia5e83042024-07-07 10:19:59 +0200107static const char * const imx8mn_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_pll_out", };
Nicolas Heemerycke5e85232023-12-11 11:06:13 +0100110
Michael Trimarchia5e83042024-07-07 10:19:59 +0200111static const char * const imx8mn_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_pll_out", };
Nicolas Heemerycke5e85232023-12-11 11:06:13 +0100114#endif
115
Michael Trimarchia5e83042024-07-07 10:19:59 +0200116static const char * const imx8mn_wdog_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_160m",
117 "m7_alt_pll", "sys_pll2_125m", "sys_pll3_out",
118 "sys_pll1_80m", "sys_pll2_166m", };
Peng Fane2f674d2019-09-16 03:09:47 +0000119
Michael Trimarchia5e83042024-07-07 10:19:59 +0200120static const char * const imx8mn_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 Fane2f674d2019-09-16 03:09:47 +0000123
Michael Trimarchia5e83042024-07-07 10:19:59 +0200124static const char * const imx8mn_qspi_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll2_333m",
125 "sys_pll2_500m", "audio_pll2_out", "sys_pll1_266m",
126 "sys_pll3_out", "sys_pll1_100m", };
Ye Li418c1fc2020-04-18 08:19:12 -0700127
Michael Trimarchi24685832024-07-07 10:19:58 +0200128static const char * const imx8mn_nand_sels[] = {"clock-osc-24m", "sys_pll2_500m", "audio_pll1_out",
Michael Trimarchi252e54e2022-08-30 16:45:20 +0200129 "sys_pll1_400m", "audio_pll2_out", "sys_pll3_out",
Dario Binacchi2f51cf92022-12-19 12:31:25 +0100130 "sys_pll2_250m", "video_pll_out", };
Michael Trimarchi252e54e2022-08-30 16:45:20 +0200131
Ye Li0321edb2020-04-19 02:22:09 -0700132static const char * const imx8mn_usb_core_sels[] = {"clock-osc-24m", "sys_pll1_100m", "sys_pll1_40m",
Michael Trimarchia5e83042024-07-07 10:19:59 +0200133 "sys_pll2_100m", "sys_pll2_200m", "clk_ext2",
134 "clk_ext3", "audio_pll2_out", };
Ye Li0321edb2020-04-19 02:22:09 -0700135
136static const char * const imx8mn_usb_phy_sels[] = {"clock-osc-24m", "sys_pll1_100m", "sys_pll1_40m",
Michael Trimarchia5e83042024-07-07 10:19:59 +0200137 "sys_pll2_100m", "sys_pll2_200m", "clk_ext2",
138 "clk_ext3", "audio_pll2_out", };
Ye Li0321edb2020-04-19 02:22:09 -0700139
Peng Fane2f674d2019-09-16 03:09:47 +0000140static int imx8mn_clk_probe(struct udevice *dev)
141{
Michael Trimarchi24685832024-07-07 10:19:58 +0200142 struct clk osc_24m_clk;
Peng Fane2f674d2019-09-16 03:09:47 +0000143 void __iomem *base;
Michael Trimarchi24685832024-07-07 10:19:58 +0200144 int ret;
Peng Fane2f674d2019-09-16 03:09:47 +0000145
146 base = (void *)ANATOP_BASE_ADDR;
147
148 clk_dm(IMX8MN_DRAM_PLL_REF_SEL,
149 imx_clk_mux("dram_pll_ref_sel", base + 0x50, 0, 2,
150 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
151 clk_dm(IMX8MN_ARM_PLL_REF_SEL,
152 imx_clk_mux("arm_pll_ref_sel", base + 0x84, 0, 2,
153 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
154 clk_dm(IMX8MN_SYS_PLL1_REF_SEL,
155 imx_clk_mux("sys_pll1_ref_sel", base + 0x94, 0, 2,
156 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
157 clk_dm(IMX8MN_SYS_PLL2_REF_SEL,
158 imx_clk_mux("sys_pll2_ref_sel", base + 0x104, 0, 2,
159 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
160 clk_dm(IMX8MN_SYS_PLL3_REF_SEL,
161 imx_clk_mux("sys_pll3_ref_sel", base + 0x114, 0, 2,
162 pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
163
164 clk_dm(IMX8MN_DRAM_PLL,
165 imx_clk_pll14xx("dram_pll", "dram_pll_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700166 base + 0x50, &imx_1443x_dram_pll));
Peng Fane2f674d2019-09-16 03:09:47 +0000167 clk_dm(IMX8MN_ARM_PLL,
168 imx_clk_pll14xx("arm_pll", "arm_pll_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700169 base + 0x84, &imx_1416x_pll));
Peng Fane2f674d2019-09-16 03:09:47 +0000170 clk_dm(IMX8MN_SYS_PLL1,
171 imx_clk_pll14xx("sys_pll1", "sys_pll1_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700172 base + 0x94, &imx_1416x_pll));
Peng Fane2f674d2019-09-16 03:09:47 +0000173 clk_dm(IMX8MN_SYS_PLL2,
174 imx_clk_pll14xx("sys_pll2", "sys_pll2_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700175 base + 0x104, &imx_1416x_pll));
Peng Fane2f674d2019-09-16 03:09:47 +0000176 clk_dm(IMX8MN_SYS_PLL3,
177 imx_clk_pll14xx("sys_pll3", "sys_pll3_ref_sel",
Angus Ainslie73d75ec2022-03-29 07:02:40 -0700178 base + 0x114, &imx_1416x_pll));
Peng Fane2f674d2019-09-16 03:09:47 +0000179
180 /* PLL bypass out */
181 clk_dm(IMX8MN_DRAM_PLL_BYPASS,
182 imx_clk_mux_flags("dram_pll_bypass", base + 0x50, 4, 1,
183 dram_pll_bypass_sels,
184 ARRAY_SIZE(dram_pll_bypass_sels),
185 CLK_SET_RATE_PARENT));
186 clk_dm(IMX8MN_ARM_PLL_BYPASS,
187 imx_clk_mux_flags("arm_pll_bypass", base + 0x84, 4, 1,
188 arm_pll_bypass_sels,
189 ARRAY_SIZE(arm_pll_bypass_sels),
190 CLK_SET_RATE_PARENT));
191 clk_dm(IMX8MN_SYS_PLL1_BYPASS,
192 imx_clk_mux_flags("sys_pll1_bypass", base + 0x94, 4, 1,
193 sys_pll1_bypass_sels,
194 ARRAY_SIZE(sys_pll1_bypass_sels),
195 CLK_SET_RATE_PARENT));
196 clk_dm(IMX8MN_SYS_PLL2_BYPASS,
197 imx_clk_mux_flags("sys_pll2_bypass", base + 0x104, 4, 1,
198 sys_pll2_bypass_sels,
199 ARRAY_SIZE(sys_pll2_bypass_sels),
200 CLK_SET_RATE_PARENT));
201 clk_dm(IMX8MN_SYS_PLL3_BYPASS,
202 imx_clk_mux_flags("sys_pll3_bypass", base + 0x114, 4, 1,
203 sys_pll3_bypass_sels,
204 ARRAY_SIZE(sys_pll3_bypass_sels),
205 CLK_SET_RATE_PARENT));
206
207 /* PLL out gate */
208 clk_dm(IMX8MN_DRAM_PLL_OUT,
209 imx_clk_gate("dram_pll_out", "dram_pll_bypass",
210 base + 0x50, 13));
211 clk_dm(IMX8MN_ARM_PLL_OUT,
212 imx_clk_gate("arm_pll_out", "arm_pll_bypass",
213 base + 0x84, 11));
214 clk_dm(IMX8MN_SYS_PLL1_OUT,
215 imx_clk_gate("sys_pll1_out", "sys_pll1_bypass",
216 base + 0x94, 11));
217 clk_dm(IMX8MN_SYS_PLL2_OUT,
218 imx_clk_gate("sys_pll2_out", "sys_pll2_bypass",
219 base + 0x104, 11));
220 clk_dm(IMX8MN_SYS_PLL3_OUT,
221 imx_clk_gate("sys_pll3_out", "sys_pll3_bypass",
222 base + 0x114, 11));
223
224 /* SYS PLL fixed output */
225 clk_dm(IMX8MN_SYS_PLL1_40M,
226 imx_clk_fixed_factor("sys_pll1_40m", "sys_pll1_out", 1, 20));
227 clk_dm(IMX8MN_SYS_PLL1_80M,
228 imx_clk_fixed_factor("sys_pll1_80m", "sys_pll1_out", 1, 10));
229 clk_dm(IMX8MN_SYS_PLL1_100M,
230 imx_clk_fixed_factor("sys_pll1_100m", "sys_pll1_out", 1, 8));
231 clk_dm(IMX8MN_SYS_PLL1_133M,
232 imx_clk_fixed_factor("sys_pll1_133m", "sys_pll1_out", 1, 6));
233 clk_dm(IMX8MN_SYS_PLL1_160M,
234 imx_clk_fixed_factor("sys_pll1_160m", "sys_pll1_out", 1, 5));
235 clk_dm(IMX8MN_SYS_PLL1_200M,
236 imx_clk_fixed_factor("sys_pll1_200m", "sys_pll1_out", 1, 4));
237 clk_dm(IMX8MN_SYS_PLL1_266M,
238 imx_clk_fixed_factor("sys_pll1_266m", "sys_pll1_out", 1, 3));
239 clk_dm(IMX8MN_SYS_PLL1_400M,
240 imx_clk_fixed_factor("sys_pll1_400m", "sys_pll1_out", 1, 2));
241 clk_dm(IMX8MN_SYS_PLL1_800M,
242 imx_clk_fixed_factor("sys_pll1_800m", "sys_pll1_out", 1, 1));
243
244 clk_dm(IMX8MN_SYS_PLL2_50M,
245 imx_clk_fixed_factor("sys_pll2_50m", "sys_pll2_out", 1, 20));
246 clk_dm(IMX8MN_SYS_PLL2_100M,
247 imx_clk_fixed_factor("sys_pll2_100m", "sys_pll2_out", 1, 10));
248 clk_dm(IMX8MN_SYS_PLL2_125M,
249 imx_clk_fixed_factor("sys_pll2_125m", "sys_pll2_out", 1, 8));
250 clk_dm(IMX8MN_SYS_PLL2_166M,
251 imx_clk_fixed_factor("sys_pll2_166m", "sys_pll2_out", 1, 6));
252 clk_dm(IMX8MN_SYS_PLL2_200M,
253 imx_clk_fixed_factor("sys_pll2_200m", "sys_pll2_out", 1, 5));
254 clk_dm(IMX8MN_SYS_PLL2_250M,
255 imx_clk_fixed_factor("sys_pll2_250m", "sys_pll2_out", 1, 4));
256 clk_dm(IMX8MN_SYS_PLL2_333M,
257 imx_clk_fixed_factor("sys_pll2_333m", "sys_pll2_out", 1, 3));
258 clk_dm(IMX8MN_SYS_PLL2_500M,
259 imx_clk_fixed_factor("sys_pll2_500m", "sys_pll2_out", 1, 2));
260 clk_dm(IMX8MN_SYS_PLL2_1000M,
261 imx_clk_fixed_factor("sys_pll2_1000m", "sys_pll2_out", 1, 1));
262
Michael Trimarchi24685832024-07-07 10:19:58 +0200263 ret = clk_get_by_name(dev, "osc_24m", &osc_24m_clk);
264 if (ret)
265 return ret;
266 clk_dm(IMX8MN_CLK_24M, dev_get_clk_ptr(osc_24m_clk.dev));
267
Peng Fane2f674d2019-09-16 03:09:47 +0000268 base = dev_read_addr_ptr(dev);
Sean Andersonb58106d2019-12-24 23:57:47 -0500269 if (!base)
Peng Fane2f674d2019-09-16 03:09:47 +0000270 return -EINVAL;
271
272 clk_dm(IMX8MN_CLK_A53_SRC,
273 imx_clk_mux2("arm_a53_src", base + 0x8000, 24, 3,
274 imx8mn_a53_sels, ARRAY_SIZE(imx8mn_a53_sels)));
275 clk_dm(IMX8MN_CLK_A53_CG,
276 imx_clk_gate3("arm_a53_cg", "arm_a53_src", base + 0x8000, 28));
277 clk_dm(IMX8MN_CLK_A53_DIV,
278 imx_clk_divider2("arm_a53_div", "arm_a53_cg",
279 base + 0x8000, 0, 3));
280
281 clk_dm(IMX8MN_CLK_AHB,
282 imx8m_clk_composite_critical("ahb", imx8mn_ahb_sels,
283 base + 0x9000));
284 clk_dm(IMX8MN_CLK_IPG_ROOT,
285 imx_clk_divider2("ipg_root", "ahb", base + 0x9080, 0, 1));
286
287 clk_dm(IMX8MN_CLK_ENET_AXI,
288 imx8m_clk_composite("enet_axi", imx8mn_enet_axi_sels,
289 base + 0x8880));
290 clk_dm(IMX8MN_CLK_NAND_USDHC_BUS,
291 imx8m_clk_composite_critical("nand_usdhc_bus",
292 imx8mn_nand_usdhc_sels,
293 base + 0x8900));
Ye Li0321edb2020-04-19 02:22:09 -0700294 clk_dm(IMX8MN_CLK_USB_BUS,
295 imx8m_clk_composite("usb_bus", imx8mn_usb_bus_sels, base + 0x8b80));
Peng Fane2f674d2019-09-16 03:09:47 +0000296
297 /* IP */
298 clk_dm(IMX8MN_CLK_USDHC1,
299 imx8m_clk_composite("usdhc1", imx8mn_usdhc1_sels,
300 base + 0xac00));
301 clk_dm(IMX8MN_CLK_USDHC2,
302 imx8m_clk_composite("usdhc2", imx8mn_usdhc2_sels,
303 base + 0xac80));
304 clk_dm(IMX8MN_CLK_I2C1,
305 imx8m_clk_composite("i2c1", imx8mn_i2c1_sels, base + 0xad00));
306 clk_dm(IMX8MN_CLK_I2C2,
307 imx8m_clk_composite("i2c2", imx8mn_i2c2_sels, base + 0xad80));
308 clk_dm(IMX8MN_CLK_I2C3,
309 imx8m_clk_composite("i2c3", imx8mn_i2c3_sels, base + 0xae00));
310 clk_dm(IMX8MN_CLK_I2C4,
311 imx8m_clk_composite("i2c4", imx8mn_i2c4_sels, base + 0xae80));
312 clk_dm(IMX8MN_CLK_WDOG,
313 imx8m_clk_composite("wdog", imx8mn_wdog_sels, base + 0xb900));
314 clk_dm(IMX8MN_CLK_USDHC3,
315 imx8m_clk_composite("usdhc3", imx8mn_usdhc3_sels,
316 base + 0xbc80));
Michael Trimarchi252e54e2022-08-30 16:45:20 +0200317 clk_dm(IMX8MN_CLK_NAND,
318 imx8m_clk_composite("nand", imx8mn_nand_sels, base + 0xab00));
Ye Li418c1fc2020-04-18 08:19:12 -0700319 clk_dm(IMX8MN_CLK_QSPI,
320 imx8m_clk_composite("qspi", imx8mn_qspi_sels, base + 0xab80));
Ye Li0321edb2020-04-19 02:22:09 -0700321 clk_dm(IMX8MN_CLK_USB_CORE_REF,
322 imx8m_clk_composite("usb_core_ref", imx8mn_usb_core_sels, base + 0xb100));
323 clk_dm(IMX8MN_CLK_USB_PHY_REF,
324 imx8m_clk_composite("usb_phy_ref", imx8mn_usb_phy_sels, base + 0xb180));
Peng Fane2f674d2019-09-16 03:09:47 +0000325
326 clk_dm(IMX8MN_CLK_I2C1_ROOT,
327 imx_clk_gate4("i2c1_root_clk", "i2c1", base + 0x4170, 0));
328 clk_dm(IMX8MN_CLK_I2C2_ROOT,
329 imx_clk_gate4("i2c2_root_clk", "i2c2", base + 0x4180, 0));
330 clk_dm(IMX8MN_CLK_I2C3_ROOT,
331 imx_clk_gate4("i2c3_root_clk", "i2c3", base + 0x4190, 0));
332 clk_dm(IMX8MN_CLK_I2C4_ROOT,
333 imx_clk_gate4("i2c4_root_clk", "i2c4", base + 0x41a0, 0));
334 clk_dm(IMX8MN_CLK_OCOTP_ROOT,
335 imx_clk_gate4("ocotp_root_clk", "ipg_root", base + 0x4220, 0));
336 clk_dm(IMX8MN_CLK_USDHC1_ROOT,
337 imx_clk_gate4("usdhc1_root_clk", "usdhc1", base + 0x4510, 0));
338 clk_dm(IMX8MN_CLK_USDHC2_ROOT,
339 imx_clk_gate4("usdhc2_root_clk", "usdhc2", base + 0x4520, 0));
340 clk_dm(IMX8MN_CLK_WDOG1_ROOT,
341 imx_clk_gate4("wdog1_root_clk", "wdog", base + 0x4530, 0));
342 clk_dm(IMX8MN_CLK_WDOG2_ROOT,
343 imx_clk_gate4("wdog2_root_clk", "wdog", base + 0x4540, 0));
344 clk_dm(IMX8MN_CLK_WDOG3_ROOT,
345 imx_clk_gate4("wdog3_root_clk", "wdog", base + 0x4550, 0));
346 clk_dm(IMX8MN_CLK_USDHC3_ROOT,
347 imx_clk_gate4("usdhc3_root_clk", "usdhc3", base + 0x45e0, 0));
Ye Li418c1fc2020-04-18 08:19:12 -0700348 clk_dm(IMX8MN_CLK_QSPI_ROOT,
349 imx_clk_gate4("qspi_root_clk", "qspi", base + 0x42f0, 0));
Michael Trimarchi252e54e2022-08-30 16:45:20 +0200350 clk_dm(IMX8MN_CLK_NAND_ROOT,
351 imx_clk_gate2_shared2("nand_root_clk", "nand", base + 0x4300, 0, &share_count_nand));
352 clk_dm(IMX8MN_CLK_NAND_USDHC_BUS_RAWNAND_CLK,
353 imx_clk_gate2_shared2("nand_usdhc_rawnand_clk",
354 "nand_usdhc_bus", base + 0x4300, 0,
355 &share_count_nand));
Ye Li0321edb2020-04-19 02:22:09 -0700356 clk_dm(IMX8MN_CLK_USB1_CTRL_ROOT,
357 imx_clk_gate4("usb1_ctrl_root_clk", "usb_bus", base + 0x44d0, 0));
Ye Li418c1fc2020-04-18 08:19:12 -0700358
359 /* clks not needed in SPL stage */
360#ifndef CONFIG_SPL_BUILD
361 clk_dm(IMX8MN_CLK_ENET_REF,
362 imx8m_clk_composite("enet_ref", imx8mn_enet_ref_sels,
363 base + 0xa980));
364 clk_dm(IMX8MN_CLK_ENET_TIMER,
365 imx8m_clk_composite("enet_timer", imx8mn_enet_timer_sels,
366 base + 0xaa00));
367 clk_dm(IMX8MN_CLK_ENET_PHY_REF,
368 imx8m_clk_composite("enet_phy", imx8mn_enet_phy_sels,
369 base + 0xaa80));
370 clk_dm(IMX8MN_CLK_ENET1_ROOT,
371 imx_clk_gate4("enet1_root_clk", "enet_axi",
372 base + 0x40a0, 0));
Nicolas Heemerycke5e85232023-12-11 11:06:13 +0100373 clk_dm(IMX8MN_CLK_PWM1,
374 imx8m_clk_composite("pwm1", imx8mn_pwm1_sels, base + 0xb380));
375 clk_dm(IMX8MN_CLK_PWM2,
376 imx8m_clk_composite("pwm2", imx8mn_pwm2_sels, base + 0xb400));
377 clk_dm(IMX8MN_CLK_PWM3,
378 imx8m_clk_composite("pwm3", imx8mn_pwm3_sels, base + 0xb480));
379 clk_dm(IMX8MN_CLK_PWM4,
380 imx8m_clk_composite("pwm4", imx8mn_pwm4_sels, base + 0xb500));
381 clk_dm(IMX8MN_CLK_PWM1_ROOT,
382 imx_clk_gate4("pwm1_root_clk", "pwm1", base + 0x4280, 0));
383 clk_dm(IMX8MN_CLK_PWM2_ROOT,
384 imx_clk_gate4("pwm2_root_clk", "pwm2", base + 0x4290, 0));
385 clk_dm(IMX8MN_CLK_PWM3_ROOT,
386 imx_clk_gate4("pwm3_root_clk", "pwm3", base + 0x42a0, 0));
387 clk_dm(IMX8MN_CLK_PWM4_ROOT,
388 imx_clk_gate4("pwm4_root_clk", "pwm4", base + 0x42b0, 0));
Ye Li418c1fc2020-04-18 08:19:12 -0700389#endif
Peng Fane2f674d2019-09-16 03:09:47 +0000390
Marek Vasutb1a8bb02021-01-19 00:58:31 +0100391#if CONFIG_IS_ENABLED(DM_SPI)
392 clk_dm(IMX8MN_CLK_ECSPI1,
393 imx8m_clk_composite("ecspi1", imx8mn_ecspi1_sels, base + 0xb280));
394 clk_dm(IMX8MN_CLK_ECSPI2,
395 imx8m_clk_composite("ecspi2", imx8mn_ecspi2_sels, base + 0xb300));
396 clk_dm(IMX8MN_CLK_ECSPI3,
397 imx8m_clk_composite("ecspi3", imx8mn_ecspi3_sels, base + 0xc180));
398 clk_dm(IMX8MN_CLK_ECSPI1_ROOT,
399 imx_clk_gate4("ecspi1_root_clk", "ecspi1", base + 0x4070, 0));
400 clk_dm(IMX8MN_CLK_ECSPI2_ROOT,
401 imx_clk_gate4("ecspi2_root_clk", "ecspi2", base + 0x4080, 0));
402 clk_dm(IMX8MN_CLK_ECSPI3_ROOT,
403 imx_clk_gate4("ecspi3_root_clk", "ecspi3", base + 0x4090, 0));
404#endif
405
Peng Fane2f674d2019-09-16 03:09:47 +0000406 return 0;
407}
408
409static const struct udevice_id imx8mn_clk_ids[] = {
410 { .compatible = "fsl,imx8mn-ccm" },
411 { },
412};
413
414U_BOOT_DRIVER(imx8mn_clk) = {
415 .name = "clk_imx8mn",
416 .id = UCLASS_CLK,
417 .of_match = imx8mn_clk_ids,
Sean Anderson35c84642022-03-20 16:34:46 -0400418 .ops = &ccf_clk_ops,
Peng Fane2f674d2019-09-16 03:09:47 +0000419 .probe = imx8mn_clk_probe,
420 .flags = DM_FLAG_PRE_RELOC,
421};