xref: /OK3568_Linux_fs/kernel/arch/mips/cavium-octeon/executive/cvmx-interrupt-rsl.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /***********************license start***************
2*4882a593Smuzhiyun  * Author: Cavium Networks
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Contact: support@caviumnetworks.com
5*4882a593Smuzhiyun  * This file is part of the OCTEON SDK
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Copyright (c) 2003-2008 Cavium Networks
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  * This file is free software; you can redistribute it and/or modify
10*4882a593Smuzhiyun  * it under the terms of the GNU General Public License, Version 2, as
11*4882a593Smuzhiyun  * published by the Free Software Foundation.
12*4882a593Smuzhiyun  *
13*4882a593Smuzhiyun  * This file is distributed in the hope that it will be useful, but
14*4882a593Smuzhiyun  * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
15*4882a593Smuzhiyun  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
16*4882a593Smuzhiyun  * NONINFRINGEMENT.  See the GNU General Public License for more
17*4882a593Smuzhiyun  * details.
18*4882a593Smuzhiyun  *
19*4882a593Smuzhiyun  * You should have received a copy of the GNU General Public License
20*4882a593Smuzhiyun  * along with this file; if not, write to the Free Software
21*4882a593Smuzhiyun  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22*4882a593Smuzhiyun  * or visit http://www.gnu.org/licenses/.
23*4882a593Smuzhiyun  *
24*4882a593Smuzhiyun  * This file may also be available under a different license from Cavium.
25*4882a593Smuzhiyun  * Contact Cavium Networks for more information
26*4882a593Smuzhiyun  ***********************license end**************************************/
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun /*
29*4882a593Smuzhiyun  * Utility functions to decode Octeon's RSL_INT_BLOCKS
30*4882a593Smuzhiyun  * interrupts into error messages.
31*4882a593Smuzhiyun  */
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #include <asm/octeon/octeon.h>
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #include <asm/octeon/cvmx-asxx-defs.h>
36*4882a593Smuzhiyun #include <asm/octeon/cvmx-gmxx-defs.h>
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun #ifndef PRINT_ERROR
39*4882a593Smuzhiyun #define PRINT_ERROR(format, ...)
40*4882a593Smuzhiyun #endif
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun void __cvmx_interrupt_gmxx_rxx_int_en_enable(int index, int block);
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun /**
45*4882a593Smuzhiyun  * Enable ASX error interrupts that exist on CN3XXX, CN50XX, and
46*4882a593Smuzhiyun  * CN58XX.
47*4882a593Smuzhiyun  *
48*4882a593Smuzhiyun  * @block:  Interface to enable 0-1
49*4882a593Smuzhiyun  */
__cvmx_interrupt_asxx_enable(int block)50*4882a593Smuzhiyun void __cvmx_interrupt_asxx_enable(int block)
51*4882a593Smuzhiyun {
52*4882a593Smuzhiyun 	int mask;
53*4882a593Smuzhiyun 	union cvmx_asxx_int_en csr;
54*4882a593Smuzhiyun 	/*
55*4882a593Smuzhiyun 	 * CN38XX and CN58XX have two interfaces with 4 ports per
56*4882a593Smuzhiyun 	 * interface. All other chips have a max of 3 ports on
57*4882a593Smuzhiyun 	 * interface 0
58*4882a593Smuzhiyun 	 */
59*4882a593Smuzhiyun 	if (OCTEON_IS_MODEL(OCTEON_CN38XX) || OCTEON_IS_MODEL(OCTEON_CN58XX))
60*4882a593Smuzhiyun 		mask = 0xf;	/* Set enables for 4 ports */
61*4882a593Smuzhiyun 	else
62*4882a593Smuzhiyun 		mask = 0x7;	/* Set enables for 3 ports */
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun 	/* Enable interface interrupts */
65*4882a593Smuzhiyun 	csr.u64 = cvmx_read_csr(CVMX_ASXX_INT_EN(block));
66*4882a593Smuzhiyun 	csr.s.txpsh = mask;
67*4882a593Smuzhiyun 	csr.s.txpop = mask;
68*4882a593Smuzhiyun 	csr.s.ovrflw = mask;
69*4882a593Smuzhiyun 	cvmx_write_csr(CVMX_ASXX_INT_EN(block), csr.u64);
70*4882a593Smuzhiyun }
71*4882a593Smuzhiyun /**
72*4882a593Smuzhiyun  * Enable GMX error reporting for the supplied interface
73*4882a593Smuzhiyun  *
74*4882a593Smuzhiyun  * @interface: Interface to enable
75*4882a593Smuzhiyun  */
__cvmx_interrupt_gmxx_enable(int interface)76*4882a593Smuzhiyun void __cvmx_interrupt_gmxx_enable(int interface)
77*4882a593Smuzhiyun {
78*4882a593Smuzhiyun 	union cvmx_gmxx_inf_mode mode;
79*4882a593Smuzhiyun 	union cvmx_gmxx_tx_int_en gmx_tx_int_en;
80*4882a593Smuzhiyun 	int num_ports;
81*4882a593Smuzhiyun 	int index;
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun 	mode.u64 = cvmx_read_csr(CVMX_GMXX_INF_MODE(interface));
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun 	if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX)) {
86*4882a593Smuzhiyun 		if (mode.s.en) {
87*4882a593Smuzhiyun 			switch (mode.cn52xx.mode) {
88*4882a593Smuzhiyun 			case 1: /* XAUI */
89*4882a593Smuzhiyun 				num_ports = 1;
90*4882a593Smuzhiyun 				break;
91*4882a593Smuzhiyun 			case 2: /* SGMII */
92*4882a593Smuzhiyun 			case 3: /* PICMG */
93*4882a593Smuzhiyun 				num_ports = 4;
94*4882a593Smuzhiyun 				break;
95*4882a593Smuzhiyun 			default:	/* Disabled */
96*4882a593Smuzhiyun 				num_ports = 0;
97*4882a593Smuzhiyun 				break;
98*4882a593Smuzhiyun 			}
99*4882a593Smuzhiyun 		} else
100*4882a593Smuzhiyun 			num_ports = 0;
101*4882a593Smuzhiyun 	} else {
102*4882a593Smuzhiyun 		if (mode.s.en) {
103*4882a593Smuzhiyun 			if (OCTEON_IS_MODEL(OCTEON_CN38XX)
104*4882a593Smuzhiyun 			    || OCTEON_IS_MODEL(OCTEON_CN58XX)) {
105*4882a593Smuzhiyun 				/*
106*4882a593Smuzhiyun 				 * SPI on CN38XX and CN58XX report all
107*4882a593Smuzhiyun 				 * errors through port 0.  RGMII needs
108*4882a593Smuzhiyun 				 * to check all 4 ports
109*4882a593Smuzhiyun 				 */
110*4882a593Smuzhiyun 				if (mode.s.type)
111*4882a593Smuzhiyun 					num_ports = 1;
112*4882a593Smuzhiyun 				else
113*4882a593Smuzhiyun 					num_ports = 4;
114*4882a593Smuzhiyun 			} else {
115*4882a593Smuzhiyun 				/*
116*4882a593Smuzhiyun 				 * CN30XX, CN31XX, and CN50XX have two
117*4882a593Smuzhiyun 				 * or three ports. GMII and MII has 2,
118*4882a593Smuzhiyun 				 * RGMII has three
119*4882a593Smuzhiyun 				 */
120*4882a593Smuzhiyun 				if (mode.s.type)
121*4882a593Smuzhiyun 					num_ports = 2;
122*4882a593Smuzhiyun 				else
123*4882a593Smuzhiyun 					num_ports = 3;
124*4882a593Smuzhiyun 			}
125*4882a593Smuzhiyun 		} else
126*4882a593Smuzhiyun 			num_ports = 0;
127*4882a593Smuzhiyun 	}
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun 	gmx_tx_int_en.u64 = 0;
130*4882a593Smuzhiyun 	if (num_ports) {
131*4882a593Smuzhiyun 		if (OCTEON_IS_MODEL(OCTEON_CN38XX)
132*4882a593Smuzhiyun 		    || OCTEON_IS_MODEL(OCTEON_CN58XX))
133*4882a593Smuzhiyun 			gmx_tx_int_en.cn38xx.ncb_nxa = 1;
134*4882a593Smuzhiyun 		gmx_tx_int_en.s.pko_nxa = 1;
135*4882a593Smuzhiyun 	}
136*4882a593Smuzhiyun 	gmx_tx_int_en.s.undflw = (1 << num_ports) - 1;
137*4882a593Smuzhiyun 	cvmx_write_csr(CVMX_GMXX_TX_INT_EN(interface), gmx_tx_int_en.u64);
138*4882a593Smuzhiyun 	for (index = 0; index < num_ports; index++)
139*4882a593Smuzhiyun 		__cvmx_interrupt_gmxx_rxx_int_en_enable(index, interface);
140*4882a593Smuzhiyun }
141