1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2019 Intel Corporation <www.intel.com>
12 #include <asm/arch/clock_manager.h>
13 #include <asm/arch/system_manager.h>
15 #include <dt-bindings/clock/agilex-clock.h>
17 DECLARE_GLOBAL_DATA_PTR;
19 static ulong cm_get_rate_dm(u32 id)
26 ret = uclass_get_device_by_driver(UCLASS_CLK,
27 DM_DRIVER_GET(socfpga_agilex_clk),
33 ret = clk_request(dev, &clk);
37 rate = clk_get_rate(&clk);
41 if ((rate == (unsigned long)-ENOSYS) ||
42 (rate == (unsigned long)-ENXIO) ||
43 (rate == (unsigned long)-EIO)) {
44 debug("%s id %u: clk_get_rate err: %ld\n",
52 static u32 cm_get_rate_dm_khz(u32 id)
54 return cm_get_rate_dm(id) / 1000;
57 unsigned long cm_get_mpu_clk_hz(void)
59 return cm_get_rate_dm(AGILEX_MPU_CLK);
62 unsigned int cm_get_l4_sys_free_clk_hz(void)
64 return cm_get_rate_dm(AGILEX_L4_SYS_FREE_CLK);
67 u32 cm_get_qspi_controller_clk_hz(void)
69 return readl(socfpga_get_sysmgr_addr() +
70 SYSMGR_SOC64_BOOT_SCRATCH_COLD0);
73 void cm_print_clock_quick_summary(void)
75 printf("MPU %10d kHz\n",
76 cm_get_rate_dm_khz(AGILEX_MPU_CLK));
77 printf("L4 Main %8d kHz\n",
78 cm_get_rate_dm_khz(AGILEX_L4_MAIN_CLK));
79 printf("L4 sys free %8d kHz\n",
80 cm_get_rate_dm_khz(AGILEX_L4_SYS_FREE_CLK));
81 printf("L4 MP %8d kHz\n",
82 cm_get_rate_dm_khz(AGILEX_L4_MP_CLK));
83 printf("L4 SP %8d kHz\n",
84 cm_get_rate_dm_khz(AGILEX_L4_SP_CLK));
85 printf("SDMMC %8d kHz\n",
86 cm_get_rate_dm_khz(AGILEX_SDMMC_CLK));