1/***********************license start*************** 2 * Copyright (c) 2011 Cavium Inc. (support@cavium.com). All rights 3 * reserved. 4 * 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 18 * * Neither the name of Cavium Inc. nor the names of 19 * its contributors may be used to endorse or promote products 20 * derived from this software without specific prior written 21 * permission. 22 23 * This Software, including technical data, may be subject to U.S. export control 24 * laws, including the U.S. Export Administration Act and its associated 25 * regulations, and may be subject to export or import regulations in other 26 * countries. 27 28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 29 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR 30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO 31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR 32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM 33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, 34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF 35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR 36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR 37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 38 ***********************license end**************************************/ 39 40 41/** 42 * @file 43 * 44 * Helper utilities for qlm. 45 * 46 * <hr>$Revision: 70030 $<hr> 47 */ 48 49 50#ifndef __CVMX_QLM_H__ 51#define __CVMX_QLM_H__ 52 53#include "cvmx.h" 54 55typedef struct 56{ 57 const char *name; 58 int stop_bit; 59 int start_bit; 60} __cvmx_qlm_jtag_field_t; 61 62/** 63 * Return the number of QLMs supported by the chip 64 * 65 * @return Number of QLMs 66 */ 67extern int cvmx_qlm_get_num(void); 68 69/** 70 * Return the qlm number based on the interface 71 * 72 * @param interface Interface to look up 73 */ 74extern int cvmx_qlm_interface(int interface); 75 76/** 77 * Return number of lanes for a given qlm 78 * 79 * @return Number of lanes 80 */ 81extern int cvmx_qlm_get_lanes(int qlm); 82 83/** 84 * Get the QLM JTAG fields based on Octeon model on the supported chips. 85 * 86 * @return qlm_jtag_field_t structure 87 */ 88extern const __cvmx_qlm_jtag_field_t *cvmx_qlm_jtag_get_field(void); 89 90/** 91 * Get the QLM JTAG length by going through qlm_jtag_field for each 92 * Octeon model that is supported 93 * 94 * @return return the length. 95 */ 96extern int cvmx_qlm_jtag_get_length(void); 97 98/** 99 * Initialize the QLM layer 100 */ 101extern void cvmx_qlm_init(void); 102 103/** 104 * Get a field in a QLM JTAG chain 105 * 106 * @param qlm QLM to get 107 * @param lane Lane in QLM to get 108 * @param name String name of field 109 * 110 * @return JTAG field value 111 */ 112extern uint64_t cvmx_qlm_jtag_get(int qlm, int lane, const char *name); 113 114/** 115 * Set a field in a QLM JTAG chain 116 * 117 * @param qlm QLM to set 118 * @param lane Lane in QLM to set, or -1 for all lanes 119 * @param name String name of field 120 * @param value Value of the field 121 */ 122extern void cvmx_qlm_jtag_set(int qlm, int lane, const char *name, uint64_t value); 123 124/** 125 * Errata G-16094: QLM Gen2 Equalizer Default Setting Change. 126 * CN68XX pass 1.x and CN66XX pass 1.x QLM tweak. This function tweaks the 127 * JTAG setting for a QLMs to run better at 5 and 6.25Ghz. 128 */ 129extern void __cvmx_qlm_speed_tweak(void); 130 131/** 132 * Errata G-16174: QLM Gen2 PCIe IDLE DAC change. 133 * CN68XX pass 1.x, CN66XX pass 1.x and CN63XX pass 1.0-2.2 QLM tweak. 134 * This function tweaks the JTAG setting for a QLMs for PCIe to run better. 135 */ 136extern void __cvmx_qlm_pcie_idle_dac_tweak(void); 137 138#ifndef CVMX_BUILD_FOR_LINUX_HOST 139/** 140 * Get the speed (Gbaud) of the QLM in Mhz. 141 * 142 * @param qlm QLM to examine 143 * 144 * @return Speed in Mhz 145 */ 146extern int cvmx_qlm_get_gbaud_mhz(int qlm); 147#endif 148 149/* 150 * Read QLM and return status based on CN66XX. 151 * @return Return 1 if QLM is SGMII 152 * 2 if QLM is XAUI 153 * 3 if QLM is PCIe gen2 / gen1 154 * 4 if QLM is SRIO 1x4 short / long 155 * 5 if QLM is SRIO 2x2 short / long 156 * 6 is reserved 157 * 7 if QLM is PCIe 1x2 gen2 / gen1 158 * 8 if QLM is PCIe 2x1 gen2 / gen1 159 * 9 if QLM is ILK 160 * 10 if QLM is RXAUI 161 * -1 otherwise 162 */ 163extern int cvmx_qlm_get_status(int qlm); 164 165#endif /* __CVMX_QLM_H__ */ 166