Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * drivers/net/ethernet/ibm/emac/phy.h
0004  *
0005  * Driver for PowerPC 4xx on-chip ethernet controller, PHY support
0006  *
0007  * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
0008  *                <benh@kernel.crashing.org>
0009  *
0010  * Based on the arch/ppc version of the driver:
0011  *
0012  * Benjamin Herrenschmidt <benh@kernel.crashing.org>
0013  * February 2003
0014  *
0015  * Minor additions by Eugene Surovegin <ebs@ebshome.net>, 2004
0016  *
0017  * This file basically duplicates sungem_phy.{c,h} with different PHYs
0018  * supported. I'm looking into merging that in a single mii layer more
0019  * flexible than mii.c
0020  */
0021 
0022 #ifndef __IBM_NEWEMAC_PHY_H
0023 #define __IBM_NEWEMAC_PHY_H
0024 
0025 struct mii_phy;
0026 
0027 /* Operations supported by any kind of PHY */
0028 struct mii_phy_ops {
0029     int (*init) (struct mii_phy * phy);
0030     int (*suspend) (struct mii_phy * phy, int wol_options);
0031     int (*setup_aneg) (struct mii_phy * phy, u32 advertise);
0032     int (*setup_forced) (struct mii_phy * phy, int speed, int fd);
0033     int (*poll_link) (struct mii_phy * phy);
0034     int (*read_link) (struct mii_phy * phy);
0035 };
0036 
0037 /* Structure used to statically define an mii/gii based PHY */
0038 struct mii_phy_def {
0039     u32 phy_id;     /* Concatenated ID1 << 16 | ID2 */
0040     u32 phy_id_mask;    /* Significant bits */
0041     u32 features;       /* Ethtool SUPPORTED_* defines or
0042                    0 for autodetect */
0043     int magic_aneg;     /* Autoneg does all speed test for us */
0044     const char *name;
0045     const struct mii_phy_ops *ops;
0046 };
0047 
0048 /* An instance of a PHY, partially borrowed from mii_if_info */
0049 struct mii_phy {
0050     struct mii_phy_def *def;
0051     u32 advertising;    /* Ethtool ADVERTISED_* defines */
0052     u32 features;       /* Copied from mii_phy_def.features
0053                    or determined automaticaly */
0054     int address;        /* PHY address */
0055     int mode;       /* PHY mode */
0056     int gpcs_address;   /* GPCS PHY address */
0057 
0058     /* 1: autoneg enabled, 0: disabled */
0059     int autoneg;
0060 
0061     /* forced speed & duplex (no autoneg)
0062      * partner speed & duplex & pause (autoneg)
0063      */
0064     int speed;
0065     int duplex;
0066     int pause;
0067     int asym_pause;
0068 
0069     /* Provided by host chip */
0070     struct net_device *dev;
0071     int (*mdio_read) (struct net_device * dev, int addr, int reg);
0072     void (*mdio_write) (struct net_device * dev, int addr, int reg,
0073                 int val);
0074 };
0075 
0076 /* Pass in a struct mii_phy with dev, mdio_read and mdio_write
0077  * filled, the remaining fields will be filled on return
0078  */
0079 int emac_mii_phy_probe(struct mii_phy *phy, int address);
0080 int emac_mii_reset_phy(struct mii_phy *phy);
0081 int emac_mii_reset_gpcs(struct mii_phy *phy);
0082 
0083 #endif /* __IBM_NEWEMAC_PHY_H */