blob: a2b3ce78cc181424c019d56c902d9204ca7ac76d [file] [log] [blame]
Peng Fanb15705a2021-08-07 16:00:35 +08001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2020 NXP
4 */
5
6#include <common.h>
Peng Fan690eea12021-08-07 16:00:45 +08007#include <command.h>
Peng Fanb15705a2021-08-07 16:00:35 +08008#include <div64.h>
Peng Fan690eea12021-08-07 16:00:45 +08009#include <asm/arch/imx-regs.h>
Peng Fanb15705a2021-08-07 16:00:35 +080010#include <asm/io.h>
11#include <errno.h>
12#include <asm/arch/clock.h>
Peng Fan690eea12021-08-07 16:00:45 +080013#include <asm/arch/pcc.h>
14#include <asm/arch/cgc.h>
Peng Fanb15705a2021-08-07 16:00:35 +080015#include <asm/arch/sys_proto.h>
Peng Fan690eea12021-08-07 16:00:45 +080016#include <asm/global_data.h>
17#include <linux/delay.h>
Peng Fanb15705a2021-08-07 16:00:35 +080018
19DECLARE_GLOBAL_DATA_PTR;
20
Peng Fan690eea12021-08-07 16:00:45 +080021#define PLL_USB_EN_USB_CLKS_MASK (0x01 << 6)
22#define PLL_USB_PWR_MASK (0x01 << 12)
23#define PLL_USB_ENABLE_MASK (0x01 << 13)
24#define PLL_USB_BYPASS_MASK (0x01 << 16)
25#define PLL_USB_REG_ENABLE_MASK (0x01 << 21)
26#define PLL_USB_DIV_SEL_MASK (0x07 << 22)
27#define PLL_USB_LOCK_MASK (0x01 << 31)
28#define PCC5_LPDDR4_ADDR 0x2da70108
29
Ye Lida0469d2021-10-29 09:46:18 +080030static void lpuart_set_clk(u32 index, enum cgc_clk clk)
Peng Fan690eea12021-08-07 16:00:45 +080031{
32 const u32 lpuart_pcc_slots[] = {
33 LPUART4_PCC3_SLOT,
34 LPUART5_PCC3_SLOT,
35 LPUART6_PCC4_SLOT,
36 LPUART7_PCC4_SLOT,
37 };
38
39 const u32 lpuart_pcc[] = {
40 3, 3, 4, 4,
41 };
42
43 if (index > 3)
44 return;
45
46 pcc_clock_enable(lpuart_pcc[index], lpuart_pcc_slots[index], false);
47 pcc_clock_sel(lpuart_pcc[index], lpuart_pcc_slots[index], clk);
48 pcc_clock_enable(lpuart_pcc[index], lpuart_pcc_slots[index], true);
49
50 pcc_reset_peripheral(lpuart_pcc[index], lpuart_pcc_slots[index], false);
51}
52
53static void init_clk_lpuart(void)
54{
55 u32 index = 0, i;
56
57 const u32 lpuart_array[] = {
58 LPUART4_RBASE,
59 LPUART5_RBASE,
60 LPUART6_RBASE,
61 LPUART7_RBASE,
62 };
63
64 for (i = 0; i < 4; i++) {
65 if (lpuart_array[i] == LPUART_BASE) {
66 index = i;
67 break;
68 }
69 }
70
71 lpuart_set_clk(index, SOSC_DIV2);
72}
73
74void init_clk_fspi(int index)
75{
76 pcc_clock_enable(4, FLEXSPI2_PCC4_SLOT, false);
77 pcc_clock_sel(4, FLEXSPI2_PCC4_SLOT, PLL3_PFD2_DIV1);
78 pcc_clock_div_config(4, FLEXSPI2_PCC4_SLOT, false, 8);
79 pcc_clock_enable(4, FLEXSPI2_PCC4_SLOT, true);
80 pcc_reset_peripheral(4, FLEXSPI2_PCC4_SLOT, false);
81}
82
83void setclkout_ddr(void)
84{
85 writel(0x12800000, 0x2DA60020);
86 writel(0xa00, 0x298C0000); /* PTD0 */
87}
88
89void ddrphy_pll_lock(void)
90{
91 writel(0x00011542, 0x2E065964);
92 writel(0x00011542, 0x2E06586C);
93
94 writel(0x00000B01, 0x2E062000);
95 writel(0x00000B01, 0x2E060000);
96}
97
98void init_clk_ddr(void)
99{
Ye Li328f2012021-10-29 09:46:26 +0800100 /* disable the ddr pcc */
101 writel(0xc0000000, PCC5_LPDDR4_ADDR);
102
Peng Fan690eea12021-08-07 16:00:45 +0800103 /* enable pll4 and ddrclk*/
104 cgc2_pll4_init();
105 cgc2_ddrclk_config(1, 1);
106
107 /* enable ddr pcc */
108 writel(0xd0000000, PCC5_LPDDR4_ADDR);
109
Ye Li88408302021-10-29 09:46:30 +0800110 /* Wait until ddrclk reg lock bit is cleared, so that the div update is finished */
111 cgc2_ddrclk_wait_unlock();
112
Peng Fan690eea12021-08-07 16:00:45 +0800113 /* for debug */
114 /* setclkout_ddr(); */
115}
116
117int set_ddr_clk(u32 phy_freq_mhz)
118{
119 debug("%s %u\n", __func__, phy_freq_mhz);
120
121 if (phy_freq_mhz == 48) {
122 writel(0x90000000, PCC5_LPDDR4_ADDR); /* disable ddr pcc */
123 cgc2_ddrclk_config(2, 0); /* 24Mhz DDR clock */
124 writel(0xd0000000, PCC5_LPDDR4_ADDR); /* enable ddr pcc */
125 } else if (phy_freq_mhz == 384) {
126 writel(0x90000000, PCC5_LPDDR4_ADDR); /* disable ddr pcc */
127 cgc2_ddrclk_config(0, 0); /* 192Mhz DDR clock */
128 writel(0xd0000000, PCC5_LPDDR4_ADDR); /* enable ddr pcc */
129 } else if (phy_freq_mhz == 528) {
130 writel(0x90000000, PCC5_LPDDR4_ADDR); /* disable ddr pcc */
131 cgc2_ddrclk_config(4, 1); /* 264Mhz DDR clock */
132 writel(0xd0000000, PCC5_LPDDR4_ADDR); /* enable ddr pcc */
133 } else if (phy_freq_mhz == 264) {
134 writel(0x90000000, PCC5_LPDDR4_ADDR); /* disable ddr pcc */
135 cgc2_ddrclk_config(4, 3); /* 132Mhz DDR clock */
136 writel(0xd0000000, PCC5_LPDDR4_ADDR); /* enable ddr pcc */
137 } else if (phy_freq_mhz == 192) {
138 writel(0x90000000, PCC5_LPDDR4_ADDR); /* disable ddr pcc */
139 cgc2_ddrclk_config(0, 1); /* 96Mhz DDR clock */
140 writel(0xd0000000, PCC5_LPDDR4_ADDR); /* enable ddr pcc */
141 } else if (phy_freq_mhz == 96) {
142 writel(0x90000000, PCC5_LPDDR4_ADDR); /* disable ddr pcc */
143 cgc2_ddrclk_config(0, 3); /* 48Mhz DDR clock */
144 writel(0xd0000000, PCC5_LPDDR4_ADDR); /* enable ddr pcc */
145 } else {
146 printf("ddr phy clk %uMhz is not supported\n", phy_freq_mhz);
147 return -EINVAL;
148 }
149
Ye Li88408302021-10-29 09:46:30 +0800150 /* Wait until ddrclk reg lock bit is cleared, so that the div update is finished */
151 cgc2_ddrclk_wait_unlock();
152
Peng Fan690eea12021-08-07 16:00:45 +0800153 return 0;
154}
155
Peng Fanb15705a2021-08-07 16:00:35 +0800156void clock_init(void)
157{
Peng Fan690eea12021-08-07 16:00:45 +0800158 cgc1_soscdiv_init();
159 cgc1_init_core_clk();
160
161 init_clk_lpuart();
162
163 pcc_clock_enable(4, SDHC0_PCC4_SLOT, false);
164 pcc_clock_sel(4, SDHC0_PCC4_SLOT, PLL3_PFD1_DIV2);
165 pcc_clock_enable(4, SDHC0_PCC4_SLOT, true);
166 pcc_reset_peripheral(4, SDHC0_PCC4_SLOT, false);
167
168 pcc_clock_enable(4, SDHC1_PCC4_SLOT, false);
169 pcc_clock_sel(4, SDHC1_PCC4_SLOT, PLL3_PFD2_DIV1);
170 pcc_clock_enable(4, SDHC1_PCC4_SLOT, true);
171 pcc_reset_peripheral(4, SDHC1_PCC4_SLOT, false);
172
173 pcc_clock_enable(4, SDHC2_PCC4_SLOT, false);
174 pcc_clock_sel(4, SDHC2_PCC4_SLOT, PLL3_PFD2_DIV1);
175 pcc_clock_enable(4, SDHC2_PCC4_SLOT, true);
176 pcc_reset_peripheral(4, SDHC2_PCC4_SLOT, false);
177
178 /* Enable upower mu1 clk */
179 pcc_clock_enable(3, UPOWER_PCC3_SLOT, true);
180
181 /*
182 * Enable clock division
183 * TODO: may not needed after ROM ready.
184 */
185}
186
187#if IS_ENABLED(CONFIG_SYS_I2C_IMX_LPI2C)
188int enable_i2c_clk(unsigned char enable, u32 i2c_num)
189{
190 /* Set parent to FIRC DIV2 clock */
191 const u32 lpi2c_pcc_clks[] = {
192 LPI2C4_PCC3_SLOT << 8 | 3,
193 LPI2C5_PCC3_SLOT << 8 | 3,
194 LPI2C6_PCC4_SLOT << 8 | 4,
195 LPI2C7_PCC4_SLOT << 8 | 4,
196 };
197
Ye Li27666ca2021-10-29 09:46:21 +0800198 if (i2c_num == 0)
199 return 0;
200
Peng Fan690eea12021-08-07 16:00:45 +0800201 if (i2c_num < 4 || i2c_num > 7)
202 return -EINVAL;
203
204 if (enable) {
205 pcc_clock_enable(lpi2c_pcc_clks[i2c_num - 4] & 0xff,
206 lpi2c_pcc_clks[i2c_num - 4] >> 8, false);
207 pcc_clock_sel(lpi2c_pcc_clks[i2c_num - 4] & 0xff,
208 lpi2c_pcc_clks[i2c_num - 4] >> 8, SOSC_DIV2);
209 pcc_clock_enable(lpi2c_pcc_clks[i2c_num - 4] & 0xff,
210 lpi2c_pcc_clks[i2c_num - 4] >> 8, true);
211 pcc_reset_peripheral(lpi2c_pcc_clks[i2c_num - 4] & 0xff,
212 lpi2c_pcc_clks[i2c_num - 4] >> 8, false);
213 } else {
214 pcc_clock_enable(lpi2c_pcc_clks[i2c_num - 4] & 0xff,
215 lpi2c_pcc_clks[i2c_num - 4] >> 8, false);
216 }
217 return 0;
218}
219
220u32 imx_get_i2cclk(u32 i2c_num)
221{
222 const u32 lpi2c_pcc_clks[] = {
223 LPI2C4_PCC3_SLOT << 8 | 3,
224 LPI2C5_PCC3_SLOT << 8 | 3,
225 LPI2C6_PCC4_SLOT << 8 | 4,
226 LPI2C7_PCC4_SLOT << 8 | 4,
227 };
228
Ye Li27666ca2021-10-29 09:46:21 +0800229 if (i2c_num == 0)
230 return 24000000;
231
Peng Fan690eea12021-08-07 16:00:45 +0800232 if (i2c_num < 4 || i2c_num > 7)
233 return 0;
234
235 return pcc_clock_get_rate(lpi2c_pcc_clks[i2c_num - 4] & 0xff,
236 lpi2c_pcc_clks[i2c_num - 4] >> 8);
237}
238#endif
239
Clark Wang276dfd52022-04-06 14:30:09 +0800240#if IS_ENABLED(CONFIG_SYS_I2C_IMX_I3C)
241int enable_i3c_clk(unsigned char enable, u32 i3c_num)
242{
243 if (enable) {
244 pcc_clock_enable(3, I3C2_PCC3_SLOT, false);
245 pcc_clock_sel(3, I3C2_PCC3_SLOT, SOSC_DIV2);
246 pcc_clock_enable(3, I3C2_PCC3_SLOT, true);
247 pcc_reset_peripheral(3, I3C2_PCC3_SLOT, false);
248 } else {
249 pcc_clock_enable(3, I3C2_PCC3_SLOT, false);
250 }
251 return 0;
252}
253
254u32 imx_get_i3cclk(u32 i3c_num)
255{
256 return pcc_clock_get_rate(3, I3C2_PCC3_SLOT);
257}
258#endif
259
Peng Fan690eea12021-08-07 16:00:45 +0800260void enable_usboh3_clk(unsigned char enable)
261{
262 if (enable) {
263 pcc_clock_enable(4, USB0_PCC4_SLOT, true);
264 pcc_clock_enable(4, USBPHY_PCC4_SLOT, true);
265 pcc_reset_peripheral(4, USB0_PCC4_SLOT, false);
266 pcc_reset_peripheral(4, USBPHY_PCC4_SLOT, false);
267
268#ifdef CONFIG_USB_MAX_CONTROLLER_COUNT
269 if (CONFIG_USB_MAX_CONTROLLER_COUNT > 1) {
270 pcc_clock_enable(4, USB1_PCC4_SLOT, true);
271 pcc_clock_enable(4, USB1PHY_PCC4_SLOT, true);
272 pcc_reset_peripheral(4, USB1_PCC4_SLOT, false);
273 pcc_reset_peripheral(4, USB1PHY_PCC4_SLOT, false);
274 }
275#endif
276
277 pcc_clock_enable(4, USB_XBAR_PCC4_SLOT, true);
278 } else {
279 pcc_clock_enable(4, USB0_PCC4_SLOT, false);
280 pcc_clock_enable(4, USB1_PCC4_SLOT, false);
281 pcc_clock_enable(4, USBPHY_PCC4_SLOT, false);
282 pcc_clock_enable(4, USB1PHY_PCC4_SLOT, false);
283 pcc_clock_enable(4, USB_XBAR_PCC4_SLOT, false);
284 }
Peng Fanb15705a2021-08-07 16:00:35 +0800285}
286
Peng Fan690eea12021-08-07 16:00:45 +0800287int enable_usb_pll(ulong usb_phy_base)
Peng Fanb15705a2021-08-07 16:00:35 +0800288{
Peng Fan690eea12021-08-07 16:00:45 +0800289 u32 sosc_rate;
290 s32 timeout = 1000000;
291
292 struct usbphy_regs *usbphy =
293 (struct usbphy_regs *)usb_phy_base;
294
295 sosc_rate = cgc1_sosc_div(SOSC);
296 if (!sosc_rate)
297 return -EPERM;
298
299 if (!(readl(&usbphy->usb1_pll_480_ctrl) & PLL_USB_LOCK_MASK)) {
300 writel(0x1c00000, &usbphy->usb1_pll_480_ctrl_clr);
301
302 switch (sosc_rate) {
303 case 24000000:
304 writel(0xc00000, &usbphy->usb1_pll_480_ctrl_set);
305 break;
306
307 case 30000000:
308 writel(0x800000, &usbphy->usb1_pll_480_ctrl_set);
309 break;
310
311 case 19200000:
312 writel(0x1400000, &usbphy->usb1_pll_480_ctrl_set);
313 break;
314
315 default:
316 writel(0xc00000, &usbphy->usb1_pll_480_ctrl_set);
317 break;
318 }
319
320 /* Enable the regulator first */
321 writel(PLL_USB_REG_ENABLE_MASK,
322 &usbphy->usb1_pll_480_ctrl_set);
323
324 /* Wait at least 15us */
325 udelay(15);
326
327 /* Enable the power */
328 writel(PLL_USB_PWR_MASK, &usbphy->usb1_pll_480_ctrl_set);
329
330 /* Wait lock */
331 while (timeout--) {
332 if (readl(&usbphy->usb1_pll_480_ctrl) &
333 PLL_USB_LOCK_MASK)
334 break;
335 }
336
337 if (timeout <= 0) {
338 /* If timeout, we power down the pll */
339 writel(PLL_USB_PWR_MASK,
340 &usbphy->usb1_pll_480_ctrl_clr);
341 return -ETIME;
342 }
343 }
344
345 /* Clear the bypass */
346 writel(PLL_USB_BYPASS_MASK, &usbphy->usb1_pll_480_ctrl_clr);
347
348 /* Enable the PLL clock out to USB */
349 writel((PLL_USB_EN_USB_CLKS_MASK | PLL_USB_ENABLE_MASK),
350 &usbphy->usb1_pll_480_ctrl_set);
351
Peng Fanb15705a2021-08-07 16:00:35 +0800352 return 0;
353}
354
Ye Li3d3dfb02021-10-29 09:46:19 +0800355void enable_mipi_dsi_clk(unsigned char enable)
356{
357 if (enable) {
358 pcc_clock_enable(5, DSI_PCC5_SLOT, false);
Ye Licb7e3752021-10-29 09:46:27 +0800359 pcc_reset_peripheral(5, DSI_PCC5_SLOT, true);
Ye Li3d3dfb02021-10-29 09:46:19 +0800360 pcc_clock_sel(5, DSI_PCC5_SLOT, PLL4_PFD3_DIV2);
361 pcc_clock_div_config(5, DSI_PCC5_SLOT, 0, 6);
362 pcc_clock_enable(5, DSI_PCC5_SLOT, true);
363 pcc_reset_peripheral(5, DSI_PCC5_SLOT, false);
364 } else {
365 pcc_clock_enable(5, DSI_PCC5_SLOT, false);
366 pcc_reset_peripheral(5, DSI_PCC5_SLOT, true);
367 }
368}
369
Alice Guo23ee0e12021-10-29 09:46:29 +0800370void enable_adc1_clk(bool enable)
371{
372 if (enable) {
373 pcc_clock_enable(1, ADC1_PCC1_SLOT, false);
374 pcc_clock_sel(1, ADC1_PCC1_SLOT, CM33_BUSCLK);
375 pcc_clock_enable(1, ADC1_PCC1_SLOT, true);
376 pcc_reset_peripheral(1, ADC1_PCC1_SLOT, false);
377 } else {
378 pcc_clock_enable(1, ADC1_PCC1_SLOT, false);
379 }
380}
381
Ye Licb7e3752021-10-29 09:46:27 +0800382void reset_lcdclk(void)
383{
384 /* Disable clock and reset dcnano*/
385 pcc_clock_enable(5, DCNANO_PCC5_SLOT, false);
386 pcc_reset_peripheral(5, DCNANO_PCC5_SLOT, true);
387}
388
Ye Li3d3dfb02021-10-29 09:46:19 +0800389void mxs_set_lcdclk(u32 base_addr, u32 freq_in_khz)
390{
391 u8 pcd, best_pcd = 0;
392 u32 frac, rate, parent_rate, pfd, div;
393 u32 best_pfd = 0, best_frac = 0, best = 0, best_div = 0;
394 u32 pll4_rate;
395
396 pcc_clock_enable(5, DCNANO_PCC5_SLOT, false);
397
398 pll4_rate = cgc_clk_get_rate(PLL4);
399 pll4_rate = pll4_rate / 1000; /* Change to khz*/
400
401 debug("PLL4 rate %ukhz\n", pll4_rate);
402
403 for (pfd = 12; pfd <= 35; pfd++) {
404 parent_rate = pll4_rate;
405 parent_rate = parent_rate * 18 / pfd;
406
407 for (div = 1; div <= 64; div++) {
408 parent_rate = parent_rate / div;
409
410 for (pcd = 0; pcd < 8; pcd++) {
411 for (frac = 0; frac < 2; frac++) {
412 if (pcd == 0 && frac == 1)
413 continue;
414
415 rate = parent_rate * (frac + 1) / (pcd + 1);
416 if (rate > freq_in_khz)
417 continue;
418
419 if (best == 0 || rate > best) {
420 best = rate;
421 best_pfd = pfd;
422 best_frac = frac;
423 best_pcd = pcd;
424 best_div = div;
425 }
426 }
427 }
428 }
429 }
430
431 if (best == 0) {
432 printf("Can't find parent clock for LCDIF, target freq: %u\n", freq_in_khz);
433 return;
434 }
435
436 debug("LCD target rate %ukhz, best rate %ukhz, frac %u, pcd %u, best_pfd %u, best_div %u\n",
437 freq_in_khz, best, best_frac, best_pcd, best_pfd, best_div);
438
439 cgc2_pll4_pfd_config(PLL4_PFD0, best_pfd);
440 cgc2_pll4_pfddiv_config(PLL4_PFD0_DIV1, best_div - 1);
441
442 pcc_clock_sel(5, DCNANO_PCC5_SLOT, PLL4_PFD0_DIV1);
443 pcc_clock_div_config(5, DCNANO_PCC5_SLOT, best_frac, best_pcd + 1);
444 pcc_clock_enable(5, DCNANO_PCC5_SLOT, true);
445 pcc_reset_peripheral(5, DCNANO_PCC5_SLOT, false);
446}
447
Peng Fan690eea12021-08-07 16:00:45 +0800448u32 mxc_get_clock(enum mxc_clock clk)
449{
450 switch (clk) {
451 case MXC_ESDHC_CLK:
452 return pcc_clock_get_rate(4, SDHC0_PCC4_SLOT);
453 case MXC_ESDHC2_CLK:
454 return pcc_clock_get_rate(4, SDHC1_PCC4_SLOT);
455 case MXC_ESDHC3_CLK:
456 return pcc_clock_get_rate(4, SDHC2_PCC4_SLOT);
457 case MXC_ARM_CLK:
Ye Lida0469d2021-10-29 09:46:18 +0800458 return cgc_clk_get_rate(PLL2);
Peng Fan690eea12021-08-07 16:00:45 +0800459 default:
460 return 0;
461 }
462}
463
Peng Fanb15705a2021-08-07 16:00:35 +0800464u32 get_lpuart_clk(void)
465{
Peng Fan690eea12021-08-07 16:00:45 +0800466 int index = 0;
467
468 const u32 lpuart_array[] = {
469 LPUART4_RBASE,
470 LPUART5_RBASE,
471 LPUART6_RBASE,
472 LPUART7_RBASE,
473 };
474
475 const u32 lpuart_pcc_slots[] = {
476 LPUART4_PCC3_SLOT,
477 LPUART5_PCC3_SLOT,
478 LPUART6_PCC4_SLOT,
479 LPUART7_PCC4_SLOT,
480 };
481
482 const u32 lpuart_pcc[] = {
483 3, 3, 4, 4,
484 };
485
486 for (index = 0; index < 4; index++) {
487 if (lpuart_array[index] == LPUART_BASE)
488 break;
489 }
490
491 if (index > 3)
492 return 0;
493
494 return pcc_clock_get_rate(lpuart_pcc[index], lpuart_pcc_slots[index]);
495}
496
497#ifndef CONFIG_SPL_BUILD
498/*
499 * Dump some core clockes.
500 */
501int do_mx8ulp_showclocks(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
502{
503 printf("SDHC0 %8d MHz\n", pcc_clock_get_rate(4, SDHC0_PCC4_SLOT) / 1000000);
504 printf("SDHC1 %8d MHz\n", pcc_clock_get_rate(4, SDHC1_PCC4_SLOT) / 1000000);
505 printf("SDHC2 %8d MHz\n", pcc_clock_get_rate(4, SDHC2_PCC4_SLOT) / 1000000);
506
Ye Lida0469d2021-10-29 09:46:18 +0800507 printf("SOSC %8d MHz\n", cgc_clk_get_rate(SOSC) / 1000000);
508 printf("FRO %8d MHz\n", cgc_clk_get_rate(FRO) / 1000000);
509 printf("PLL2 %8d MHz\n", cgc_clk_get_rate(PLL2) / 1000000);
510 printf("PLL3 %8d MHz\n", cgc_clk_get_rate(PLL3) / 1000000);
511 printf("PLL3_VCODIV %8d MHz\n", cgc_clk_get_rate(PLL3_VCODIV) / 1000000);
512 printf("PLL3_PFD0 %8d MHz\n", cgc_clk_get_rate(PLL3_PFD0) / 1000000);
513 printf("PLL3_PFD1 %8d MHz\n", cgc_clk_get_rate(PLL3_PFD1) / 1000000);
514 printf("PLL3_PFD2 %8d MHz\n", cgc_clk_get_rate(PLL3_PFD2) / 1000000);
515 printf("PLL3_PFD3 %8d MHz\n", cgc_clk_get_rate(PLL3_PFD3) / 1000000);
516
517 printf("PLL4_PFD0 %8d MHz\n", cgc_clk_get_rate(PLL4_PFD0) / 1000000);
518 printf("PLL4_PFD1 %8d MHz\n", cgc_clk_get_rate(PLL4_PFD1) / 1000000);
519 printf("PLL4_PFD2 %8d MHz\n", cgc_clk_get_rate(PLL4_PFD2) / 1000000);
520 printf("PLL4_PFD3 %8d MHz\n", cgc_clk_get_rate(PLL4_PFD3) / 1000000);
521
522 printf("PLL4_PFD0_DIV1 %8d MHz\n", cgc_clk_get_rate(PLL4_PFD0_DIV1) / 1000000);
523 printf("PLL4_PFD0_DIV2 %8d MHz\n", cgc_clk_get_rate(PLL4_PFD0_DIV2) / 1000000);
524 printf("PLL4_PFD1_DIV1 %8d MHz\n", cgc_clk_get_rate(PLL4_PFD1_DIV1) / 1000000);
525 printf("PLL4_PFD1_DIV2 %8d MHz\n", cgc_clk_get_rate(PLL4_PFD1_DIV2) / 1000000);
526
527 printf("PLL4_PFD2_DIV1 %8d MHz\n", cgc_clk_get_rate(PLL4_PFD2_DIV1) / 1000000);
528 printf("PLL4_PFD2_DIV2 %8d MHz\n", cgc_clk_get_rate(PLL4_PFD2_DIV2) / 1000000);
529 printf("PLL4_PFD3_DIV1 %8d MHz\n", cgc_clk_get_rate(PLL4_PFD3_DIV1) / 1000000);
530 printf("PLL4_PFD3_DIV2 %8d MHz\n", cgc_clk_get_rate(PLL4_PFD3_DIV2) / 1000000);
531
532 printf("LPAV_AXICLK %8d MHz\n", cgc_clk_get_rate(LPAV_AXICLK) / 1000000);
533 printf("LPAV_AHBCLK %8d MHz\n", cgc_clk_get_rate(LPAV_AHBCLK) / 1000000);
534 printf("LPAV_BUSCLK %8d MHz\n", cgc_clk_get_rate(LPAV_BUSCLK) / 1000000);
535 printf("NIC_APCLK %8d MHz\n", cgc_clk_get_rate(NIC_APCLK) / 1000000);
Peng Fan690eea12021-08-07 16:00:45 +0800536
Ye Lida0469d2021-10-29 09:46:18 +0800537 printf("NIC_PERCLK %8d MHz\n", cgc_clk_get_rate(NIC_PERCLK) / 1000000);
538 printf("XBAR_APCLK %8d MHz\n", cgc_clk_get_rate(XBAR_APCLK) / 1000000);
539 printf("XBAR_BUSCLK %8d MHz\n", cgc_clk_get_rate(XBAR_BUSCLK) / 1000000);
540 printf("AD_SLOWCLK %8d MHz\n", cgc_clk_get_rate(AD_SLOWCLK) / 1000000);
Peng Fan690eea12021-08-07 16:00:45 +0800541 return 0;
Peng Fanb15705a2021-08-07 16:00:35 +0800542}
Peng Fan690eea12021-08-07 16:00:45 +0800543
544U_BOOT_CMD(
545 clocks, CONFIG_SYS_MAXARGS, 1, do_mx8ulp_showclocks,
546 "display clocks",
547 ""
548);
549#endif