Lines Matching refs:gtr_dev
276 static inline u32 xpsgtr_read(struct xpsgtr_dev *gtr_dev, u32 reg) in xpsgtr_read() argument
278 return readl(gtr_dev->serdes + reg); in xpsgtr_read()
281 static inline void xpsgtr_write(struct xpsgtr_dev *gtr_dev, u32 reg, u32 value) in xpsgtr_write() argument
283 writel(value, gtr_dev->serdes + reg); in xpsgtr_write()
286 static inline void xpsgtr_clr_set(struct xpsgtr_dev *gtr_dev, u32 reg, in xpsgtr_clr_set() argument
289 u32 value = xpsgtr_read(gtr_dev, reg); in xpsgtr_clr_set()
293 xpsgtr_write(gtr_dev, reg, value); in xpsgtr_clr_set()
326 static void xpsgtr_save_lane_regs(struct xpsgtr_dev *gtr_dev) in xpsgtr_save_lane_regs() argument
331 gtr_dev->saved_regs[i] = xpsgtr_read(gtr_dev, in xpsgtr_save_lane_regs()
339 static void xpsgtr_restore_lane_regs(struct xpsgtr_dev *gtr_dev) in xpsgtr_restore_lane_regs() argument
344 xpsgtr_write(gtr_dev, save_reg_address[i], in xpsgtr_restore_lane_regs()
345 gtr_dev->saved_regs[i]); in xpsgtr_restore_lane_regs()
356 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; in xpsgtr_wait_pll_lock() local
360 dev_dbg(gtr_dev->dev, "Waiting for PLL lock\n"); in xpsgtr_wait_pll_lock()
379 dev_err(gtr_dev->dev, in xpsgtr_wait_pll_lock()
439 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; in xpsgtr_lane_set_protocol() local
444 xpsgtr_clr_set(gtr_dev, ICM_CFG0, ICM_CFG0_L0_MASK, protocol); in xpsgtr_lane_set_protocol()
447 xpsgtr_clr_set(gtr_dev, ICM_CFG0, ICM_CFG0_L1_MASK, in xpsgtr_lane_set_protocol()
451 xpsgtr_clr_set(gtr_dev, ICM_CFG1, ICM_CFG0_L0_MASK, protocol); in xpsgtr_lane_set_protocol()
454 xpsgtr_clr_set(gtr_dev, ICM_CFG1, ICM_CFG0_L1_MASK, in xpsgtr_lane_set_protocol()
486 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; in xpsgtr_phy_init_sata() local
490 writel(gtr_phy->lane, gtr_dev->siou + SATA_CONTROL_OFFSET); in xpsgtr_phy_init_sata()
496 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; in xpsgtr_phy_init_sgmii() local
501 xpsgtr_clr_set(gtr_dev, TX_PROT_BUS_WIDTH, mask, val); in xpsgtr_phy_init_sgmii()
502 xpsgtr_clr_set(gtr_dev, RX_PROT_BUS_WIDTH, mask, val); in xpsgtr_phy_init_sgmii()
554 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; in xpsgtr_phy_tx_term_fix() local
559 xpsgtr_clr_set(gtr_dev, TM_CMN_RST, TM_CMN_RST_MASK, TM_CMN_RST_SET); in xpsgtr_phy_tx_term_fix()
562 xpsgtr_clr_set(gtr_dev, TM_CMN_RST, TM_CMN_RST_MASK, TM_CMN_RST_EN); in xpsgtr_phy_tx_term_fix()
564 xpsgtr_write(gtr_dev, L3_TM_CALIB_DIG18, 0x00); in xpsgtr_phy_tx_term_fix()
565 xpsgtr_write(gtr_dev, L3_TM_CALIB_DIG19, L3_TM_OVERRIDE_NSW_CODE); in xpsgtr_phy_tx_term_fix()
575 xpsgtr_clr_set(gtr_dev, TM_CMN_RST, TM_CMN_RST_MASK, TM_CMN_RST_SET); in xpsgtr_phy_tx_term_fix()
577 dev_dbg(gtr_dev->dev, "calibrating...\n"); in xpsgtr_phy_tx_term_fix()
580 u32 reg = xpsgtr_read(gtr_dev, L3_CALIB_DONE_STATUS); in xpsgtr_phy_tx_term_fix()
586 dev_err(gtr_dev->dev, "calibration time out\n"); in xpsgtr_phy_tx_term_fix()
593 dev_dbg(gtr_dev->dev, "calibration done\n"); in xpsgtr_phy_tx_term_fix()
596 nsw = xpsgtr_read(gtr_dev, L0_TXPMA_ST_3) & L0_DN_CALIB_CODE; in xpsgtr_phy_tx_term_fix()
599 xpsgtr_clr_set(gtr_dev, TM_CMN_RST, TM_CMN_RST_MASK, TM_CMN_RST_EN); in xpsgtr_phy_tx_term_fix()
602 xpsgtr_write(gtr_dev, L3_TM_CALIB_DIG19, nsw >> L3_NSW_CALIB_SHIFT); in xpsgtr_phy_tx_term_fix()
605 xpsgtr_write(gtr_dev, L3_TM_CALIB_DIG18, in xpsgtr_phy_tx_term_fix()
610 xpsgtr_clr_set(gtr_dev, TM_CMN_RST, TM_CMN_RST_MASK, TM_CMN_RST_SET); in xpsgtr_phy_tx_term_fix()
618 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; in xpsgtr_phy_init() local
621 mutex_lock(>r_dev->gtr_mutex); in xpsgtr_phy_init()
624 if (clk_prepare_enable(gtr_dev->clk[gtr_phy->refclk])) in xpsgtr_phy_init()
631 if (gtr_dev->tx_term_fix) { in xpsgtr_phy_init()
636 gtr_dev->tx_term_fix = false; in xpsgtr_phy_init()
664 mutex_unlock(>r_dev->gtr_mutex); in xpsgtr_phy_init()
671 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; in xpsgtr_phy_exit() local
676 clk_disable_unprepare(gtr_dev->clk[gtr_phy->refclk]); in xpsgtr_phy_exit()
821 struct xpsgtr_dev *gtr_dev = dev_get_drvdata(dev); in xpsgtr_xlate() local
840 if (phy_lane >= ARRAY_SIZE(gtr_dev->phys)) { in xpsgtr_xlate()
845 gtr_phy = >r_dev->phys[phy_lane]; in xpsgtr_xlate()
852 dev_err(gtr_dev->dev, "Invalid PHY type and/or instance\n"); in xpsgtr_xlate()
857 if (refclk >= ARRAY_SIZE(gtr_dev->refclk_sscs) || in xpsgtr_xlate()
858 !gtr_dev->refclk_sscs[refclk]) { in xpsgtr_xlate()
883 struct xpsgtr_dev *gtr_dev = dev_get_drvdata(dev); in xpsgtr_runtime_suspend() local
886 gtr_dev->saved_icm_cfg0 = xpsgtr_read(gtr_dev, ICM_CFG0); in xpsgtr_runtime_suspend()
887 gtr_dev->saved_icm_cfg1 = xpsgtr_read(gtr_dev, ICM_CFG1); in xpsgtr_runtime_suspend()
889 xpsgtr_save_lane_regs(gtr_dev); in xpsgtr_runtime_suspend()
896 struct xpsgtr_dev *gtr_dev = dev_get_drvdata(dev); in xpsgtr_runtime_resume() local
901 xpsgtr_restore_lane_regs(gtr_dev); in xpsgtr_runtime_resume()
903 icm_cfg0 = xpsgtr_read(gtr_dev, ICM_CFG0); in xpsgtr_runtime_resume()
904 icm_cfg1 = xpsgtr_read(gtr_dev, ICM_CFG1); in xpsgtr_runtime_resume()
907 if (!gtr_dev->saved_icm_cfg0 && !gtr_dev->saved_icm_cfg1) in xpsgtr_runtime_resume()
911 if (icm_cfg0 == gtr_dev->saved_icm_cfg0 && in xpsgtr_runtime_resume()
912 icm_cfg1 == gtr_dev->saved_icm_cfg1) in xpsgtr_runtime_resume()
918 for (i = 0; i < ARRAY_SIZE(gtr_dev->phys); i++) in xpsgtr_runtime_resume()
919 gtr_dev->phys[i].skip_phy_init = skip_phy_init; in xpsgtr_runtime_resume()
930 static int xpsgtr_get_ref_clocks(struct xpsgtr_dev *gtr_dev) in xpsgtr_get_ref_clocks() argument
934 for (refclk = 0; refclk < ARRAY_SIZE(gtr_dev->refclk_sscs); ++refclk) { in xpsgtr_get_ref_clocks()
941 clk = devm_clk_get_optional(gtr_dev->dev, name); in xpsgtr_get_ref_clocks()
943 return dev_err_probe(gtr_dev->dev, PTR_ERR(clk), in xpsgtr_get_ref_clocks()
951 gtr_dev->clk[refclk] = clk; in xpsgtr_get_ref_clocks()
964 gtr_dev->refclk_sscs[refclk] = &ssc_lookup[i]; in xpsgtr_get_ref_clocks()
970 dev_err(gtr_dev->dev, in xpsgtr_get_ref_clocks()
983 struct xpsgtr_dev *gtr_dev; in xpsgtr_probe() local
988 gtr_dev = devm_kzalloc(&pdev->dev, sizeof(*gtr_dev), GFP_KERNEL); in xpsgtr_probe()
989 if (!gtr_dev) in xpsgtr_probe()
992 gtr_dev->dev = &pdev->dev; in xpsgtr_probe()
993 platform_set_drvdata(pdev, gtr_dev); in xpsgtr_probe()
995 mutex_init(>r_dev->gtr_mutex); in xpsgtr_probe()
998 gtr_dev->tx_term_fix = in xpsgtr_probe()
1002 gtr_dev->serdes = devm_platform_ioremap_resource_byname(pdev, "serdes"); in xpsgtr_probe()
1003 if (IS_ERR(gtr_dev->serdes)) in xpsgtr_probe()
1004 return PTR_ERR(gtr_dev->serdes); in xpsgtr_probe()
1006 gtr_dev->siou = devm_platform_ioremap_resource_byname(pdev, "siou"); in xpsgtr_probe()
1007 if (IS_ERR(gtr_dev->siou)) in xpsgtr_probe()
1008 return PTR_ERR(gtr_dev->siou); in xpsgtr_probe()
1010 ret = xpsgtr_get_ref_clocks(gtr_dev); in xpsgtr_probe()
1015 for (port = 0; port < ARRAY_SIZE(gtr_dev->phys); ++port) { in xpsgtr_probe()
1016 struct xpsgtr_phy *gtr_phy = >r_dev->phys[port]; in xpsgtr_probe()
1020 gtr_phy->dev = gtr_dev; in xpsgtr_probe()
1039 pm_runtime_set_active(gtr_dev->dev); in xpsgtr_probe()
1040 pm_runtime_enable(gtr_dev->dev); in xpsgtr_probe()
1042 ret = pm_runtime_resume_and_get(gtr_dev->dev); in xpsgtr_probe()
1044 pm_runtime_disable(gtr_dev->dev); in xpsgtr_probe()
1048 gtr_dev->saved_regs = devm_kmalloc(gtr_dev->dev, in xpsgtr_probe()
1051 if (!gtr_dev->saved_regs) in xpsgtr_probe()
1059 struct xpsgtr_dev *gtr_dev = platform_get_drvdata(pdev); in xpsgtr_remove() local
1061 pm_runtime_disable(gtr_dev->dev); in xpsgtr_remove()
1062 pm_runtime_put_noidle(gtr_dev->dev); in xpsgtr_remove()
1063 pm_runtime_set_suspended(gtr_dev->dev); in xpsgtr_remove()