1 /***********************license start***************
2 * Copyright (c) 2003-2010 Cavium Inc. (support@cavium.com). All rights
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
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.
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
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
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**************************************/
45 #ifndef __CVMX_CSR_DB_H__
46 #define __CVMX_CSR_DB_H__
50 * Interface for the Octeon CSR database.
53 * <hr>$Revision: 70030 $<hr>
56 #if !defined(CVMX_BUILD_FOR_LINUX_KERNEL) && !defined(CVMX_BUILD_FOR_FREEBSD_KERNEL)
57 #include "cvmx-platform.h"
65 CVMX_CSR_DB_TYPE_RSL, /**< Octeon internal address, but indirect and slow (not used for addresses) */
66 CVMX_CSR_DB_TYPE_NCB, /**< Octeon internal address */
67 CVMX_CSR_DB_TYPE_PCI_NCB, /**< Can be accessed through PCI BAR0, also an NCB alias (not used for addresses) */
68 CVMX_CSR_DB_TYPE_PCICONFIG, /**< PCI Config, also an NCB alias */
69 CVMX_CSR_DB_TYPE_PCI, /**< PCI BAR0 (only) */
70 CVMX_CSR_DB_TYPE_PEXP, /**< PCIe BAR 0 address only */
71 CVMX_CSR_DB_TYPE_PEXP_NCB, /**< NCB-direct and PCIe BAR0 address */
72 CVMX_CSR_DB_TYPE_PCICONFIGEP, /**< PCIe config address (EP mode) + indirect through PESC*_CFG_RD/PESC*_CFG_WR */
73 CVMX_CSR_DB_TYPE_PCICONFIGRC, /**< PCICONFIGRC - PCIe config address (RC mode) + indirect through PESC*_CFG_RD/PESC*_CFG_WR */
74 CVMX_CSR_DB_TYPE_SRIOMAINT /**< SRIOMAINT - SRIO maintenance registers */
75 } CVMX_CSR_DB_TYPE_FIELD;
78 * the structure for the cvmx_csr_db_addresses[] array that
79 * holds all possible Octeon CSR addresses
82 char * name; /**< CSR name at the supplied address */
83 uint64_t address; /**< Address = octeon internal, PCI BAR0 relative, PCI CONFIG relative */
84 CVMX_CSR_DB_TYPE_FIELD type:8; /**< the type */
85 uint8_t widthbits; /**< the width of the CSR in bits */
86 uint16_t csroff; /**< position of the CSR in cvmx_csr_db[] */
87 } __attribute__ ((packed)) CVMX_CSR_DB_ADDRESS_TYPE;
90 * the structure for the cvmx_csr_db_fields[] array that
91 * holds all possible Octeon CSR fields
94 char * name; /**< name of the field */
95 uint8_t startbit; /**< starting bit position of the field */
96 uint8_t sizebits; /**< the size of the field in bits */
97 uint16_t csroff; /**< position of the CSR containing the field in cvmx_csr_db[] (get alias from there) */
98 char * type; /**< the type of the field R/W, R/W1C, ... */
99 uint8_t rst_unp; /**< set if the reset value is unknown */
100 uint8_t typ_unp; /**< set if the typical value is unknown */
101 uint64_t rst_val; /**< the reset value of the field */
102 uint64_t typ_val; /**< the typical value of the field */
103 } __attribute__ ((packed)) CVMX_CSR_DB_FIELD_TYPE;
106 * the structure for the cvmx_csr_db[] array that holds all
107 * possible Octeon CSR forms
110 char *basename; /**< the base name of the CSR */
111 CVMX_CSR_DB_TYPE_FIELD type:8; /**< the type */
112 uint8_t widthbits; /**< the width of the CSR in bits */
113 uint16_t addoff; /**< the position of the first address in cvmx_csr_db_csr_addresses[] (numblocks*indexnum is #) */
114 uint8_t numfields; /**< the number of fields in the CSR (and in cvmx_csr_db_csr_fields[]) */
115 uint16_t fieldoff; /**< the position of the first field in cvmx_csr_db_csr_fields[] */
116 } __attribute__ ((packed)) CVMX_CSR_DB_TYPE;
120 * This NULL terminated array contains the CVMX_CSR_DB_TYPE
121 * arrays for each chip. Each array entry is another NULL
122 * terminated array of CSRs.
124 extern const CVMX_CSR_DB_TYPE *cvmx_csr_db[];
127 * This NULL terminated array contains the CVMX_CSR_DB_ADDRESS_TYPE
128 * arrays for each chip. Each array entry is another NULL
129 * terminated array of CSR addresses.
131 extern const CVMX_CSR_DB_ADDRESS_TYPE *cvmx_csr_db_addresses[];
134 * This NULL terminated array contains the CVMX_CSR_DB_FIELD_TYPE
135 * arrays for each chip. Each array entry is another NULL
136 * terminated array of CSR fields.
138 extern const CVMX_CSR_DB_FIELD_TYPE *cvmx_csr_db_fields[];
141 * Figure out which database to use for this chip. The passed
142 * identifier can be a processor ID or a PCI ID.
144 * @param identifier processor ID or a PCI ID
146 * @return index into the csr db
148 extern int cvmx_db_get_chipindex(int identifier);
151 * Get the CSR DB entry for the passed Octeon model and CSR name. The
152 * model can either be specified as a processor id or PCI id.
154 * @param identifier Identifer to choose the CSR DB with
155 * @param name CSR name to lookup
157 * @return CSR DB entry or NULL on failure
159 extern const CVMX_CSR_DB_ADDRESS_TYPE *cvmx_csr_db_get(int identifier, const char *name);
162 * Decode a CSR value into named bitfields. The model can either
163 * be specified as a processor id or PCI id.
165 * @param identifier Identifer to choose the CSR DB with
166 * @param address CSR address being decoded
167 * @param value Value to decode
169 extern void cvmx_csr_db_decode(int identifier, uint64_t address, uint64_t value);
172 * Decode a CSR value into named bitfields. The model can either
173 * be specified as a processor id or PCI id.
175 * @param identifier Identifer to choose the CSR DB with
176 * @param name CSR name to decode
177 * @param value Value to decode
179 extern void cvmx_csr_db_decode_by_name(int identifier, const char *name, uint64_t value);
182 * Print a list of csrs begimning with a prefix. The
183 * model can either be specified as a processor id or PCI id.
185 * @param identifier Identifer to choose the CSR DB with
186 * @param prefix Beginning prefix to look for
188 extern void cvmx_csr_db_display_list(int identifier, const char *prefix);