aboutsummaryrefslogtreecommitdiff
path: root/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-config.h
blob: 6848fd687cbfd7234b1724bed9c5cdcfcaa1d113 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
/***********************license start***********************************
* Copyright (c) 2003-2017  Cavium Inc. (support@cavium.com). All rights
* reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*   * Redistributions of source code must retain the above copyright
*     notice, this list of conditions and the following disclaimer.
*
*   * Redistributions in binary form must reproduce the above
*     copyright notice, this list of conditions and the following
*     disclaimer in the documentation and/or other materials provided
*     with the distribution.
*
*   * Neither the name of Cavium Inc. nor the names of
*     its contributors may be used to endorse or promote products
*     derived from this software without specific prior written
*     permission.
*
* This Software, including technical data, may be subject to U.S. export
* control laws, including the U.S. Export Administration Act and its
* associated regulations, and may be subject to export or import
* regulations in other countries.
*
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
* AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
* WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT
* TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
* REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
* DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
* OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
* PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT,
* QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK
* ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
***********************license end**************************************/

/**
 * @file
 *
 * Functions for controlling the system configuration.
 *
 * <hr>$Revision: 49448 $<hr>
 *
 * @addtogroup hal
 * @{
 */

#define BDK_CONFIG_MANUFACTURING_ADDRESS 0xff0000 /* 16MB - 64KB */

