• Home
  • Raw
  • Download

Lines Matching +full:lynx +full:- +full:pcs

1 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
3 * Lynx PCS MDIO helpers
8 #include <linux/pcs-lynx.h>
11 #define SGMII_CLOCK_PERIOD_NS 8 /* PCS is clocked at 125 MHz */
24 struct phylink_pcs pcs; member
35 #define phylink_pcs_to_lynx(pl_pcs) container_of((pl_pcs), struct lynx_pcs, pcs)
36 #define lynx_to_phylink_pcs(lynx) (&(lynx)->pcs) argument
38 static void lynx_pcs_get_state_usxgmii(struct mdio_device *pcs, in lynx_pcs_get_state_usxgmii() argument
41 struct mii_bus *bus = pcs->bus; in lynx_pcs_get_state_usxgmii()
42 int addr = pcs->addr; in lynx_pcs_get_state_usxgmii()
49 state->link = !!(status & MDIO_STAT1_LSTATUS); in lynx_pcs_get_state_usxgmii()
50 state->an_complete = !!(status & MDIO_AN_STAT1_COMPLETE); in lynx_pcs_get_state_usxgmii()
51 if (!state->link || !state->an_complete) in lynx_pcs_get_state_usxgmii()
61 static void lynx_pcs_get_state_2500basex(struct mdio_device *pcs, in lynx_pcs_get_state_2500basex() argument
66 bmsr = mdiodev_read(pcs, MII_BMSR); in lynx_pcs_get_state_2500basex()
67 lpa = mdiodev_read(pcs, MII_LPA); in lynx_pcs_get_state_2500basex()
69 state->link = false; in lynx_pcs_get_state_2500basex()
73 state->link = !!(bmsr & BMSR_LSTATUS); in lynx_pcs_get_state_2500basex()
74 state->an_complete = !!(bmsr & BMSR_ANEGCOMPLETE); in lynx_pcs_get_state_2500basex()
75 if (!state->link) in lynx_pcs_get_state_2500basex()
78 state->speed = SPEED_2500; in lynx_pcs_get_state_2500basex()
79 state->pause |= MLO_PAUSE_TX | MLO_PAUSE_RX; in lynx_pcs_get_state_2500basex()
80 state->duplex = DUPLEX_FULL; in lynx_pcs_get_state_2500basex()
83 static void lynx_pcs_get_state(struct phylink_pcs *pcs, in lynx_pcs_get_state() argument
86 struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); in lynx_pcs_get_state() local
88 switch (state->interface) { in lynx_pcs_get_state()
92 phylink_mii_c22_pcs_get_state(lynx->mdio, state); in lynx_pcs_get_state()
95 lynx_pcs_get_state_2500basex(lynx->mdio, state); in lynx_pcs_get_state()
98 lynx_pcs_get_state_usxgmii(lynx->mdio, state); in lynx_pcs_get_state()
101 phylink_mii_c45_pcs_get_state(lynx->mdio, state); in lynx_pcs_get_state()
107 dev_dbg(&lynx->mdio->dev, in lynx_pcs_get_state()
109 phy_modes(state->interface), in lynx_pcs_get_state()
110 phy_speed_to_str(state->speed), in lynx_pcs_get_state()
111 phy_duplex_to_str(state->duplex), in lynx_pcs_get_state()
112 state->link, state->an_complete); in lynx_pcs_get_state()
115 static int lynx_pcs_config_giga(struct mdio_device *pcs, in lynx_pcs_config_giga() argument
129 mdiodev_write(pcs, LINK_TIMER_LO, link_timer & 0xffff); in lynx_pcs_config_giga()
130 mdiodev_write(pcs, LINK_TIMER_HI, link_timer >> 16); in lynx_pcs_config_giga()
142 err = mdiodev_modify(pcs, IF_MODE, in lynx_pcs_config_giga()
148 return phylink_mii_c22_pcs_config(pcs, interface, advertising, in lynx_pcs_config_giga()
152 static int lynx_pcs_config_usxgmii(struct mdio_device *pcs, in lynx_pcs_config_usxgmii() argument
156 struct mii_bus *bus = pcs->bus; in lynx_pcs_config_usxgmii()
157 int addr = pcs->addr; in lynx_pcs_config_usxgmii()
160 dev_err(&pcs->dev, "USXGMII only supports in-band AN for now\n"); in lynx_pcs_config_usxgmii()
161 return -EOPNOTSUPP; in lynx_pcs_config_usxgmii()
171 static int lynx_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, in lynx_pcs_config() argument
175 struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); in lynx_pcs_config() local
181 return lynx_pcs_config_giga(lynx->mdio, ifmode, advertising, in lynx_pcs_config()
185 dev_err(&lynx->mdio->dev, in lynx_pcs_config()
187 return -EOPNOTSUPP; in lynx_pcs_config()
191 return lynx_pcs_config_usxgmii(lynx->mdio, advertising, in lynx_pcs_config()
197 return -EOPNOTSUPP; in lynx_pcs_config()
203 static void lynx_pcs_an_restart(struct phylink_pcs *pcs) in lynx_pcs_an_restart() argument
205 struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); in lynx_pcs_an_restart() local
207 phylink_mii_c22_pcs_an_restart(lynx->mdio); in lynx_pcs_an_restart()
210 static void lynx_pcs_link_up_sgmii(struct mdio_device *pcs, in lynx_pcs_link_up_sgmii() argument
216 /* The PCS needs to be configured manually only in lynx_pcs_link_up_sgmii()
217 * when not operating on in-band mode in lynx_pcs_link_up_sgmii()
239 dev_err(&pcs->dev, "Invalid PCS speed %d\n", speed); in lynx_pcs_link_up_sgmii()
244 mdiodev_modify(pcs, IF_MODE, in lynx_pcs_link_up_sgmii()
249 /* 2500Base-X is SerDes protocol 7 on Felix and 6 on ENETC. It is a SerDes lane
251 * auto-negotiation of any link parameters. Electrically it is compatible with
255 * - Downgrading the link speed by duplicating symbols
256 * - Auto-negotiation
261 * AN, we call this PHY interface type 2500Base-X. In case a PHY negotiates a
262 * lower link speed on line side, the system-side interface remains fixed at
265 static void lynx_pcs_link_up_2500basex(struct mdio_device *pcs, in lynx_pcs_link_up_2500basex() argument
272 dev_err(&pcs->dev, "AN not supported for 2500BaseX\n"); in lynx_pcs_link_up_2500basex()
280 mdiodev_modify(pcs, IF_MODE, in lynx_pcs_link_up_2500basex()
285 static void lynx_pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode, in lynx_pcs_link_up() argument
289 struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); in lynx_pcs_link_up() local
294 lynx_pcs_link_up_sgmii(lynx->mdio, neg_mode, speed, duplex); in lynx_pcs_link_up()
297 lynx_pcs_link_up_2500basex(lynx->mdio, neg_mode, speed, duplex); in lynx_pcs_link_up()
300 /* At the moment, only in-band AN is supported for USXGMII in lynx_pcs_link_up()
318 struct lynx_pcs *lynx; in lynx_pcs_create() local
320 lynx = kzalloc(sizeof(*lynx), GFP_KERNEL); in lynx_pcs_create()
321 if (!lynx) in lynx_pcs_create()
322 return ERR_PTR(-ENOMEM); in lynx_pcs_create()
325 lynx->mdio = mdio; in lynx_pcs_create()
326 lynx->pcs.ops = &lynx_pcs_phylink_ops; in lynx_pcs_create()
327 lynx->pcs.neg_mode = true; in lynx_pcs_create()
328 lynx->pcs.poll = true; in lynx_pcs_create()
330 return lynx_to_phylink_pcs(lynx); in lynx_pcs_create()
336 struct phylink_pcs *pcs; in lynx_pcs_create_mdiodev() local
342 pcs = lynx_pcs_create(mdio); in lynx_pcs_create_mdiodev()
352 return pcs; in lynx_pcs_create_mdiodev()
357 * lynx_pcs_create_fwnode() creates a lynx PCS instance from the fwnode
361 * -ENODEV if the fwnode is marked unavailable
362 * -EPROBE_DEFER if we fail to find the device
363 * -ENOMEM if we fail to allocate memory
369 struct phylink_pcs *pcs; in lynx_pcs_create_fwnode() local
372 return ERR_PTR(-ENODEV); in lynx_pcs_create_fwnode()
376 return ERR_PTR(-EPROBE_DEFER); in lynx_pcs_create_fwnode()
378 pcs = lynx_pcs_create(mdio); in lynx_pcs_create_fwnode()
388 return pcs; in lynx_pcs_create_fwnode()
392 void lynx_pcs_destroy(struct phylink_pcs *pcs) in lynx_pcs_destroy() argument
394 struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); in lynx_pcs_destroy() local
396 mdio_device_put(lynx->mdio); in lynx_pcs_destroy()
397 kfree(lynx); in lynx_pcs_destroy()