of_mdio.h 2.0 KB

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