typedef enum
{
    /* Board manufacturing data */
    BDK_CONFIG_BOARD_MODEL,         /* No parameters */
    BDK_CONFIG_BOARD_REVISION,      /* No parameters */
    BDK_CONFIG_BOARD_SERIAL,        /* No parameters */
    BDK_CONFIG_MAC_ADDRESS,         /* No parameters */
    BDK_CONFIG_MAC_ADDRESS_NUM,     /* No parameters */
    BDK_CONFIG_MAC_ADDRESS_NUM_OVERRIDE, /* No parameters */

    /* Board generic */
    BDK_CONFIG_BMC_TWSI,            /* No parameters */
    BDK_CONFIG_WATCHDOG_TIMEOUT,    /* No parameters */
    BDK_CONFIG_TWSI_WRITE,          /* Parameters: Write number */
    BDK_CONFIG_MDIO_WRITE,          /* Parameters: Write number */

    /* Board wiring of network ports and PHYs */
    BDK_CONFIG_PHY_ADDRESS,         /* Parameters: Node, Interface, Port */
    BDK_CONFIG_BGX_ENABLE,          /* Parameters: Node, BGX, Port */
    /* Non-EBB specific SFF8104 board and alike */
    BDK_CONFIG_AQUANTIA_PHY,        /* Parameters: Node, BGX, Port */

    /* BDK Configuration params */
    BDK_CONFIG_VERSION,
    BDK_CONFIG_NUM_PACKET_BUFFERS,
    BDK_CONFIG_PACKET_BUFFER_SIZE,
    BDK_CONFIG_SHOW_LINK_STATUS,
    BDK_CONFIG_COREMASK,
    BDK_CONFIG_BOOT_MENU_TIMEOUT,
    BDK_CONFIG_BOOT_PATH_OPTION,
    BDK_CONFIG_BOOT_NEXT_STAGE,
    BDK_CONFIG_TRACE,

    /* Chip feature items */
    BDK_CONFIG_MULTI_NODE,          /* No parameters */
    BDK_CONFIG_PCIE_EA,             /* No parameters */
    BDK_CONFIG_PCIE_ORDERING,       /* No parameters */
    BDK_CONFIG_PCIE_PRESET_REQUEST_VECTOR, /* Parameters: Node, Port */
    BDK_CONFIG_PCIE_WIDTH,          /* Parameters: Node, Port */
    BDK_CONFIG_PCIE_PHYSICAL_SLOT,  /* Parameters: Node, Port */
    BDK_CONFIG_PCIE_FLASH,          /* Parameters: Node, Port */
    BDK_CONFIG_CCPI_LANE_REVERSE,   /* No parameters */
    BDK_CONFIG_CHIP_SKU,            /* Parameter: Node */
    BDK_CONFIG_CHIP_SERIAL,         /* Parameter: Node */
    BDK_CONFIG_CHIP_UNIQUE_ID,      /* Parameter: Node */

    /* QLM related config */
    BDK_CONFIG_QLM_AUTO_CONFIG,     /* Parameters: Node */
    /* SFF8104 related QLM config */
    BDK_CONFIG_QLM_DIP_AUTO_CONFIG, /* Parameters: Node */
    BDK_CONFIG_QLM_MODE,            /* Parameters: Node, QLM */
    BDK_CONFIG_QLM_FREQ,            /* Parameters: Node, QLM */
    BDK_CONFIG_QLM_CLK,             /* Parameters: Node, QLM */
    BDK_CONFIG_QLM_TUNING_TX_SWING, /* Parameters: Node, QLM, Lane */
    BDK_CONFIG_QLM_TUNING_TX_PREMPTAP, /* Parameters: Node, QLM, Lane */
    BDK_CONFIG_QLM_TUNING_TX_GAIN,  /* Parameters: Node, QLM, Lane */
    BDK_CONFIG_QLM_TUNING_TX_VBOOST, /* Parameters: Node, QLM, Lane */
    BDK_CONFIG_QLM_CHANNEL_LOSS,    /* Parameters: Node, QLM */

    /* DRAM configuration options */
    BDK_CONFIG_DDR_SPEED,                                           /* Parameters: Node */
    BDK_CONFIG_DDR_ALT_REFCLK,                                      /* Parameters: Node */
    BDK_CONFIG_DDR_SPD_ADDR,                                        /* Parameters: DIMM, LMC, Node */
    BDK_CONFIG_DDR_SPD_DATA,                                        /* Parameters: DIMM, LMC, Node */
    BDK_CONFIG_DDR_RANKS_DQX_CTL,                                   /* Parameters: Num Ranks, Num DIMMs, LMC, Node */
    BDK_CONFIG_DDR_RANKS_WODT_MASK,                                 /* Parameters: Num Ranks, Num DIMMs, LMC, Node */
    BDK_CONFIG_DDR_RANKS_MODE1_PASR,                                /* Parameters: Num Ranks, Num DIMMs, Rank, LMC, Node */
    BDK_CONFIG_DDR_RANKS_MODE1_ASR,                                 /* Parameters: Num Ranks, Num DIMMs, Rank, LMC, Node */
    BDK_CONFIG_DDR_RANKS_MODE1_SRT,                                 /* Parameters: Num Ranks, Num DIMMs, Rank, LMC, Node */
    BDK_CONFIG_DDR_RANKS_MODE1_RTT_WR,                              /* Parameters: Num Ranks, Num DIMMs, Rank, LMC, Node */
    BDK_CONFIG_DDR_RANKS_MODE1_DIC,                                 /* Parameters: Num Ranks, Num DIMMs, Rank, LMC, Node */
    BDK_CONFIG_DDR_RANKS_MODE1_RTT_NOM,                             /* Parameters: Num Ranks, Num DIMMs, Rank, LMC, Node */
    BDK_CONFIG_DDR_RANKS_MODE1_DB_OUTPUT_IMPEDANCE,                 /* Parameters: Num Ranks, Num DIMMs, LMC, Node */
    BDK_CONFIG_DDR_RANKS_MODE2_RTT_PARK,                            /* Parameters: Num Ranks, Num DIMMs, Rank, LMC, Node */
    BDK_CONFIG_DDR_RANKS_MODE2_VREF_VALUE,                          /* Parameters: Num Ranks, Num DIMMs, Rank, LMC, Node */
    BDK_CONFIG_DDR_RANKS_MODE2_VREF_RANGE,                          /* Parameters: Num Ranks, Num DIMMs, Rank, LMC, Node */
    BDK_CONFIG_DDR_RANKS_MODE2_VREFDQ_TRAIN_EN,                     /* Parameters: Num Ranks, Num DIMMs, LMC, Node */
    BDK_CONFIG_DDR_RANKS_RODT_CTL,                                  /* Parameters: Num Ranks, Num DIMMs, LMC, Node */
    BDK_CONFIG_DDR_RANKS_RODT_MASK,                                 /* Parameters: Num Ranks, Num DIMMs, LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_MIN_RTT_NOM_IDX,                          /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_MAX_RTT_NOM_IDX,                          /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_MIN_RODT_CTL,                             /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_MAX_RODT_CTL,                             /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_CK_CTL,                                   /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_CMD_CTL,                                  /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_CTL_CTL,                                  /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_MIN_CAS_LATENCY,                          /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_OFFSET_EN,                                /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_OFFSET,                                   /* Parameters: Type(UDIMM,RDIMM), LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_RLEVEL_COMPUTE,                           /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_RLEVEL_COMP_OFFSET,                       /* Parameters: Type(UDIMM,RDIMM), LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_DDR2T,                                    /* Parameters: Type(UDIMM,RDIMM), LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_DISABLE_SEQUENTIAL_DELAY_CHECK,           /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_MAXIMUM_ADJACENT_RLEVEL_DELAY_INCREMENT,  /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_PARITY,                                   /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_FPRCH2,                                   /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_MODE32B,                                  /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_MEASURED_VREF,                            /* Parameters: LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_DLL_WRITE_OFFSET,                         /* Parameters: Byte, LMC, Node */
    BDK_CONFIG_DDR_CUSTOM_DLL_READ_OFFSET,                          /* Parameters: Byte, LMC, Node */

    /* High level DRAM options */
    BDK_CONFIG_DRAM_VERBOSE,        /* Parameters: Node */
    BDK_CONFIG_DRAM_BOOT_TEST,      /* Parameters: Node */
    BDK_CONFIG_DRAM_CONFIG_GPIO,    /* No parameters */
    BDK_CONFIG_DRAM_SCRAMBLE,       /* No parameters */

    /* USB */
    BDK_CONFIG_USB_PWR_GPIO,        /* Parameters: Node, Port */
    BDK_CONFIG_USB_PWR_GPIO_POLARITY, /* Parameters: Node, Port */
    BDK_CONFIG_USB_REFCLK_SRC, /* Parameters: Node, Port */

    /* Nitrox reset - For CN88XX SC and SNT part. High drives Nitrox DC_OK high */
    BDK_CONFIG_NITROX_GPIO,         /* Parameters: Node */

    /* How EYE diagrams are captured from a QLM */
    BDK_CONFIG_EYE_ZEROS,           /* No parameters */
    BDK_CONFIG_EYE_SAMPLE_TIME,     /* No parameters */
    BDK_CONFIG_EYE_SETTLE_TIME,     /* No parameters */

    /* SGPIO */
    BDK_CONFIG_SGPIO_SCLOCK_FREQ,   /* Parameters: Node */
    BDK_CONFIG_SGPIO_PIN_POWER,     /* Parameters: Node */
    BDK_CONFIG_SGPIO_PIN_SCLOCK,    /* Parameters: Node */
    BDK_CONFIG_SGPIO_PIN_SLOAD,     /* Parameters: Node */
    BDK_CONFIG_SGPIO_PIN_SDATAOUT,  /* Parameters: Node, Dataline */

    /* VRM temperature throttling */
    BDK_CONFIG_VRM_TEMP_TRIP,       /* Parameters: Node */
    BDK_CONFIG_VRM_TEMP_HIGH,       /* Parameters: Node */
    BDK_CONFIG_VRM_TEMP_LOW,        /* Parameters: Node */
    BDK_CONFIG_VRM_THROTTLE_NORMAL, /* Parameters: Node */
    BDK_CONFIG_VRM_THROTTLE_THERM,  /* Parameters: Node */

    /* Generic GPIO, unrelated to a specific block */
    BDK_CONFIG_GPIO_PIN_SELECT,     /* Parameters: GPIO, Node */
    BDK_CONFIG_GPIO_POLARITY,       /* Parameters: GPIO, Node */

    /* PBUS */
    BDK_CONFIG_PBUS_CFG,            /* Parameters: Region, Node */
    BDK_CONFIG_PBUS_TIM,            /* Parameters: Region, Node */

    /* Trusted boot information */
    BDK_CONFIG_TRUST_CSIB,          /* No parameters */
    BDK_CONFIG_TRUST_ROT_ADDR,      /* No parameters */
    BDK_CONFIG_TRUST_BSSK_ADDR,     /* No parameters */

    __BDK_CONFIG_END
} bdk_config_t;

