1 /***********************license start***************
2 * Copyright (c) 2003-2008 Cavium Networks (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 Networks 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 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25 * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26 * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27 * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28 * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30 * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31 * POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT
32 * OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
35 * For any questions regarding licensing please contact marketing@caviumnetworks.com
37 ***********************license end**************************************/
43 #ifndef __CVMX_CSR_DB_H__
44 #define __CVMX_CSR_DB_H__
48 * Interface for the Octeon CSR database.
51 * <hr>$Revision: 41586 $<hr>
54 #include "cvmx-platform.h"
61 CVMX_CSR_DB_TYPE_RSL, /**< Octeon internal address, but indirect and slow (not used for addresses) */
62 CVMX_CSR_DB_TYPE_NCB, /**< Octeon internal address */
63 CVMX_CSR_DB_TYPE_PCI_NCB, /**< Can be accessed through PCI BAR0, also an NCB alias (not used for addresses) */
64 CVMX_CSR_DB_TYPE_PCICONFIG, /**< PCI Config, also an NCB alias */
65 CVMX_CSR_DB_TYPE_PCI, /**< PCI BAR0 (only) */
66 CVMX_CSR_DB_TYPE_PEXP, /**< PCIe BAR 0 address only */
67 CVMX_CSR_DB_TYPE_PEXP_NCB, /**< NCB-direct and PCIe BAR0 address */
68 CVMX_CSR_DB_TYPE_PCICONFIGEP, /**< PCIe config address (EP mode) + indirect through PESC*_CFG_RD/PESC*_CFG_WR */
69 CVMX_CSR_DB_TYPE_PCICONFIGRC /**< PCICONFIGRC - PCIe config address (RC mode) + indirect through PESC*_CFG_RD/PESC*_CFG_WR */
70 } CVMX_CSR_DB_TYPE_FIELD;
73 * the structure for the cvmx_csr_db_addresses[] array that
74 * holds all possible Octeon CSR addresses
77 char * name; /**< CSR name at the supplied address */
78 uint64_t address; /**< Address = octeon internal, PCI BAR0 relative, PCI CONFIG relative */
79 CVMX_CSR_DB_TYPE_FIELD type:8; /**< the type */
80 uint8_t widthbits; /**< the width of the CSR in bits */
81 uint16_t csroff; /**< position of the CSR in cvmx_csr_db[] */
82 } __attribute__ ((packed)) CVMX_CSR_DB_ADDRESS_TYPE;
85 * the structure for the cvmx_csr_db_fields[] array that
86 * holds all possible Octeon CSR fields
89 char * name; /**< name of the field */
90 uint8_t startbit; /**< starting bit position of the field */
91 uint8_t sizebits; /**< the size of the field in bits */
92 uint16_t csroff; /**< position of the CSR containing the field in cvmx_csr_db[] (get alias from there) */
93 char * type; /**< the type of the field R/W, R/W1C, ... */
94 uint8_t rst_unp; /**< set if the reset value is unknown */
95 uint8_t typ_unp; /**< set if the typical value is unknown */
96 uint64_t rst_val; /**< the reset value of the field */
97 uint64_t typ_val; /**< the typical value of the field */
98 } __attribute__ ((packed)) CVMX_CSR_DB_FIELD_TYPE;
101 * the structure for the cvmx_csr_db[] array that holds all
102 * possible Octeon CSR forms
105 char *basename; /**< the base name of the CSR */
106 CVMX_CSR_DB_TYPE_FIELD type:8; /**< the type */
107 uint8_t widthbits; /**< the width of the CSR in bits */
108 uint16_t addoff; /**< the position of the first address in cvmx_csr_db_csr_addresses[] (numblocks*indexnum is #) */
109 uint8_t numfields; /**< the number of fields in the CSR (and in cvmx_csr_db_csr_fields[]) */
110 uint16_t fieldoff; /**< the position of the first field in cvmx_csr_db_csr_fields[] */
111 } __attribute__ ((packed)) CVMX_CSR_DB_TYPE;
115 * This NULL terminated array contains the CVMX_CSR_DB_TYPE
116 * arrays for each chip. Each array entry is another NULL
117 * terminated array of CSRs.
119 extern const CVMX_CSR_DB_TYPE *cvmx_csr_db[];
122 * This NULL terminated array contains the CVMX_CSR_DB_ADDRESS_TYPE
123 * arrays for each chip. Each array entry is another NULL
124 * terminated array of CSR addresses.
126 extern const CVMX_CSR_DB_ADDRESS_TYPE *cvmx_csr_db_addresses[];
129 * This NULL terminated array contains the CVMX_CSR_DB_FIELD_TYPE
130 * arrays for each chip. Each array entry is another NULL
131 * terminated array of CSR fields.
133 extern const CVMX_CSR_DB_FIELD_TYPE *cvmx_csr_db_fields[];
136 * Figure out which database to use for this chip. The passed
137 * identifier can be a processor ID or a PCI ID.
139 * @param identifier processor ID or a PCI ID
141 * @return index into the csr db
143 extern int cvmx_db_get_chipindex(int identifier);
146 * Get the CSR DB entry for the passed Octeon model and CSR name. The
147 * model can either be specified as a processor id or PCI id.
149 * @param identifier Identifer to choose the CSR DB with
150 * @param name CSR name to lookup
152 * @return CSR DB entry or NULL on failure
154 extern const CVMX_CSR_DB_ADDRESS_TYPE *cvmx_csr_db_get(int identifier, const char *name);
157 * Decode a CSR value into named bitfields. The model can either
158 * be specified as a processor id or PCI id.
160 * @param identifier Identifer to choose the CSR DB with
161 * @param address CSR address being decoded
162 * @param value Value to decode
164 extern void cvmx_csr_db_decode(int identifier, uint64_t address, uint64_t value);
167 * Print a list of csrs begimning with a prefix. The
168 * model can either be specified as a processor id or PCI id.
170 * @param identifier Identifer to choose the CSR DB with
171 * @param prefix Beginning prefix to look for
173 extern void cvmx_csr_db_display_list(int identifier, const char *prefix);