cvmx-interrupt-rsl.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. * Utility functions to decode Octeon's RSL_INT_BLOCKS
  29. * interrupts into error messages.
  30. */
  31. #include <asm/octeon/octeon.h>
  32. #include "cvmx-asxx-defs.h"
  33. #include "cvmx-gmxx-defs.h"
  34. #ifndef PRINT_ERROR
  35. #define PRINT_ERROR(format, ...)
  36. #endif
  37. void __cvmx_interrupt_gmxx_rxx_int_en_enable(int index, int block);
  38. /**
  39. * Enable ASX error interrupts that exist on CN3XXX, CN50XX, and
  40. * CN58XX.
  41. *
  42. * @block: Interface to enable 0-1
  43. */
  44. void __cvmx_interrupt_asxx_enable(int block)
  45. {
  46. int mask;
  47. union cvmx_asxx_int_en csr;
  48. /*
  49. * CN38XX and CN58XX have two interfaces with 4 ports per
  50. * interface. All other chips have a max of 3 ports on
  51. * interface 0
  52. */
  53. if (OCTEON_IS_MODEL(OCTEON_CN38XX) || OCTEON_IS_MODEL(OCTEON_CN58XX))
  54. mask = 0xf; /* Set enables for 4 ports */
  55. else
  56. mask = 0x7; /* Set enables for 3 ports */
  57. /* Enable interface interrupts */
  58. csr.u64 = cvmx_read_csr(CVMX_ASXX_INT_EN(block));
  59. csr.s.txpsh = mask;
  60. csr.s.txpop = mask;
  61. csr.s.ovrflw = mask;
  62. cvmx_write_csr(CVMX_ASXX_INT_EN(block), csr.u64);
  63. }
  64. /**
  65. * Enable GMX error reporting for the supplied interface
  66. *
  67. * @interface: Interface to enable
  68. */
  69. void __cvmx_interrupt_gmxx_enable(int interface)
  70. {
  71. union cvmx_gmxx_inf_mode mode;
  72. union cvmx_gmxx_tx_int_en gmx_tx_int_en;
  73. int num_ports;
  74. int index;
  75. mode.u64 = cvmx_read_csr(CVMX_GMXX_INF_MODE(interface));
  76. if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX)) {
  77. if (mode.s.en) {
  78. switch (mode.cn56xx.mode) {
  79. case 1: /* XAUI */
  80. num_ports = 1;
  81. break;
  82. case 2: /* SGMII */
  83. case 3: /* PICMG */
  84. num_ports = 4;
  85. break;
  86. default: /* Disabled */
  87. num_ports = 0;
  88. break;
  89. }
  90. } else
  91. num_ports = 0;
  92. } else {
  93. if (mode.s.en) {
  94. if (OCTEON_IS_MODEL(OCTEON_CN38XX)
  95. || OCTEON_IS_MODEL(OCTEON_CN58XX)) {
  96. /*
  97. * SPI on CN38XX and CN58XX report all
  98. * errors through port 0. RGMII needs
  99. * to check all 4 ports
  100. */
  101. if (mode.s.type)
  102. num_ports = 1;
  103. else
  104. num_ports = 4;
  105. } else {
  106. /*
  107. * CN30XX, CN31XX, and CN50XX have two
  108. * or three ports. GMII and MII has 2,
  109. * RGMII has three
  110. */
  111. if (mode.s.type)
  112. num_ports = 2;
  113. else
  114. num_ports = 3;
  115. }
  116. } else
  117. num_ports = 0;
  118. }
  119. gmx_tx_int_en.u64 = 0;
  120. if (num_ports) {
  121. if (OCTEON_IS_MODEL(OCTEON_CN38XX)
  122. || OCTEON_IS_MODEL(OCTEON_CN58XX))
  123. gmx_tx_int_en.s.ncb_nxa = 1;
  124. gmx_tx_int_en.s.pko_nxa = 1;
  125. }
  126. gmx_tx_int_en.s.undflw = (1 << num_ports) - 1;
  127. cvmx_write_csr(CVMX_GMXX_TX_INT_EN(interface), gmx_tx_int_en.u64);
  128. for (index = 0; index < num_ports; index++)
  129. __cvmx_interrupt_gmxx_rxx_int_en_enable(index, interface);
  130. }