1 // SPDX-License-Identifier: GPL-2.0-only 2 #include "stmmac.h" 3 #include "stmmac_pcs.h" 4 5 static int dwmac_integrated_pcs_enable(struct phylink_pcs *pcs) 6 { 7 struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); 8 9 stmmac_mac_irq_modify(spcs->priv, 0, spcs->int_mask); 10 11 return 0; 12 } 13 14 static void dwmac_integrated_pcs_disable(struct phylink_pcs *pcs) 15 { 16 struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); 17 18 stmmac_mac_irq_modify(spcs->priv, spcs->int_mask, 0); 19 } 20 21 static void dwmac_integrated_pcs_get_state(struct phylink_pcs *pcs, 22 unsigned int neg_mode, 23 struct phylink_link_state *state) 24 { 25 state->link = false; 26 } 27 28 static int dwmac_integrated_pcs_config(struct phylink_pcs *pcs, 29 unsigned int neg_mode, 30 phy_interface_t interface, 31 const unsigned long *advertising, 32 bool permit_pause_to_mac) 33 { 34 struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); 35 36 dwmac_ctrl_ane(spcs->base, 0, 1, spcs->priv->hw->reverse_sgmii_enable); 37 38 return 0; 39 } 40 41 static const struct phylink_pcs_ops dwmac_integrated_pcs_ops = { 42 .pcs_enable = dwmac_integrated_pcs_enable, 43 .pcs_disable = dwmac_integrated_pcs_disable, 44 .pcs_get_state = dwmac_integrated_pcs_get_state, 45 .pcs_config = dwmac_integrated_pcs_config, 46 }; 47 48 int stmmac_integrated_pcs_init(struct stmmac_priv *priv, unsigned int offset, 49 u32 int_mask) 50 { 51 struct stmmac_pcs *spcs; 52 53 spcs = devm_kzalloc(priv->device, sizeof(*spcs), GFP_KERNEL); 54 if (!spcs) 55 return -ENOMEM; 56 57 spcs->priv = priv; 58 spcs->base = priv->ioaddr + offset; 59 spcs->int_mask = int_mask; 60 spcs->pcs.ops = &dwmac_integrated_pcs_ops; 61 62 __set_bit(PHY_INTERFACE_MODE_SGMII, spcs->pcs.supported_interfaces); 63 64 priv->integrated_pcs = spcs; 65 66 return 0; 67 } 68