18c2ecf20Sopenharmony_ci/***********************license start*************** 28c2ecf20Sopenharmony_ci * Author: Cavium Networks 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Contact: support@caviumnetworks.com 58c2ecf20Sopenharmony_ci * This file is part of the OCTEON SDK 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (c) 2003-2008 Cavium Networks 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * This file is free software; you can redistribute it and/or modify 108c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License, Version 2, as 118c2ecf20Sopenharmony_ci * published by the Free Software Foundation. 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * This file is distributed in the hope that it will be useful, but 148c2ecf20Sopenharmony_ci * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty 158c2ecf20Sopenharmony_ci * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or 168c2ecf20Sopenharmony_ci * NONINFRINGEMENT. See the GNU General Public License for more 178c2ecf20Sopenharmony_ci * details. 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License 208c2ecf20Sopenharmony_ci * along with this file; if not, write to the Free Software 218c2ecf20Sopenharmony_ci * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 228c2ecf20Sopenharmony_ci * or visit http://www.gnu.org/licenses/. 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * This file may also be available under a different license from Cavium. 258c2ecf20Sopenharmony_ci * Contact Cavium Networks for more information 268c2ecf20Sopenharmony_ci ***********************license end**************************************/ 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* 298c2ecf20Sopenharmony_ci * Utility functions to decode Octeon's RSL_INT_BLOCKS 308c2ecf20Sopenharmony_ci * interrupts into error messages. 318c2ecf20Sopenharmony_ci */ 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#include <asm/octeon/octeon.h> 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#include <asm/octeon/cvmx-asxx-defs.h> 368c2ecf20Sopenharmony_ci#include <asm/octeon/cvmx-gmxx-defs.h> 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#ifndef PRINT_ERROR 398c2ecf20Sopenharmony_ci#define PRINT_ERROR(format, ...) 408c2ecf20Sopenharmony_ci#endif 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_civoid __cvmx_interrupt_gmxx_rxx_int_en_enable(int index, int block); 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/** 458c2ecf20Sopenharmony_ci * Enable ASX error interrupts that exist on CN3XXX, CN50XX, and 468c2ecf20Sopenharmony_ci * CN58XX. 478c2ecf20Sopenharmony_ci * 488c2ecf20Sopenharmony_ci * @block: Interface to enable 0-1 498c2ecf20Sopenharmony_ci */ 508c2ecf20Sopenharmony_civoid __cvmx_interrupt_asxx_enable(int block) 518c2ecf20Sopenharmony_ci{ 528c2ecf20Sopenharmony_ci int mask; 538c2ecf20Sopenharmony_ci union cvmx_asxx_int_en csr; 548c2ecf20Sopenharmony_ci /* 558c2ecf20Sopenharmony_ci * CN38XX and CN58XX have two interfaces with 4 ports per 568c2ecf20Sopenharmony_ci * interface. All other chips have a max of 3 ports on 578c2ecf20Sopenharmony_ci * interface 0 588c2ecf20Sopenharmony_ci */ 598c2ecf20Sopenharmony_ci if (OCTEON_IS_MODEL(OCTEON_CN38XX) || OCTEON_IS_MODEL(OCTEON_CN58XX)) 608c2ecf20Sopenharmony_ci mask = 0xf; /* Set enables for 4 ports */ 618c2ecf20Sopenharmony_ci else 628c2ecf20Sopenharmony_ci mask = 0x7; /* Set enables for 3 ports */ 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci /* Enable interface interrupts */ 658c2ecf20Sopenharmony_ci csr.u64 = cvmx_read_csr(CVMX_ASXX_INT_EN(block)); 668c2ecf20Sopenharmony_ci csr.s.txpsh = mask; 678c2ecf20Sopenharmony_ci csr.s.txpop = mask; 688c2ecf20Sopenharmony_ci csr.s.ovrflw = mask; 698c2ecf20Sopenharmony_ci cvmx_write_csr(CVMX_ASXX_INT_EN(block), csr.u64); 708c2ecf20Sopenharmony_ci} 718c2ecf20Sopenharmony_ci/** 728c2ecf20Sopenharmony_ci * Enable GMX error reporting for the supplied interface 738c2ecf20Sopenharmony_ci * 748c2ecf20Sopenharmony_ci * @interface: Interface to enable 758c2ecf20Sopenharmony_ci */ 768c2ecf20Sopenharmony_civoid __cvmx_interrupt_gmxx_enable(int interface) 778c2ecf20Sopenharmony_ci{ 788c2ecf20Sopenharmony_ci union cvmx_gmxx_inf_mode mode; 798c2ecf20Sopenharmony_ci union cvmx_gmxx_tx_int_en gmx_tx_int_en; 808c2ecf20Sopenharmony_ci int num_ports; 818c2ecf20Sopenharmony_ci int index; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci mode.u64 = cvmx_read_csr(CVMX_GMXX_INF_MODE(interface)); 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX)) { 868c2ecf20Sopenharmony_ci if (mode.s.en) { 878c2ecf20Sopenharmony_ci switch (mode.cn52xx.mode) { 888c2ecf20Sopenharmony_ci case 1: /* XAUI */ 898c2ecf20Sopenharmony_ci num_ports = 1; 908c2ecf20Sopenharmony_ci break; 918c2ecf20Sopenharmony_ci case 2: /* SGMII */ 928c2ecf20Sopenharmony_ci case 3: /* PICMG */ 938c2ecf20Sopenharmony_ci num_ports = 4; 948c2ecf20Sopenharmony_ci break; 958c2ecf20Sopenharmony_ci default: /* Disabled */ 968c2ecf20Sopenharmony_ci num_ports = 0; 978c2ecf20Sopenharmony_ci break; 988c2ecf20Sopenharmony_ci } 998c2ecf20Sopenharmony_ci } else 1008c2ecf20Sopenharmony_ci num_ports = 0; 1018c2ecf20Sopenharmony_ci } else { 1028c2ecf20Sopenharmony_ci if (mode.s.en) { 1038c2ecf20Sopenharmony_ci if (OCTEON_IS_MODEL(OCTEON_CN38XX) 1048c2ecf20Sopenharmony_ci || OCTEON_IS_MODEL(OCTEON_CN58XX)) { 1058c2ecf20Sopenharmony_ci /* 1068c2ecf20Sopenharmony_ci * SPI on CN38XX and CN58XX report all 1078c2ecf20Sopenharmony_ci * errors through port 0. RGMII needs 1088c2ecf20Sopenharmony_ci * to check all 4 ports 1098c2ecf20Sopenharmony_ci */ 1108c2ecf20Sopenharmony_ci if (mode.s.type) 1118c2ecf20Sopenharmony_ci num_ports = 1; 1128c2ecf20Sopenharmony_ci else 1138c2ecf20Sopenharmony_ci num_ports = 4; 1148c2ecf20Sopenharmony_ci } else { 1158c2ecf20Sopenharmony_ci /* 1168c2ecf20Sopenharmony_ci * CN30XX, CN31XX, and CN50XX have two 1178c2ecf20Sopenharmony_ci * or three ports. GMII and MII has 2, 1188c2ecf20Sopenharmony_ci * RGMII has three 1198c2ecf20Sopenharmony_ci */ 1208c2ecf20Sopenharmony_ci if (mode.s.type) 1218c2ecf20Sopenharmony_ci num_ports = 2; 1228c2ecf20Sopenharmony_ci else 1238c2ecf20Sopenharmony_ci num_ports = 3; 1248c2ecf20Sopenharmony_ci } 1258c2ecf20Sopenharmony_ci } else 1268c2ecf20Sopenharmony_ci num_ports = 0; 1278c2ecf20Sopenharmony_ci } 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci gmx_tx_int_en.u64 = 0; 1308c2ecf20Sopenharmony_ci if (num_ports) { 1318c2ecf20Sopenharmony_ci if (OCTEON_IS_MODEL(OCTEON_CN38XX) 1328c2ecf20Sopenharmony_ci || OCTEON_IS_MODEL(OCTEON_CN58XX)) 1338c2ecf20Sopenharmony_ci gmx_tx_int_en.cn38xx.ncb_nxa = 1; 1348c2ecf20Sopenharmony_ci gmx_tx_int_en.s.pko_nxa = 1; 1358c2ecf20Sopenharmony_ci } 1368c2ecf20Sopenharmony_ci gmx_tx_int_en.s.undflw = (1 << num_ports) - 1; 1378c2ecf20Sopenharmony_ci cvmx_write_csr(CVMX_GMXX_TX_INT_EN(interface), gmx_tx_int_en.u64); 1388c2ecf20Sopenharmony_ci for (index = 0; index < num_ports; index++) 1398c2ecf20Sopenharmony_ci __cvmx_interrupt_gmxx_rxx_int_en_enable(index, interface); 1408c2ecf20Sopenharmony_ci} 141