1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2020 Synopsys, Inc. and/or its affiliates. 4 * Synopsys DesignWare XPCS helpers 5 */ 6 7 #ifndef __LINUX_PCS_XPCS_H 8 #define __LINUX_PCS_XPCS_H 9 10 #include <linux/phy.h> 11 #include <linux/phylink.h> 12 #include <linux/types.h> 13 14 /* AN mode */ 15 #define DW_AN_C73 1 16 #define DW_AN_C37_SGMII 2 17 #define DW_2500BASEX 3 18 #define DW_AN_C37_1000BASEX 4 19 #define DW_10GBASER 5 20 21 struct dw_xpcs_desc; 22 23 enum dw_xpcs_pcs_id { 24 NXP_SJA1105_XPCS_ID = 0x00000010, 25 NXP_SJA1110_XPCS_ID = 0x00000020, 26 DW_XPCS_ID = 0x7996ced0, 27 DW_XPCS_ID_MASK = 0xffffffff, 28 }; 29 30 enum dw_xpcs_pma_id { 31 WX_TXGBE_XPCS_PMA_10G_ID = 0x0018fc80, 32 }; 33 34 struct dw_xpcs_info { 35 u32 pcs; 36 u32 pma; 37 }; 38 39 struct dw_xpcs { 40 struct dw_xpcs_info info; 41 const struct dw_xpcs_desc *desc; 42 struct mdio_device *mdiodev; 43 struct phylink_pcs pcs; 44 phy_interface_t interface; 45 }; 46 47 int xpcs_get_an_mode(struct dw_xpcs *xpcs, phy_interface_t interface); 48 void xpcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode, 49 phy_interface_t interface, int speed, int duplex); 50 int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, 51 const unsigned long *advertising, unsigned int neg_mode); 52 void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces); 53 int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, 54 int enable); 55 struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, 56 phy_interface_t interface); 57 void xpcs_destroy(struct dw_xpcs *xpcs); 58 59 #endif /* __LINUX_PCS_XPCS_H */ 60