1*2874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 29aa32835SJeff Kirsher /* 33396c782SPaul Gortmaker * drivers/net/ethernet/ibm/emac/phy.h 49aa32835SJeff Kirsher * 59aa32835SJeff Kirsher * Driver for PowerPC 4xx on-chip ethernet controller, PHY support 69aa32835SJeff Kirsher * 79aa32835SJeff Kirsher * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. 89aa32835SJeff Kirsher * <benh@kernel.crashing.org> 99aa32835SJeff Kirsher * 109aa32835SJeff Kirsher * Based on the arch/ppc version of the driver: 119aa32835SJeff Kirsher * 129aa32835SJeff Kirsher * Benjamin Herrenschmidt <benh@kernel.crashing.org> 139aa32835SJeff Kirsher * February 2003 149aa32835SJeff Kirsher * 159aa32835SJeff Kirsher * Minor additions by Eugene Surovegin <ebs@ebshome.net>, 2004 169aa32835SJeff Kirsher * 179aa32835SJeff Kirsher * This file basically duplicates sungem_phy.{c,h} with different PHYs 189aa32835SJeff Kirsher * supported. I'm looking into merging that in a single mii layer more 199aa32835SJeff Kirsher * flexible than mii.c 209aa32835SJeff Kirsher */ 219aa32835SJeff Kirsher 229aa32835SJeff Kirsher #ifndef __IBM_NEWEMAC_PHY_H 239aa32835SJeff Kirsher #define __IBM_NEWEMAC_PHY_H 249aa32835SJeff Kirsher 259aa32835SJeff Kirsher struct mii_phy; 269aa32835SJeff Kirsher 279aa32835SJeff Kirsher /* Operations supported by any kind of PHY */ 289aa32835SJeff Kirsher struct mii_phy_ops { 299aa32835SJeff Kirsher int (*init) (struct mii_phy * phy); 309aa32835SJeff Kirsher int (*suspend) (struct mii_phy * phy, int wol_options); 319aa32835SJeff Kirsher int (*setup_aneg) (struct mii_phy * phy, u32 advertise); 329aa32835SJeff Kirsher int (*setup_forced) (struct mii_phy * phy, int speed, int fd); 339aa32835SJeff Kirsher int (*poll_link) (struct mii_phy * phy); 349aa32835SJeff Kirsher int (*read_link) (struct mii_phy * phy); 359aa32835SJeff Kirsher }; 369aa32835SJeff Kirsher 379aa32835SJeff Kirsher /* Structure used to statically define an mii/gii based PHY */ 389aa32835SJeff Kirsher struct mii_phy_def { 399aa32835SJeff Kirsher u32 phy_id; /* Concatenated ID1 << 16 | ID2 */ 409aa32835SJeff Kirsher u32 phy_id_mask; /* Significant bits */ 419aa32835SJeff Kirsher u32 features; /* Ethtool SUPPORTED_* defines or 429aa32835SJeff Kirsher 0 for autodetect */ 439aa32835SJeff Kirsher int magic_aneg; /* Autoneg does all speed test for us */ 449aa32835SJeff Kirsher const char *name; 459aa32835SJeff Kirsher const struct mii_phy_ops *ops; 469aa32835SJeff Kirsher }; 479aa32835SJeff Kirsher 489aa32835SJeff Kirsher /* An instance of a PHY, partially borrowed from mii_if_info */ 499aa32835SJeff Kirsher struct mii_phy { 509aa32835SJeff Kirsher struct mii_phy_def *def; 519aa32835SJeff Kirsher u32 advertising; /* Ethtool ADVERTISED_* defines */ 529aa32835SJeff Kirsher u32 features; /* Copied from mii_phy_def.features 539aa32835SJeff Kirsher or determined automaticaly */ 549aa32835SJeff Kirsher int address; /* PHY address */ 559aa32835SJeff Kirsher int mode; /* PHY mode */ 569aa32835SJeff Kirsher int gpcs_address; /* GPCS PHY address */ 579aa32835SJeff Kirsher 589aa32835SJeff Kirsher /* 1: autoneg enabled, 0: disabled */ 599aa32835SJeff Kirsher int autoneg; 609aa32835SJeff Kirsher 619aa32835SJeff Kirsher /* forced speed & duplex (no autoneg) 629aa32835SJeff Kirsher * partner speed & duplex & pause (autoneg) 639aa32835SJeff Kirsher */ 649aa32835SJeff Kirsher int speed; 659aa32835SJeff Kirsher int duplex; 669aa32835SJeff Kirsher int pause; 679aa32835SJeff Kirsher int asym_pause; 689aa32835SJeff Kirsher 699aa32835SJeff Kirsher /* Provided by host chip */ 709aa32835SJeff Kirsher struct net_device *dev; 719aa32835SJeff Kirsher int (*mdio_read) (struct net_device * dev, int addr, int reg); 729aa32835SJeff Kirsher void (*mdio_write) (struct net_device * dev, int addr, int reg, 739aa32835SJeff Kirsher int val); 749aa32835SJeff Kirsher }; 759aa32835SJeff Kirsher 769aa32835SJeff Kirsher /* Pass in a struct mii_phy with dev, mdio_read and mdio_write 779aa32835SJeff Kirsher * filled, the remaining fields will be filled on return 789aa32835SJeff Kirsher */ 799aa32835SJeff Kirsher int emac_mii_phy_probe(struct mii_phy *phy, int address); 809aa32835SJeff Kirsher int emac_mii_reset_phy(struct mii_phy *phy); 819aa32835SJeff Kirsher int emac_mii_reset_gpcs(struct mii_phy *phy); 829aa32835SJeff Kirsher 839aa32835SJeff Kirsher #endif /* __IBM_NEWEMAC_PHY_H */ 84