of_mdio.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * OF helpers for the MDIO (Ethernet PHY) API
  3. *
  4. * Copyright (c) 2009 Secret Lab Technologies, Ltd.
  5. *
  6. * This file is released under the GPLv2
  7. */
  8. #ifndef __LINUX_OF_MDIO_H
  9. #define __LINUX_OF_MDIO_H
  10. #include <linux/phy.h>
  11. #include <linux/of.h>
  12. #ifdef CONFIG_OF
  13. extern int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np);
  14. extern struct phy_device *of_phy_find_device(struct device_node *phy_np);
  15. extern struct phy_device *of_phy_connect(struct net_device *dev,
  16. struct device_node *phy_np,
  17. void (*hndlr)(struct net_device *),
  18. u32 flags, phy_interface_t iface);
  19. struct phy_device *of_phy_attach(struct net_device *dev,
  20. struct device_node *phy_np, u32 flags,
  21. phy_interface_t iface);
  22. extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
  23. extern int of_mdio_parse_addr(struct device *dev, const struct device_node *np);
  24. #else /* CONFIG_OF */
  25. static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
  26. {
  27. /*
  28. * Fall back to the non-DT function to register a bus.
  29. * This way, we don't have to keep compat bits around in drivers.
  30. */
  31. return mdiobus_register(mdio);
  32. }
  33. static inline struct phy_device *of_phy_find_device(struct device_node *phy_np)
  34. {
  35. return NULL;
  36. }
  37. static inline struct phy_device *of_phy_connect(struct net_device *dev,
  38. struct device_node *phy_np,
  39. void (*hndlr)(struct net_device *),
  40. u32 flags, phy_interface_t iface)
  41. {
  42. return NULL;
  43. }
  44. static inline struct phy_device *of_phy_attach(struct net_device *dev,
  45. struct device_node *phy_np,
  46. u32 flags, phy_interface_t iface)
  47. {
  48. return NULL;
  49. }
  50. static inline struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np)
  51. {
  52. return NULL;
  53. }
  54. static inline int of_mdio_parse_addr(struct device *dev,
  55. const struct device_node *np)
  56. {
  57. return -ENOSYS;
  58. }
  59. #endif /* CONFIG_OF */
  60. #if defined(CONFIG_OF) && defined(CONFIG_FIXED_PHY)
  61. extern int of_phy_register_fixed_link(struct device_node *np);
  62. extern bool of_phy_is_fixed_link(struct device_node *np);
  63. #else
  64. static inline int of_phy_register_fixed_link(struct device_node *np)
  65. {
  66. return -ENOSYS;
  67. }
  68. static inline bool of_phy_is_fixed_link(struct device_node *np)
  69. {
  70. return false;
  71. }
  72. #endif
  73. #endif /* __LINUX_OF_MDIO_H */