of_mdio.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. extern struct phy_device *
  20. of_phy_get_and_connect(struct net_device *dev, struct device_node *np,
  21. void (*hndlr)(struct net_device *));
  22. struct phy_device *of_phy_attach(struct net_device *dev,
  23. struct device_node *phy_np, u32 flags,
  24. phy_interface_t iface);
  25. extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
  26. extern int of_mdio_parse_addr(struct device *dev, const struct device_node *np);
  27. extern int of_phy_register_fixed_link(struct device_node *np);
  28. extern void of_phy_deregister_fixed_link(struct device_node *np);
  29. extern bool of_phy_is_fixed_link(struct device_node *np);
  30. #else /* CONFIG_OF */
  31. static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
  32. {
  33. /*
  34. * Fall back to the non-DT function to register a bus.
  35. * This way, we don't have to keep compat bits around in drivers.
  36. */
  37. return mdiobus_register(mdio);
  38. }
  39. static inline struct phy_device *of_phy_find_device(struct device_node *phy_np)
  40. {
  41. return NULL;
  42. }
  43. static inline struct phy_device *of_phy_connect(struct net_device *dev,
  44. struct device_node *phy_np,
  45. void (*hndlr)(struct net_device *),
  46. u32 flags, phy_interface_t iface)
  47. {
  48. return NULL;
  49. }
  50. static inline struct phy_device *
  51. of_phy_get_and_connect(struct net_device *dev, struct device_node *np,
  52. void (*hndlr)(struct net_device *))
  53. {
  54. return NULL;
  55. }
  56. static inline struct phy_device *of_phy_attach(struct net_device *dev,
  57. struct device_node *phy_np,
  58. u32 flags, phy_interface_t iface)
  59. {
  60. return NULL;
  61. }
  62. static inline struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np)
  63. {
  64. return NULL;
  65. }
  66. static inline int of_mdio_parse_addr(struct device *dev,
  67. const struct device_node *np)
  68. {
  69. return -ENOSYS;
  70. }
  71. static inline int of_phy_register_fixed_link(struct device_node *np)
  72. {
  73. return -ENOSYS;
  74. }
  75. static inline void of_phy_deregister_fixed_link(struct device_node *np)
  76. {
  77. }
  78. static inline bool of_phy_is_fixed_link(struct device_node *np)
  79. {
  80. return false;
  81. }
  82. #endif
  83. #endif /* __LINUX_OF_MDIO_H */