/**
 * Internal BDK function to initialize the config system. Must be called before
 * any configuration functions are called
 */
extern void __bdk_config_init(void);

/**
 * Return a help string for the given configuration parameter
 *
 * @param cfg_item Configuration parameter to get help for
 *
 * @return Help string for the user
 */
extern const char *bdk_config_get_help(bdk_config_t cfg_item);

/**
 * Get an integer configuration item
 *
 * @param cfg_item  Config item to get. If the item takes parameters (see bdk_config_t), then the
 *                  parameters are listed following cfg_item.
 *
 * @return The value of the configuration item, or def_value if the item is not set
 */
extern int64_t bdk_config_get_int(bdk_config_t cfg_item, ...);

/**
 * Get a string configuration item
 *
 * @param cfg_item  Config item to get. If the item takes parameters (see bdk_config_t), then the
 *                  parameters are listed following cfg_item.
 *
 * @return The value of the configuration item, or def_value if the item is not set
 */
extern const char *bdk_config_get_str(bdk_config_t cfg_item, ...);

/**
 * Get a binary blob
 *
 * @param blob_size Integer to receive the size of the blob
 * @param cfg_item  Config item to get. If the item takes parameters (see bdk_config_t), then the
 *                  parameters are listed following cfg_item.
 *
 * @return The value of the configuration item, or def_value if the item is not set
 */
