Lines Matching defs:macro
180 static int lan966x_sd6g40_reg_cfg(struct serdes_macro *macro,
203 macro->ctrl->regs, HSIO_SD_CFG(idx));
209 macro->ctrl->regs, HSIO_MPLL_CFG(idx));
213 macro->ctrl->regs, HSIO_SD_CFG(idx));
217 macro->ctrl->regs, HSIO_MPLL_CFG(idx));
223 macro->ctrl->regs, HSIO_SD_CFG(idx));
229 macro->ctrl->regs, HSIO_MPLL_CFG(idx));
233 value = readl(macro->ctrl->regs + lan_offset(HSIO_SD_STAT(idx)));
236 dev_err(macro->ctrl->dev,
244 macro->ctrl->regs, HSIO_SD_CFG(idx));
248 value = readl(macro->ctrl->regs + lan_offset(HSIO_SD_STAT(idx)));
251 dev_err(macro->ctrl->dev,
261 macro->ctrl->regs, HSIO_SD_CFG(idx));
266 value = readl(macro->ctrl->regs + lan_offset(HSIO_SD_STAT(idx)));
269 dev_err(macro->ctrl->dev,
276 value = readl(macro->ctrl->regs + lan_offset(HSIO_SD_STAT(idx)));
279 dev_err(macro->ctrl->dev,
289 macro->ctrl->regs, HSIO_SD_CFG(idx));
294 static int lan966x_sd6g40_get_conf_from_mode(struct serdes_macro *macro,
318 ret_val->mpll_multiplier = macro->speed == SPEED_2500 ? 50 : 40;
320 ret_val->tx_rate = macro->speed == SPEED_2500 ? 0x1 : 0x2;
321 ret_val->rx_rate = macro->speed == SPEED_2500 ? 0x1 : 0x2;
323 ret_val->mpll_multiplier = macro->speed == SPEED_2500 ? 125 : 100;
325 ret_val->tx_rate = macro->speed == SPEED_2500 ? 0x1 : 0x2;
326 ret_val->rx_rate = macro->speed == SPEED_2500 ? 0x1 : 0x2;
337 static int lan966x_calc_sd6g40_setup_lane(struct serdes_macro *macro,
345 ret = lan966x_sd6g40_get_conf_from_mode(macro, config.mode,
368 static int lan966x_sd6g40_setup_lane(struct serdes_macro *macro,
375 ret = lan966x_calc_sd6g40_setup_lane(macro, config, &calc_results);
379 return lan966x_sd6g40_reg_cfg(macro, &calc_results, idx);
382 static int lan966x_sd6g40_setup(struct serdes_macro *macro, u32 idx, int mode)
386 conf.refclk125M = macro->ctrl->ref125;
393 return lan966x_sd6g40_setup_lane(macro, conf, idx);
396 static int lan966x_rgmii_setup(struct serdes_macro *macro, u32 idx, int mode)
404 HSIO_RGMII_CFG_TX_CLK_CFG_SET(macro->speed == SPEED_1000 ? 1 :
405 macro->speed == SPEED_100 ? 2 :
406 macro->speed == SPEED_10 ? 3 : 0),
410 macro->ctrl->regs, HSIO_RGMII_CFG(idx));
425 macro->ctrl->regs, HSIO_DLL_CFG(idx == 0 ? 0x0 : 0x2));
429 macro->ctrl->regs, HSIO_DLL_CFG(idx == 0 ? 0x0 : 0x2));
435 macro->ctrl->regs, HSIO_DLL_CFG(idx == 0 ? 0x1 : 0x3));
439 macro->ctrl->regs, HSIO_DLL_CFG(idx == 0 ? 0x1 : 0x3));
446 struct serdes_macro *macro = phy_get_drvdata(phy);
448 if (!phy_interface_mode_is_rgmii(macro->mode))
451 macro->speed = speed;
452 lan966x_rgmii_setup(macro, macro->idx - (SERDES6G_MAX + 1), macro->mode);
459 struct serdes_macro *macro = phy_get_drvdata(phy);
468 macro->speed = SPEED_2500;
470 macro->speed = SPEED_1000;
480 if (macro->idx != lan966x_serdes_muxes[i].idx ||
483 macro->port != lan966x_serdes_muxes[i].port)
486 val = readl(macro->ctrl->regs + lan_offset(HSIO_HW_CFG));
489 macro->ctrl->regs, HSIO_HW_CFG);
491 macro->mode = lan966x_serdes_muxes[i].submode;
493 if (macro->idx < CU_MAX)
496 if (macro->idx < SERDES6G_MAX)
497 return lan966x_sd6g40_setup(macro,
498 macro->idx - (CU_MAX + 1),
499 macro->mode);
501 if (macro->idx < RGMII_MAX)
502 return lan966x_rgmii_setup(macro,
503 macro->idx - (SERDES6G_MAX + 1),
504 macro->mode);
531 struct serdes_macro *macro = phy_get_drvdata(ctrl->phys[i]);
533 if (idx != macro->idx)
536 macro->port = port;
545 struct serdes_macro *macro;
551 macro = devm_kzalloc(ctrl->dev, sizeof(*macro), GFP_KERNEL);
552 if (!macro)
555 macro->idx = idx;
556 macro->ctrl = ctrl;
557 macro->port = -1;
559 phy_set_drvdata(*phy, macro);