octeon-feature.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /***********************license start***************
  2. * Author: Cavium Networks
  3. *
  4. * Contact: support@caviumnetworks.com
  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. * File defining checks for different Octeon features.
  29. */
  30. #ifndef __OCTEON_FEATURE_H__
  31. #define __OCTEON_FEATURE_H__
  32. enum octeon_feature {
  33. /*
  34. * Octeon models in the CN5XXX family and higher support
  35. * atomic add instructions to memory (saa/saad).
  36. */
  37. OCTEON_FEATURE_SAAD,
  38. /* Does this Octeon support the ZIP offload engine? */
  39. OCTEON_FEATURE_ZIP,
  40. /* Does this Octeon support crypto acceleration using COP2? */
  41. OCTEON_FEATURE_CRYPTO,
  42. /* Does this Octeon support PCI express? */
  43. OCTEON_FEATURE_PCIE,
  44. /* Some Octeon models support internal memory for storing
  45. * cryptographic keys */
  46. OCTEON_FEATURE_KEY_MEMORY,
  47. /* Octeon has a LED controller for banks of external LEDs */
  48. OCTEON_FEATURE_LED_CONTROLLER,
  49. /* Octeon has a trace buffer */
  50. OCTEON_FEATURE_TRA,
  51. /* Octeon has a management port */
  52. OCTEON_FEATURE_MGMT_PORT,
  53. /* Octeon has a raid unit */
  54. OCTEON_FEATURE_RAID,
  55. /* Octeon has a builtin USB */
  56. OCTEON_FEATURE_USB,
  57. /* Octeon IPD can run without using work queue entries */
  58. OCTEON_FEATURE_NO_WPTR,
  59. /* Octeon has DFA state machines */
  60. OCTEON_FEATURE_DFA,
  61. /* Octeon MDIO block supports clause 45 transactions for 10
  62. * Gig support */
  63. OCTEON_FEATURE_MDIO_CLAUSE_45,
  64. };
  65. static inline int cvmx_fuse_read(int fuse);
  66. /**
  67. * Determine if the current Octeon supports a specific feature. These
  68. * checks have been optimized to be fairly quick, but they should still
  69. * be kept out of fast path code.
  70. *
  71. * @feature: Feature to check for. This should always be a constant so the
  72. * compiler can remove the switch statement through optimization.
  73. *
  74. * Returns Non zero if the feature exists. Zero if the feature does not
  75. * exist.
  76. */
  77. static inline int octeon_has_feature(enum octeon_feature feature)
  78. {
  79. switch (feature) {
  80. case OCTEON_FEATURE_SAAD:
  81. return !OCTEON_IS_MODEL(OCTEON_CN3XXX);
  82. case OCTEON_FEATURE_ZIP:
  83. if (OCTEON_IS_MODEL(OCTEON_CN30XX)
  84. || OCTEON_IS_MODEL(OCTEON_CN50XX)
  85. || OCTEON_IS_MODEL(OCTEON_CN52XX))
  86. return 0;
  87. else if (OCTEON_IS_MODEL(OCTEON_CN38XX_PASS1))
  88. return 1;
  89. else
  90. return !cvmx_fuse_read(121);
  91. case OCTEON_FEATURE_CRYPTO:
  92. return !cvmx_fuse_read(90);
  93. case OCTEON_FEATURE_PCIE:
  94. return OCTEON_IS_MODEL(OCTEON_CN56XX)
  95. || OCTEON_IS_MODEL(OCTEON_CN52XX);
  96. case OCTEON_FEATURE_KEY_MEMORY:
  97. case OCTEON_FEATURE_LED_CONTROLLER:
  98. return OCTEON_IS_MODEL(OCTEON_CN38XX)
  99. || OCTEON_IS_MODEL(OCTEON_CN58XX)
  100. || OCTEON_IS_MODEL(OCTEON_CN56XX);
  101. case OCTEON_FEATURE_TRA:
  102. return !(OCTEON_IS_MODEL(OCTEON_CN30XX)
  103. || OCTEON_IS_MODEL(OCTEON_CN50XX));
  104. case OCTEON_FEATURE_MGMT_PORT:
  105. return OCTEON_IS_MODEL(OCTEON_CN56XX)
  106. || OCTEON_IS_MODEL(OCTEON_CN52XX);
  107. case OCTEON_FEATURE_RAID:
  108. return OCTEON_IS_MODEL(OCTEON_CN56XX)
  109. || OCTEON_IS_MODEL(OCTEON_CN52XX);
  110. case OCTEON_FEATURE_USB:
  111. return !(OCTEON_IS_MODEL(OCTEON_CN38XX)
  112. || OCTEON_IS_MODEL(OCTEON_CN58XX));
  113. case OCTEON_FEATURE_NO_WPTR:
  114. return (OCTEON_IS_MODEL(OCTEON_CN56XX)
  115. || OCTEON_IS_MODEL(OCTEON_CN52XX))
  116. && !OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X)
  117. && !OCTEON_IS_MODEL(OCTEON_CN52XX_PASS1_X);
  118. case OCTEON_FEATURE_DFA:
  119. if (!OCTEON_IS_MODEL(OCTEON_CN38XX)
  120. && !OCTEON_IS_MODEL(OCTEON_CN31XX)
  121. && !OCTEON_IS_MODEL(OCTEON_CN58XX))
  122. return 0;
  123. else if (OCTEON_IS_MODEL(OCTEON_CN3020))
  124. return 0;
  125. else if (OCTEON_IS_MODEL(OCTEON_CN38XX_PASS1))
  126. return 1;
  127. else
  128. return !cvmx_fuse_read(120);
  129. case OCTEON_FEATURE_MDIO_CLAUSE_45:
  130. return !(OCTEON_IS_MODEL(OCTEON_CN3XXX)
  131. || OCTEON_IS_MODEL(OCTEON_CN58XX)
  132. || OCTEON_IS_MODEL(OCTEON_CN50XX));
  133. }
  134. return 0;
  135. }
  136. #endif /* __OCTEON_FEATURE_H__ */