1 2 /* 3 * ibm_ocp_phy.h 4 * 5 * 6 * Benjamin Herrenschmidt <benh@kernel.crashing.org> 7 * February 2003 8 * 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. 13 * 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. 24 * 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. 28 * 29 * 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 32 * flexible than mii.c 33 */ 34 35 #ifndef _IBM_OCP_PHY_H_ 36 #define _IBM_OCP_PHY_H_ 37 38 struct mii_phy; 39 40 /* Operations supported by any kind of PHY */ 41 struct mii_phy_ops 42 { 43 int (*init)(struct mii_phy *phy); 44 int (*suspend)(struct mii_phy *phy, int wol_options); 45 int (*setup_aneg)(struct mii_phy *phy, u32 advertise); 46 int (*setup_forced)(struct mii_phy *phy, int speed, int fd); 47 int (*poll_link)(struct mii_phy *phy); 48 int (*read_link)(struct mii_phy *phy); 49 }; 50 51 /* Structure used to statically define an mii/gii based PHY */ 52 struct mii_phy_def 53 { 54 u32 phy_id; /* Concatenated ID1 << 16 | ID2 */ 55 u32 phy_id_mask; /* Significant bits */ 56 u32 features; /* Ethtool SUPPORTED_* defines */ 57 int magic_aneg; /* Autoneg does all speed test for us */ 58 const char* name; 59 const struct mii_phy_ops* ops; 60 }; 61 62 /* An instance of a PHY, partially borrowed from mii_if_info */ 63 struct mii_phy 64 { 65 struct mii_phy_def* def; 66 int advertising; 67 int mii_id; 68 69 /* 1: autoneg enabled, 0: disabled */ 70 int autoneg; 71 72 /* forced speed & duplex (no autoneg) 73 * partner speed & duplex & pause (autoneg) 74 */ 75 int speed; 76 int duplex; 77 int pause; 78 79 /* Provided by host chip */ 80 struct net_device* dev; 81 int (*mdio_read) (struct net_device *dev, int mii_id, int reg); 82 void (*mdio_write) (struct net_device *dev, int mii_id, int reg, int val); 83 }; 84 85 /* Pass in a struct mii_phy with dev, mdio_read and mdio_write 86 * filled, the remaining fields will be filled on return 87 */ 88 extern int mii_phy_probe(struct mii_phy *phy, int mii_id); 89 90 #endif /* _IBM_OCP_PHY_H_ */ 91