Lines Matching full:xpcs
4 #include <linux/pcs/pcs-xpcs.h>
6 #include "pcs-xpcs.h"
49 static int txgbe_read_pma(struct dw_xpcs *xpcs, int reg) in txgbe_read_pma() argument
51 return xpcs_read(xpcs, MDIO_MMD_PMAPMD, TXGBE_PMA_MMD + reg); in txgbe_read_pma()
54 static int txgbe_write_pma(struct dw_xpcs *xpcs, int reg, u16 val) in txgbe_write_pma() argument
56 return xpcs_write(xpcs, MDIO_MMD_PMAPMD, TXGBE_PMA_MMD + reg, val); in txgbe_write_pma()
59 static void txgbe_pma_config_10gbaser(struct dw_xpcs *xpcs) in txgbe_pma_config_10gbaser() argument
63 txgbe_write_pma(xpcs, TXGBE_MPLLA_CTL0, 0x21); in txgbe_pma_config_10gbaser()
64 txgbe_write_pma(xpcs, TXGBE_MPLLA_CTL3, 0); in txgbe_pma_config_10gbaser()
65 val = txgbe_read_pma(xpcs, TXGBE_TX_GENCTL1); in txgbe_pma_config_10gbaser()
67 txgbe_write_pma(xpcs, TXGBE_TX_GENCTL1, val); in txgbe_pma_config_10gbaser()
68 txgbe_write_pma(xpcs, TXGBE_MISC_CTL0, TXGBE_MISC_CTL0_PLL | in txgbe_pma_config_10gbaser()
70 txgbe_write_pma(xpcs, TXGBE_VCO_CAL_LD0, 0x549); in txgbe_pma_config_10gbaser()
71 txgbe_write_pma(xpcs, TXGBE_VCO_CAL_REF0, 0x29); in txgbe_pma_config_10gbaser()
72 txgbe_write_pma(xpcs, TXGBE_TX_RATE_CTL, 0); in txgbe_pma_config_10gbaser()
73 txgbe_write_pma(xpcs, TXGBE_RX_RATE_CTL, 0); in txgbe_pma_config_10gbaser()
74 txgbe_write_pma(xpcs, TXGBE_TX_GEN_CTL2, TXGBE_TX_GEN_CTL2_TX0_WIDTH(3)); in txgbe_pma_config_10gbaser()
75 txgbe_write_pma(xpcs, TXGBE_RX_GEN_CTL2, TXGBE_RX_GEN_CTL2_RX0_WIDTH(3)); in txgbe_pma_config_10gbaser()
76 txgbe_write_pma(xpcs, TXGBE_MPLLA_CTL2, TXGBE_MPLLA_CTL2_DIV16P5_CLK_EN | in txgbe_pma_config_10gbaser()
79 txgbe_write_pma(xpcs, TXGBE_RX_EQ_CTL0, TXGBE_RX_EQ_CTL0_CTLE_POLE(2) | in txgbe_pma_config_10gbaser()
81 val = txgbe_read_pma(xpcs, TXGBE_RX_EQ_ATTN_CTL); in txgbe_pma_config_10gbaser()
83 txgbe_write_pma(xpcs, TXGBE_RX_EQ_ATTN_CTL, val); in txgbe_pma_config_10gbaser()
84 txgbe_write_pma(xpcs, TXGBE_DFE_TAP_CTL0, 0xBE); in txgbe_pma_config_10gbaser()
85 val = txgbe_read_pma(xpcs, TXGBE_AFE_DFE_ENABLE); in txgbe_pma_config_10gbaser()
87 txgbe_write_pma(xpcs, TXGBE_AFE_DFE_ENABLE, val); in txgbe_pma_config_10gbaser()
88 val = txgbe_read_pma(xpcs, TXGBE_RX_EQ_CTL4); in txgbe_pma_config_10gbaser()
90 txgbe_write_pma(xpcs, TXGBE_RX_EQ_CTL4, val); in txgbe_pma_config_10gbaser()
93 static void txgbe_pma_config_1g(struct dw_xpcs *xpcs) in txgbe_pma_config_1g() argument
97 val = txgbe_read_pma(xpcs, TXGBE_TX_GENCTL1); in txgbe_pma_config_1g()
100 txgbe_write_pma(xpcs, TXGBE_TX_GENCTL1, val); in txgbe_pma_config_1g()
101 txgbe_write_pma(xpcs, TXGBE_MISC_CTL0, TXGBE_MISC_CTL0_PLL | in txgbe_pma_config_1g()
104 txgbe_write_pma(xpcs, TXGBE_RX_EQ_CTL0, TXGBE_RX_EQ_CTL0_VGA1_GAIN(7) | in txgbe_pma_config_1g()
106 val = txgbe_read_pma(xpcs, TXGBE_RX_EQ_ATTN_CTL); in txgbe_pma_config_1g()
108 txgbe_write_pma(xpcs, TXGBE_RX_EQ_ATTN_CTL, val); in txgbe_pma_config_1g()
109 txgbe_write_pma(xpcs, TXGBE_DFE_TAP_CTL0, 0); in txgbe_pma_config_1g()
110 val = txgbe_read_pma(xpcs, TXGBE_RX_GEN_CTL3); in txgbe_pma_config_1g()
112 txgbe_write_pma(xpcs, TXGBE_RX_GEN_CTL3, val); in txgbe_pma_config_1g()
114 txgbe_write_pma(xpcs, TXGBE_MPLLA_CTL0, 0x20); in txgbe_pma_config_1g()
115 txgbe_write_pma(xpcs, TXGBE_MPLLA_CTL3, 0x46); in txgbe_pma_config_1g()
116 txgbe_write_pma(xpcs, TXGBE_VCO_CAL_LD0, 0x540); in txgbe_pma_config_1g()
117 txgbe_write_pma(xpcs, TXGBE_VCO_CAL_REF0, 0x2A); in txgbe_pma_config_1g()
118 txgbe_write_pma(xpcs, TXGBE_AFE_DFE_ENABLE, 0); in txgbe_pma_config_1g()
119 txgbe_write_pma(xpcs, TXGBE_RX_EQ_CTL4, TXGBE_RX_EQ_CTL4_CONT_OFF_CAN0); in txgbe_pma_config_1g()
120 txgbe_write_pma(xpcs, TXGBE_TX_RATE_CTL, TXGBE_TX_RATE_CTL_TX0_RATE(3)); in txgbe_pma_config_1g()
121 txgbe_write_pma(xpcs, TXGBE_RX_RATE_CTL, TXGBE_RX_RATE_CTL_RX0_RATE(3)); in txgbe_pma_config_1g()
122 txgbe_write_pma(xpcs, TXGBE_TX_GEN_CTL2, TXGBE_TX_GEN_CTL2_TX0_WIDTH(1)); in txgbe_pma_config_1g()
123 txgbe_write_pma(xpcs, TXGBE_RX_GEN_CTL2, TXGBE_RX_GEN_CTL2_RX0_WIDTH(1)); in txgbe_pma_config_1g()
124 txgbe_write_pma(xpcs, TXGBE_MPLLA_CTL2, TXGBE_MPLLA_CTL2_DIV10_CLK_EN); in txgbe_pma_config_1g()
127 static int txgbe_pcs_poll_power_up(struct dw_xpcs *xpcs) in txgbe_pcs_poll_power_up() argument
131 /* Wait xpcs power-up good */ in txgbe_pcs_poll_power_up()
135 xpcs, DW_VR_XS_PCS_DIG_STS); in txgbe_pcs_poll_power_up()
137 dev_err(&xpcs->mdiodev->dev, "xpcs power-up timeout\n"); in txgbe_pcs_poll_power_up()
142 static int txgbe_pma_init_done(struct dw_xpcs *xpcs) in txgbe_pma_init_done() argument
146 xpcs_write_vpcs(xpcs, DW_VR_XS_PCS_DIG_CTRL1, DW_VR_RST | DW_EN_VSMMD1); in txgbe_pma_init_done()
151 xpcs, DW_VR_XS_PCS_DIG_CTRL1); in txgbe_pma_init_done()
153 dev_err(&xpcs->mdiodev->dev, "xpcs pma initialization timeout\n"); in txgbe_pma_init_done()
158 static bool txgbe_xpcs_mode_quirk(struct dw_xpcs *xpcs) in txgbe_xpcs_mode_quirk() argument
163 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_CTRL2); in txgbe_xpcs_mode_quirk()
166 xpcs->interface != PHY_INTERFACE_MODE_10GBASER) || in txgbe_xpcs_mode_quirk()
167 xpcs->interface == PHY_INTERFACE_MODE_SGMII) in txgbe_xpcs_mode_quirk()
173 int txgbe_xpcs_switch_mode(struct dw_xpcs *xpcs, phy_interface_t interface) in txgbe_xpcs_switch_mode() argument
186 if (xpcs->interface == interface && !txgbe_xpcs_mode_quirk(xpcs)) in txgbe_xpcs_switch_mode()
189 xpcs->interface = interface; in txgbe_xpcs_switch_mode()
191 ret = txgbe_pcs_poll_power_up(xpcs); in txgbe_xpcs_switch_mode()
196 xpcs_write(xpcs, MDIO_MMD_PCS, MDIO_CTRL2, MDIO_PCS_CTRL2_10GBR); in txgbe_xpcs_switch_mode()
197 val = xpcs_read(xpcs, MDIO_MMD_PMAPMD, MDIO_CTRL1); in txgbe_xpcs_switch_mode()
199 xpcs_write(xpcs, MDIO_MMD_PMAPMD, MDIO_CTRL1, val); in txgbe_xpcs_switch_mode()
200 txgbe_pma_config_10gbaser(xpcs); in txgbe_xpcs_switch_mode()
202 xpcs_write(xpcs, MDIO_MMD_PCS, MDIO_CTRL2, MDIO_PCS_CTRL2_10GBX); in txgbe_xpcs_switch_mode()
203 xpcs_write(xpcs, MDIO_MMD_PMAPMD, MDIO_CTRL1, 0); in txgbe_xpcs_switch_mode()
204 xpcs_write(xpcs, MDIO_MMD_PCS, MDIO_CTRL1, 0); in txgbe_xpcs_switch_mode()
205 txgbe_pma_config_1g(xpcs); in txgbe_xpcs_switch_mode()
208 return txgbe_pma_init_done(xpcs); in txgbe_xpcs_switch_mode()