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