cvmx-helper-rgmii.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2020 Marvell International Ltd.
  4. *
  5. * Functions for RGMII/GMII/MII initialization, configuration,
  6. * and monitoring.
  7. */
  8. #ifndef __CVMX_HELPER_RGMII_H__
  9. #define __CVMX_HELPER_RGMII_H__
  10. /**
  11. * @INTERNAL
  12. * Probe RGMII ports and determine the number present
  13. *
  14. * @param xiface Interface to probe
  15. *
  16. * Return: Number of RGMII/GMII/MII ports (0-4).
  17. */
  18. int __cvmx_helper_rgmii_probe(int xiface);
  19. /**
  20. * Put an RGMII interface in loopback mode. Internal packets sent
  21. * out will be received back again on the same port. Externally
  22. * received packets will echo back out.
  23. *
  24. * @param port IPD port number to loop.
  25. */
  26. void cvmx_helper_rgmii_internal_loopback(int port);
  27. /**
  28. * @INTERNAL
  29. * Configure all of the ASX, GMX, and PKO regsiters required
  30. * to get RGMII to function on the supplied interface.
  31. *
  32. * @param xiface PKO Interface to configure (0 or 1)
  33. *
  34. * Return: Zero on success
  35. */
  36. int __cvmx_helper_rgmii_enable(int xiface);
  37. /**
  38. * @INTERNAL
  39. * Return the link state of an IPD/PKO port as returned by
  40. * auto negotiation. The result of this function may not match
  41. * Octeon's link config if auto negotiation has changed since
  42. * the last call to cvmx_helper_link_set().
  43. *
  44. * @param ipd_port IPD/PKO port to query
  45. *
  46. * Return: Link state
  47. */
  48. cvmx_helper_link_info_t __cvmx_helper_gmii_link_get(int ipd_port);
  49. /**
  50. * @INTERNAL
  51. * Return the link state of an IPD/PKO port as returned by
  52. * auto negotiation. The result of this function may not match
  53. * Octeon's link config if auto negotiation has changed since
  54. * the last call to cvmx_helper_link_set().
  55. *
  56. * @param ipd_port IPD/PKO port to query
  57. *
  58. * Return: Link state
  59. */
  60. cvmx_helper_link_info_t __cvmx_helper_rgmii_link_get(int ipd_port);
  61. /**
  62. * @INTERNAL
  63. * Configure an IPD/PKO port for the specified link state. This
  64. * function does not influence auto negotiation at the PHY level.
  65. * The passed link state must always match the link state returned
  66. * by cvmx_helper_link_get(). It is normally best to use
  67. * cvmx_helper_link_autoconf() instead.
  68. *
  69. * @param ipd_port IPD/PKO port to configure
  70. * @param link_info The new link state
  71. *
  72. * Return: Zero on success, negative on failure
  73. */
  74. int __cvmx_helper_rgmii_link_set(int ipd_port, cvmx_helper_link_info_t link_info);
  75. /**
  76. * @INTERNAL
  77. * Configure a port for internal and/or external loopback. Internal loopback
  78. * causes packets sent by the port to be received by Octeon. External loopback
  79. * causes packets received from the wire to sent out again.
  80. *
  81. * @param ipd_port IPD/PKO port to loopback.
  82. * @param enable_internal
  83. * Non zero if you want internal loopback
  84. * @param enable_external
  85. * Non zero if you want external loopback
  86. *
  87. * Return: Zero on success, negative on failure.
  88. */
  89. int __cvmx_helper_rgmii_configure_loopback(int ipd_port, int enable_internal, int enable_external);
  90. #endif