|
72 | 72 | /* Register to QPHY wrapper control */ |
73 | 73 | #define SGMSYS_QPHY_WRAP_CTRL 0xec |
74 | 74 | #define SGMII_PN_SWAP_MASK GENMASK(1, 0) |
75 | | -#define SGMII_PN_SWAP_TX_RX (BIT(0) | BIT(1)) |
| 75 | +#define SGMII_PN_SWAP_RX BIT(1) |
| 76 | +#define SGMII_PN_SWAP_TX BIT(0) |
76 | 77 |
|
77 | 78 | #define MTK_NETSYS_V3_AMA_RGC3 0x128 |
78 | 79 |
|
@@ -163,6 +164,7 @@ static int mtk_pcs_lynxi_config(struct phylink_pcs *pcs, unsigned int neg_mode, |
163 | 164 | struct mtk_pcs_lynxi *mpcs = pcs_to_mtk_pcs_lynxi(pcs); |
164 | 165 | bool mode_changed = false, changed; |
165 | 166 | unsigned int rgc3, sgm_mode, bmcr; |
| 167 | + unsigned int pnswap_tx, pnswap_rx; |
166 | 168 | int link_timer; |
167 | 169 |
|
168 | 170 | if (advertising) { |
@@ -209,10 +211,14 @@ static int mtk_pcs_lynxi_config(struct phylink_pcs *pcs, unsigned int neg_mode, |
209 | 211 | regmap_set_bits(mpcs->regmap, SGMSYS_RESERVED_0, |
210 | 212 | SGMII_SW_RESET); |
211 | 213 |
|
212 | | - if (mpcs->flags & MTK_SGMII_FLAG_PN_SWAP) |
213 | | - regmap_update_bits(mpcs->regmap, SGMSYS_QPHY_WRAP_CTRL, |
214 | | - SGMII_PN_SWAP_MASK, |
215 | | - SGMII_PN_SWAP_TX_RX); |
| 214 | + /* Configure the interface polarity */ |
| 215 | + pnswap_tx = (mpcs->flags & MTK_SGMII_FLAG_PN_SWAP_TX) ? |
| 216 | + SGMII_PN_SWAP_TX : 0; |
| 217 | + pnswap_rx = (mpcs->flags & MTK_SGMII_FLAG_PN_SWAP_RX) ? |
| 218 | + SGMII_PN_SWAP_RX : 0; |
| 219 | + regmap_update_bits(mpcs->regmap, SGMSYS_QPHY_WRAP_CTRL, |
| 220 | + SGMII_PN_SWAP_MASK, |
| 221 | + pnswap_tx | pnswap_rx); |
216 | 222 |
|
217 | 223 | if (interface == PHY_INTERFACE_MODE_2500BASEX) |
218 | 224 | rgc3 = SGMII_PHY_SPEED_3_125G; |
@@ -433,7 +439,11 @@ static int mtk_pcs_lynxi_probe(struct platform_device *pdev) |
433 | 439 | return PTR_ERR(regmap); |
434 | 440 |
|
435 | 441 | if (of_property_read_bool(np->parent, "mediatek,pnswap")) |
436 | | - flags |= MTK_SGMII_FLAG_PN_SWAP; |
| 442 | + flags |= MTK_SGMII_FLAG_PN_SWAP_TX | MTK_SGMII_FLAG_PN_SWAP_RX; |
| 443 | + else if (of_property_read_bool(np->parent, "mediatek,pnswap-tx")) |
| 444 | + flags |= MTK_SGMII_FLAG_PN_SWAP_TX; |
| 445 | + else if (of_property_read_bool(np->parent, "mediatek,pnswap-rx")) |
| 446 | + flags |= MTK_SGMII_FLAG_PN_SWAP_RX; |
437 | 447 |
|
438 | 448 | if (of_parse_phandle(np->parent, "resets", 0)) { |
439 | 449 | mpcs->rstc = of_reset_control_get_shared(np->parent, NULL); |
|
0 commit comments