ibm_emac_phy.h 2.4 KB

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