1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
3 * Copyright(c) 2015, 2016 Intel Corporation.
9 #define METADATA_TABLE_FIELD_START_SHIFT 0
10 #define METADATA_TABLE_FIELD_START_LEN_BITS 15
11 #define METADATA_TABLE_FIELD_LEN_SHIFT 16
12 #define METADATA_TABLE_FIELD_LEN_LEN_BITS 16
14 /* Header structure */
15 #define PLATFORM_CONFIG_HEADER_RECORD_IDX_SHIFT 0
16 #define PLATFORM_CONFIG_HEADER_RECORD_IDX_LEN_BITS 6
17 #define PLATFORM_CONFIG_HEADER_TABLE_LENGTH_SHIFT 16
18 #define PLATFORM_CONFIG_HEADER_TABLE_LENGTH_LEN_BITS 12
19 #define PLATFORM_CONFIG_HEADER_TABLE_TYPE_SHIFT 28
20 #define PLATFORM_CONFIG_HEADER_TABLE_TYPE_LEN_BITS 4
22 enum platform_config_table_type_encoding
{
23 PLATFORM_CONFIG_TABLE_RESERVED
,
24 PLATFORM_CONFIG_SYSTEM_TABLE
,
25 PLATFORM_CONFIG_PORT_TABLE
,
26 PLATFORM_CONFIG_RX_PRESET_TABLE
,
27 PLATFORM_CONFIG_TX_PRESET_TABLE
,
28 PLATFORM_CONFIG_QSFP_ATTEN_TABLE
,
29 PLATFORM_CONFIG_VARIABLE_SETTINGS_TABLE
,
30 PLATFORM_CONFIG_TABLE_MAX
33 enum platform_config_system_table_fields
{
34 SYSTEM_TABLE_RESERVED
,
35 SYSTEM_TABLE_NODE_STRING
,
36 SYSTEM_TABLE_SYSTEM_IMAGE_GUID
,
37 SYSTEM_TABLE_NODE_GUID
,
38 SYSTEM_TABLE_REVISION
,
39 SYSTEM_TABLE_VENDOR_OUI
,
40 SYSTEM_TABLE_META_VERSION
,
41 SYSTEM_TABLE_DEVICE_ID
,
42 SYSTEM_TABLE_PARTITION_ENFORCEMENT_CAP
,
43 SYSTEM_TABLE_QSFP_POWER_CLASS_MAX
,
44 SYSTEM_TABLE_QSFP_ATTENUATION_DEFAULT_12G
,
45 SYSTEM_TABLE_QSFP_ATTENUATION_DEFAULT_25G
,
46 SYSTEM_TABLE_VARIABLE_TABLE_ENTRIES_PER_PORT
,
50 enum platform_config_port_table_fields
{
53 PORT_TABLE_LOCAL_ATTEN_12G
,
54 PORT_TABLE_LOCAL_ATTEN_25G
,
55 PORT_TABLE_LINK_SPEED_SUPPORTED
,
56 PORT_TABLE_LINK_WIDTH_SUPPORTED
,
57 PORT_TABLE_AUTO_LANE_SHEDDING_ENABLED
,
58 PORT_TABLE_EXTERNAL_LOOPBACK_ALLOWED
,
61 PORT_TABLE_TX_LANE_ENABLE_MASK
,
62 PORT_TABLE_LOCAL_MAX_TIMEOUT
,
63 PORT_TABLE_REMOTE_ATTEN_12G
,
64 PORT_TABLE_REMOTE_ATTEN_25G
,
65 PORT_TABLE_TX_PRESET_IDX_ACTIVE_NO_EQ
,
66 PORT_TABLE_TX_PRESET_IDX_ACTIVE_EQ
,
67 PORT_TABLE_RX_PRESET_IDX
,
68 PORT_TABLE_CABLE_REACH_CLASS
,
72 enum platform_config_rx_preset_table_fields
{
73 RX_PRESET_TABLE_RESERVED
,
74 RX_PRESET_TABLE_QSFP_RX_CDR_APPLY
,
75 RX_PRESET_TABLE_QSFP_RX_EMP_APPLY
,
76 RX_PRESET_TABLE_QSFP_RX_AMP_APPLY
,
77 RX_PRESET_TABLE_QSFP_RX_CDR
,
78 RX_PRESET_TABLE_QSFP_RX_EMP
,
79 RX_PRESET_TABLE_QSFP_RX_AMP
,
83 enum platform_config_tx_preset_table_fields
{
84 TX_PRESET_TABLE_RESERVED
,
85 TX_PRESET_TABLE_PRECUR
,
87 TX_PRESET_TABLE_POSTCUR
,
88 TX_PRESET_TABLE_QSFP_TX_CDR_APPLY
,
89 TX_PRESET_TABLE_QSFP_TX_EQ_APPLY
,
90 TX_PRESET_TABLE_QSFP_TX_CDR
,
91 TX_PRESET_TABLE_QSFP_TX_EQ
,
95 enum platform_config_qsfp_attn_table_fields
{
96 QSFP_ATTEN_TABLE_RESERVED
,
97 QSFP_ATTEN_TABLE_TX_PRESET_IDX
,
98 QSFP_ATTEN_TABLE_RX_PRESET_IDX
,
102 enum platform_config_variable_settings_table_fields
{
103 VARIABLE_SETTINGS_TABLE_RESERVED
,
104 VARIABLE_SETTINGS_TABLE_TX_PRESET_IDX
,
105 VARIABLE_SETTINGS_TABLE_RX_PRESET_IDX
,
106 VARIABLE_SETTINGS_TABLE_MAX
109 struct platform_config
{
114 struct platform_config_data
{
121 * This struct acts as a quick reference into the platform_data binary image
122 * and is populated by parse_platform_config(...) depending on the specific
125 struct platform_config_cache
{
127 struct platform_config_data config_tables
[PLATFORM_CONFIG_TABLE_MAX
];
130 /* This section defines default values and encodings for the
131 * fields defined for each table above
135 * =====================================================
136 * System table encodings
137 * =====================================================
139 #define PLATFORM_CONFIG_MAGIC_NUM 0x3d4f5041
140 #define PLATFORM_CONFIG_MAGIC_NUMBER_LEN 4
143 * These power classes are the same as defined in SFF 8636 spec rev 2.4
144 * describing byte 129 in table 6-16, except enumerated in a different order
146 enum platform_config_qsfp_power_class_encoding
{
147 QSFP_POWER_CLASS_1
= 1,
157 * ====================================================
158 * Port table encodings
159 * ====================================================
161 enum platform_config_port_type_encoding
{
163 PORT_TYPE_DISCONNECTED
,
170 enum platform_config_link_speed_supported_encoding
{
171 LINK_SPEED_SUPP_12G
= 1,
173 LINK_SPEED_SUPP_12G_25G
,
178 * This is a subset (not strict) of the link downgrades
179 * supported. The link downgrades supported are expected
180 * to be supplied to the driver by another entity such as
183 enum platform_config_link_width_supported_encoding
{
184 LINK_WIDTH_SUPP_1X
= 1,
186 LINK_WIDTH_SUPP_2X_1X
,
188 LINK_WIDTH_SUPP_3X_1X
,
189 LINK_WIDTH_SUPP_3X_2X
,
190 LINK_WIDTH_SUPP_3X_2X_1X
,
192 LINK_WIDTH_SUPP_4X_1X
,
193 LINK_WIDTH_SUPP_4X_2X
,
194 LINK_WIDTH_SUPP_4X_2X_1X
,
195 LINK_WIDTH_SUPP_4X_3X
,
196 LINK_WIDTH_SUPP_4X_3X_1X
,
197 LINK_WIDTH_SUPP_4X_3X_2X
,
198 LINK_WIDTH_SUPP_4X_3X_2X_1X
,
202 enum platform_config_virtual_lane_capability_encoding
{
222 enum platform_config_mtu_capability_encoding
{
232 enum platform_config_local_max_timeout_encoding
{
233 LOCAL_MAX_TIMEOUT_10_MS
= 1,
234 LOCAL_MAX_TIMEOUT_100_MS
,
235 LOCAL_MAX_TIMEOUT_1_S
,
236 LOCAL_MAX_TIMEOUT_10_S
,
237 LOCAL_MAX_TIMEOUT_100_S
,
238 LOCAL_MAX_TIMEOUT_1000_S
241 enum link_tuning_encoding
{
248 * Shifts and masks for the link SI tuning values stuffed into the ASIC scratch
249 * registers for integrated platforms
251 #define PORT0_PORT_TYPE_SHIFT 0
252 #define PORT0_LOCAL_ATTEN_SHIFT 4
253 #define PORT0_REMOTE_ATTEN_SHIFT 10
254 #define PORT0_DEFAULT_ATTEN_SHIFT 32
256 #define PORT1_PORT_TYPE_SHIFT 16
257 #define PORT1_LOCAL_ATTEN_SHIFT 20
258 #define PORT1_REMOTE_ATTEN_SHIFT 26
259 #define PORT1_DEFAULT_ATTEN_SHIFT 40
261 #define PORT0_PORT_TYPE_MASK 0xFUL
262 #define PORT0_LOCAL_ATTEN_MASK 0x3FUL
263 #define PORT0_REMOTE_ATTEN_MASK 0x3FUL
264 #define PORT0_DEFAULT_ATTEN_MASK 0xFFUL
266 #define PORT1_PORT_TYPE_MASK 0xFUL
267 #define PORT1_LOCAL_ATTEN_MASK 0x3FUL
268 #define PORT1_REMOTE_ATTEN_MASK 0x3FUL
269 #define PORT1_DEFAULT_ATTEN_MASK 0xFFUL
271 #define PORT0_PORT_TYPE_SMASK (PORT0_PORT_TYPE_MASK << \
272 PORT0_PORT_TYPE_SHIFT)
273 #define PORT0_LOCAL_ATTEN_SMASK (PORT0_LOCAL_ATTEN_MASK << \
274 PORT0_LOCAL_ATTEN_SHIFT)
275 #define PORT0_REMOTE_ATTEN_SMASK (PORT0_REMOTE_ATTEN_MASK << \
276 PORT0_REMOTE_ATTEN_SHIFT)
277 #define PORT0_DEFAULT_ATTEN_SMASK (PORT0_DEFAULT_ATTEN_MASK << \
278 PORT0_DEFAULT_ATTEN_SHIFT)
280 #define PORT1_PORT_TYPE_SMASK (PORT1_PORT_TYPE_MASK << \
281 PORT1_PORT_TYPE_SHIFT)
282 #define PORT1_LOCAL_ATTEN_SMASK (PORT1_LOCAL_ATTEN_MASK << \
283 PORT1_LOCAL_ATTEN_SHIFT)
284 #define PORT1_REMOTE_ATTEN_SMASK (PORT1_REMOTE_ATTEN_MASK << \
285 PORT1_REMOTE_ATTEN_SHIFT)
286 #define PORT1_DEFAULT_ATTEN_SMASK (PORT1_DEFAULT_ATTEN_MASK << \
287 PORT1_DEFAULT_ATTEN_SHIFT)
289 #define QSFP_MAX_POWER_SHIFT 0
290 #define TX_NO_EQ_SHIFT 4
291 #define TX_EQ_SHIFT 25
294 #define QSFP_MAX_POWER_MASK 0xFUL
295 #define TX_NO_EQ_MASK 0x1FFFFFUL
296 #define TX_EQ_MASK 0x1FFFFFUL
297 #define RX_MASK 0xFFFFUL
299 #define QSFP_MAX_POWER_SMASK (QSFP_MAX_POWER_MASK << \
300 QSFP_MAX_POWER_SHIFT)
301 #define TX_NO_EQ_SMASK (TX_NO_EQ_MASK << TX_NO_EQ_SHIFT)
302 #define TX_EQ_SMASK (TX_EQ_MASK << TX_EQ_SHIFT)
303 #define RX_SMASK (RX_MASK << RX_SHIFT)
305 #define TX_PRECUR_SHIFT 0
306 #define TX_ATTN_SHIFT 4
307 #define QSFP_TX_CDR_APPLY_SHIFT 9
308 #define QSFP_TX_EQ_APPLY_SHIFT 10
309 #define QSFP_TX_CDR_SHIFT 11
310 #define QSFP_TX_EQ_SHIFT 12
311 #define TX_POSTCUR_SHIFT 16
313 #define TX_PRECUR_MASK 0xFUL
314 #define TX_ATTN_MASK 0x1FUL
315 #define QSFP_TX_CDR_APPLY_MASK 0x1UL
316 #define QSFP_TX_EQ_APPLY_MASK 0x1UL
317 #define QSFP_TX_CDR_MASK 0x1UL
318 #define QSFP_TX_EQ_MASK 0xFUL
319 #define TX_POSTCUR_MASK 0x1FUL
321 #define TX_PRECUR_SMASK (TX_PRECUR_MASK << TX_PRECUR_SHIFT)
322 #define TX_ATTN_SMASK (TX_ATTN_MASK << TX_ATTN_SHIFT)
323 #define QSFP_TX_CDR_APPLY_SMASK (QSFP_TX_CDR_APPLY_MASK << \
324 QSFP_TX_CDR_APPLY_SHIFT)
325 #define QSFP_TX_EQ_APPLY_SMASK (QSFP_TX_EQ_APPLY_MASK << \
326 QSFP_TX_EQ_APPLY_SHIFT)
327 #define QSFP_TX_CDR_SMASK (QSFP_TX_CDR_MASK << QSFP_TX_CDR_SHIFT)
328 #define QSFP_TX_EQ_SMASK (QSFP_TX_EQ_MASK << QSFP_TX_EQ_SHIFT)
329 #define TX_POSTCUR_SMASK (TX_POSTCUR_MASK << TX_POSTCUR_SHIFT)
331 #define QSFP_RX_CDR_APPLY_SHIFT 0
332 #define QSFP_RX_EMP_APPLY_SHIFT 1
333 #define QSFP_RX_AMP_APPLY_SHIFT 2
334 #define QSFP_RX_CDR_SHIFT 3
335 #define QSFP_RX_EMP_SHIFT 4
336 #define QSFP_RX_AMP_SHIFT 8
338 #define QSFP_RX_CDR_APPLY_MASK 0x1UL
339 #define QSFP_RX_EMP_APPLY_MASK 0x1UL
340 #define QSFP_RX_AMP_APPLY_MASK 0x1UL
341 #define QSFP_RX_CDR_MASK 0x1UL
342 #define QSFP_RX_EMP_MASK 0xFUL
343 #define QSFP_RX_AMP_MASK 0x3UL
345 #define QSFP_RX_CDR_APPLY_SMASK (QSFP_RX_CDR_APPLY_MASK << \
346 QSFP_RX_CDR_APPLY_SHIFT)
347 #define QSFP_RX_EMP_APPLY_SMASK (QSFP_RX_EMP_APPLY_MASK << \
348 QSFP_RX_EMP_APPLY_SHIFT)
349 #define QSFP_RX_AMP_APPLY_SMASK (QSFP_RX_AMP_APPLY_MASK << \
350 QSFP_RX_AMP_APPLY_SHIFT)
351 #define QSFP_RX_CDR_SMASK (QSFP_RX_CDR_MASK << QSFP_RX_CDR_SHIFT)
352 #define QSFP_RX_EMP_SMASK (QSFP_RX_EMP_MASK << QSFP_RX_EMP_SHIFT)
353 #define QSFP_RX_AMP_SMASK (QSFP_RX_AMP_MASK << QSFP_RX_AMP_SHIFT)
355 #define BITMAP_VERSION 1
356 #define BITMAP_VERSION_SHIFT 44
357 #define BITMAP_VERSION_MASK 0xFUL
358 #define BITMAP_VERSION_SMASK (BITMAP_VERSION_MASK << \
359 BITMAP_VERSION_SHIFT)
360 #define CHECKSUM_SHIFT 48
361 #define CHECKSUM_MASK 0xFFFFUL
362 #define CHECKSUM_SMASK (CHECKSUM_MASK << CHECKSUM_SHIFT)
365 void get_platform_config(struct hfi1_devdata
*dd
);
366 void free_platform_config(struct hfi1_devdata
*dd
);
367 void get_port_type(struct hfi1_pportdata
*ppd
);
368 int set_qsfp_tx(struct hfi1_pportdata
*ppd
, int on
);
369 void tune_serdes(struct hfi1_pportdata
*ppd
);
371 #endif /*__PLATFORM_H*/