Lines Matching full:xpcs
4 * Synopsys DesignWare XPCS helpers
11 #include <linux/pcs/pcs-xpcs.h>
17 #include "pcs-xpcs.h"
158 int (*pma_config)(struct dw_xpcs *xpcs);
168 xpcs_find_compat(struct dw_xpcs *xpcs, phy_interface_t interface) in xpcs_find_compat() argument
172 for (compat = xpcs->desc->compat; compat->supported; compat++) in xpcs_find_compat()
179 struct phylink_pcs *xpcs_to_phylink_pcs(struct dw_xpcs *xpcs) in xpcs_to_phylink_pcs() argument
181 return &xpcs->pcs; in xpcs_to_phylink_pcs()
185 int xpcs_get_an_mode(struct dw_xpcs *xpcs, phy_interface_t interface) in xpcs_get_an_mode() argument
189 compat = xpcs_find_compat(xpcs, interface); in xpcs_get_an_mode()
212 int xpcs_read(struct dw_xpcs *xpcs, int dev, u32 reg) in xpcs_read() argument
214 return mdiodev_c45_read(xpcs->mdiodev, dev, reg); in xpcs_read()
217 int xpcs_write(struct dw_xpcs *xpcs, int dev, u32 reg, u16 val) in xpcs_write() argument
219 return mdiodev_c45_write(xpcs->mdiodev, dev, reg, val); in xpcs_write()
222 int xpcs_modify(struct dw_xpcs *xpcs, int dev, u32 reg, u16 mask, u16 set) in xpcs_modify() argument
224 return mdiodev_c45_modify(xpcs->mdiodev, dev, reg, mask, set); in xpcs_modify()
227 static int xpcs_modify_changed(struct dw_xpcs *xpcs, int dev, u32 reg, in xpcs_modify_changed() argument
230 return mdiodev_c45_modify_changed(xpcs->mdiodev, dev, reg, mask, set); in xpcs_modify_changed()
233 static int xpcs_read_vendor(struct dw_xpcs *xpcs, int dev, u32 reg) in xpcs_read_vendor() argument
235 return xpcs_read(xpcs, dev, DW_VENDOR | reg); in xpcs_read_vendor()
238 static int xpcs_write_vendor(struct dw_xpcs *xpcs, int dev, int reg, in xpcs_write_vendor() argument
241 return xpcs_write(xpcs, dev, DW_VENDOR | reg, val); in xpcs_write_vendor()
244 static int xpcs_modify_vendor(struct dw_xpcs *xpcs, int dev, int reg, u16 mask, in xpcs_modify_vendor() argument
247 return xpcs_modify(xpcs, dev, DW_VENDOR | reg, mask, set); in xpcs_modify_vendor()
250 int xpcs_read_vpcs(struct dw_xpcs *xpcs, int reg) in xpcs_read_vpcs() argument
252 return xpcs_read_vendor(xpcs, MDIO_MMD_PCS, reg); in xpcs_read_vpcs()
255 int xpcs_write_vpcs(struct dw_xpcs *xpcs, int reg, u16 val) in xpcs_write_vpcs() argument
257 return xpcs_write_vendor(xpcs, MDIO_MMD_PCS, reg, val); in xpcs_write_vpcs()
260 static int xpcs_modify_vpcs(struct dw_xpcs *xpcs, int reg, u16 mask, u16 val) in xpcs_modify_vpcs() argument
262 return xpcs_modify_vendor(xpcs, MDIO_MMD_PCS, reg, mask, val); in xpcs_modify_vpcs()
265 static int xpcs_poll_reset(struct dw_xpcs *xpcs, int dev) in xpcs_poll_reset() argument
271 50000, 600000, true, xpcs, dev, MII_BMCR); in xpcs_poll_reset()
278 static int xpcs_soft_reset(struct dw_xpcs *xpcs, in xpcs_soft_reset() argument
297 ret = xpcs_write(xpcs, dev, MII_BMCR, BMCR_RESET); in xpcs_soft_reset()
301 return xpcs_poll_reset(xpcs, dev); in xpcs_soft_reset()
310 static int xpcs_read_fault_c73(struct dw_xpcs *xpcs, in xpcs_read_fault_c73() argument
317 xpcs_warn(xpcs, state, "Link fault condition detected!\n"); in xpcs_read_fault_c73()
321 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_STAT2); in xpcs_read_fault_c73()
326 xpcs_warn(xpcs, state, "Receiver fault detected!\n"); in xpcs_read_fault_c73()
328 xpcs_warn(xpcs, state, "Transmitter fault detected!\n"); in xpcs_read_fault_c73()
330 ret = xpcs_read_vendor(xpcs, MDIO_MMD_PCS, DW_VR_XS_PCS_DIG_STS); in xpcs_read_fault_c73()
335 xpcs_warn(xpcs, state, "FIFO fault condition detected!\n"); in xpcs_read_fault_c73()
339 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_PCS_10GBRT_STAT1); in xpcs_read_fault_c73()
344 xpcs_warn(xpcs, state, "Link is not locked!\n"); in xpcs_read_fault_c73()
346 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_PCS_10GBRT_STAT2); in xpcs_read_fault_c73()
351 xpcs_warn(xpcs, state, "Link has errors!\n"); in xpcs_read_fault_c73()
358 static void xpcs_link_up_usxgmii(struct dw_xpcs *xpcs, int speed) in xpcs_link_up_usxgmii() argument
386 ret = xpcs_modify_vpcs(xpcs, MDIO_CTRL1, DW_USXGMII_EN, DW_USXGMII_EN); in xpcs_link_up_usxgmii()
390 ret = xpcs_modify(xpcs, MDIO_MMD_VEND2, MII_BMCR, DW_USXGMII_SS_MASK, in xpcs_link_up_usxgmii()
395 ret = xpcs_modify_vpcs(xpcs, MDIO_CTRL1, DW_USXGMII_RST, in xpcs_link_up_usxgmii()
403 dev_err(&xpcs->mdiodev->dev, "%s: XPCS access returned %pe\n", in xpcs_link_up_usxgmii()
407 static int _xpcs_config_aneg_c73(struct dw_xpcs *xpcs, in _xpcs_config_aneg_c73() argument
412 /* By default, in USXGMII mode XPCS operates at 10G baud and in _xpcs_config_aneg_c73()
425 ret = xpcs_write(xpcs, MDIO_MMD_AN, DW_SR_AN_ADV3, adv); in _xpcs_config_aneg_c73()
438 ret = xpcs_write(xpcs, MDIO_MMD_AN, DW_SR_AN_ADV2, adv); in _xpcs_config_aneg_c73()
449 return xpcs_write(xpcs, MDIO_MMD_AN, DW_SR_AN_ADV1, adv); in _xpcs_config_aneg_c73()
452 static int xpcs_config_aneg_c73(struct dw_xpcs *xpcs, in xpcs_config_aneg_c73() argument
457 ret = _xpcs_config_aneg_c73(xpcs, compat); in xpcs_config_aneg_c73()
461 return xpcs_modify(xpcs, MDIO_MMD_AN, MDIO_CTRL1, in xpcs_config_aneg_c73()
466 static int xpcs_aneg_done_c73(struct dw_xpcs *xpcs, in xpcs_aneg_done_c73() argument
473 ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_AN_LPA); in xpcs_aneg_done_c73()
479 xpcs_config_aneg_c73(xpcs, compat); in xpcs_aneg_done_c73()
489 static int xpcs_read_lpa_c73(struct dw_xpcs *xpcs, in xpcs_read_lpa_c73() argument
504 ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_AN_LPA + i); in xpcs_read_lpa_c73()
516 static int xpcs_get_max_xlgmii_speed(struct dw_xpcs *xpcs, in xpcs_get_max_xlgmii_speed() argument
570 static int xpcs_c45_read_pcs_speed(struct dw_xpcs *xpcs, in xpcs_c45_read_pcs_speed() argument
575 pcs_ctrl1 = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_CTRL1); in xpcs_c45_read_pcs_speed()
597 static int xpcs_resolve_pma(struct dw_xpcs *xpcs, in xpcs_resolve_pma() argument
607 if (xpcs->info.pma == MP_FBNIC_XPCS_PMA_100G_ID) { in xpcs_resolve_pma()
608 pmd_rxdet = xpcs_read(xpcs, MDIO_MMD_PMAPMD, MDIO_PMA_RXDET); in xpcs_resolve_pma()
629 state->speed = xpcs_get_max_xlgmii_speed(xpcs, state); in xpcs_resolve_pma()
635 err = xpcs_c45_read_pcs_speed(xpcs, state); in xpcs_resolve_pma()
650 struct dw_xpcs *xpcs; in xpcs_validate() local
653 xpcs = phylink_pcs_to_xpcs(pcs); in xpcs_validate()
654 compat = xpcs_find_compat(xpcs, state->interface); in xpcs_validate()
673 struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); in xpcs_inband_caps() local
676 compat = xpcs_find_compat(xpcs, interface); in xpcs_inband_caps()
697 static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces) in xpcs_get_interfaces() argument
701 for (compat = xpcs->desc->compat; compat->supported; compat++) in xpcs_get_interfaces()
705 static int xpcs_switch_interface_mode(struct dw_xpcs *xpcs, in xpcs_switch_interface_mode() argument
710 if (xpcs->info.pma == WX_TXGBE_XPCS_PMA_10G_ID) { in xpcs_switch_interface_mode()
711 ret = txgbe_xpcs_switch_mode(xpcs, interface); in xpcs_switch_interface_mode()
712 } else if (xpcs->interface != interface) { in xpcs_switch_interface_mode()
714 xpcs->need_reset = true; in xpcs_switch_interface_mode()
715 xpcs->interface = interface; in xpcs_switch_interface_mode()
723 struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); in xpcs_pre_config() local
727 ret = xpcs_switch_interface_mode(xpcs, interface); in xpcs_pre_config()
729 dev_err(&xpcs->mdiodev->dev, "switch interface failed: %pe\n", in xpcs_pre_config()
732 if (!xpcs->need_reset) in xpcs_pre_config()
735 compat = xpcs_find_compat(xpcs, interface); in xpcs_pre_config()
737 dev_err(&xpcs->mdiodev->dev, "unsupported interface %s\n", in xpcs_pre_config()
742 ret = xpcs_soft_reset(xpcs, compat); in xpcs_pre_config()
744 dev_err(&xpcs->mdiodev->dev, "soft reset failed: %pe\n", in xpcs_pre_config()
747 xpcs->need_reset = false; in xpcs_pre_config()
750 static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, in xpcs_config_aneg_c37_sgmii() argument
761 * DW xPCS used with DW EQoS MAC is always MAC side SGMII. in xpcs_config_aneg_c37_sgmii()
774 mdio_ctrl = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_BMCR); in xpcs_config_aneg_c37_sgmii()
779 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MII_BMCR, in xpcs_config_aneg_c37_sgmii()
789 if (xpcs->info.pma == WX_TXGBE_XPCS_PMA_10G_ID) { in xpcs_config_aneg_c37_sgmii()
800 ret = xpcs_modify(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_CTRL, mask, val); in xpcs_config_aneg_c37_sgmii()
810 if (xpcs->info.pma == WX_TXGBE_XPCS_PMA_10G_ID) { in xpcs_config_aneg_c37_sgmii()
815 ret = xpcs_modify(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1, mask, val); in xpcs_config_aneg_c37_sgmii()
820 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MII_BMCR, in xpcs_config_aneg_c37_sgmii()
826 static int xpcs_config_aneg_c37_1000basex(struct dw_xpcs *xpcs, in xpcs_config_aneg_c37_1000basex() argument
842 mdio_ctrl = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_BMCR); in xpcs_config_aneg_c37_1000basex()
847 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MII_BMCR, in xpcs_config_aneg_c37_1000basex()
857 if (!xpcs->pcs.poll) { in xpcs_config_aneg_c37_1000basex()
862 ret = xpcs_modify(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_CTRL, mask, val); in xpcs_config_aneg_c37_1000basex()
872 ret = xpcs_modify_changed(xpcs, MDIO_MMD_VEND2, in xpcs_config_aneg_c37_1000basex()
881 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0); in xpcs_config_aneg_c37_1000basex()
886 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MII_BMCR, in xpcs_config_aneg_c37_1000basex()
895 static int xpcs_config_2500basex(struct dw_xpcs *xpcs) in xpcs_config_2500basex() argument
899 ret = xpcs_modify(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1, in xpcs_config_2500basex()
906 return xpcs_modify(xpcs, MDIO_MMD_VEND2, MII_BMCR, in xpcs_config_2500basex()
911 static int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, in xpcs_do_config() argument
918 compat = xpcs_find_compat(xpcs, interface); in xpcs_do_config()
922 if (xpcs->info.pma == WX_TXGBE_XPCS_PMA_10G_ID) { in xpcs_do_config()
928 xpcs_write_vpcs(xpcs, DW_VR_XS_PCS_DIG_CTRL1, in xpcs_do_config()
937 ret = xpcs_config_aneg_c73(xpcs, compat); in xpcs_do_config()
943 ret = xpcs_config_aneg_c37_sgmii(xpcs, neg_mode); in xpcs_do_config()
948 ret = xpcs_config_aneg_c37_1000basex(xpcs, neg_mode, in xpcs_do_config()
954 ret = xpcs_config_2500basex(xpcs); in xpcs_do_config()
963 ret = compat->pma_config(xpcs); in xpcs_do_config()
976 struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); in xpcs_config() local
978 return xpcs_do_config(xpcs, interface, advertising, neg_mode); in xpcs_config()
981 static int xpcs_get_state_c73(struct dw_xpcs *xpcs, in xpcs_get_state_c73() argument
994 pcs_stat1 = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_STAT1); in xpcs_get_state_c73()
1004 ret = xpcs_read_fault_c73(xpcs, state, pcs_stat1); in xpcs_get_state_c73()
1006 ret = xpcs_soft_reset(xpcs, compat); in xpcs_get_state_c73()
1012 return xpcs_do_config(xpcs, state->interface, NULL, in xpcs_get_state_c73()
1027 an_stat1 = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_STAT1); in xpcs_get_state_c73()
1033 state->an_complete = xpcs_aneg_done_c73(xpcs, state, compat, in xpcs_get_state_c73()
1040 ret = xpcs_read_lpa_c73(xpcs, state, an_stat1); in xpcs_get_state_c73()
1048 ret = xpcs_resolve_pma(xpcs, state); in xpcs_get_state_c73()
1054 static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs, in xpcs_get_state_c37_sgmii() argument
1068 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS); in xpcs_get_state_c37_sgmii()
1094 speed = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_BMCR); in xpcs_get_state_c37_sgmii()
1106 duplex = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_ADVERTISE); in xpcs_get_state_c37_sgmii()
1115 xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0); in xpcs_get_state_c37_sgmii()
1121 static int xpcs_get_state_c37_1000basex(struct dw_xpcs *xpcs, in xpcs_get_state_c37_1000basex() argument
1132 lpa = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_LPA); in xpcs_get_state_c37_1000basex()
1136 bmsr = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_BMSR); in xpcs_get_state_c37_1000basex()
1141 if (!xpcs->pcs.poll) { in xpcs_get_state_c37_1000basex()
1144 an_intr = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS); in xpcs_get_state_c37_1000basex()
1147 xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, an_intr); in xpcs_get_state_c37_1000basex()
1157 static int xpcs_get_state_2500basex(struct dw_xpcs *xpcs, in xpcs_get_state_2500basex() argument
1162 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_BMSR); in xpcs_get_state_2500basex()
1182 struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); in xpcs_get_state() local
1186 compat = xpcs_find_compat(xpcs, state->interface); in xpcs_get_state()
1192 phylink_mii_c45_pcs_get_state(xpcs->mdiodev, state); in xpcs_get_state()
1195 ret = xpcs_get_state_c73(xpcs, state, compat); in xpcs_get_state()
1197 dev_err(&xpcs->mdiodev->dev, "%s returned %pe\n", in xpcs_get_state()
1201 ret = xpcs_get_state_c37_sgmii(xpcs, state); in xpcs_get_state()
1203 dev_err(&xpcs->mdiodev->dev, "%s returned %pe\n", in xpcs_get_state()
1207 ret = xpcs_get_state_c37_1000basex(xpcs, neg_mode, state); in xpcs_get_state()
1209 dev_err(&xpcs->mdiodev->dev, "%s returned %pe\n", in xpcs_get_state()
1213 ret = xpcs_get_state_2500basex(xpcs, state); in xpcs_get_state()
1215 dev_err(&xpcs->mdiodev->dev, "%s returned %pe\n", in xpcs_get_state()
1223 static void xpcs_link_up_sgmii_1000basex(struct dw_xpcs *xpcs, in xpcs_link_up_sgmii_1000basex() argument
1235 dev_err(&xpcs->mdiodev->dev, in xpcs_link_up_sgmii_1000basex()
1242 dev_err(&xpcs->mdiodev->dev, in xpcs_link_up_sgmii_1000basex()
1247 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MII_BMCR, in xpcs_link_up_sgmii_1000basex()
1250 dev_err(&xpcs->mdiodev->dev, "%s: xpcs_write returned %pe\n", in xpcs_link_up_sgmii_1000basex()
1257 struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); in xpcs_link_up() local
1261 xpcs_link_up_usxgmii(xpcs, speed); in xpcs_link_up()
1266 xpcs_link_up_sgmii_1000basex(xpcs, neg_mode, interface, speed, in xpcs_link_up()
1277 struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); in xpcs_an_restart() local
1279 xpcs_modify(xpcs, MDIO_MMD_VEND2, MII_BMCR, BMCR_ANRESTART, in xpcs_an_restart()
1283 static int xpcs_config_eee(struct dw_xpcs *xpcs, bool enable) in xpcs_config_eee() argument
1298 xpcs->eee_mult_fact); in xpcs_config_eee()
1302 ret = xpcs_modify(xpcs, MDIO_MMD_VEND2, DW_VR_MII_EEE_MCTRL0, mask, in xpcs_config_eee()
1307 return xpcs_modify(xpcs, MDIO_MMD_VEND2, DW_VR_MII_EEE_MCTRL1, in xpcs_config_eee()
1314 struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); in xpcs_disable_eee() local
1316 xpcs_config_eee(xpcs, false); in xpcs_disable_eee()
1321 struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); in xpcs_enable_eee() local
1323 xpcs_config_eee(xpcs, true); in xpcs_enable_eee()
1328 * @xpcs: pointer to a &struct dw_xpcs instance
1334 void xpcs_config_eee_mult_fact(struct dw_xpcs *xpcs, u8 mult_fact) in xpcs_config_eee_mult_fact() argument
1336 xpcs->eee_mult_fact = mult_fact; in xpcs_config_eee_mult_fact()
1340 static int xpcs_read_ids(struct dw_xpcs *xpcs) in xpcs_read_ids() argument
1348 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MII_PHYSID1); in xpcs_read_ids()
1354 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MII_PHYSID2); in xpcs_read_ids()
1365 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_PHYSID1); in xpcs_read_ids()
1371 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_PHYSID2); in xpcs_read_ids()
1379 if (xpcs->info.pcs == DW_XPCS_ID_NATIVE) in xpcs_read_ids()
1380 xpcs->info.pcs = id; in xpcs_read_ids()
1383 ret = xpcs_read(xpcs, MDIO_MMD_PMAPMD, MDIO_DEVID1); in xpcs_read_ids()
1389 ret = xpcs_read(xpcs, MDIO_MMD_PMAPMD, MDIO_DEVID2); in xpcs_read_ids()
1399 if (xpcs->info.pma == DW_XPCS_PMA_ID_NATIVE) in xpcs_read_ids()
1400 xpcs->info.pma = id; in xpcs_read_ids()
1507 static int xpcs_identify(struct dw_xpcs *xpcs) in xpcs_identify() argument
1511 ret = xpcs_read_ids(xpcs); in xpcs_identify()
1518 if ((xpcs->info.pcs & entry->mask) == entry->id) { in xpcs_identify()
1519 xpcs->desc = entry; in xpcs_identify()
1529 struct dw_xpcs *xpcs; in xpcs_create_data() local
1531 xpcs = kzalloc_obj(*xpcs); in xpcs_create_data()
1532 if (!xpcs) in xpcs_create_data()
1536 xpcs->mdiodev = mdiodev; in xpcs_create_data()
1537 xpcs->pcs.ops = &xpcs_phylink_ops; in xpcs_create_data()
1538 xpcs->pcs.poll = true; in xpcs_create_data()
1540 return xpcs; in xpcs_create_data()
1543 static void xpcs_free_data(struct dw_xpcs *xpcs) in xpcs_free_data() argument
1545 mdio_device_put(xpcs->mdiodev); in xpcs_free_data()
1546 kfree(xpcs); in xpcs_free_data()
1549 static int xpcs_init_clks(struct dw_xpcs *xpcs) in xpcs_init_clks() argument
1555 struct device *dev = &xpcs->mdiodev->dev; in xpcs_init_clks()
1559 xpcs->clks[i].id = ids[i]; in xpcs_init_clks()
1561 ret = clk_bulk_get_optional(dev, DW_XPCS_NUM_CLKS, xpcs->clks); in xpcs_init_clks()
1565 ret = clk_bulk_prepare_enable(DW_XPCS_NUM_CLKS, xpcs->clks); in xpcs_init_clks()
1572 static void xpcs_clear_clks(struct dw_xpcs *xpcs) in xpcs_clear_clks() argument
1574 clk_bulk_disable_unprepare(DW_XPCS_NUM_CLKS, xpcs->clks); in xpcs_clear_clks()
1576 clk_bulk_put(DW_XPCS_NUM_CLKS, xpcs->clks); in xpcs_clear_clks()
1579 static int xpcs_init_id(struct dw_xpcs *xpcs) in xpcs_init_id() argument
1583 info = dev_get_platdata(&xpcs->mdiodev->dev); in xpcs_init_id()
1585 xpcs->info.pcs = DW_XPCS_ID_NATIVE; in xpcs_init_id()
1586 xpcs->info.pma = DW_XPCS_PMA_ID_NATIVE; in xpcs_init_id()
1588 xpcs->info = *info; in xpcs_init_id()
1591 return xpcs_identify(xpcs); in xpcs_init_id()
1596 struct dw_xpcs *xpcs; in xpcs_create() local
1599 xpcs = xpcs_create_data(mdiodev); in xpcs_create()
1600 if (IS_ERR(xpcs)) in xpcs_create()
1601 return xpcs; in xpcs_create()
1603 ret = xpcs_init_clks(xpcs); in xpcs_create()
1607 ret = xpcs_init_id(xpcs); in xpcs_create()
1611 xpcs_get_interfaces(xpcs, xpcs->pcs.supported_interfaces); in xpcs_create()
1613 if (xpcs->info.pma == WX_TXGBE_XPCS_PMA_10G_ID || in xpcs_create()
1614 xpcs->info.pma == MP_FBNIC_XPCS_PMA_100G_ID) in xpcs_create()
1615 xpcs->pcs.poll = false; in xpcs_create()
1617 xpcs->need_reset = true; in xpcs_create()
1619 return xpcs; in xpcs_create()
1622 xpcs_clear_clks(xpcs); in xpcs_create()
1625 xpcs_free_data(xpcs); in xpcs_create()
1631 * xpcs_create_mdiodev() - create a DW xPCS instance with the MDIO @addr
1635 * Return: a pointer to the DW XPCS handle if successful, otherwise -ENODEV if
1642 struct dw_xpcs *xpcs; in xpcs_create_mdiodev() local
1648 xpcs = xpcs_create(mdiodev); in xpcs_create_mdiodev()
1658 return xpcs; in xpcs_create_mdiodev()
1664 struct dw_xpcs *xpcs; in xpcs_create_pcs_mdiodev() local
1666 xpcs = xpcs_create_mdiodev(bus, addr); in xpcs_create_pcs_mdiodev()
1667 if (IS_ERR(xpcs)) in xpcs_create_pcs_mdiodev()
1668 return ERR_CAST(xpcs); in xpcs_create_pcs_mdiodev()
1670 return &xpcs->pcs; in xpcs_create_pcs_mdiodev()
1675 * xpcs_create_fwnode() - Create a DW xPCS instance from @fwnode
1676 * @fwnode: fwnode handle poining to the DW XPCS device
1678 * Return: a pointer to the DW XPCS handle if successful, otherwise -ENODEV if
1687 struct dw_xpcs *xpcs; in xpcs_create_fwnode() local
1696 xpcs = xpcs_create(mdiodev); in xpcs_create_fwnode()
1706 return xpcs; in xpcs_create_fwnode()
1710 void xpcs_destroy(struct dw_xpcs *xpcs) in xpcs_destroy() argument
1712 if (!xpcs) in xpcs_destroy()
1715 xpcs_clear_clks(xpcs); in xpcs_destroy()
1717 xpcs_free_data(xpcs); in xpcs_destroy()
1727 MODULE_DESCRIPTION("Synopsys DesignWare XPCS library");