1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Copyright 2011 Freescale Semiconductor, Inc. 3*4882a593Smuzhiyun * Andy Fleming <afleming@gmail.com> 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * SPDX-License-Identifier: GPL-2.0+ 6*4882a593Smuzhiyun * 7*4882a593Smuzhiyun * This file pretty much stolen from Linux's mii.h/ethtool.h/phy.h 8*4882a593Smuzhiyun */ 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun #ifndef _PHY_H 11*4882a593Smuzhiyun #define _PHY_H 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun #include <dm.h> 14*4882a593Smuzhiyun #include <linux/list.h> 15*4882a593Smuzhiyun #include <linux/mii.h> 16*4882a593Smuzhiyun #include <linux/ethtool.h> 17*4882a593Smuzhiyun #include <linux/mdio.h> 18*4882a593Smuzhiyun #include <phy_interface.h> 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun #define PHY_FIXED_ID 0xa5a55a5a 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun #define PHY_MAX_ADDR 32 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun #define PHY_FLAG_BROKEN_RESET (1 << 0) /* soft reset not supported */ 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun #define PHY_DEFAULT_FEATURES (SUPPORTED_Autoneg | \ 27*4882a593Smuzhiyun SUPPORTED_TP | \ 28*4882a593Smuzhiyun SUPPORTED_MII) 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun #define PHY_10BT_FEATURES (SUPPORTED_10baseT_Half | \ 31*4882a593Smuzhiyun SUPPORTED_10baseT_Full) 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun #define PHY_100BT_FEATURES (SUPPORTED_100baseT_Half | \ 34*4882a593Smuzhiyun SUPPORTED_100baseT_Full) 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun #define PHY_1000BT_FEATURES (SUPPORTED_1000baseT_Half | \ 37*4882a593Smuzhiyun SUPPORTED_1000baseT_Full) 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun #define PHY_BASIC_FEATURES (PHY_10BT_FEATURES | \ 40*4882a593Smuzhiyun PHY_100BT_FEATURES | \ 41*4882a593Smuzhiyun PHY_DEFAULT_FEATURES) 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun #define PHY_GBIT_FEATURES (PHY_BASIC_FEATURES | \ 44*4882a593Smuzhiyun PHY_1000BT_FEATURES) 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun #define PHY_10G_FEATURES (PHY_GBIT_FEATURES | \ 47*4882a593Smuzhiyun SUPPORTED_10000baseT_Full) 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun #ifndef PHY_ANEG_TIMEOUT 50*4882a593Smuzhiyun #define PHY_ANEG_TIMEOUT 4000 51*4882a593Smuzhiyun #endif 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun struct phy_device; 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun #define MDIO_NAME_LEN 32 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun struct mii_dev { 59*4882a593Smuzhiyun struct list_head link; 60*4882a593Smuzhiyun char name[MDIO_NAME_LEN]; 61*4882a593Smuzhiyun void *priv; 62*4882a593Smuzhiyun int (*read)(struct mii_dev *bus, int addr, int devad, int reg); 63*4882a593Smuzhiyun int (*write)(struct mii_dev *bus, int addr, int devad, int reg, 64*4882a593Smuzhiyun u16 val); 65*4882a593Smuzhiyun int (*reset)(struct mii_dev *bus); 66*4882a593Smuzhiyun struct phy_device *phymap[PHY_MAX_ADDR]; 67*4882a593Smuzhiyun u32 phy_mask; 68*4882a593Smuzhiyun }; 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun /* struct phy_driver: a structure which defines PHY behavior 71*4882a593Smuzhiyun * 72*4882a593Smuzhiyun * uid will contain a number which represents the PHY. During 73*4882a593Smuzhiyun * startup, the driver will poll the PHY to find out what its 74*4882a593Smuzhiyun * UID--as defined by registers 2 and 3--is. The 32-bit result 75*4882a593Smuzhiyun * gotten from the PHY will be masked to 76*4882a593Smuzhiyun * discard any bits which may change based on revision numbers 77*4882a593Smuzhiyun * unimportant to functionality 78*4882a593Smuzhiyun * 79*4882a593Smuzhiyun */ 80*4882a593Smuzhiyun struct phy_driver { 81*4882a593Smuzhiyun char *name; 82*4882a593Smuzhiyun unsigned int uid; 83*4882a593Smuzhiyun unsigned int mask; 84*4882a593Smuzhiyun unsigned int mmds; 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun u32 features; 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun /* Called to do any driver startup necessities */ 89*4882a593Smuzhiyun /* Will be called during phy_connect */ 90*4882a593Smuzhiyun int (*probe)(struct phy_device *phydev); 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun /* Called to configure the PHY, and modify the controller 93*4882a593Smuzhiyun * based on the results. Should be called after phy_connect */ 94*4882a593Smuzhiyun int (*config)(struct phy_device *phydev); 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun /* Called when starting up the controller */ 97*4882a593Smuzhiyun int (*startup)(struct phy_device *phydev); 98*4882a593Smuzhiyun 99*4882a593Smuzhiyun /* Called when bringing down the controller */ 100*4882a593Smuzhiyun int (*shutdown)(struct phy_device *phydev); 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun int (*readext)(struct phy_device *phydev, int addr, int devad, int reg); 103*4882a593Smuzhiyun int (*writeext)(struct phy_device *phydev, int addr, int devad, int reg, 104*4882a593Smuzhiyun u16 val); 105*4882a593Smuzhiyun 106*4882a593Smuzhiyun /* Phy specific driver override for reading a MMD register */ 107*4882a593Smuzhiyun int (*read_mmd)(struct phy_device *phydev, int devad, int reg); 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun /* Phy specific driver override for writing a MMD register */ 110*4882a593Smuzhiyun int (*write_mmd)(struct phy_device *phydev, int devad, int reg, 111*4882a593Smuzhiyun u16 val); 112*4882a593Smuzhiyun 113*4882a593Smuzhiyun struct list_head list; 114*4882a593Smuzhiyun }; 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun struct phy_device { 117*4882a593Smuzhiyun /* Information about the PHY type */ 118*4882a593Smuzhiyun /* And management functions */ 119*4882a593Smuzhiyun struct mii_dev *bus; 120*4882a593Smuzhiyun struct phy_driver *drv; 121*4882a593Smuzhiyun void *priv; 122*4882a593Smuzhiyun 123*4882a593Smuzhiyun #ifdef CONFIG_DM_ETH 124*4882a593Smuzhiyun struct udevice *dev; 125*4882a593Smuzhiyun ofnode node; 126*4882a593Smuzhiyun #else 127*4882a593Smuzhiyun struct eth_device *dev; 128*4882a593Smuzhiyun #endif 129*4882a593Smuzhiyun 130*4882a593Smuzhiyun /* forced speed & duplex (no autoneg) 131*4882a593Smuzhiyun * partner speed & duplex & pause (autoneg) 132*4882a593Smuzhiyun */ 133*4882a593Smuzhiyun int speed; 134*4882a593Smuzhiyun int duplex; 135*4882a593Smuzhiyun 136*4882a593Smuzhiyun /* The most recently read link state */ 137*4882a593Smuzhiyun int link; 138*4882a593Smuzhiyun int port; 139*4882a593Smuzhiyun phy_interface_t interface; 140*4882a593Smuzhiyun 141*4882a593Smuzhiyun u32 advertising; 142*4882a593Smuzhiyun u32 supported; 143*4882a593Smuzhiyun u32 mmds; 144*4882a593Smuzhiyun 145*4882a593Smuzhiyun int autoneg; 146*4882a593Smuzhiyun int addr; 147*4882a593Smuzhiyun int pause; 148*4882a593Smuzhiyun int asym_pause; 149*4882a593Smuzhiyun u32 phy_id; 150*4882a593Smuzhiyun bool is_c45; 151*4882a593Smuzhiyun u32 flags; 152*4882a593Smuzhiyun }; 153*4882a593Smuzhiyun 154*4882a593Smuzhiyun struct fixed_link { 155*4882a593Smuzhiyun int phy_id; 156*4882a593Smuzhiyun int duplex; 157*4882a593Smuzhiyun int link_speed; 158*4882a593Smuzhiyun int pause; 159*4882a593Smuzhiyun int asym_pause; 160*4882a593Smuzhiyun }; 161*4882a593Smuzhiyun 162*4882a593Smuzhiyun static inline int phy_read(struct phy_device *phydev, int devad, int regnum) 163*4882a593Smuzhiyun { 164*4882a593Smuzhiyun struct mii_dev *bus = phydev->bus; 165*4882a593Smuzhiyun 166*4882a593Smuzhiyun return bus->read(bus, phydev->addr, devad, regnum); 167*4882a593Smuzhiyun } 168*4882a593Smuzhiyun 169*4882a593Smuzhiyun static inline int phy_write(struct phy_device *phydev, int devad, int regnum, 170*4882a593Smuzhiyun u16 val) 171*4882a593Smuzhiyun { 172*4882a593Smuzhiyun struct mii_dev *bus = phydev->bus; 173*4882a593Smuzhiyun 174*4882a593Smuzhiyun return bus->write(bus, phydev->addr, devad, regnum, val); 175*4882a593Smuzhiyun } 176*4882a593Smuzhiyun 177*4882a593Smuzhiyun static inline void phy_mmd_start_indirect(struct phy_device *phydev, int devad, 178*4882a593Smuzhiyun int regnum) 179*4882a593Smuzhiyun { 180*4882a593Smuzhiyun /* Write the desired MMD Devad */ 181*4882a593Smuzhiyun phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_CTRL, devad); 182*4882a593Smuzhiyun 183*4882a593Smuzhiyun /* Write the desired MMD register address */ 184*4882a593Smuzhiyun phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_DATA, regnum); 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun /* Select the Function : DATA with no post increment */ 187*4882a593Smuzhiyun phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_CTRL, 188*4882a593Smuzhiyun (devad | MII_MMD_CTRL_NOINCR)); 189*4882a593Smuzhiyun } 190*4882a593Smuzhiyun 191*4882a593Smuzhiyun static inline int phy_read_mmd(struct phy_device *phydev, int devad, 192*4882a593Smuzhiyun int regnum) 193*4882a593Smuzhiyun { 194*4882a593Smuzhiyun struct phy_driver *drv = phydev->drv; 195*4882a593Smuzhiyun 196*4882a593Smuzhiyun if (regnum > (u16)~0 || devad > 32) 197*4882a593Smuzhiyun return -EINVAL; 198*4882a593Smuzhiyun 199*4882a593Smuzhiyun /* driver-specific access */ 200*4882a593Smuzhiyun if (drv->read_mmd) 201*4882a593Smuzhiyun return drv->read_mmd(phydev, devad, regnum); 202*4882a593Smuzhiyun 203*4882a593Smuzhiyun /* direct C45 / C22 access */ 204*4882a593Smuzhiyun if ((drv->features & PHY_10G_FEATURES) == PHY_10G_FEATURES || 205*4882a593Smuzhiyun devad == MDIO_DEVAD_NONE || !devad) 206*4882a593Smuzhiyun return phy_read(phydev, devad, regnum); 207*4882a593Smuzhiyun 208*4882a593Smuzhiyun /* indirect C22 access */ 209*4882a593Smuzhiyun phy_mmd_start_indirect(phydev, devad, regnum); 210*4882a593Smuzhiyun 211*4882a593Smuzhiyun /* Read the content of the MMD's selected register */ 212*4882a593Smuzhiyun return phy_read(phydev, MDIO_DEVAD_NONE, MII_MMD_DATA); 213*4882a593Smuzhiyun } 214*4882a593Smuzhiyun 215*4882a593Smuzhiyun static inline int phy_write_mmd(struct phy_device *phydev, int devad, 216*4882a593Smuzhiyun int regnum, u16 val) 217*4882a593Smuzhiyun { 218*4882a593Smuzhiyun struct phy_driver *drv = phydev->drv; 219*4882a593Smuzhiyun 220*4882a593Smuzhiyun if (regnum > (u16)~0 || devad > 32) 221*4882a593Smuzhiyun return -EINVAL; 222*4882a593Smuzhiyun 223*4882a593Smuzhiyun /* driver-specific access */ 224*4882a593Smuzhiyun if (drv->write_mmd) 225*4882a593Smuzhiyun return drv->write_mmd(phydev, devad, regnum, val); 226*4882a593Smuzhiyun 227*4882a593Smuzhiyun /* direct C45 / C22 access */ 228*4882a593Smuzhiyun if ((drv->features & PHY_10G_FEATURES) == PHY_10G_FEATURES || 229*4882a593Smuzhiyun devad == MDIO_DEVAD_NONE || !devad) 230*4882a593Smuzhiyun return phy_write(phydev, devad, regnum, val); 231*4882a593Smuzhiyun 232*4882a593Smuzhiyun /* indirect C22 access */ 233*4882a593Smuzhiyun phy_mmd_start_indirect(phydev, devad, regnum); 234*4882a593Smuzhiyun 235*4882a593Smuzhiyun /* Write the data into MMD's selected register */ 236*4882a593Smuzhiyun return phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_DATA, val); 237*4882a593Smuzhiyun } 238*4882a593Smuzhiyun 239*4882a593Smuzhiyun #ifdef CONFIG_PHYLIB_10G 240*4882a593Smuzhiyun extern struct phy_driver gen10g_driver; 241*4882a593Smuzhiyun 242*4882a593Smuzhiyun /* For now, XGMII is the only 10G interface */ 243*4882a593Smuzhiyun static inline int is_10g_interface(phy_interface_t interface) 244*4882a593Smuzhiyun { 245*4882a593Smuzhiyun return interface == PHY_INTERFACE_MODE_XGMII; 246*4882a593Smuzhiyun } 247*4882a593Smuzhiyun 248*4882a593Smuzhiyun #endif 249*4882a593Smuzhiyun 250*4882a593Smuzhiyun /** 251*4882a593Smuzhiyun * phy_init() - Initializes the PHY drivers 252*4882a593Smuzhiyun * 253*4882a593Smuzhiyun * This function registers all available PHY drivers 254*4882a593Smuzhiyun * 255*4882a593Smuzhiyun * @return 0 if OK, -ve on error 256*4882a593Smuzhiyun */ 257*4882a593Smuzhiyun int phy_init(void); 258*4882a593Smuzhiyun 259*4882a593Smuzhiyun /** 260*4882a593Smuzhiyun * phy_reset() - Resets the specified PHY 261*4882a593Smuzhiyun * 262*4882a593Smuzhiyun * Issues a reset of the PHY and waits for it to complete 263*4882a593Smuzhiyun * 264*4882a593Smuzhiyun * @phydev: PHY to reset 265*4882a593Smuzhiyun * @return 0 if OK, -ve on error 266*4882a593Smuzhiyun */ 267*4882a593Smuzhiyun int phy_reset(struct phy_device *phydev); 268*4882a593Smuzhiyun 269*4882a593Smuzhiyun /** 270*4882a593Smuzhiyun * phy_find_by_mask() - Searches for a PHY on the specified MDIO bus 271*4882a593Smuzhiyun * 272*4882a593Smuzhiyun * The function checks the PHY addresses flagged in phy_mask and returns a 273*4882a593Smuzhiyun * phy_device pointer if it detects a PHY. 274*4882a593Smuzhiyun * This function should only be called if just one PHY is expected to be present 275*4882a593Smuzhiyun * in the set of addresses flagged in phy_mask. If multiple PHYs are present, 276*4882a593Smuzhiyun * it is undefined which of these PHYs is returned. 277*4882a593Smuzhiyun * 278*4882a593Smuzhiyun * @bus: MII/MDIO bus to scan 279*4882a593Smuzhiyun * @phy_mask: bitmap of PYH addresses to scan 280*4882a593Smuzhiyun * @interface: type of MAC-PHY interface 281*4882a593Smuzhiyun * @return pointer to phy_device if a PHY is found, or NULL otherwise 282*4882a593Smuzhiyun */ 283*4882a593Smuzhiyun struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask, 284*4882a593Smuzhiyun phy_interface_t interface); 285*4882a593Smuzhiyun 286*4882a593Smuzhiyun #ifdef CONFIG_DM_ETH 287*4882a593Smuzhiyun 288*4882a593Smuzhiyun /** 289*4882a593Smuzhiyun * phy_connect_dev() - Associates the given pair of PHY and Ethernet devices 290*4882a593Smuzhiyun * @phydev: PHY device 291*4882a593Smuzhiyun * @dev: Ethernet device 292*4882a593Smuzhiyun */ 293*4882a593Smuzhiyun void phy_connect_dev(struct phy_device *phydev, struct udevice *dev); 294*4882a593Smuzhiyun 295*4882a593Smuzhiyun /** 296*4882a593Smuzhiyun * phy_connect() - Creates a PHY device for the Ethernet interface 297*4882a593Smuzhiyun * 298*4882a593Smuzhiyun * Creates a PHY device for the PHY at the given address, if one doesn't exist 299*4882a593Smuzhiyun * already, and associates it with the Ethernet device. 300*4882a593Smuzhiyun * The function may be called with addr <= 0, in this case addr value is ignored 301*4882a593Smuzhiyun * and the bus is scanned to detect a PHY. Scanning should only be used if only 302*4882a593Smuzhiyun * one PHY is expected to be present on the MDIO bus, otherwise it is undefined 303*4882a593Smuzhiyun * which PHY is returned. 304*4882a593Smuzhiyun * 305*4882a593Smuzhiyun * @bus: MII/MDIO bus that hosts the PHY 306*4882a593Smuzhiyun * @addr: PHY address on MDIO bus 307*4882a593Smuzhiyun * @dev: Ethernet device to associate to the PHY 308*4882a593Smuzhiyun * @interface: type of MAC-PHY interface 309*4882a593Smuzhiyun * @return pointer to phy_device if a PHY is found, or NULL otherwise 310*4882a593Smuzhiyun */ 311*4882a593Smuzhiyun struct phy_device *phy_connect(struct mii_dev *bus, int addr, 312*4882a593Smuzhiyun struct udevice *dev, 313*4882a593Smuzhiyun phy_interface_t interface); 314*4882a593Smuzhiyun 315*4882a593Smuzhiyun static inline ofnode phy_get_ofnode(struct phy_device *phydev) 316*4882a593Smuzhiyun { 317*4882a593Smuzhiyun if (ofnode_valid(phydev->node)) 318*4882a593Smuzhiyun return phydev->node; 319*4882a593Smuzhiyun else 320*4882a593Smuzhiyun return dev_ofnode(phydev->dev); 321*4882a593Smuzhiyun } 322*4882a593Smuzhiyun #else 323*4882a593Smuzhiyun 324*4882a593Smuzhiyun /** 325*4882a593Smuzhiyun * phy_connect_dev() - Associates the given pair of PHY and Ethernet devices 326*4882a593Smuzhiyun * @phydev: PHY device 327*4882a593Smuzhiyun * @dev: Ethernet device 328*4882a593Smuzhiyun */ 329*4882a593Smuzhiyun void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev); 330*4882a593Smuzhiyun 331*4882a593Smuzhiyun /** 332*4882a593Smuzhiyun * phy_connect() - Creates a PHY device for the Ethernet interface 333*4882a593Smuzhiyun * 334*4882a593Smuzhiyun * Creates a PHY device for the PHY at the given address, if one doesn't exist 335*4882a593Smuzhiyun * already, and associates it with the Ethernet device. 336*4882a593Smuzhiyun * The function may be called with addr <= 0, in this case addr value is ignored 337*4882a593Smuzhiyun * and the bus is scanned to detect a PHY. Scanning should only be used if only 338*4882a593Smuzhiyun * one PHY is expected to be present on the MDIO bus, otherwise it is undefined 339*4882a593Smuzhiyun * which PHY is returned. 340*4882a593Smuzhiyun * 341*4882a593Smuzhiyun * @bus: MII/MDIO bus that hosts the PHY 342*4882a593Smuzhiyun * @addr: PHY address on MDIO bus 343*4882a593Smuzhiyun * @dev: Ethernet device to associate to the PHY 344*4882a593Smuzhiyun * @interface: type of MAC-PHY interface 345*4882a593Smuzhiyun * @return pointer to phy_device if a PHY is found, or NULL otherwise 346*4882a593Smuzhiyun */ 347*4882a593Smuzhiyun struct phy_device *phy_connect(struct mii_dev *bus, int addr, 348*4882a593Smuzhiyun struct eth_device *dev, 349*4882a593Smuzhiyun phy_interface_t interface); 350*4882a593Smuzhiyun 351*4882a593Smuzhiyun static inline ofnode phy_get_ofnode(struct phy_device *phydev) 352*4882a593Smuzhiyun { 353*4882a593Smuzhiyun return ofnode_null(); 354*4882a593Smuzhiyun } 355*4882a593Smuzhiyun #endif 356*4882a593Smuzhiyun int phy_startup(struct phy_device *phydev); 357*4882a593Smuzhiyun int phy_config(struct phy_device *phydev); 358*4882a593Smuzhiyun int phy_shutdown(struct phy_device *phydev); 359*4882a593Smuzhiyun int phy_register(struct phy_driver *drv); 360*4882a593Smuzhiyun int phy_set_supported(struct phy_device *phydev, u32 max_speed); 361*4882a593Smuzhiyun int genphy_config_aneg(struct phy_device *phydev); 362*4882a593Smuzhiyun int genphy_restart_aneg(struct phy_device *phydev); 363*4882a593Smuzhiyun int genphy_update_link(struct phy_device *phydev); 364*4882a593Smuzhiyun int genphy_parse_link(struct phy_device *phydev); 365*4882a593Smuzhiyun int genphy_config(struct phy_device *phydev); 366*4882a593Smuzhiyun int genphy_startup(struct phy_device *phydev); 367*4882a593Smuzhiyun int genphy_shutdown(struct phy_device *phydev); 368*4882a593Smuzhiyun int gen10g_config(struct phy_device *phydev); 369*4882a593Smuzhiyun int gen10g_startup(struct phy_device *phydev); 370*4882a593Smuzhiyun int gen10g_shutdown(struct phy_device *phydev); 371*4882a593Smuzhiyun int gen10g_discover_mmds(struct phy_device *phydev); 372*4882a593Smuzhiyun 373*4882a593Smuzhiyun int phy_mv88e61xx_init(void); 374*4882a593Smuzhiyun int phy_aquantia_init(void); 375*4882a593Smuzhiyun int phy_atheros_init(void); 376*4882a593Smuzhiyun int phy_broadcom_init(void); 377*4882a593Smuzhiyun int phy_cortina_init(void); 378*4882a593Smuzhiyun int phy_davicom_init(void); 379*4882a593Smuzhiyun int phy_et1011c_init(void); 380*4882a593Smuzhiyun int phy_lxt_init(void); 381*4882a593Smuzhiyun int phy_marvell_init(void); 382*4882a593Smuzhiyun int phy_micrel_ksz8xxx_init(void); 383*4882a593Smuzhiyun int phy_micrel_ksz90x1_init(void); 384*4882a593Smuzhiyun int phy_natsemi_init(void); 385*4882a593Smuzhiyun int phy_realtek_init(void); 386*4882a593Smuzhiyun int phy_rk630_init(void); 387*4882a593Smuzhiyun int phy_smsc_init(void); 388*4882a593Smuzhiyun int phy_teranetics_init(void); 389*4882a593Smuzhiyun int phy_ti_init(void); 390*4882a593Smuzhiyun int phy_vitesse_init(void); 391*4882a593Smuzhiyun int phy_xilinx_init(void); 392*4882a593Smuzhiyun int phy_mscc_init(void); 393*4882a593Smuzhiyun int phy_fixed_init(void); 394*4882a593Smuzhiyun 395*4882a593Smuzhiyun int board_phy_config(struct phy_device *phydev); 396*4882a593Smuzhiyun int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id); 397*4882a593Smuzhiyun 398*4882a593Smuzhiyun /** 399*4882a593Smuzhiyun * phy_get_interface_by_name() - Look up a PHY interface name 400*4882a593Smuzhiyun * 401*4882a593Smuzhiyun * @str: PHY interface name, e.g. "mii" 402*4882a593Smuzhiyun * @return PHY_INTERFACE_MODE_... value, or -1 if not found 403*4882a593Smuzhiyun */ 404*4882a593Smuzhiyun int phy_get_interface_by_name(const char *str); 405*4882a593Smuzhiyun 406*4882a593Smuzhiyun /** 407*4882a593Smuzhiyun * phy_interface_is_rgmii - Convenience function for testing if a PHY interface 408*4882a593Smuzhiyun * is RGMII (all variants) 409*4882a593Smuzhiyun * @phydev: the phy_device struct 410*4882a593Smuzhiyun */ 411*4882a593Smuzhiyun static inline bool phy_interface_is_rgmii(struct phy_device *phydev) 412*4882a593Smuzhiyun { 413*4882a593Smuzhiyun return phydev->interface >= PHY_INTERFACE_MODE_RGMII && 414*4882a593Smuzhiyun phydev->interface <= PHY_INTERFACE_MODE_RGMII_TXID; 415*4882a593Smuzhiyun } 416*4882a593Smuzhiyun 417*4882a593Smuzhiyun /** 418*4882a593Smuzhiyun * phy_interface_is_sgmii - Convenience function for testing if a PHY interface 419*4882a593Smuzhiyun * is SGMII (all variants) 420*4882a593Smuzhiyun * @phydev: the phy_device struct 421*4882a593Smuzhiyun */ 422*4882a593Smuzhiyun static inline bool phy_interface_is_sgmii(struct phy_device *phydev) 423*4882a593Smuzhiyun { 424*4882a593Smuzhiyun return phydev->interface >= PHY_INTERFACE_MODE_SGMII && 425*4882a593Smuzhiyun phydev->interface <= PHY_INTERFACE_MODE_QSGMII; 426*4882a593Smuzhiyun } 427*4882a593Smuzhiyun 428*4882a593Smuzhiyun /* PHY UIDs for various PHYs that are referenced in external code */ 429*4882a593Smuzhiyun #define PHY_UID_CS4340 0x13e51002 430*4882a593Smuzhiyun #define PHY_UID_CS4223 0x03e57003 431*4882a593Smuzhiyun #define PHY_UID_TN2020 0x00a19410 432*4882a593Smuzhiyun #define PHY_UID_IN112525_S03 0x02107440 433*4882a593Smuzhiyun 434*4882a593Smuzhiyun #endif 435