1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2013 Soren Brinkmann <soren.brinkmann@xilinx.com>
4 * Copyright (C) 2013 Xilinx, Inc. All rights reserved.
9 #include <asm/arch/clk.h>
11 DECLARE_GLOBAL_DATA_PTR;
13 static const char * const clk_names[clk_max] = {
14 "armpll", "ddrpll", "iopll",
15 "cpu_6or4x", "cpu_3or2x", "cpu_2x", "cpu_1x",
16 "ddr2x", "ddr3x", "dci",
17 "lqspi", "smc", "pcap", "gem0", "gem1",
18 "fclk0", "fclk1", "fclk2", "fclk3", "can0", "can1",
19 "sdio0", "sdio1", "uart0", "uart1", "spi0", "spi1", "dma",
20 "usb0_aper", "usb1_aper", "gem0_aper", "gem1_aper",
21 "sdio0_aper", "sdio1_aper", "spi0_aper", "spi1_aper",
22 "can0_aper", "can1_aper", "i2c0_aper", "i2c1_aper",
23 "uart0_aper", "uart1_aper", "gpio_aper", "lqspi_aper",
24 "smc_aper", "swdt", "dbg_trc", "dbg_apb"
28 * set_cpu_clk_info() - Setup clock information
30 * This function is called from common code after relocation and sets up the
33 int set_cpu_clk_info(void)
40 ret = uclass_get_device_by_driver(UCLASS_CLK,
41 DM_GET_DRIVER(zynq_clk), &dev);
45 for (i = 0; i < 2; i++) {
46 clk.id = i ? ddr3x_clk : cpu_6or4x_clk;
47 ret = clk_request(dev, &clk);
51 rate = clk_get_rate(&clk) / 1000000;
53 gd->bd->bi_ddr_freq = rate;
55 gd->bd->bi_arm_freq = rate;
59 gd->bd->bi_dsp_freq = 0;
65 * soc_clk_dump() - Print clock frequencies
66 * Returns zero on success
68 * Implementation for the clk dump command.
70 int soc_clk_dump(void)
75 ret = uclass_get_device_by_driver(UCLASS_CLK,
76 DM_GET_DRIVER(zynq_clk), &dev);
80 printf("clk\t\tfrequency\n");
81 for (i = 0; i < clk_max; i++) {
82 const char *name = clk_names[i];
88 ret = clk_request(dev, &clk);
92 rate = clk_get_rate(&clk);
96 if ((rate == (unsigned long)-ENOSYS) ||
97 (rate == (unsigned long)-ENXIO))
98 printf("%10s%20s\n", name, "unknown");
100 printf("%10s%20lu\n", name, rate);