xref: /openbmc/linux/include/linux/sungem_phy.h (revision 2bb698412d8aab0bfc3f269f5ebe8eb67d7cc8f4)
1*2bb69841SDavid S. Miller #ifndef __SUNGEM_PHY_H__
2*2bb69841SDavid S. Miller #define __SUNGEM_PHY_H__
3*2bb69841SDavid S. Miller 
4*2bb69841SDavid S. Miller struct mii_phy;
5*2bb69841SDavid S. Miller 
6*2bb69841SDavid S. Miller /* Operations supported by any kind of PHY */
7*2bb69841SDavid S. Miller struct mii_phy_ops
8*2bb69841SDavid S. Miller {
9*2bb69841SDavid S. Miller 	int		(*init)(struct mii_phy *phy);
10*2bb69841SDavid S. Miller 	int		(*suspend)(struct mii_phy *phy);
11*2bb69841SDavid S. Miller 	int		(*setup_aneg)(struct mii_phy *phy, u32 advertise);
12*2bb69841SDavid S. Miller 	int		(*setup_forced)(struct mii_phy *phy, int speed, int fd);
13*2bb69841SDavid S. Miller 	int		(*poll_link)(struct mii_phy *phy);
14*2bb69841SDavid S. Miller 	int		(*read_link)(struct mii_phy *phy);
15*2bb69841SDavid S. Miller 	int		(*enable_fiber)(struct mii_phy *phy, int autoneg);
16*2bb69841SDavid S. Miller };
17*2bb69841SDavid S. Miller 
18*2bb69841SDavid S. Miller /* Structure used to statically define an mii/gii based PHY */
19*2bb69841SDavid S. Miller struct mii_phy_def
20*2bb69841SDavid S. Miller {
21*2bb69841SDavid S. Miller 	u32				phy_id;		/* Concatenated ID1 << 16 | ID2 */
22*2bb69841SDavid S. Miller 	u32				phy_id_mask;	/* Significant bits */
23*2bb69841SDavid S. Miller 	u32				features;	/* Ethtool SUPPORTED_* defines */
24*2bb69841SDavid S. Miller 	int				magic_aneg;	/* Autoneg does all speed test for us */
25*2bb69841SDavid S. Miller 	const char*			name;
26*2bb69841SDavid S. Miller 	const struct mii_phy_ops*	ops;
27*2bb69841SDavid S. Miller };
28*2bb69841SDavid S. Miller 
29*2bb69841SDavid S. Miller enum {
30*2bb69841SDavid S. Miller 	BCM54XX_COPPER,
31*2bb69841SDavid S. Miller 	BCM54XX_FIBER,
32*2bb69841SDavid S. Miller 	BCM54XX_GBIC,
33*2bb69841SDavid S. Miller 	BCM54XX_SGMII,
34*2bb69841SDavid S. Miller 	BCM54XX_UNKNOWN,
35*2bb69841SDavid S. Miller };
36*2bb69841SDavid S. Miller 
37*2bb69841SDavid S. Miller /* An instance of a PHY, partially borrowed from mii_if_info */
38*2bb69841SDavid S. Miller struct mii_phy
39*2bb69841SDavid S. Miller {
40*2bb69841SDavid S. Miller 	struct mii_phy_def*	def;
41*2bb69841SDavid S. Miller 	u32			advertising;
42*2bb69841SDavid S. Miller 	int			mii_id;
43*2bb69841SDavid S. Miller 
44*2bb69841SDavid S. Miller 	/* 1: autoneg enabled, 0: disabled */
45*2bb69841SDavid S. Miller 	int			autoneg;
46*2bb69841SDavid S. Miller 
47*2bb69841SDavid S. Miller 	/* forced speed & duplex (no autoneg)
48*2bb69841SDavid S. Miller 	 * partner speed & duplex & pause (autoneg)
49*2bb69841SDavid S. Miller 	 */
50*2bb69841SDavid S. Miller 	int			speed;
51*2bb69841SDavid S. Miller 	int			duplex;
52*2bb69841SDavid S. Miller 	int			pause;
53*2bb69841SDavid S. Miller 
54*2bb69841SDavid S. Miller 	/* Provided by host chip */
55*2bb69841SDavid S. Miller 	struct net_device	*dev;
56*2bb69841SDavid S. Miller 	int (*mdio_read) (struct net_device *dev, int mii_id, int reg);
57*2bb69841SDavid S. Miller 	void (*mdio_write) (struct net_device *dev, int mii_id, int reg, int val);
58*2bb69841SDavid S. Miller 	void			*platform_data;
59*2bb69841SDavid S. Miller };
60*2bb69841SDavid S. Miller 
61*2bb69841SDavid S. Miller /* Pass in a struct mii_phy with dev, mdio_read and mdio_write
62*2bb69841SDavid S. Miller  * filled, the remaining fields will be filled on return
63*2bb69841SDavid S. Miller  */
64*2bb69841SDavid S. Miller extern int mii_phy_probe(struct mii_phy *phy, int mii_id);
65*2bb69841SDavid S. Miller 
66*2bb69841SDavid S. Miller 
67*2bb69841SDavid S. Miller /* MII definitions missing from mii.h */
68*2bb69841SDavid S. Miller 
69*2bb69841SDavid S. Miller #define BMCR_SPD2	0x0040		/* Gigabit enable (bcm54xx)	*/
70*2bb69841SDavid S. Miller #define LPA_PAUSE	0x0400
71*2bb69841SDavid S. Miller 
72*2bb69841SDavid S. Miller /* More PHY registers (model specific) */
73*2bb69841SDavid S. Miller 
74*2bb69841SDavid S. Miller /* MII BCM5201 MULTIPHY interrupt register */
75*2bb69841SDavid S. Miller #define MII_BCM5201_INTERRUPT			0x1A
76*2bb69841SDavid S. Miller #define MII_BCM5201_INTERRUPT_INTENABLE		0x4000
77*2bb69841SDavid S. Miller 
78*2bb69841SDavid S. Miller #define MII_BCM5201_AUXMODE2			0x1B
79*2bb69841SDavid S. Miller #define MII_BCM5201_AUXMODE2_LOWPOWER		0x0008
80*2bb69841SDavid S. Miller 
81*2bb69841SDavid S. Miller #define MII_BCM5201_MULTIPHY                    0x1E
82*2bb69841SDavid S. Miller 
83*2bb69841SDavid S. Miller /* MII BCM5201 MULTIPHY register bits */
84*2bb69841SDavid S. Miller #define MII_BCM5201_MULTIPHY_SERIALMODE         0x0002
85*2bb69841SDavid S. Miller #define MII_BCM5201_MULTIPHY_SUPERISOLATE       0x0008
86*2bb69841SDavid S. Miller 
87*2bb69841SDavid S. Miller /* MII BCM5221 Additional registers */
88*2bb69841SDavid S. Miller #define MII_BCM5221_TEST			0x1f
89*2bb69841SDavid S. Miller #define MII_BCM5221_TEST_ENABLE_SHADOWS		0x0080
90*2bb69841SDavid S. Miller #define MII_BCM5221_SHDOW_AUX_STAT2		0x1b
91*2bb69841SDavid S. Miller #define MII_BCM5221_SHDOW_AUX_STAT2_APD		0x0020
92*2bb69841SDavid S. Miller #define MII_BCM5221_SHDOW_AUX_MODE4		0x1a
93*2bb69841SDavid S. Miller #define MII_BCM5221_SHDOW_AUX_MODE4_IDDQMODE	0x0001
94*2bb69841SDavid S. Miller #define MII_BCM5221_SHDOW_AUX_MODE4_CLKLOPWR	0x0004
95*2bb69841SDavid S. Miller 
96*2bb69841SDavid S. Miller /* MII BCM5241 Additional registers */
97*2bb69841SDavid S. Miller #define MII_BCM5241_SHDOW_AUX_MODE4_STANDBYPWR	0x0008
98*2bb69841SDavid S. Miller 
99*2bb69841SDavid S. Miller /* MII BCM5400 1000-BASET Control register */
100*2bb69841SDavid S. Miller #define MII_BCM5400_GB_CONTROL			0x09
101*2bb69841SDavid S. Miller #define MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP	0x0200
102*2bb69841SDavid S. Miller 
103*2bb69841SDavid S. Miller /* MII BCM5400 AUXCONTROL register */
104*2bb69841SDavid S. Miller #define MII_BCM5400_AUXCONTROL                  0x18
105*2bb69841SDavid S. Miller #define MII_BCM5400_AUXCONTROL_PWR10BASET       0x0004
106*2bb69841SDavid S. Miller 
107*2bb69841SDavid S. Miller /* MII BCM5400 AUXSTATUS register */
108*2bb69841SDavid S. Miller #define MII_BCM5400_AUXSTATUS                   0x19
109*2bb69841SDavid S. Miller #define MII_BCM5400_AUXSTATUS_LINKMODE_MASK     0x0700
110*2bb69841SDavid S. Miller #define MII_BCM5400_AUXSTATUS_LINKMODE_SHIFT    8
111*2bb69841SDavid S. Miller 
112*2bb69841SDavid S. Miller /* 1000BT control (Marvell & BCM54xx at least) */
113*2bb69841SDavid S. Miller #define MII_1000BASETCONTROL			0x09
114*2bb69841SDavid S. Miller #define MII_1000BASETCONTROL_FULLDUPLEXCAP	0x0200
115*2bb69841SDavid S. Miller #define MII_1000BASETCONTROL_HALFDUPLEXCAP	0x0100
116*2bb69841SDavid S. Miller 
117*2bb69841SDavid S. Miller /* Marvell 88E1011 PHY control */
118*2bb69841SDavid S. Miller #define MII_M1011_PHY_SPEC_CONTROL		0x10
119*2bb69841SDavid S. Miller #define MII_M1011_PHY_SPEC_CONTROL_MANUAL_MDIX	0x20
120*2bb69841SDavid S. Miller #define MII_M1011_PHY_SPEC_CONTROL_AUTO_MDIX	0x40
121*2bb69841SDavid S. Miller 
122*2bb69841SDavid S. Miller /* Marvell 88E1011 PHY status */
123*2bb69841SDavid S. Miller #define MII_M1011_PHY_SPEC_STATUS		0x11
124*2bb69841SDavid S. Miller #define MII_M1011_PHY_SPEC_STATUS_1000		0x8000
125*2bb69841SDavid S. Miller #define MII_M1011_PHY_SPEC_STATUS_100		0x4000
126*2bb69841SDavid S. Miller #define MII_M1011_PHY_SPEC_STATUS_SPD_MASK	0xc000
127*2bb69841SDavid S. Miller #define MII_M1011_PHY_SPEC_STATUS_FULLDUPLEX	0x2000
128*2bb69841SDavid S. Miller #define MII_M1011_PHY_SPEC_STATUS_RESOLVED	0x0800
129*2bb69841SDavid S. Miller #define MII_M1011_PHY_SPEC_STATUS_TX_PAUSE	0x0008
130*2bb69841SDavid S. Miller #define MII_M1011_PHY_SPEC_STATUS_RX_PAUSE	0x0004
131*2bb69841SDavid S. Miller 
132*2bb69841SDavid S. Miller #endif /* __SUNGEM_PHY_H__ */
133