]> CyberLeo.Net >> Repos - FreeBSD/releng/8.2.git/blob - sys/contrib/octeon-sdk/cvmx-csr-db.h
Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.
[FreeBSD/releng/8.2.git] / sys / contrib / octeon-sdk / cvmx-csr-db.h
1 /***********************license start***************
2  *  Copyright (c) 2003-2008 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  *  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.
33  *
34  *
35  *  For any questions regarding licensing please contact marketing@caviumnetworks.com
36  *
37  ***********************license end**************************************/
38
39
40
41
42
43 #ifndef __CVMX_CSR_DB_H__
44 #define __CVMX_CSR_DB_H__
45
46 /**
47  * @file
48  * Interface for the Octeon CSR database.
49  *
50  *
51  * <hr>$Revision: 41586 $<hr>
52  *
53  */
54 #include "cvmx-platform.h"
55
56 #ifdef  __cplusplus
57 extern "C" {
58 #endif
59
60 typedef enum {
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;
71
72 /**
73  * the structure for the cvmx_csr_db_addresses[] array that
74  * holds all possible Octeon CSR addresses
75  */
76 typedef struct {
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;
83
84 /**
85  * the structure for the cvmx_csr_db_fields[] array that
86  * holds all possible Octeon CSR fields
87  */
88 typedef struct {
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;
99
100 /**
101  * the structure for the cvmx_csr_db[] array that holds all
102  * possible Octeon CSR forms
103  */
104 typedef struct {
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;
112
113
114 /**
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.
118  */
119 extern const CVMX_CSR_DB_TYPE *cvmx_csr_db[];
120
121 /**
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.
125  */
126 extern const CVMX_CSR_DB_ADDRESS_TYPE *cvmx_csr_db_addresses[];
127
128 /**
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.
132  */
133 extern const CVMX_CSR_DB_FIELD_TYPE *cvmx_csr_db_fields[];
134
135 /**
136  * Figure out which database to use for this chip. The passed
137  * identifier can be a processor ID or a PCI ID.
138  *
139  * @param identifier processor ID or a PCI ID
140  *
141  * @return index into the csr db
142  */
143 extern int cvmx_db_get_chipindex(int identifier);
144
145 /**
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.
148  *
149  * @param identifier Identifer to choose the CSR DB with
150  * @param name       CSR name to lookup
151  *
152  * @return CSR DB entry or NULL on failure
153  */
154 extern const CVMX_CSR_DB_ADDRESS_TYPE *cvmx_csr_db_get(int identifier, const char *name);
155
156 /**
157  * Decode a CSR value into named bitfields. The model can either
158  * be specified as a processor id or PCI id.
159  *
160  * @param identifier Identifer to choose the CSR DB with
161  * @param address    CSR address being decoded
162  * @param value      Value to decode
163  */
164 extern void cvmx_csr_db_decode(int identifier, uint64_t address, uint64_t value);
165
166 /**
167  * Print a list of csrs begimning with a prefix. The
168  * model can either be specified as a processor id or PCI id.
169  *
170  * @param identifier Identifer to choose the CSR DB with
171  * @param prefix     Beginning prefix to look for
172  */
173 extern void cvmx_csr_db_display_list(int identifier, const char *prefix);
174
175 #ifdef  __cplusplus
176 }
177 #endif
178
179 #endif