extern const void *bdk_config_get_blob(int *blob_size, bdk_config_t cfg_item, ...);

/**
 * Set an integer configuration item. Note this only sets the item in memory,
 * persistent storage is not updated. The optional parameters for the setting are
 * not supplied, meaning this function only changes the global default.
 *
 * @param value    Configuration item value
 * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the
 *                 parameters are listed following cfg_item.
 */
extern void bdk_config_set_int_no_param(int64_t value, bdk_config_t cfg_item);

/**
 * Set an integer configuration item. Note this only sets the item in memory,
 * persistent storage is not updated.
 *
 * @param value    Configuration item value
 * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the
 *                 parameters are listed following cfg_item.
 */
extern void bdk_config_set_int(int64_t value, bdk_config_t cfg_item, ...);

/**
 * Set an integer configuration item. Note this only sets the item in memory,
 * persistent storage is not updated.
 *
 * @param value    Configuration item value
 * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the
 *                 parameters are listed following cfg_item.
 */
extern void bdk_config_set_str(const char *value, bdk_config_t cfg_item, ...);

/**
 * Set a blob configuration item. Note this only sets the
 * item in memory, persistent storage is not updated. The optional
 * parameters for the setting are not supplied, meaning this function
 * only changes the global default.
 *
 * @param size     Size of the item in bytes. A size of zero removes the device tree field
 * @param value    Configuration item value
 * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the
 *                 parameters are listed following cfg_item.
 */
extern void bdk_config_set_blob_no_param(int size, const void *value, bdk_config_t cfg_item);

/**
 * Set a blob configuration item. Note this only sets the
 * item in memory, persistent storage is not updated.
 *
 * @param size     Size of the item in bytes. A size of zero removes the device tree field
 * @param value    Configuration item value
 * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the
 *                 parameters are listed following cfg_item.
 */
extern void bdk_config_set_blob(int size, const void *value, bdk_config_t cfg_item, ...);

/**
 * Display the active configuration
 */
extern void bdk_config_show(void);

/**
 * Display a list of all posssible config items with help text
 */
extern void bdk_config_help(void);

/**
 * Save the current configuration to flash
 *
 * @return Zero on success, negative on failure
 */
extern int bdk_config_save(void);

/**
 * Takes the current live device tree and exports it to a memory address suitable
 * for passing to the next binary in register X1.
 *
 * @return Physical address of the device tree, or 0 on failure
 */
extern uint64_t __bdk_config_export_to_mem(void);

/**
 * Return a pointer to the device tree used for configuration
 *
 * @return FDT or NULL on failure
 */
extern void* bdk_config_get_fdt(void);

/**
 * Set the device tree used for configuration
 *
 * @param fdt    Device tree to use. Memory is assumed to be from malloc() and bdk_config takes
 *               over ownership on success
 *
 * @return Zero on success, negative on failure
 */
extern int bdk_config_set_fdt(void *fdt);

/**
 * Write all default values to a FDT. Missing config items get defaults in the
 * BDK config, this function adds those defaults to the FDT. This way other code
 * gets the default value without needing special code.
 *
 * @param fdt    FDT structure to fill defaults into
 *
 * @return Zero on success, negative on failure
 */
extern int bdk_config_expand_defaults(void *fdt);

/** @} */