6 * Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
20 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
30 * This file basically duplicates sungem_phy.{c,h} with different PHYs
31 * supported. I'm looking into merging that in a single mii layer more
35 #ifndef _IBM_EMAC_PHY_H_
36 #define _IBM_EMAC_PHY_H_
40 * Used for multi-mode capable PHYs
43 #define PHY_MODE_MII 1
44 #define PHY_MODE_RMII 2
45 #define PHY_MODE_SMII 3
46 #define PHY_MODE_RGMII 4
47 #define PHY_MODE_TBI 5
48 #define PHY_MODE_GMII 6
49 #define PHY_MODE_RTBI 7
50 #define PHY_MODE_SGMII 8
53 * PHY specific registers/values
57 #define MII_CIS8201_EPCR 0x17
58 #define EPCR_MODE_MASK 0x3000
59 #define EPCR_GMII_MODE 0x0000
60 #define EPCR_RGMII_MODE 0x1000
61 #define EPCR_TBI_MODE 0x2000
62 #define EPCR_RTBI_MODE 0x3000
66 /* Operations supported by any kind of PHY */
68 int (*init
) (struct mii_phy
* phy
);
69 int (*suspend
) (struct mii_phy
* phy
, int wol_options
);
70 int (*setup_aneg
) (struct mii_phy
* phy
, u32 advertise
);
71 int (*setup_forced
) (struct mii_phy
* phy
, int speed
, int fd
);
72 int (*poll_link
) (struct mii_phy
* phy
);
73 int (*read_link
) (struct mii_phy
* phy
);
76 /* Structure used to statically define an mii/gii based PHY */
78 u32 phy_id
; /* Concatenated ID1 << 16 | ID2 */
79 u32 phy_id_mask
; /* Significant bits */
80 u32 features
; /* Ethtool SUPPORTED_* defines */
81 int magic_aneg
; /* Autoneg does all speed test for us */
83 const struct mii_phy_ops
*ops
;
86 /* An instance of a PHY, partially borrowed from mii_if_info */
88 struct mii_phy_def
*def
;
92 /* 1: autoneg enabled, 0: disabled */
95 /* forced speed & duplex (no autoneg)
96 * partner speed & duplex & pause (autoneg)
102 /* PHY mode - if needed */
105 /* Provided by host chip */
106 struct net_device
*dev
;
107 int (*mdio_read
) (struct net_device
* dev
, int mii_id
, int reg
);
108 void (*mdio_write
) (struct net_device
* dev
, int mii_id
, int reg
,
112 /* Pass in a struct mii_phy with dev, mdio_read and mdio_write
113 * filled, the remaining fields will be filled on return
115 extern int mii_phy_probe(struct mii_phy
*phy
, int mii_id
);
117 static inline int __phy_read(struct mii_phy
*phy
, int id
, int reg
)
119 return phy
->mdio_read(phy
->dev
, id
, reg
);
122 static inline void __phy_write(struct mii_phy
*phy
, int id
, int reg
, int val
)
124 phy
->mdio_write(phy
->dev
, id
, reg
, val
);
127 static inline int phy_read(struct mii_phy
*phy
, int reg
)
129 return phy
->mdio_read(phy
->dev
, phy
->mii_id
, reg
);
132 static inline void phy_write(struct mii_phy
*phy
, int reg
, int val
)
134 phy
->mdio_write(phy
->dev
, phy
->mii_id
, reg
, val
);
137 #endif /* _IBM_EMAC_PHY_H_ */