Lines Matching refs:gtr_phy

296 static inline u32 xpsgtr_read_phy(struct xpsgtr_phy *gtr_phy, u32 reg)  in xpsgtr_read_phy()  argument
298 void __iomem *addr = gtr_phy->dev->serdes in xpsgtr_read_phy()
299 + gtr_phy->lane * PHY_REG_OFFSET + reg; in xpsgtr_read_phy()
304 static inline void xpsgtr_write_phy(struct xpsgtr_phy *gtr_phy, in xpsgtr_write_phy() argument
307 void __iomem *addr = gtr_phy->dev->serdes in xpsgtr_write_phy()
308 + gtr_phy->lane * PHY_REG_OFFSET + reg; in xpsgtr_write_phy()
313 static inline void xpsgtr_clr_set_phy(struct xpsgtr_phy *gtr_phy, in xpsgtr_clr_set_phy() argument
316 void __iomem *addr = gtr_phy->dev->serdes in xpsgtr_clr_set_phy()
317 + gtr_phy->lane * PHY_REG_OFFSET + reg; in xpsgtr_clr_set_phy()
355 struct xpsgtr_phy *gtr_phy = phy_get_drvdata(phy); in xpsgtr_wait_pll_lock() local
356 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; in xpsgtr_wait_pll_lock()
363 u32 reg = xpsgtr_read_phy(gtr_phy, L0_PLL_STATUS_READ_1); in xpsgtr_wait_pll_lock()
381 gtr_phy->lane, gtr_phy->type, gtr_phy->protocol); in xpsgtr_wait_pll_lock()
387 static void xpsgtr_configure_pll(struct xpsgtr_phy *gtr_phy) in xpsgtr_configure_pll() argument
392 ssc = gtr_phy->dev->refclk_sscs[gtr_phy->refclk]; in xpsgtr_configure_pll()
395 xpsgtr_clr_set(gtr_phy->dev, PLL_REF_SEL(gtr_phy->lane), in xpsgtr_configure_pll()
399 if (gtr_phy->refclk == gtr_phy->lane) in xpsgtr_configure_pll()
400 xpsgtr_clr_set(gtr_phy->dev, L0_Ln_REF_CLK_SEL(gtr_phy->lane), in xpsgtr_configure_pll()
403 xpsgtr_clr_set(gtr_phy->dev, L0_Ln_REF_CLK_SEL(gtr_phy->lane), in xpsgtr_configure_pll()
404 L0_REF_CLK_SEL_MASK, 1 << gtr_phy->refclk); in xpsgtr_configure_pll()
407 xpsgtr_clr_set_phy(gtr_phy, L0_PLL_SS_STEP_SIZE_0_LSB, in xpsgtr_configure_pll()
412 xpsgtr_clr_set_phy(gtr_phy, L0_PLL_SS_STEP_SIZE_1, in xpsgtr_configure_pll()
417 xpsgtr_clr_set_phy(gtr_phy, L0_PLL_SS_STEP_SIZE_2, in xpsgtr_configure_pll()
421 xpsgtr_clr_set_phy(gtr_phy, L0_PLL_SS_STEPS_0_LSB, in xpsgtr_configure_pll()
425 xpsgtr_clr_set_phy(gtr_phy, L0_PLL_SS_STEPS_1_MSB, in xpsgtr_configure_pll()
431 xpsgtr_clr_set_phy(gtr_phy, L0_PLL_SS_STEP_SIZE_3_MSB, in xpsgtr_configure_pll()
437 static void xpsgtr_lane_set_protocol(struct xpsgtr_phy *gtr_phy) in xpsgtr_lane_set_protocol() argument
439 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; in xpsgtr_lane_set_protocol()
440 u8 protocol = gtr_phy->protocol; in xpsgtr_lane_set_protocol()
442 switch (gtr_phy->lane) { in xpsgtr_lane_set_protocol()
464 static void xpsgtr_bypass_scrambler_8b10b(struct xpsgtr_phy *gtr_phy) in xpsgtr_bypass_scrambler_8b10b() argument
466 xpsgtr_write_phy(gtr_phy, L0_TM_DIG_6, L0_TM_DIS_DESCRAMBLE_DECODER); in xpsgtr_bypass_scrambler_8b10b()
467 xpsgtr_write_phy(gtr_phy, L0_TX_DIG_61, L0_TM_DISABLE_SCRAMBLE_ENCODER); in xpsgtr_bypass_scrambler_8b10b()
471 static void xpsgtr_phy_init_dp(struct xpsgtr_phy *gtr_phy) in xpsgtr_phy_init_dp() argument
473 xpsgtr_write_phy(gtr_phy, L0_TXPMD_TM_45, in xpsgtr_phy_init_dp()
479 xpsgtr_write_phy(gtr_phy, L0_TX_ANA_TM_118, in xpsgtr_phy_init_dp()
484 static void xpsgtr_phy_init_sata(struct xpsgtr_phy *gtr_phy) in xpsgtr_phy_init_sata() argument
486 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; in xpsgtr_phy_init_sata()
488 xpsgtr_bypass_scrambler_8b10b(gtr_phy); in xpsgtr_phy_init_sata()
490 writel(gtr_phy->lane, gtr_dev->siou + SATA_CONTROL_OFFSET); in xpsgtr_phy_init_sata()
494 static void xpsgtr_phy_init_sgmii(struct xpsgtr_phy *gtr_phy) in xpsgtr_phy_init_sgmii() argument
496 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; in xpsgtr_phy_init_sgmii()
497 u32 mask = PROT_BUS_WIDTH_MASK(gtr_phy->lane); in xpsgtr_phy_init_sgmii()
498 u32 val = PROT_BUS_WIDTH_10 << PROT_BUS_WIDTH_SHIFT(gtr_phy->lane); in xpsgtr_phy_init_sgmii()
504 xpsgtr_bypass_scrambler_8b10b(gtr_phy); in xpsgtr_phy_init_sgmii()
508 static void xpsgtr_phy_configure_dp(struct xpsgtr_phy *gtr_phy, unsigned int pre, in xpsgtr_phy_configure_dp() argument
524 xpsgtr_write_phy(gtr_phy, L0_TXPMD_TM_48, voltage_swing[pre][voltage]); in xpsgtr_phy_configure_dp()
525 xpsgtr_write_phy(gtr_phy, L0_TX_ANA_TM_18, pre_emphasis[pre][voltage]); in xpsgtr_phy_configure_dp()
532 static bool xpsgtr_phy_init_required(struct xpsgtr_phy *gtr_phy) in xpsgtr_phy_init_required() argument
541 if (gtr_phy->protocol == ICM_PROTOCOL_USB && gtr_phy->skip_phy_init) in xpsgtr_phy_init_required()
552 static int xpsgtr_phy_tx_term_fix(struct xpsgtr_phy *gtr_phy) in xpsgtr_phy_tx_term_fix() argument
554 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; in xpsgtr_phy_tx_term_fix()
572 xpsgtr_lane_set_protocol(gtr_phy); in xpsgtr_phy_tx_term_fix()
617 struct xpsgtr_phy *gtr_phy = phy_get_drvdata(phy); in xpsgtr_phy_init() local
618 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; in xpsgtr_phy_init()
624 if (clk_prepare_enable(gtr_dev->clk[gtr_phy->refclk])) in xpsgtr_phy_init()
628 if (!xpsgtr_phy_init_required(gtr_phy)) in xpsgtr_phy_init()
632 ret = xpsgtr_phy_tx_term_fix(gtr_phy); in xpsgtr_phy_init()
640 xpsgtr_write_phy(gtr_phy, L0_TM_PLL_DIG_37, L0_TM_COARSE_CODE_LIMIT); in xpsgtr_phy_init()
646 xpsgtr_configure_pll(gtr_phy); in xpsgtr_phy_init()
647 xpsgtr_lane_set_protocol(gtr_phy); in xpsgtr_phy_init()
649 switch (gtr_phy->protocol) { in xpsgtr_phy_init()
651 xpsgtr_phy_init_dp(gtr_phy); in xpsgtr_phy_init()
655 xpsgtr_phy_init_sata(gtr_phy); in xpsgtr_phy_init()
659 xpsgtr_phy_init_sgmii(gtr_phy); in xpsgtr_phy_init()
670 struct xpsgtr_phy *gtr_phy = phy_get_drvdata(phy); in xpsgtr_phy_exit() local
671 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; in xpsgtr_phy_exit()
673 gtr_phy->skip_phy_init = false; in xpsgtr_phy_exit()
676 clk_disable_unprepare(gtr_dev->clk[gtr_phy->refclk]); in xpsgtr_phy_exit()
683 struct xpsgtr_phy *gtr_phy = phy_get_drvdata(phy); in xpsgtr_phy_power_on() local
687 if (!xpsgtr_phy_init_required(gtr_phy)) in xpsgtr_phy_power_on()
694 if (gtr_phy->protocol != ICM_PROTOCOL_DP || in xpsgtr_phy_power_on()
695 gtr_phy->type == XPSGTR_TYPE_DP_0) in xpsgtr_phy_power_on()
703 struct xpsgtr_phy *gtr_phy = phy_get_drvdata(phy); in xpsgtr_phy_configure() local
705 if (gtr_phy->protocol != ICM_PROTOCOL_DP) in xpsgtr_phy_configure()
708 xpsgtr_phy_configure_dp(gtr_phy, opts->dp.pre[0], opts->dp.voltage[0]); in xpsgtr_phy_configure()
726 static int xpsgtr_set_lane_type(struct xpsgtr_phy *gtr_phy, u8 phy_type, in xpsgtr_set_lane_type() argument
741 gtr_phy->protocol = ICM_PROTOCOL_SATA; in xpsgtr_set_lane_type()
752 gtr_phy->protocol = ICM_PROTOCOL_USB; in xpsgtr_set_lane_type()
763 gtr_phy->protocol = ICM_PROTOCOL_DP; in xpsgtr_set_lane_type()
776 gtr_phy->protocol = ICM_PROTOCOL_PCIE; in xpsgtr_set_lane_type()
789 gtr_phy->protocol = ICM_PROTOCOL_SGMII; in xpsgtr_set_lane_type()
799 gtr_phy->type = phy_types[phy_instance]; in xpsgtr_set_lane_type()
822 struct xpsgtr_phy *gtr_phy; in xpsgtr_xlate() local
845 gtr_phy = &gtr_dev->phys[phy_lane]; in xpsgtr_xlate()
849 guard(mutex)(&gtr_phy->phy->mutex); in xpsgtr_xlate()
850 ret = xpsgtr_set_lane_type(gtr_phy, phy_type, phy_instance); in xpsgtr_xlate()
863 gtr_phy->refclk = refclk; in xpsgtr_xlate()
870 if (icm_matrix[phy_lane][i] == gtr_phy->type) in xpsgtr_xlate()
871 return gtr_phy->phy; in xpsgtr_xlate()
1016 struct xpsgtr_phy *gtr_phy = &gtr_dev->phys[port]; in xpsgtr_probe() local
1019 gtr_phy->lane = port; in xpsgtr_probe()
1020 gtr_phy->dev = gtr_dev; in xpsgtr_probe()
1028 gtr_phy->phy = phy; in xpsgtr_probe()
1029 phy_set_drvdata(phy, gtr_phy); in xpsgtr_probe()