phy.h 2.6 KB

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