cvmx-helper.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /***********************license start***************
  2. * Author: Cavium Networks
  3. *
  4. * Contact: [email protected]
  5. * This file is part of the OCTEON SDK
  6. *
  7. * Copyright (c) 2003-2008 Cavium Networks
  8. *
  9. * This file is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License, Version 2, as
  11. * published by the Free Software Foundation.
  12. *
  13. * This file is distributed in the hope that it will be useful, but
  14. * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
  16. * NONINFRINGEMENT. See the GNU General Public License for more
  17. * details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this file; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  22. * or visit http://www.gnu.org/licenses/.
  23. *
  24. * This file may also be available under a different license from Cavium.
  25. * Contact Cavium Networks for more information
  26. ***********************license end**************************************/
  27. /*
  28. *
  29. * Helper functions for common, but complicated tasks.
  30. *
  31. */
  32. #ifndef __CVMX_HELPER_H__
  33. #define __CVMX_HELPER_H__
  34. #include <asm/octeon/cvmx-config.h>
  35. #include <asm/octeon/cvmx-fpa.h>
  36. #include <asm/octeon/cvmx-wqe.h>
  37. typedef enum {
  38. CVMX_HELPER_INTERFACE_MODE_DISABLED,
  39. CVMX_HELPER_INTERFACE_MODE_RGMII,
  40. CVMX_HELPER_INTERFACE_MODE_GMII,
  41. CVMX_HELPER_INTERFACE_MODE_SPI,
  42. CVMX_HELPER_INTERFACE_MODE_PCIE,
  43. CVMX_HELPER_INTERFACE_MODE_XAUI,
  44. CVMX_HELPER_INTERFACE_MODE_SGMII,
  45. CVMX_HELPER_INTERFACE_MODE_PICMG,
  46. CVMX_HELPER_INTERFACE_MODE_NPI,
  47. CVMX_HELPER_INTERFACE_MODE_LOOP,
  48. } cvmx_helper_interface_mode_t;
  49. union cvmx_helper_link_info {
  50. uint64_t u64;
  51. struct {
  52. uint64_t reserved_20_63:44;
  53. uint64_t link_up:1; /**< Is the physical link up? */
  54. uint64_t full_duplex:1; /**< 1 if the link is full duplex */
  55. uint64_t speed:18; /**< Speed of the link in Mbps */
  56. } s;
  57. };
  58. #include <asm/octeon/cvmx-helper-errata.h>
  59. #include <asm/octeon/cvmx-helper-loop.h>
  60. #include <asm/octeon/cvmx-helper-npi.h>
  61. #include <asm/octeon/cvmx-helper-rgmii.h>
  62. #include <asm/octeon/cvmx-helper-sgmii.h>
  63. #include <asm/octeon/cvmx-helper-spi.h>
  64. #include <asm/octeon/cvmx-helper-util.h>
  65. #include <asm/octeon/cvmx-helper-xaui.h>
  66. /**
  67. * This function enables the IPD and also enables the packet interfaces.
  68. * The packet interfaces (RGMII and SPI) must be enabled after the
  69. * IPD. This should be called by the user program after any additional
  70. * IPD configuration changes are made if CVMX_HELPER_ENABLE_IPD
  71. * is not set in the executive-config.h file.
  72. *
  73. * Returns 0 on success
  74. * -1 on failure
  75. */
  76. extern int cvmx_helper_ipd_and_packet_input_enable(void);
  77. /**
  78. * Initialize the PIP, IPD, and PKO hardware to support
  79. * simple priority based queues for the ethernet ports. Each
  80. * port is configured with a number of priority queues based
  81. * on CVMX_PKO_QUEUES_PER_PORT_* where each queue is lower
  82. * priority than the previous.
  83. *
  84. * Returns Zero on success, non-zero on failure
  85. */
  86. extern int cvmx_helper_initialize_packet_io_global(void);
  87. /**
  88. * Returns the number of ports on the given interface.
  89. * The interface must be initialized before the port count
  90. * can be returned.
  91. *
  92. * @interface: Which interface to return port count for.
  93. *
  94. * Returns Port count for interface
  95. * -1 for uninitialized interface
  96. */
  97. extern int cvmx_helper_ports_on_interface(int interface);
  98. /**
  99. * Return the number of interfaces the chip has. Each interface
  100. * may have multiple ports. Most chips support two interfaces,
  101. * but the CNX0XX and CNX1XX are exceptions. These only support
  102. * one interface.
  103. *
  104. * Returns Number of interfaces on chip
  105. */
  106. extern int cvmx_helper_get_number_of_interfaces(void);
  107. /**
  108. * Get the operating mode of an interface. Depending on the Octeon
  109. * chip and configuration, this function returns an enumeration
  110. * of the type of packet I/O supported by an interface.
  111. *
  112. * @interface: Interface to probe
  113. *
  114. * Returns Mode of the interface. Unknown or unsupported interfaces return
  115. * DISABLED.
  116. */
  117. extern cvmx_helper_interface_mode_t cvmx_helper_interface_get_mode(int
  118. interface);
  119. /**
  120. * Return the link state of an IPD/PKO port as returned by
  121. * auto negotiation. The result of this function may not match
  122. * Octeon's link config if auto negotiation has changed since
  123. * the last call to cvmx_helper_link_set().
  124. *
  125. * @ipd_port: IPD/PKO port to query
  126. *
  127. * Returns Link state
  128. */
  129. extern union cvmx_helper_link_info cvmx_helper_link_get(int ipd_port);
  130. /**
  131. * Configure an IPD/PKO port for the specified link state. This
  132. * function does not influence auto negotiation at the PHY level.
  133. * The passed link state must always match the link state returned
  134. * by cvmx_helper_link_get().
  135. *
  136. * @ipd_port: IPD/PKO port to configure
  137. * @link_info: The new link state
  138. *
  139. * Returns Zero on success, negative on failure
  140. */
  141. extern int cvmx_helper_link_set(int ipd_port,
  142. union cvmx_helper_link_info link_info);
  143. /**
  144. * This function probes an interface to determine the actual
  145. * number of hardware ports connected to it. It doesn't setup the
  146. * ports or enable them. The main goal here is to set the global
  147. * interface_port_count[interface] correctly. Hardware setup of the
  148. * ports will be performed later.
  149. *
  150. * @interface: Interface to probe
  151. *
  152. * Returns Zero on success, negative on failure
  153. */
  154. extern int cvmx_helper_interface_probe(int interface);
  155. extern int cvmx_helper_interface_enumerate(int interface);
  156. #endif /* __CVMX_HELPER_H__ */