]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/contrib/octeon-sdk/cvmx-csr-db.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / contrib / octeon-sdk / cvmx-csr-db.h
1 /***********************license start***************
2  * Copyright (c) 2003-2010  Cavium Networks (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 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
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  NETWORKS 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
43
44
45 #ifndef __CVMX_CSR_DB_H__
46 #define __CVMX_CSR_DB_H__
47
48 /**
49  * @file
50  * Interface for the Octeon CSR database.
51  *
52  *
53  * <hr>$Revision: 49507 $<hr>
54  *
55  */
56 #if !defined(CVMX_BUILD_FOR_LINUX_KERNEL) && !defined(CVMX_BUILD_FOR_FREEBSD_KERNEL)
57 #include "cvmx-platform.h"
58 #endif
59
60 #ifdef  __cplusplus
61 extern "C" {
62 #endif
63
64 typedef enum {
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;
76
77 /**
78  * the structure for the cvmx_csr_db_addresses[] array that
79  * holds all possible Octeon CSR addresses
80  */
81 typedef struct {
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;
88
89 /**
90  * the structure for the cvmx_csr_db_fields[] array that
91  * holds all possible Octeon CSR fields
92  */
93 typedef struct {
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;
104
105 /**
106  * the structure for the cvmx_csr_db[] array that holds all
107  * possible Octeon CSR forms
108  */
109 typedef struct {
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;
117
118
119 /**
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.
123  */
124 extern const CVMX_CSR_DB_TYPE *cvmx_csr_db[];
125
126 /**
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.
130  */
131 extern const CVMX_CSR_DB_ADDRESS_TYPE *cvmx_csr_db_addresses[];
132
133 /**
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.
137  */
138 extern const CVMX_CSR_DB_FIELD_TYPE *cvmx_csr_db_fields[];
139
140 /**
141  * Figure out which database to use for this chip. The passed
142  * identifier can be a processor ID or a PCI ID.
143  *
144  * @param identifier processor ID or a PCI ID
145  *
146  * @return index into the csr db
147  */
148 extern int cvmx_db_get_chipindex(int identifier);
149
150 /**
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.
153  *
154  * @param identifier Identifer to choose the CSR DB with
155  * @param name       CSR name to lookup
156  *
157  * @return CSR DB entry or NULL on failure
158  */
159 extern const CVMX_CSR_DB_ADDRESS_TYPE *cvmx_csr_db_get(int identifier, const char *name);
160
161 /**
162  * Decode a CSR value into named bitfields. The model can either
163  * be specified as a processor id or PCI id.
164  *
165  * @param identifier Identifer to choose the CSR DB with
166  * @param address    CSR address being decoded
167  * @param value      Value to decode
168  */
169 extern void cvmx_csr_db_decode(int identifier, uint64_t address, uint64_t value);
170
171 /**
172  * Decode a CSR value into named bitfields. The model can either
173  * be specified as a processor id or PCI id.
174  *
175  * @param identifier Identifer to choose the CSR DB with
176  * @param name       CSR name to decode
177  * @param value      Value to decode
178  */
179 extern void cvmx_csr_db_decode_by_name(int identifier, const char *name, uint64_t value);
180
181 /**
182  * Print a list of csrs begimning with a prefix. The
183  * model can either be specified as a processor id or PCI id.
184  *
185  * @param identifier Identifer to choose the CSR DB with
186  * @param prefix     Beginning prefix to look for
187  */
188 extern void cvmx_csr_db_display_list(int identifier, const char *prefix);
189
190 #ifdef  __cplusplus
191 }
192 #endif
193
194 #endif