162306a36Sopenharmony_ci/***********************license start*************** 262306a36Sopenharmony_ci * Author: Cavium Networks 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Contact: support@caviumnetworks.com 562306a36Sopenharmony_ci * This file is part of the OCTEON SDK 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright (c) 2003-2008 Cavium Networks 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * This file is free software; you can redistribute it and/or modify 1062306a36Sopenharmony_ci * it under the terms of the GNU General Public License, Version 2, as 1162306a36Sopenharmony_ci * published by the Free Software Foundation. 1262306a36Sopenharmony_ci * 1362306a36Sopenharmony_ci * This file is distributed in the hope that it will be useful, but 1462306a36Sopenharmony_ci * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty 1562306a36Sopenharmony_ci * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or 1662306a36Sopenharmony_ci * NONINFRINGEMENT. See the GNU General Public License for more 1762306a36Sopenharmony_ci * details. 1862306a36Sopenharmony_ci * 1962306a36Sopenharmony_ci * You should have received a copy of the GNU General Public License 2062306a36Sopenharmony_ci * along with this file; if not, write to the Free Software 2162306a36Sopenharmony_ci * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 2262306a36Sopenharmony_ci * or visit http://www.gnu.org/licenses/. 2362306a36Sopenharmony_ci * 2462306a36Sopenharmony_ci * This file may also be available under a different license from Cavium. 2562306a36Sopenharmony_ci * Contact Cavium Networks for more information 2662306a36Sopenharmony_ci ***********************license end**************************************/ 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci/* 2962306a36Sopenharmony_ci * Utility functions to decode Octeon's RSL_INT_BLOCKS 3062306a36Sopenharmony_ci * interrupts into error messages. 3162306a36Sopenharmony_ci */ 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci#include <asm/octeon/octeon.h> 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#include <asm/octeon/cvmx-asxx-defs.h> 3662306a36Sopenharmony_ci#include <asm/octeon/cvmx-gmxx-defs.h> 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#ifndef PRINT_ERROR 3962306a36Sopenharmony_ci#define PRINT_ERROR(format, ...) 4062306a36Sopenharmony_ci#endif 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_civoid __cvmx_interrupt_gmxx_rxx_int_en_enable(int index, int block); 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci/** 4562306a36Sopenharmony_ci * Enable ASX error interrupts that exist on CN3XXX, CN50XX, and 4662306a36Sopenharmony_ci * CN58XX. 4762306a36Sopenharmony_ci * 4862306a36Sopenharmony_ci * @block: Interface to enable 0-1 4962306a36Sopenharmony_ci */ 5062306a36Sopenharmony_civoid __cvmx_interrupt_asxx_enable(int block) 5162306a36Sopenharmony_ci{ 5262306a36Sopenharmony_ci int mask; 5362306a36Sopenharmony_ci union cvmx_asxx_int_en csr; 5462306a36Sopenharmony_ci /* 5562306a36Sopenharmony_ci * CN38XX and CN58XX have two interfaces with 4 ports per 5662306a36Sopenharmony_ci * interface. All other chips have a max of 3 ports on 5762306a36Sopenharmony_ci * interface 0 5862306a36Sopenharmony_ci */ 5962306a36Sopenharmony_ci if (OCTEON_IS_MODEL(OCTEON_CN38XX) || OCTEON_IS_MODEL(OCTEON_CN58XX)) 6062306a36Sopenharmony_ci mask = 0xf; /* Set enables for 4 ports */ 6162306a36Sopenharmony_ci else 6262306a36Sopenharmony_ci mask = 0x7; /* Set enables for 3 ports */ 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci /* Enable interface interrupts */ 6562306a36Sopenharmony_ci csr.u64 = cvmx_read_csr(CVMX_ASXX_INT_EN(block)); 6662306a36Sopenharmony_ci csr.s.txpsh = mask; 6762306a36Sopenharmony_ci csr.s.txpop = mask; 6862306a36Sopenharmony_ci csr.s.ovrflw = mask; 6962306a36Sopenharmony_ci cvmx_write_csr(CVMX_ASXX_INT_EN(block), csr.u64); 7062306a36Sopenharmony_ci} 7162306a36Sopenharmony_ci/** 7262306a36Sopenharmony_ci * Enable GMX error reporting for the supplied interface 7362306a36Sopenharmony_ci * 7462306a36Sopenharmony_ci * @interface: Interface to enable 7562306a36Sopenharmony_ci */ 7662306a36Sopenharmony_civoid __cvmx_interrupt_gmxx_enable(int interface) 7762306a36Sopenharmony_ci{ 7862306a36Sopenharmony_ci union cvmx_gmxx_inf_mode mode; 7962306a36Sopenharmony_ci union cvmx_gmxx_tx_int_en gmx_tx_int_en; 8062306a36Sopenharmony_ci int num_ports; 8162306a36Sopenharmony_ci int index; 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci mode.u64 = cvmx_read_csr(CVMX_GMXX_INF_MODE(interface)); 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX)) { 8662306a36Sopenharmony_ci if (mode.s.en) { 8762306a36Sopenharmony_ci switch (mode.cn52xx.mode) { 8862306a36Sopenharmony_ci case 1: /* XAUI */ 8962306a36Sopenharmony_ci num_ports = 1; 9062306a36Sopenharmony_ci break; 9162306a36Sopenharmony_ci case 2: /* SGMII */ 9262306a36Sopenharmony_ci case 3: /* PICMG */ 9362306a36Sopenharmony_ci num_ports = 4; 9462306a36Sopenharmony_ci break; 9562306a36Sopenharmony_ci default: /* Disabled */ 9662306a36Sopenharmony_ci num_ports = 0; 9762306a36Sopenharmony_ci break; 9862306a36Sopenharmony_ci } 9962306a36Sopenharmony_ci } else 10062306a36Sopenharmony_ci num_ports = 0; 10162306a36Sopenharmony_ci } else { 10262306a36Sopenharmony_ci if (mode.s.en) { 10362306a36Sopenharmony_ci if (OCTEON_IS_MODEL(OCTEON_CN38XX) 10462306a36Sopenharmony_ci || OCTEON_IS_MODEL(OCTEON_CN58XX)) { 10562306a36Sopenharmony_ci /* 10662306a36Sopenharmony_ci * SPI on CN38XX and CN58XX report all 10762306a36Sopenharmony_ci * errors through port 0. RGMII needs 10862306a36Sopenharmony_ci * to check all 4 ports 10962306a36Sopenharmony_ci */ 11062306a36Sopenharmony_ci if (mode.s.type) 11162306a36Sopenharmony_ci num_ports = 1; 11262306a36Sopenharmony_ci else 11362306a36Sopenharmony_ci num_ports = 4; 11462306a36Sopenharmony_ci } else { 11562306a36Sopenharmony_ci /* 11662306a36Sopenharmony_ci * CN30XX, CN31XX, and CN50XX have two 11762306a36Sopenharmony_ci * or three ports. GMII and MII has 2, 11862306a36Sopenharmony_ci * RGMII has three 11962306a36Sopenharmony_ci */ 12062306a36Sopenharmony_ci if (mode.s.type) 12162306a36Sopenharmony_ci num_ports = 2; 12262306a36Sopenharmony_ci else 12362306a36Sopenharmony_ci num_ports = 3; 12462306a36Sopenharmony_ci } 12562306a36Sopenharmony_ci } else 12662306a36Sopenharmony_ci num_ports = 0; 12762306a36Sopenharmony_ci } 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci gmx_tx_int_en.u64 = 0; 13062306a36Sopenharmony_ci if (num_ports) { 13162306a36Sopenharmony_ci if (OCTEON_IS_MODEL(OCTEON_CN38XX) 13262306a36Sopenharmony_ci || OCTEON_IS_MODEL(OCTEON_CN58XX)) 13362306a36Sopenharmony_ci gmx_tx_int_en.cn38xx.ncb_nxa = 1; 13462306a36Sopenharmony_ci gmx_tx_int_en.s.pko_nxa = 1; 13562306a36Sopenharmony_ci } 13662306a36Sopenharmony_ci gmx_tx_int_en.s.undflw = (1 << num_ports) - 1; 13762306a36Sopenharmony_ci cvmx_write_csr(CVMX_GMXX_TX_INT_EN(interface), gmx_tx_int_en.u64); 13862306a36Sopenharmony_ci for (index = 0; index < num_ports; index++) 13962306a36Sopenharmony_ci __cvmx_interrupt_gmxx_rxx_int_en_enable(index, interface); 14062306a36Sopenharmony_ci} 141