162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * drivers/net/ethernet/ibm/emac/phy.h 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Driver for PowerPC 4xx on-chip ethernet controller, PHY support 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. 862306a36Sopenharmony_ci * <benh@kernel.crashing.org> 962306a36Sopenharmony_ci * 1062306a36Sopenharmony_ci * Based on the arch/ppc version of the driver: 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * Benjamin Herrenschmidt <benh@kernel.crashing.org> 1362306a36Sopenharmony_ci * February 2003 1462306a36Sopenharmony_ci * 1562306a36Sopenharmony_ci * Minor additions by Eugene Surovegin <ebs@ebshome.net>, 2004 1662306a36Sopenharmony_ci * 1762306a36Sopenharmony_ci * This file basically duplicates sungem_phy.{c,h} with different PHYs 1862306a36Sopenharmony_ci * supported. I'm looking into merging that in a single mii layer more 1962306a36Sopenharmony_ci * flexible than mii.c 2062306a36Sopenharmony_ci */ 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#ifndef __IBM_NEWEMAC_PHY_H 2362306a36Sopenharmony_ci#define __IBM_NEWEMAC_PHY_H 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_cistruct mii_phy; 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci/* Operations supported by any kind of PHY */ 2862306a36Sopenharmony_cistruct mii_phy_ops { 2962306a36Sopenharmony_ci int (*init) (struct mii_phy * phy); 3062306a36Sopenharmony_ci int (*suspend) (struct mii_phy * phy, int wol_options); 3162306a36Sopenharmony_ci int (*setup_aneg) (struct mii_phy * phy, u32 advertise); 3262306a36Sopenharmony_ci int (*setup_forced) (struct mii_phy * phy, int speed, int fd); 3362306a36Sopenharmony_ci int (*poll_link) (struct mii_phy * phy); 3462306a36Sopenharmony_ci int (*read_link) (struct mii_phy * phy); 3562306a36Sopenharmony_ci}; 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci/* Structure used to statically define an mii/gii based PHY */ 3862306a36Sopenharmony_cistruct mii_phy_def { 3962306a36Sopenharmony_ci u32 phy_id; /* Concatenated ID1 << 16 | ID2 */ 4062306a36Sopenharmony_ci u32 phy_id_mask; /* Significant bits */ 4162306a36Sopenharmony_ci u32 features; /* Ethtool SUPPORTED_* defines or 4262306a36Sopenharmony_ci 0 for autodetect */ 4362306a36Sopenharmony_ci int magic_aneg; /* Autoneg does all speed test for us */ 4462306a36Sopenharmony_ci const char *name; 4562306a36Sopenharmony_ci const struct mii_phy_ops *ops; 4662306a36Sopenharmony_ci}; 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci/* An instance of a PHY, partially borrowed from mii_if_info */ 4962306a36Sopenharmony_cistruct mii_phy { 5062306a36Sopenharmony_ci struct mii_phy_def *def; 5162306a36Sopenharmony_ci u32 advertising; /* Ethtool ADVERTISED_* defines */ 5262306a36Sopenharmony_ci u32 features; /* Copied from mii_phy_def.features 5362306a36Sopenharmony_ci or determined automaticaly */ 5462306a36Sopenharmony_ci int address; /* PHY address */ 5562306a36Sopenharmony_ci int mode; /* PHY mode */ 5662306a36Sopenharmony_ci int gpcs_address; /* GPCS PHY address */ 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci /* 1: autoneg enabled, 0: disabled */ 5962306a36Sopenharmony_ci int autoneg; 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci /* forced speed & duplex (no autoneg) 6262306a36Sopenharmony_ci * partner speed & duplex & pause (autoneg) 6362306a36Sopenharmony_ci */ 6462306a36Sopenharmony_ci int speed; 6562306a36Sopenharmony_ci int duplex; 6662306a36Sopenharmony_ci int pause; 6762306a36Sopenharmony_ci int asym_pause; 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci /* Provided by host chip */ 7062306a36Sopenharmony_ci struct net_device *dev; 7162306a36Sopenharmony_ci int (*mdio_read) (struct net_device * dev, int addr, int reg); 7262306a36Sopenharmony_ci void (*mdio_write) (struct net_device * dev, int addr, int reg, 7362306a36Sopenharmony_ci int val); 7462306a36Sopenharmony_ci}; 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci/* Pass in a struct mii_phy with dev, mdio_read and mdio_write 7762306a36Sopenharmony_ci * filled, the remaining fields will be filled on return 7862306a36Sopenharmony_ci */ 7962306a36Sopenharmony_ciint emac_mii_phy_probe(struct mii_phy *phy, int address); 8062306a36Sopenharmony_ciint emac_mii_reset_phy(struct mii_phy *phy); 8162306a36Sopenharmony_ciint emac_mii_reset_gpcs(struct mii_phy *phy); 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci#endif /* __IBM_NEWEMAC_PHY_H */ 84