xref: /openbmc/linux/include/linux/pcs/pcs-xpcs.h (revision cd99b9eb)
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 
13 #define NXP_SJA1105_XPCS_ID		0x00000010
14 #define NXP_SJA1110_XPCS_ID		0x00000020
15 
16 /* AN mode */
17 #define DW_AN_C73			1
18 #define DW_AN_C37_SGMII			2
19 #define DW_2500BASEX			3
20 #define DW_AN_C37_1000BASEX		4
21 #define DW_10GBASER			5
22 
23 /* device vendor OUI */
24 #define DW_OUI_WX			0x0018fc80
25 
26 /* dev_flag */
27 #define DW_DEV_TXGBE			BIT(0)
28 
29 struct xpcs_id;
30 
31 struct dw_xpcs {
32 	struct mdio_device *mdiodev;
33 	const struct xpcs_id *id;
34 	struct phylink_pcs pcs;
35 	phy_interface_t interface;
36 	int dev_flag;
37 };
38 
39 int xpcs_get_an_mode(struct dw_xpcs *xpcs, phy_interface_t interface);
40 void xpcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode,
41 		  phy_interface_t interface, int speed, int duplex);
42 int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface,
43 		   const unsigned long *advertising, unsigned int neg_mode);
44 void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces);
45 int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns,
46 		    int enable);
47 struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr,
48 				    phy_interface_t interface);
49 void xpcs_destroy(struct dw_xpcs *xpcs);
50 
51 #endif /* __LINUX_PCS_XPCS_H */
52