Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: pcs: add pcs-lynx 1000BASE-X support

Add support for 1000BASE-X to pcs-lynx for the LX2160A.

This commit prepares the ground work for allowing 1G fiber connections
to be used with DPAA2 on the SolidRun CEX7 platforms.

Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Russell King and committed by
Jakub Kicinski
694a0006 8cc8993c

+36
+36
drivers/net/pcs/pcs-lynx.c
··· 11 11 #define LINK_TIMER_VAL(ns) ((u32)((ns) / SGMII_CLOCK_PERIOD_NS)) 12 12 13 13 #define SGMII_AN_LINK_TIMER_NS 1600000 /* defined by SGMII spec */ 14 + #define IEEE8023_LINK_TIMER_NS 10000000 14 15 15 16 #define LINK_TIMER_LO 0x12 16 17 #define LINK_TIMER_HI 0x13 ··· 84 83 struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); 85 84 86 85 switch (state->interface) { 86 + case PHY_INTERFACE_MODE_1000BASEX: 87 87 case PHY_INTERFACE_MODE_SGMII: 88 88 case PHY_INTERFACE_MODE_QSGMII: 89 89 phylink_mii_c22_pcs_get_state(lynx->mdio, state); ··· 108 106 phy_speed_to_str(state->speed), 109 107 phy_duplex_to_str(state->duplex), 110 108 state->link, state->an_enabled, state->an_complete); 109 + } 110 + 111 + static int lynx_pcs_config_1000basex(struct mdio_device *pcs, 112 + unsigned int mode, 113 + const unsigned long *advertising) 114 + { 115 + struct mii_bus *bus = pcs->bus; 116 + int addr = pcs->addr; 117 + u32 link_timer; 118 + int err; 119 + 120 + link_timer = LINK_TIMER_VAL(IEEE8023_LINK_TIMER_NS); 121 + mdiobus_write(bus, addr, LINK_TIMER_LO, link_timer & 0xffff); 122 + mdiobus_write(bus, addr, LINK_TIMER_HI, link_timer >> 16); 123 + 124 + err = mdiobus_modify(bus, addr, IF_MODE, 125 + IF_MODE_SGMII_EN | IF_MODE_USE_SGMII_AN, 126 + 0); 127 + if (err) 128 + return err; 129 + 130 + return phylink_mii_c22_pcs_config(pcs, mode, 131 + PHY_INTERFACE_MODE_1000BASEX, 132 + advertising); 111 133 } 112 134 113 135 static int lynx_pcs_config_sgmii(struct mdio_device *pcs, unsigned int mode, ··· 189 163 struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); 190 164 191 165 switch (ifmode) { 166 + case PHY_INTERFACE_MODE_1000BASEX: 167 + return lynx_pcs_config_1000basex(lynx->mdio, mode, advertising); 192 168 case PHY_INTERFACE_MODE_SGMII: 193 169 case PHY_INTERFACE_MODE_QSGMII: 194 170 return lynx_pcs_config_sgmii(lynx->mdio, mode, advertising); ··· 211 183 } 212 184 213 185 return 0; 186 + } 187 + 188 + static void lynx_pcs_an_restart(struct phylink_pcs *pcs) 189 + { 190 + struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); 191 + 192 + phylink_mii_c22_pcs_an_restart(lynx->mdio); 214 193 } 215 194 216 195 static void lynx_pcs_link_up_sgmii(struct mdio_device *pcs, unsigned int mode, ··· 325 290 static const struct phylink_pcs_ops lynx_pcs_phylink_ops = { 326 291 .pcs_get_state = lynx_pcs_get_state, 327 292 .pcs_config = lynx_pcs_config, 293 + .pcs_an_restart = lynx_pcs_an_restart, 328 294 .pcs_link_up = lynx_pcs_link_up, 329 295 }; 330 296