1 // SPDX-License-Identifier: GPL-2.0
3 * phy-zynqmp.c - PHY driver for Xilinx ZynqMP GT.
5 * Copyright (C) 2018-2021 Xilinx Inc.
7 * Author: Anurag Kumar Vulisha <anuragku@xilinx.com>
8 * Author: Subbaraya Sundeep <sundeep.lkml@gmail.com>
9 * Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
13 #include <clk-uclass.h>
15 #include <generic-phy.h>
17 #include <power-domain.h>
21 #include <asm/arch/sys_proto.h>
22 #include <asm/arch/hardware.h>
23 #include <dm/device.h>
24 #include <dm/device_compat.h>
26 #include <dt-bindings/phy/phy.h>
27 #include <linux/bitops.h>
28 #include <linux/delay.h>
29 #include <linux/err.h>
35 /* TX De-emphasis parameters */
36 #define L0_TX_ANA_TM_18 0x0048
37 #define L0_TX_ANA_TM_118 0x01d8
38 #define L0_TX_ANA_TM_118_FORCE_17_0 BIT(0)
40 /* DN Resistor calibration code parameters */
41 #define L0_TXPMA_ST_3 0x0b0c
42 #define L0_DN_CALIB_CODE 0x3f
44 /* PMA control parameters */
45 #define L0_TXPMD_TM_45 0x0cb4
46 #define L0_TXPMD_TM_48 0x0cc0
47 #define L0_TXPMD_TM_45_OVER_DP_MAIN BIT(0)
48 #define L0_TXPMD_TM_45_ENABLE_DP_MAIN BIT(1)
49 #define L0_TXPMD_TM_45_OVER_DP_POST1 BIT(2)
50 #define L0_TXPMD_TM_45_ENABLE_DP_POST1 BIT(3)
51 #define L0_TXPMD_TM_45_OVER_DP_POST2 BIT(4)
52 #define L0_TXPMD_TM_45_ENABLE_DP_POST2 BIT(5)
54 /* PCS control parameters */
55 #define L0_TM_DIG_6 0x106c
56 #define L0_TM_DIS_DESCRAMBLE_DECODER 0x0f
57 #define L0_TX_DIG_61 0x00f4
58 #define L0_TM_DISABLE_SCRAMBLE_ENCODER 0x0f
60 /* PLL Test Mode register parameters */
61 #define L0_TM_PLL_DIG_37 0x2094
62 #define L0_TM_COARSE_CODE_LIMIT 0x10
64 /* PLL SSC step size offsets */
65 #define L0_PLL_SS_STEPS_0_LSB 0x2368
66 #define L0_PLL_SS_STEPS_1_MSB 0x236c
67 #define L0_PLL_SS_STEP_SIZE_0_LSB 0x2370
68 #define L0_PLL_SS_STEP_SIZE_1 0x2374
69 #define L0_PLL_SS_STEP_SIZE_2 0x2378
70 #define L0_PLL_SS_STEP_SIZE_3_MSB 0x237c
71 #define L0_PLL_STATUS_READ_1 0x23e4
73 /* SSC step size parameters */
74 #define STEP_SIZE_0_MASK 0xff
75 #define STEP_SIZE_1_MASK 0xff
76 #define STEP_SIZE_2_MASK 0xff
77 #define STEP_SIZE_3_MASK 0x3
78 #define STEP_SIZE_SHIFT 8
79 #define FORCE_STEP_SIZE 0x10
80 #define FORCE_STEPS 0x20
81 #define STEPS_0_MASK 0xff
82 #define STEPS_1_MASK 0x07
84 /* Reference clock selection parameters */
85 #define L0_Ln_REF_CLK_SEL(n) (0x2860 + (n) * 4)
86 #define L0_REF_CLK_SEL_MASK 0x8f
88 /* Calibration digital logic parameters */
89 #define L3_TM_CALIB_DIG19 0xec4c
90 #define L3_CALIB_DONE_STATUS 0xef14
91 #define L3_TM_CALIB_DIG18 0xec48
92 #define L3_TM_CALIB_DIG19_NSW 0x07
93 #define L3_TM_CALIB_DIG18_NSW 0xe0
94 #define L3_TM_OVERRIDE_NSW_CODE 0x20
95 #define L3_CALIB_DONE 0x02
96 #define L3_NSW_SHIFT 5
97 #define L3_NSW_PIPE_SHIFT 4
98 #define L3_NSW_CALIB_SHIFT 3
100 #define PHY_REG_OFFSET 0x4000
106 /* Refclk selection parameters */
107 #define PLL_REF_SEL(n) (0x10000 + (n) * 4)
108 #define PLL_FREQ_MASK 0x1f
109 #define PLL_STATUS_LOCKED 0x10
111 /* Inter Connect Matrix parameters */
112 #define ICM_CFG0 0x10010
113 #define ICM_CFG1 0x10014
114 #define ICM_CFG0_L0_MASK 0x07
115 #define ICM_CFG0_L1_MASK 0x70
116 #define ICM_CFG1_L2_MASK 0x07
117 #define ICM_CFG2_L3_MASK 0x70
118 #define ICM_CFG_SHIFT 4
120 /* Inter Connect Matrix allowed protocols */
121 #define ICM_PROTOCOL_PD 0x0
122 #define ICM_PROTOCOL_PCIE 0x1
123 #define ICM_PROTOCOL_SATA 0x2
124 #define ICM_PROTOCOL_USB 0x3
125 #define ICM_PROTOCOL_DP 0x4
126 #define ICM_PROTOCOL_SGMII 0x5
128 /* Test Mode common reset control parameters */
129 #define TM_CMN_RST 0x10018
130 #define TM_CMN_RST_EN 0x1
131 #define TM_CMN_RST_SET 0x2
132 #define TM_CMN_RST_MASK 0x3
134 /* Bus width parameters */
135 #define TX_PROT_BUS_WIDTH 0x10040
136 #define RX_PROT_BUS_WIDTH 0x10044
137 #define PROT_BUS_WIDTH_10 0x0
138 #define PROT_BUS_WIDTH_20 0x1
139 #define PROT_BUS_WIDTH_40 0x2
140 #define PROT_BUS_WIDTH_MASK 0x3
141 #define PROT_BUS_WIDTH_SHIFT 2
143 /* Number of GT lanes */
146 /* SIOU SATA control register */
147 #define SATA_CONTROL_OFFSET 0x0100
149 /* Total number of controllers */
150 #define CONTROLLERS_PER_LANE 5
152 /* Protocol Type parameters */
154 XPSGTR_TYPE_USB0 = 0, /* USB controller 0 */
155 XPSGTR_TYPE_USB1 = 1, /* USB controller 1 */
156 XPSGTR_TYPE_SATA_0 = 2, /* SATA controller lane 0 */
157 XPSGTR_TYPE_SATA_1 = 3, /* SATA controller lane 1 */
158 XPSGTR_TYPE_PCIE_0 = 4, /* PCIe controller lane 0 */
159 XPSGTR_TYPE_PCIE_1 = 5, /* PCIe controller lane 1 */
160 XPSGTR_TYPE_PCIE_2 = 6, /* PCIe controller lane 2 */
161 XPSGTR_TYPE_PCIE_3 = 7, /* PCIe controller lane 3 */
162 XPSGTR_TYPE_DP_0 = 8, /* Display Port controller lane 0 */
163 XPSGTR_TYPE_DP_1 = 9, /* Display Port controller lane 1 */
164 XPSGTR_TYPE_SGMII0 = 10, /* Ethernet SGMII controller 0 */
165 XPSGTR_TYPE_SGMII1 = 11, /* Ethernet SGMII controller 1 */
166 XPSGTR_TYPE_SGMII2 = 12, /* Ethernet SGMII controller 2 */
167 XPSGTR_TYPE_SGMII3 = 13, /* Ethernet SGMII controller 3 */
171 #define TIMEOUT_US 1000
173 #define IOU_SLCR_GEM_CLK_CTRL 0x308
174 #define GEM_CTRL_GEM_SGMII_MODE BIT(2)
175 #define GEM_CTRL_GEM_REF_SRC_SEL BIT(1)
177 #define IOU_SLCR_GEM_CTRL 0x360
178 #define GEM_CTRL_GEM_SGMII_SD BIT(0)
181 * struct xpsgtr_ssc - structure to hold SSC settings for a lane
182 * @refclk_rate: PLL reference clock frequency
183 * @pll_ref_clk: value to be written to register for corresponding ref clk rate
184 * @steps: number of steps of SSC (Spread Spectrum Clock)
185 * @step_size: step size of each step
195 * struct xpsgtr_phy - representation of a lane
196 * @dev: pointer to the xpsgtr_dev instance
197 * @refclk: reference clock index
198 * @type: controller which uses this lane
200 * @protocol: protocol in which the lane operates
203 struct xpsgtr_dev *dev;
211 * struct xpsgtr_dev - representation of a ZynMP GT device
212 * @dev: pointer to device
213 * @serdes: serdes base address
214 * @siou: siou base address
216 * @refclk_sscs: spread spectrum settings for the reference clocks
217 * @clk: reference clocks
223 struct xpsgtr_phy phys[NUM_LANES];
224 const struct xpsgtr_ssc *refclk_sscs[NUM_LANES];
225 struct clk clk[NUM_LANES];
228 /* Configuration Data */
229 /* lookup table to hold all settings needed for a ref clock frequency */
230 static const struct xpsgtr_ssc ssc_lookup[] = {
231 { 19200000, 0x05, 608, 264020 },
232 { 20000000, 0x06, 634, 243454 },
233 { 24000000, 0x07, 760, 168973 },
234 { 26000000, 0x08, 824, 143860 },
235 { 27000000, 0x09, 856, 86551 },
236 { 38400000, 0x0a, 1218, 65896 },
237 { 40000000, 0x0b, 634, 243454 },
238 { 52000000, 0x0c, 824, 143860 },
239 { 100000000, 0x0d, 1058, 87533 },
240 { 108000000, 0x0e, 856, 86551 },
241 { 125000000, 0x0f, 992, 119497 },
242 { 135000000, 0x10, 1070, 55393 },
243 { 150000000, 0x11, 792, 187091 }
247 static u32 xpsgtr_read(struct xpsgtr_dev *gtr_dev, u32 reg)
249 return readl(gtr_dev->serdes + reg);
252 static void xpsgtr_write(struct xpsgtr_dev *gtr_dev, u32 reg, u32 value)
254 writel(value, gtr_dev->serdes + reg);
257 static void xpsgtr_clr_set(struct xpsgtr_dev *gtr_dev, u32 reg,
260 u32 value = xpsgtr_read(gtr_dev, reg);
264 xpsgtr_write(gtr_dev, reg, value);
267 static u32 xpsgtr_read_phy(struct xpsgtr_phy *gtr_phy, u32 reg)
269 void __iomem *addr = gtr_phy->dev->serdes
270 + gtr_phy->lane * PHY_REG_OFFSET + reg;
275 static void xpsgtr_write_phy(struct xpsgtr_phy *gtr_phy,
278 void __iomem *addr = gtr_phy->dev->serdes
279 + gtr_phy->lane * PHY_REG_OFFSET + reg;
284 static void xpsgtr_clr_set_phy(struct xpsgtr_phy *gtr_phy,
285 u32 reg, u32 clr, u32 set)
287 void __iomem *addr = gtr_phy->dev->serdes
288 + gtr_phy->lane * PHY_REG_OFFSET + reg;
290 writel((readl(addr) & ~clr) | set, addr);
293 /* Configure PLL and spread-sprectrum clock. */
294 static void xpsgtr_configure_pll(struct xpsgtr_phy *gtr_phy)
296 const struct xpsgtr_ssc *ssc;
299 ssc = gtr_phy->dev->refclk_sscs[gtr_phy->refclk];
300 step_size = ssc->step_size;
302 xpsgtr_clr_set(gtr_phy->dev, PLL_REF_SEL(gtr_phy->lane),
303 PLL_FREQ_MASK, ssc->pll_ref_clk);
305 /* Enable lane clock sharing, if required */
306 if (gtr_phy->refclk != gtr_phy->lane) {
307 /* Lane3 Ref Clock Selection Register */
308 xpsgtr_clr_set(gtr_phy->dev, L0_Ln_REF_CLK_SEL(gtr_phy->lane),
309 L0_REF_CLK_SEL_MASK, 1 << gtr_phy->refclk);
312 /* SSC step size [7:0] */
313 xpsgtr_clr_set_phy(gtr_phy, L0_PLL_SS_STEP_SIZE_0_LSB,
314 STEP_SIZE_0_MASK, step_size & STEP_SIZE_0_MASK);
316 /* SSC step size [15:8] */
317 step_size >>= STEP_SIZE_SHIFT;
318 xpsgtr_clr_set_phy(gtr_phy, L0_PLL_SS_STEP_SIZE_1,
319 STEP_SIZE_1_MASK, step_size & STEP_SIZE_1_MASK);
321 /* SSC step size [23:16] */
322 step_size >>= STEP_SIZE_SHIFT;
323 xpsgtr_clr_set_phy(gtr_phy, L0_PLL_SS_STEP_SIZE_2,
324 STEP_SIZE_2_MASK, step_size & STEP_SIZE_2_MASK);
326 /* SSC steps [7:0] */
327 xpsgtr_clr_set_phy(gtr_phy, L0_PLL_SS_STEPS_0_LSB,
328 STEPS_0_MASK, ssc->steps & STEPS_0_MASK);
330 /* SSC steps [10:8] */
331 xpsgtr_clr_set_phy(gtr_phy, L0_PLL_SS_STEPS_1_MSB,
333 (ssc->steps >> STEP_SIZE_SHIFT) & STEPS_1_MASK);
335 /* SSC step size [24:25] */
336 step_size >>= STEP_SIZE_SHIFT;
337 xpsgtr_clr_set_phy(gtr_phy, L0_PLL_SS_STEP_SIZE_3_MSB,
338 STEP_SIZE_3_MASK, (step_size & STEP_SIZE_3_MASK) |
339 FORCE_STEP_SIZE | FORCE_STEPS);
342 /* Configure the lane protocol. */
343 static void xpsgtr_lane_set_protocol(struct xpsgtr_phy *gtr_phy)
345 struct xpsgtr_dev *gtr_dev = gtr_phy->dev;
346 u8 protocol = gtr_phy->protocol;
348 switch (gtr_phy->lane) {
350 xpsgtr_clr_set(gtr_dev, ICM_CFG0, ICM_CFG0_L0_MASK, protocol);
353 xpsgtr_clr_set(gtr_dev, ICM_CFG0, ICM_CFG0_L1_MASK,
354 protocol << ICM_CFG_SHIFT);
357 xpsgtr_clr_set(gtr_dev, ICM_CFG1, ICM_CFG0_L0_MASK, protocol);
360 xpsgtr_clr_set(gtr_dev, ICM_CFG1, ICM_CFG0_L1_MASK,
361 protocol << ICM_CFG_SHIFT);
364 /* We already checked 0 <= lane <= 3 */
369 /* Bypass (de)scrambler and 8b/10b decoder and encoder. */
370 static void xpsgtr_bypass_scrambler_8b10b(struct xpsgtr_phy *gtr_phy)
372 xpsgtr_write_phy(gtr_phy, L0_TM_DIG_6, L0_TM_DIS_DESCRAMBLE_DECODER);
373 xpsgtr_write_phy(gtr_phy, L0_TX_DIG_61, L0_TM_DISABLE_SCRAMBLE_ENCODER);
376 /* SGMII-specific initialization. */
377 static void xpsgtr_phy_init_sgmii(struct xpsgtr_phy *gtr_phy)
379 struct xpsgtr_dev *gtr_dev = gtr_phy->dev;
380 u32 shift = gtr_phy->lane * PROT_BUS_WIDTH_SHIFT;
382 /* Set SGMII protocol TX and RX bus width to 10 bits. */
383 xpsgtr_clr_set(gtr_dev, TX_PROT_BUS_WIDTH, PROT_BUS_WIDTH_MASK << shift,
384 PROT_BUS_WIDTH_10 << shift);
386 xpsgtr_clr_set(gtr_dev, RX_PROT_BUS_WIDTH, PROT_BUS_WIDTH_MASK << shift,
387 PROT_BUS_WIDTH_10 << shift);
389 xpsgtr_bypass_scrambler_8b10b(gtr_phy);
392 * Below code is just temporary solution till we have a way how to
393 * do it via firmware interface in sync with Linux. Till that happen
394 * this is the most sensible thing to do here.
396 /* GEM I/O Clock Control */
397 clrsetbits_le32(ZYNQMP_IOU_SLCR_BASEADDR + IOU_SLCR_GEM_CLK_CTRL,
399 (GEM_CTRL_GEM_SGMII_MODE | GEM_CTRL_GEM_REF_SRC_SEL) <<
402 /* Setup signal detect */
403 clrsetbits_le32(ZYNQMP_IOU_SLCR_BASEADDR + IOU_SLCR_GEM_CTRL,
404 PROT_BUS_WIDTH_MASK << shift,
405 GEM_CTRL_GEM_SGMII_SD << shift);
408 static int xpsgtr_init(struct phy *x)
410 struct xpsgtr_dev *gtr_dev = dev_get_priv(x->dev);
411 struct xpsgtr_phy *gtr_phy;
412 u32 phy_lane = x->id;
414 gtr_phy = >r_dev->phys[phy_lane];
416 /* Enable coarse code saturation limiting logic. */
417 xpsgtr_write_phy(gtr_phy, L0_TM_PLL_DIG_37, L0_TM_COARSE_CODE_LIMIT);
420 * Configure the PLL, the lane protocol, and perform protocol-specific
423 xpsgtr_configure_pll(gtr_phy);
424 xpsgtr_lane_set_protocol(gtr_phy);
426 switch (gtr_phy->protocol) {
427 case ICM_PROTOCOL_SGMII:
428 xpsgtr_phy_init_sgmii(gtr_phy);
430 case ICM_PROTOCOL_DP:
431 case ICM_PROTOCOL_SATA:
435 dev_dbg(gtr_dev->dev, "lane %u (type %u, protocol %u): init done\n",
436 gtr_phy->lane, gtr_phy->type, gtr_phy->protocol);
441 /* Wait for the PLL to lock (with a timeout). */
442 static int xpsgtr_wait_pll_lock(struct phy *phy)
444 struct xpsgtr_dev *gtr_dev = dev_get_priv(phy->dev);
445 struct xpsgtr_phy *gtr_phy;
446 u32 phy_lane = phy->id;
448 unsigned int timeout = TIMEOUT_US;
450 gtr_phy = >r_dev->phys[phy_lane];
452 dev_dbg(gtr_dev->dev, "Waiting for PLL lock\n");
455 u32 reg = xpsgtr_read_phy(gtr_phy, L0_PLL_STATUS_READ_1);
457 if ((reg & PLL_STATUS_LOCKED) == PLL_STATUS_LOCKED) {
462 if (--timeout == 0) {
470 if (ret == -ETIMEDOUT)
471 dev_err(gtr_dev->dev,
472 "lane %u (type %u, protocol %u): PLL lock timeout\n",
473 gtr_phy->lane, gtr_phy->type, gtr_phy->protocol);
478 static int xpsgtr_power_on(struct phy *phy)
480 struct xpsgtr_dev *gtr_dev = dev_get_priv(phy->dev);
481 struct xpsgtr_phy *gtr_phy;
482 u32 phy_lane = phy->id;
485 gtr_phy = >r_dev->phys[phy_lane];
488 * Wait for the PLL to lock. For DP, only wait on DP0 to avoid
489 * cumulating waits for both lanes. The user is expected to initialize
492 if (gtr_phy->protocol != ICM_PROTOCOL_DP ||
493 gtr_phy->type == XPSGTR_TYPE_DP_0)
494 ret = xpsgtr_wait_pll_lock(phy);
503 /* Set the lane type and protocol based on the PHY type and instance number. */
504 static int xpsgtr_set_lane_type(struct xpsgtr_phy *gtr_phy, u8 phy_type,
505 unsigned int phy_instance)
507 unsigned int num_phy_types;
508 const int *phy_types;
511 case PHY_TYPE_SATA: {
512 static const int types[] = {
518 num_phy_types = ARRAY_SIZE(types);
519 gtr_phy->protocol = ICM_PROTOCOL_SATA;
522 case PHY_TYPE_USB3: {
523 static const int types[] = {
529 num_phy_types = ARRAY_SIZE(types);
530 gtr_phy->protocol = ICM_PROTOCOL_USB;
534 static const int types[] = {
540 num_phy_types = ARRAY_SIZE(types);
541 gtr_phy->protocol = ICM_PROTOCOL_DP;
544 case PHY_TYPE_PCIE: {
545 static const int types[] = {
553 num_phy_types = ARRAY_SIZE(types);
554 gtr_phy->protocol = ICM_PROTOCOL_PCIE;
557 case PHY_TYPE_SGMII: {
558 static const int types[] = {
566 num_phy_types = ARRAY_SIZE(types);
567 gtr_phy->protocol = ICM_PROTOCOL_SGMII;
574 if (phy_instance >= num_phy_types)
577 gtr_phy->type = phy_types[phy_instance];
582 * Valid combinations of controllers and lanes (Interconnect Matrix).
584 static const unsigned int icm_matrix[NUM_LANES][CONTROLLERS_PER_LANE] = {
585 { XPSGTR_TYPE_PCIE_0, XPSGTR_TYPE_SATA_0, XPSGTR_TYPE_USB0,
586 XPSGTR_TYPE_DP_1, XPSGTR_TYPE_SGMII0 },
587 { XPSGTR_TYPE_PCIE_1, XPSGTR_TYPE_SATA_1, XPSGTR_TYPE_USB0,
588 XPSGTR_TYPE_DP_0, XPSGTR_TYPE_SGMII1 },
589 { XPSGTR_TYPE_PCIE_2, XPSGTR_TYPE_SATA_0, XPSGTR_TYPE_USB0,
590 XPSGTR_TYPE_DP_1, XPSGTR_TYPE_SGMII2 },
591 { XPSGTR_TYPE_PCIE_3, XPSGTR_TYPE_SATA_1, XPSGTR_TYPE_USB1,
592 XPSGTR_TYPE_DP_0, XPSGTR_TYPE_SGMII3 }
595 /* Translate OF phandle and args to PHY instance. */
596 static int xpsgtr_of_xlate(struct phy *x,
597 struct ofnode_phandle_args *args)
599 struct xpsgtr_dev *gtr_dev = dev_get_priv(x->dev);
600 struct xpsgtr_phy *gtr_phy;
601 struct udevice *dev = x->dev;
602 unsigned int phy_instance;
603 unsigned int phy_lane;
604 unsigned int phy_type;
609 if (args->args_count != 4) {
610 dev_err(dev, "Invalid number of cells in 'phy' property\n");
615 * Get the PHY parameters from the OF arguments and derive the lane
618 phy_lane = args->args[0];
619 if (phy_lane >= NUM_LANES) {
620 dev_err(dev, "Invalid lane number %u\n", phy_lane);
624 gtr_phy = >r_dev->phys[phy_lane];
625 phy_type = args->args[1];
626 phy_instance = args->args[2];
628 ret = xpsgtr_set_lane_type(gtr_phy, phy_type, phy_instance);
630 dev_err(dev, "Invalid PHY type and/or instance\n");
634 refclk = args->args[3];
635 if (refclk >= ARRAY_SIZE(gtr_dev->refclk_sscs) ||
636 !gtr_dev->refclk_sscs[refclk]) {
637 dev_err(dev, "Invalid reference clock number %u\n", refclk);
641 gtr_phy->refclk = refclk;
643 /* This is difference compare to Linux */
644 gtr_phy->dev = gtr_dev;
645 gtr_phy->lane = phy_lane;
648 * Ensure that the Interconnect Matrix is obeyed, i.e a given lane type
649 * is allowed to operate on the lane.
651 for (i = 0; i < CONTROLLERS_PER_LANE; i++) {
652 if (icm_matrix[phy_lane][i] == gtr_phy->type) {
662 * Probe & Platform Driver
664 static int xpsgtr_get_ref_clocks(struct udevice *dev)
667 struct xpsgtr_dev *gtr_dev = dev_get_priv(dev);
670 for (refclk = 0; refclk < NUM_LANES; ++refclk) {
674 struct clk *clk = >r_dev->clk[refclk];
676 snprintf(name, sizeof(name), "ref%u", refclk);
677 dev_dbg(dev, "Checking name: %s\n", name);
678 ret = clk_get_by_name(dev, name, clk);
679 if (ret == -ENODATA) {
680 dev_dbg(dev, "%s clock not specified (err %d)\n",
684 dev_dbg(dev, "couldn't get clock %s (err %d)\n",
689 rate = clk_get_rate(clk);
691 dev_dbg(dev, "clk rate %d\n", rate);
693 ret = clk_enable(clk);
695 dev_err(dev, "failed to enable refclk %d clock\n",
700 for (i = 0 ; i < ARRAY_SIZE(ssc_lookup); i++) {
701 if (rate == ssc_lookup[i].refclk_rate) {
702 gtr_dev->refclk_sscs[refclk] = &ssc_lookup[i];
703 dev_dbg(dev, "Found rate %d\n", i);
708 if (i == ARRAY_SIZE(ssc_lookup)) {
710 "Invalid rate %u for reference clock %u\n",
719 static int xpsgtr_probe(struct udevice *dev)
721 struct xpsgtr_dev *gtr_dev = dev_get_priv(dev);
723 gtr_dev->serdes = dev_remap_addr_name(dev, "serdes");
724 if (!gtr_dev->serdes)
727 gtr_dev->siou = dev_remap_addr_name(dev, "siou");
733 return xpsgtr_get_ref_clocks(dev);
736 static const struct udevice_id xpsgtr_phy_ids[] = {
737 { .compatible = "xlnx,zynqmp-psgtr-v1.1", },
741 static const struct phy_ops xpsgtr_phy_ops = {
743 .of_xlate = xpsgtr_of_xlate,
744 .power_on = xpsgtr_power_on,
747 U_BOOT_DRIVER(psgtr_phy) = {
750 .of_match = xpsgtr_phy_ids,
751 .ops = &xpsgtr_phy_ops,
752 .probe = xpsgtr_probe,
753 .priv_auto = sizeof(struct xpsgtr_dev),