phy.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * drivers/net/ethernet/ibm/emac/phy.h
  4. *
  5. * Driver for PowerPC 4xx on-chip ethernet controller, PHY support
  6. *
  7. * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
  8. * <[email protected]>
  9. *
  10. * Based on the arch/ppc version of the driver:
  11. *
  12. * Benjamin Herrenschmidt <[email protected]>
  13. * February 2003
  14. *
  15. * Minor additions by Eugene Surovegin <[email protected]>, 2004
  16. *
  17. * This file basically duplicates sungem_phy.{c,h} with different PHYs
  18. * supported. I'm looking into merging that in a single mii layer more
  19. * flexible than mii.c
  20. */
  21. #ifndef __IBM_NEWEMAC_PHY_H
  22. #define __IBM_NEWEMAC_PHY_H
  23. struct mii_phy;
  24. /* Operations supported by any kind of PHY */
  25. struct mii_phy_ops {
  26. int (*init) (struct mii_phy * phy);
  27. int (*suspend) (struct mii_phy * phy, int wol_options);
  28. int (*setup_aneg) (struct mii_phy * phy, u32 advertise);
  29. int (*setup_forced) (struct mii_phy * phy, int speed, int fd);
  30. int (*poll_link) (struct mii_phy * phy);
  31. int (*read_link) (struct mii_phy * phy);
  32. };
  33. /* Structure used to statically define an mii/gii based PHY */
  34. struct mii_phy_def {
  35. u32 phy_id; /* Concatenated ID1 << 16 | ID2 */
  36. u32 phy_id_mask; /* Significant bits */
  37. u32 features; /* Ethtool SUPPORTED_* defines or
  38. 0 for autodetect */
  39. int magic_aneg; /* Autoneg does all speed test for us */
  40. const char *name;
  41. const struct mii_phy_ops *ops;
  42. };
  43. /* An instance of a PHY, partially borrowed from mii_if_info */
  44. struct mii_phy {
  45. struct mii_phy_def *def;
  46. u32 advertising; /* Ethtool ADVERTISED_* defines */
  47. u32 features; /* Copied from mii_phy_def.features
  48. or determined automaticaly */
  49. int address; /* PHY address */
  50. int mode; /* PHY mode */
  51. int gpcs_address; /* GPCS PHY address */
  52. /* 1: autoneg enabled, 0: disabled */
  53. int autoneg;
  54. /* forced speed & duplex (no autoneg)
  55. * partner speed & duplex & pause (autoneg)
  56. */
  57. int speed;
  58. int duplex;
  59. int pause;
  60. int asym_pause;
  61. /* Provided by host chip */
  62. struct net_device *dev;
  63. int (*mdio_read) (struct net_device * dev, int addr, int reg);
  64. void (*mdio_write) (struct net_device * dev, int addr, int reg,
  65. int val);
  66. };
  67. /* Pass in a struct mii_phy with dev, mdio_read and mdio_write
  68. * filled, the remaining fields will be filled on return
  69. */
  70. int emac_mii_phy_probe(struct mii_phy *phy, int address);
  71. int emac_mii_reset_phy(struct mii_phy *phy);
  72. int emac_mii_reset_gpcs(struct mii_phy *phy);
  73. #endif /* __IBM_NEWEMAC_PHY_H */