1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2016 Xilinx, Inc.
9 #include <linux/bitops.h>
10 #include <clk-uclass.h>
12 #include <asm/arch/sys_proto.h>
15 static const resource_size_t zynqmp_crf_apb_clkc_base = 0xfd1a0020;
16 static const resource_size_t zynqmp_crl_apb_clkc_base = 0xff5e0020;
18 /* Full power domain clocks */
19 #define CRF_APB_APLL_CTRL (zynqmp_crf_apb_clkc_base + 0x00)
20 #define CRF_APB_DPLL_CTRL (zynqmp_crf_apb_clkc_base + 0x0c)
21 #define CRF_APB_VPLL_CTRL (zynqmp_crf_apb_clkc_base + 0x18)
22 #define CRF_APB_PLL_STATUS (zynqmp_crf_apb_clkc_base + 0x24)
23 #define CRF_APB_APLL_TO_LPD_CTRL (zynqmp_crf_apb_clkc_base + 0x28)
24 #define CRF_APB_DPLL_TO_LPD_CTRL (zynqmp_crf_apb_clkc_base + 0x2c)
25 #define CRF_APB_VPLL_TO_LPD_CTRL (zynqmp_crf_apb_clkc_base + 0x30)
26 /* Peripheral clocks */
27 #define CRF_APB_ACPU_CTRL (zynqmp_crf_apb_clkc_base + 0x40)
28 #define CRF_APB_DBG_TRACE_CTRL (zynqmp_crf_apb_clkc_base + 0x44)
29 #define CRF_APB_DBG_FPD_CTRL (zynqmp_crf_apb_clkc_base + 0x48)
30 #define CRF_APB_DP_VIDEO_REF_CTRL (zynqmp_crf_apb_clkc_base + 0x50)
31 #define CRF_APB_DP_AUDIO_REF_CTRL (zynqmp_crf_apb_clkc_base + 0x54)
32 #define CRF_APB_DP_STC_REF_CTRL (zynqmp_crf_apb_clkc_base + 0x5c)
33 #define CRF_APB_DDR_CTRL (zynqmp_crf_apb_clkc_base + 0x60)
34 #define CRF_APB_GPU_REF_CTRL (zynqmp_crf_apb_clkc_base + 0x64)
35 #define CRF_APB_SATA_REF_CTRL (zynqmp_crf_apb_clkc_base + 0x80)
36 #define CRF_APB_PCIE_REF_CTRL (zynqmp_crf_apb_clkc_base + 0x94)
37 #define CRF_APB_GDMA_REF_CTRL (zynqmp_crf_apb_clkc_base + 0x98)
38 #define CRF_APB_DPDMA_REF_CTRL (zynqmp_crf_apb_clkc_base + 0x9c)
39 #define CRF_APB_TOPSW_MAIN_CTRL (zynqmp_crf_apb_clkc_base + 0xa0)
40 #define CRF_APB_TOPSW_LSBUS_CTRL (zynqmp_crf_apb_clkc_base + 0xa4)
41 #define CRF_APB_GTGREF0_REF_CTRL (zynqmp_crf_apb_clkc_base + 0xa8)
42 #define CRF_APB_DBG_TSTMP_CTRL (zynqmp_crf_apb_clkc_base + 0xd8)
44 /* Low power domain clocks */
45 #define CRL_APB_IOPLL_CTRL (zynqmp_crl_apb_clkc_base + 0x00)
46 #define CRL_APB_RPLL_CTRL (zynqmp_crl_apb_clkc_base + 0x10)
47 #define CRL_APB_PLL_STATUS (zynqmp_crl_apb_clkc_base + 0x20)
48 #define CRL_APB_IOPLL_TO_FPD_CTRL (zynqmp_crl_apb_clkc_base + 0x24)
49 #define CRL_APB_RPLL_TO_FPD_CTRL (zynqmp_crl_apb_clkc_base + 0x28)
50 /* Peripheral clocks */
51 #define CRL_APB_USB3_DUAL_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x2c)
52 #define CRL_APB_GEM0_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x30)
53 #define CRL_APB_GEM1_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x34)
54 #define CRL_APB_GEM2_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x38)
55 #define CRL_APB_GEM3_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x3c)
56 #define CRL_APB_USB0_BUS_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x40)
57 #define CRL_APB_USB1_BUS_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x44)
58 #define CRL_APB_QSPI_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x48)
59 #define CRL_APB_SDIO0_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x4c)
60 #define CRL_APB_SDIO1_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x50)
61 #define CRL_APB_UART0_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x54)
62 #define CRL_APB_UART1_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x58)
63 #define CRL_APB_SPI0_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x5c)
64 #define CRL_APB_SPI1_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x60)
65 #define CRL_APB_CAN0_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x64)
66 #define CRL_APB_CAN1_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x68)
67 #define CRL_APB_CPU_R5_CTRL (zynqmp_crl_apb_clkc_base + 0x70)
68 #define CRL_APB_IOU_SWITCH_CTRL (zynqmp_crl_apb_clkc_base + 0x7c)
69 #define CRL_APB_CSU_PLL_CTRL (zynqmp_crl_apb_clkc_base + 0x80)
70 #define CRL_APB_PCAP_CTRL (zynqmp_crl_apb_clkc_base + 0x84)
71 #define CRL_APB_LPD_SWITCH_CTRL (zynqmp_crl_apb_clkc_base + 0x88)
72 #define CRL_APB_LPD_LSBUS_CTRL (zynqmp_crl_apb_clkc_base + 0x8c)
73 #define CRL_APB_DBG_LPD_CTRL (zynqmp_crl_apb_clkc_base + 0x90)
74 #define CRL_APB_NAND_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x94)
75 #define CRL_APB_ADMA_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x98)
76 #define CRL_APB_PL0_REF_CTRL (zynqmp_crl_apb_clkc_base + 0xa0)
77 #define CRL_APB_PL1_REF_CTRL (zynqmp_crl_apb_clkc_base + 0xa4)
78 #define CRL_APB_PL2_REF_CTRL (zynqmp_crl_apb_clkc_base + 0xa8)
79 #define CRL_APB_PL3_REF_CTRL (zynqmp_crl_apb_clkc_base + 0xac)
80 #define CRL_APB_PL0_THR_CNT (zynqmp_crl_apb_clkc_base + 0xb4)
81 #define CRL_APB_PL1_THR_CNT (zynqmp_crl_apb_clkc_base + 0xbc)
82 #define CRL_APB_PL2_THR_CNT (zynqmp_crl_apb_clkc_base + 0xc4)
83 #define CRL_APB_PL3_THR_CNT (zynqmp_crl_apb_clkc_base + 0xdc)
84 #define CRL_APB_GEM_TSU_REF_CTRL (zynqmp_crl_apb_clkc_base + 0xe0)
85 #define CRL_APB_DLL_REF_CTRL (zynqmp_crl_apb_clkc_base + 0xe4)
86 #define CRL_APB_AMS_REF_CTRL (zynqmp_crl_apb_clkc_base + 0xe8)
87 #define CRL_APB_I2C0_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x100)
88 #define CRL_APB_I2C1_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x104)
89 #define CRL_APB_TIMESTAMP_REF_CTRL (zynqmp_crl_apb_clkc_base + 0x108)
91 #define ZYNQ_CLK_MAXDIV 0x3f
92 #define CLK_CTRL_DIV1_SHIFT 16
93 #define CLK_CTRL_DIV1_MASK (ZYNQ_CLK_MAXDIV << CLK_CTRL_DIV1_SHIFT)
94 #define CLK_CTRL_DIV0_SHIFT 8
95 #define CLK_CTRL_DIV0_MASK (ZYNQ_CLK_MAXDIV << CLK_CTRL_DIV0_SHIFT)
96 #define CLK_CTRL_SRCSEL_SHIFT 0
97 #define CLK_CTRL_SRCSEL_MASK (0x3 << CLK_CTRL_SRCSEL_SHIFT)
98 #define PLLCTRL_FBDIV_MASK 0x7f00
99 #define PLLCTRL_FBDIV_SHIFT 8
100 #define PLLCTRL_RESET_MASK 1
101 #define PLLCTRL_RESET_SHIFT 0
102 #define PLLCTRL_BYPASS_MASK 0x8
103 #define PLLCTRL_BYPASS_SHFT 3
104 #define PLLCTRL_POST_SRC_SHFT 24
105 #define PLLCTRL_POST_SRC_MASK (0x7 << PLLCTRL_POST_SRC_SHFT)
106 #define PLLCTRL_PRE_SRC_SHFT 20
107 #define PLLCTRL_PRE_SRC_MASK (0x7 << PLLCTRL_PRE_SRC_SHFT)
110 #define NUM_MIO_PINS 77
115 iopll_to_fpd, rpll_to_fpd, apll_to_lpd, dpll_to_lpd, vpll_to_lpd,
117 dbg_fpd, dbg_lpd, dbg_trace, dbg_tstmp,
118 dp_video_ref, dp_audio_ref,
119 dp_stc_ref, gdma_ref, dpdma_ref,
120 ddr_ref, sata_ref, pcie_ref,
121 gpu_ref, gpu_pp0_ref, gpu_pp1_ref,
122 topsw_main, topsw_lsbus,
124 lpd_switch, lpd_lsbus,
125 usb0_bus_ref, usb1_bus_ref, usb3_dual_ref, usb0, usb1,
127 csu_spb, csu_pll, pcap,
129 gem_tsu_ref, gem_tsu,
130 gem0_ref, gem1_ref, gem2_ref, gem3_ref,
131 gem0_rx, gem1_rx, gem2_rx, gem3_rx,
133 sdio0_ref, sdio1_ref,
134 uart0_ref, uart1_ref,
137 i2c0_ref, i2c1_ref, can0_ref, can1_ref, can0, can1,
147 static const char * const clk_names[clk_max] = {
148 "iopll", "rpll", "apll", "dpll",
149 "vpll", "iopll_to_fpd", "rpll_to_fpd",
150 "apll_to_lpd", "dpll_to_lpd", "vpll_to_lpd",
151 "acpu", "acpu_half", "dbf_fpd", "dbf_lpd",
152 "dbg_trace", "dbg_tstmp", "dp_video_ref",
153 "dp_audio_ref", "dp_stc_ref", "gdma_ref",
154 "dpdma_ref", "ddr_ref", "sata_ref", "pcie_ref",
155 "gpu_ref", "gpu_pp0_ref", "gpu_pp1_ref",
156 "topsw_main", "topsw_lsbus", "gtgref0_ref",
157 "lpd_switch", "lpd_lsbus", "usb0_bus_ref",
158 "usb1_bus_ref", "usb3_dual_ref", "usb0",
159 "usb1", "cpu_r5", "cpu_r5_core", "csu_spb",
160 "csu_pll", "pcap", "iou_switch", "gem_tsu_ref",
161 "gem_tsu", "gem0_ref", "gem1_ref", "gem2_ref",
162 "gem3_ref", "gem0_tx", "gem1_tx", "gem2_tx",
163 "gem3_tx", "qspi_ref", "sdio0_ref", "sdio1_ref",
164 "uart0_ref", "uart1_ref", "spi0_ref",
165 "spi1_ref", "nand_ref", "i2c0_ref", "i2c1_ref",
166 "can0_ref", "can1_ref", "can0", "can1",
167 "dll_ref", "adma_ref", "timestamp_ref",
168 "ams_ref", "pl0", "pl1", "pl2", "pl3", "wdt"
171 struct zynqmp_clk_priv {
172 unsigned long ps_clk_freq;
173 unsigned long video_clk;
174 unsigned long pss_alt_ref_clk;
175 unsigned long gt_crx_ref_clk;
176 unsigned long aux_ref_clk;
179 static u32 zynqmp_clk_get_register(enum zynqmp_clk id)
183 return CRL_APB_IOPLL_CTRL;
185 return CRL_APB_RPLL_CTRL;
187 return CRF_APB_APLL_CTRL;
189 return CRF_APB_DPLL_CTRL;
191 return CRF_APB_VPLL_CTRL;
193 return CRF_APB_ACPU_CTRL;
195 return CRF_APB_DDR_CTRL;
197 return CRL_APB_QSPI_REF_CTRL;
199 return CRL_APB_GEM0_REF_CTRL;
201 return CRL_APB_GEM1_REF_CTRL;
203 return CRL_APB_GEM2_REF_CTRL;
205 return CRL_APB_GEM3_REF_CTRL;
207 return CRL_APB_UART0_REF_CTRL;
209 return CRL_APB_UART1_REF_CTRL;
211 return CRL_APB_SDIO0_REF_CTRL;
213 return CRL_APB_SDIO1_REF_CTRL;
215 return CRL_APB_SPI0_REF_CTRL;
217 return CRL_APB_SPI1_REF_CTRL;
219 return CRL_APB_NAND_REF_CTRL;
221 return CRL_APB_I2C0_REF_CTRL;
223 return CRL_APB_I2C1_REF_CTRL;
225 return CRL_APB_CAN0_REF_CTRL;
227 return CRL_APB_CAN1_REF_CTRL;
229 return CRL_APB_PL0_REF_CTRL;
231 return CRL_APB_PL1_REF_CTRL;
233 return CRL_APB_PL2_REF_CTRL;
235 return CRL_APB_PL3_REF_CTRL;
237 return CRF_APB_TOPSW_LSBUS_CTRL;
239 return CRL_APB_IOPLL_TO_FPD_CTRL;
241 debug("Invalid clk id%d\n", id);
246 static enum zynqmp_clk zynqmp_clk_get_cpu_pll(u32 clk_ctrl)
248 u32 srcsel = (clk_ctrl & CLK_CTRL_SRCSEL_MASK) >>
249 CLK_CTRL_SRCSEL_SHIFT;
262 static enum zynqmp_clk zynqmp_clk_get_ddr_pll(u32 clk_ctrl)
264 u32 srcsel = (clk_ctrl & CLK_CTRL_SRCSEL_MASK) >>
265 CLK_CTRL_SRCSEL_SHIFT;
276 static enum zynqmp_clk zynqmp_clk_get_peripheral_pll(u32 clk_ctrl)
278 u32 srcsel = (clk_ctrl & CLK_CTRL_SRCSEL_MASK) >>
279 CLK_CTRL_SRCSEL_SHIFT;
292 static enum zynqmp_clk zynqmp_clk_get_wdt_pll(u32 clk_ctrl)
294 u32 srcsel = (clk_ctrl & CLK_CTRL_SRCSEL_MASK) >>
295 CLK_CTRL_SRCSEL_SHIFT;
308 static ulong zynqmp_clk_get_pll_src(ulong clk_ctrl,
309 struct zynqmp_clk_priv *priv,
315 src_sel = (clk_ctrl & PLLCTRL_PRE_SRC_MASK) >>
316 PLLCTRL_PRE_SRC_SHFT;
318 src_sel = (clk_ctrl & PLLCTRL_POST_SRC_MASK) >>
319 PLLCTRL_POST_SRC_SHFT;
323 return priv->video_clk;
325 return priv->pss_alt_ref_clk;
327 return priv->aux_ref_clk;
329 return priv->gt_crx_ref_clk;
332 return priv->ps_clk_freq;
336 static ulong zynqmp_clk_get_pll_rate(struct zynqmp_clk_priv *priv,
339 u32 clk_ctrl, reset, mul;
343 ret = zynqmp_mmio_read(zynqmp_clk_get_register(id), &clk_ctrl);
345 printf("%s mio read fail\n", __func__);
349 if (clk_ctrl & PLLCTRL_BYPASS_MASK)
350 freq = zynqmp_clk_get_pll_src(clk_ctrl, priv, 0);
352 freq = zynqmp_clk_get_pll_src(clk_ctrl, priv, 1);
354 reset = (clk_ctrl & PLLCTRL_RESET_MASK) >> PLLCTRL_RESET_SHIFT;
355 if (reset && !(clk_ctrl & PLLCTRL_BYPASS_MASK))
358 mul = (clk_ctrl & PLLCTRL_FBDIV_MASK) >> PLLCTRL_FBDIV_SHIFT;
362 if (clk_ctrl & (1 << 16))
368 static ulong zynqmp_clk_get_cpu_rate(struct zynqmp_clk_priv *priv,
374 unsigned long pllrate;
376 ret = zynqmp_mmio_read(CRF_APB_ACPU_CTRL, &clk_ctrl);
378 printf("%s mio read fail\n", __func__);
382 div = (clk_ctrl & CLK_CTRL_DIV0_MASK) >> CLK_CTRL_DIV0_SHIFT;
384 pll = zynqmp_clk_get_cpu_pll(clk_ctrl);
385 pllrate = zynqmp_clk_get_pll_rate(priv, pll);
386 if (IS_ERR_VALUE(pllrate))
389 return DIV_ROUND_CLOSEST(pllrate, div);
392 static ulong zynqmp_clk_get_ddr_rate(struct zynqmp_clk_priv *priv)
399 ret = zynqmp_mmio_read(CRF_APB_DDR_CTRL, &clk_ctrl);
401 printf("%s mio read fail\n", __func__);
405 div = (clk_ctrl & CLK_CTRL_DIV0_MASK) >> CLK_CTRL_DIV0_SHIFT;
407 pll = zynqmp_clk_get_ddr_pll(clk_ctrl);
408 pllrate = zynqmp_clk_get_pll_rate(priv, pll);
409 if (IS_ERR_VALUE(pllrate))
412 return DIV_ROUND_CLOSEST(pllrate, div);
415 static ulong zynqmp_clk_get_peripheral_rate(struct zynqmp_clk_priv *priv,
416 enum zynqmp_clk id, bool two_divs)
424 ret = zynqmp_mmio_read(zynqmp_clk_get_register(id), &clk_ctrl);
426 printf("%s mio read fail\n", __func__);
430 div0 = (clk_ctrl & CLK_CTRL_DIV0_MASK) >> CLK_CTRL_DIV0_SHIFT;
435 div1 = (clk_ctrl & CLK_CTRL_DIV1_MASK) >> CLK_CTRL_DIV1_SHIFT;
440 pll = zynqmp_clk_get_peripheral_pll(clk_ctrl);
441 pllrate = zynqmp_clk_get_pll_rate(priv, pll);
442 if (IS_ERR_VALUE(pllrate))
447 DIV_ROUND_CLOSEST(pllrate, div0), div1);
450 static ulong zynqmp_clk_get_wdt_rate(struct zynqmp_clk_priv *priv,
451 enum zynqmp_clk id, bool two_divs)
459 ret = zynqmp_mmio_read(zynqmp_clk_get_register(id), &clk_ctrl);
461 printf("%d %s mio read fail\n", __LINE__, __func__);
465 div0 = (clk_ctrl & CLK_CTRL_DIV0_MASK) >> CLK_CTRL_DIV0_SHIFT;
469 pll = zynqmp_clk_get_wdt_pll(clk_ctrl);
471 ret = zynqmp_mmio_read(zynqmp_clk_get_register(pll), &clk_ctrl);
473 printf("%d %s mio read fail\n", __LINE__, __func__);
476 div1 = (clk_ctrl & CLK_CTRL_DIV0_MASK) >> CLK_CTRL_DIV0_SHIFT;
481 if (pll == iopll_to_fpd)
484 pllrate = zynqmp_clk_get_pll_rate(priv, pll);
485 if (IS_ERR_VALUE(pllrate))
490 DIV_ROUND_CLOSEST(pllrate, div0), div1);
493 static unsigned long zynqmp_clk_calc_peripheral_two_divs(ulong rate,
495 u32 *div0, u32 *div1)
497 long new_err, best_err = (long)(~0UL >> 1);
498 ulong new_rate, best_rate = 0;
501 for (d0 = 1; d0 <= ZYNQ_CLK_MAXDIV; d0++) {
502 for (d1 = 1; d1 <= ZYNQ_CLK_MAXDIV >> 1; d1++) {
503 new_rate = DIV_ROUND_CLOSEST(
504 DIV_ROUND_CLOSEST(pll_rate, d0), d1);
505 new_err = abs(new_rate - rate);
507 if (new_err < best_err) {
511 best_rate = new_rate;
519 static ulong zynqmp_clk_set_peripheral_rate(struct zynqmp_clk_priv *priv,
520 enum zynqmp_clk id, ulong rate,
524 u32 clk_ctrl, div0 = 0, div1 = 0;
525 ulong pll_rate, new_rate;
530 reg = zynqmp_clk_get_register(id);
531 ret = zynqmp_mmio_read(reg, &clk_ctrl);
533 printf("%s mio read fail\n", __func__);
537 pll = zynqmp_clk_get_peripheral_pll(clk_ctrl);
538 pll_rate = zynqmp_clk_get_pll_rate(priv, pll);
539 if (IS_ERR_VALUE(pll_rate))
542 clk_ctrl &= ~CLK_CTRL_DIV0_MASK;
544 clk_ctrl &= ~CLK_CTRL_DIV1_MASK;
545 new_rate = zynqmp_clk_calc_peripheral_two_divs(rate, pll_rate,
547 clk_ctrl |= div1 << CLK_CTRL_DIV1_SHIFT;
549 div0 = DIV_ROUND_CLOSEST(pll_rate, rate);
550 if (div0 > ZYNQ_CLK_MAXDIV)
551 div0 = ZYNQ_CLK_MAXDIV;
552 new_rate = DIV_ROUND_CLOSEST(rate, div0);
554 clk_ctrl |= div0 << CLK_CTRL_DIV0_SHIFT;
556 mask = (ZYNQ_CLK_MAXDIV << CLK_CTRL_DIV0_SHIFT) |
557 (ZYNQ_CLK_MAXDIV << CLK_CTRL_DIV1_SHIFT);
559 ret = zynqmp_mmio_write(reg, mask, clk_ctrl);
561 printf("%s mio write fail\n", __func__);
568 static ulong zynqmp_clk_get_rate(struct clk *clk)
570 struct zynqmp_clk_priv *priv = dev_get_priv(clk->dev);
571 enum zynqmp_clk id = clk->id;
572 bool two_divs = false;
576 return zynqmp_clk_get_pll_rate(priv, id);
578 return zynqmp_clk_get_cpu_rate(priv, id);
580 return zynqmp_clk_get_ddr_rate(priv);
581 case gem0_ref ... gem3_ref:
582 case qspi_ref ... can1_ref:
585 return zynqmp_clk_get_peripheral_rate(priv, id, two_divs);
588 return zynqmp_clk_get_wdt_rate(priv, id, two_divs);
594 static ulong zynqmp_clk_set_rate(struct clk *clk, ulong rate)
596 struct zynqmp_clk_priv *priv = dev_get_priv(clk->dev);
597 enum zynqmp_clk id = clk->id;
598 bool two_divs = true;
601 case gem0_ref ... gem3_ref:
602 case qspi_ref ... can1_ref:
603 return zynqmp_clk_set_peripheral_rate(priv, id,
610 int soc_clk_dump(void)
615 ret = uclass_get_device_by_driver(UCLASS_CLK,
616 DM_GET_DRIVER(zynqmp_clk), &dev);
620 printf("clk\t\tfrequency\n");
621 for (i = 0; i < clk_max; i++) {
622 const char *name = clk_names[i];
628 ret = clk_request(dev, &clk);
632 rate = clk_get_rate(&clk);
636 if ((rate == (unsigned long)-ENOSYS) ||
637 (rate == (unsigned long)-ENXIO) ||
638 (rate == (unsigned long)-EIO))
639 printf("%10s%20s\n", name, "unknown");
641 printf("%10s%20lu\n", name, rate);
648 static int zynqmp_get_freq_by_name(char *name, struct udevice *dev, ulong *freq)
653 ret = clk_get_by_name(dev, name, &clk);
655 dev_err(dev, "failed to get %s\n", name);
659 *freq = clk_get_rate(&clk);
660 if (IS_ERR_VALUE(*freq)) {
661 dev_err(dev, "failed to get rate %s\n", name);
667 static int zynqmp_clk_probe(struct udevice *dev)
670 struct zynqmp_clk_priv *priv = dev_get_priv(dev);
672 debug("%s\n", __func__);
673 ret = zynqmp_get_freq_by_name("pss_ref_clk", dev, &priv->ps_clk_freq);
677 ret = zynqmp_get_freq_by_name("video_clk", dev, &priv->video_clk);
681 ret = zynqmp_get_freq_by_name("pss_alt_ref_clk", dev,
682 &priv->pss_alt_ref_clk);
686 ret = zynqmp_get_freq_by_name("aux_ref_clk", dev, &priv->aux_ref_clk);
690 ret = zynqmp_get_freq_by_name("gt_crx_ref_clk", dev,
691 &priv->gt_crx_ref_clk);
698 static struct clk_ops zynqmp_clk_ops = {
699 .set_rate = zynqmp_clk_set_rate,
700 .get_rate = zynqmp_clk_get_rate,
703 static const struct udevice_id zynqmp_clk_ids[] = {
704 { .compatible = "xlnx,zynqmp-clk" },
705 { .compatible = "xlnx,zynqmp-clkc" },
709 U_BOOT_DRIVER(zynqmp_clk) = {
710 .name = "zynqmp-clk",
712 .of_match = zynqmp_clk_ids,
713 .probe = zynqmp_clk_probe,
714 .ops = &zynqmp_clk_ops,
715 .priv_auto_alloc_size = sizeof(struct zynqmp_clk_priv),