Path: blob/master/arch/mips/cavium-octeon/executive/cvmx-interrupt-rsl.c
26481 views
/***********************license start***************1* Author: Cavium Networks2*3* Contact: [email protected]4* This file is part of the OCTEON SDK5*6* Copyright (c) 2003-2008 Cavium Networks7*8* This file is free software; you can redistribute it and/or modify9* it under the terms of the GNU General Public License, Version 2, as10* published by the Free Software Foundation.11*12* This file is distributed in the hope that it will be useful, but13* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty14* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or15* NONINFRINGEMENT. See the GNU General Public License for more16* details.17*18* You should have received a copy of the GNU General Public License19* along with this file; if not, write to the Free Software20* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA21* or visit http://www.gnu.org/licenses/.22*23* This file may also be available under a different license from Cavium.24* Contact Cavium Networks for more information25***********************license end**************************************/2627/*28* Utility functions to decode Octeon's RSL_INT_BLOCKS29* interrupts into error messages.30*/3132#include <asm/octeon/octeon.h>3334#include <asm/octeon/cvmx-asxx-defs.h>35#include <asm/octeon/cvmx-gmxx-defs.h>3637#ifndef PRINT_ERROR38#define PRINT_ERROR(format, ...)39#endif4041void __cvmx_interrupt_gmxx_rxx_int_en_enable(int index, int block);4243/**44* Enable ASX error interrupts that exist on CN3XXX, CN50XX, and45* CN58XX.46*47* @block: Interface to enable 0-148*/49void __cvmx_interrupt_asxx_enable(int block)50{51int mask;52union cvmx_asxx_int_en csr;53/*54* CN38XX and CN58XX have two interfaces with 4 ports per55* interface. All other chips have a max of 3 ports on56* interface 057*/58if (OCTEON_IS_MODEL(OCTEON_CN38XX) || OCTEON_IS_MODEL(OCTEON_CN58XX))59mask = 0xf; /* Set enables for 4 ports */60else61mask = 0x7; /* Set enables for 3 ports */6263/* Enable interface interrupts */64csr.u64 = cvmx_read_csr(CVMX_ASXX_INT_EN(block));65csr.s.txpsh = mask;66csr.s.txpop = mask;67csr.s.ovrflw = mask;68cvmx_write_csr(CVMX_ASXX_INT_EN(block), csr.u64);69}70/**71* Enable GMX error reporting for the supplied interface72*73* @interface: Interface to enable74*/75void __cvmx_interrupt_gmxx_enable(int interface)76{77union cvmx_gmxx_inf_mode mode;78union cvmx_gmxx_tx_int_en gmx_tx_int_en;79int num_ports;80int index;8182mode.u64 = cvmx_read_csr(CVMX_GMXX_INF_MODE(interface));8384if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX)) {85if (mode.s.en) {86switch (mode.cn52xx.mode) {87case 1: /* XAUI */88num_ports = 1;89break;90case 2: /* SGMII */91case 3: /* PICMG */92num_ports = 4;93break;94default: /* Disabled */95num_ports = 0;96break;97}98} else99num_ports = 0;100} else {101if (mode.s.en) {102if (OCTEON_IS_MODEL(OCTEON_CN38XX)103|| OCTEON_IS_MODEL(OCTEON_CN58XX)) {104/*105* SPI on CN38XX and CN58XX report all106* errors through port 0. RGMII needs107* to check all 4 ports108*/109if (mode.s.type)110num_ports = 1;111else112num_ports = 4;113} else {114/*115* CN30XX, CN31XX, and CN50XX have two116* or three ports. GMII and MII has 2,117* RGMII has three118*/119if (mode.s.type)120num_ports = 2;121else122num_ports = 3;123}124} else125num_ports = 0;126}127128gmx_tx_int_en.u64 = 0;129if (num_ports) {130if (OCTEON_IS_MODEL(OCTEON_CN38XX)131|| OCTEON_IS_MODEL(OCTEON_CN58XX))132gmx_tx_int_en.cn38xx.ncb_nxa = 1;133gmx_tx_int_en.s.pko_nxa = 1;134}135gmx_tx_int_en.s.undflw = (1 << num_ports) - 1;136cvmx_write_csr(CVMX_GMXX_TX_INT_EN(interface), gmx_tx_int_en.u64);137for (index = 0; index < num_ports; index++)138__cvmx_interrupt_gmxx_rxx_int_en_enable(index, interface);139}140141142