of_mdio.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 void of_mdiobus_link_phydev(struct mii_bus *mdio,
  24. struct phy_device *phydev);
  25. #else /* CONFIG_OF */
  26. static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
  27. {
  28. /*
  29. * Fall back to the non-DT function to register a bus.
  30. * This way, we don't have to keep compat bits around in drivers.
  31. */
  32. return mdiobus_register(mdio);
  33. }
  34. static inline struct phy_device *of_phy_find_device(struct device_node *phy_np)
  35. {
  36. return NULL;
  37. }
  38. static inline struct phy_device *of_phy_connect(struct net_device *dev,
  39. struct device_node *phy_np,
  40. void (*hndlr)(struct net_device *),
  41. u32 flags, phy_interface_t iface)
  42. {
  43. return NULL;
  44. }
  45. static inline struct phy_device *of_phy_attach(struct net_device *dev,
  46. struct device_node *phy_np,
  47. u32 flags, phy_interface_t iface)
  48. {
  49. return NULL;
  50. }
  51. static inline struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np)
  52. {
  53. return NULL;
  54. }
  55. static inline void of_mdiobus_link_phydev(struct mii_bus *mdio,
  56. struct phy_device *phydev)
  57. {
  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 */