merlin16_internal.h (47271B)
1 /********************************************************************************** 2 ********************************************************************************** 3 * * 4 * Revision : * 5 * * 6 * Description : Internal API functions * 7 * * 8 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 9 * 10 * Copyright 2007-2019 Broadcom Inc. All rights reserved. * 11 * No portions of this material may be reproduced in any form without * 12 * the written permission of: * 13 * Broadcom Corporation * 14 * 5300 California Avenue * 15 * Irvine, CA 92617 * 16 * * 17 * All information contained in this document is Broadcom Corporation * 18 * company private proprietary, and trade secret. * 19 */ 20 21 /** @file merlin16_internal.h 22 * Internal API functions 23 */ 24 25 #ifndef MERLIN16_API_INTERNAL_H 26 #define MERLIN16_API_INTERNAL_H 27 28 #include "merlin16_ipconfig.h" 29 #include "merlin16_select_defns.h" 30 #include "common/srds_api_err_code.h" 31 #include "common/srds_api_uc_common.h" 32 #include "common/srds_api_types.h" 33 #include "merlin16_enum.h" 34 #include "merlin16_types.h" 35 #include "merlin16_usr_includes.h" 36 37 38 /*------------------------------*/ 39 /** Serdes OSR Mode Structure */ 40 /*------------------------------*/ 41 typedef struct { 42 /** TX OSR Mode */ 43 uint8_t tx; 44 /** RX OSR Mode */ 45 uint8_t rx; 46 /** OSR Mode for TX and RX (used when both TX and RX should have same OSR Mode) */ 47 uint8_t tx_rx; 48 }merlin16_osr_mode_st; 49 50 /*------------------------------*/ 51 /** Serdes Lane State Structure */ 52 /*------------------------------*/ 53 typedef struct { 54 /** uC lane configuration */ 55 uint16_t ucv_config; 56 /** uC lane status */ 57 uint8_t ucv_status; 58 /** Frequency offset of local reference clock with respect to RX data in ppm */ 59 int16_t rx_ppm; 60 /** Vertical threshold voltage of p1 slicer (mV) */ 61 int16_t p1_lvl; 62 /** Vertical threshold voltage of m1 slicer (mV) [Used to read out 'channel loss hint' in PAM4 mode] */ 63 int16_t m1_lvl; 64 /** Link time in milliseconds */ 65 uint16_t link_time; 66 /** OSR Mode */ 67 merlin16_osr_mode_st osr_mode; 68 /** Signal Detect */ 69 uint8_t sig_det; 70 /** Signal Detect Change */ 71 uint8_t sig_det_chg; 72 /** PMD RX Lock */ 73 uint8_t rx_lock; 74 /** PMD RX Lock Change */ 75 uint8_t rx_lock_chg; 76 /** Delay of zero crossing slicer, m1, wrt to data in PI codes */ 77 int8_t clk90; 78 /** Delay of diagnostic/lms slicer, p1, wrt to data in PI codes */ 79 int8_t clkp1; 80 /** Peaking Filter Main Settings */ 81 int8_t pf_main; 82 /** Peaking Filter Hiz mode enable */ 83 int8_t pf_hiz; 84 /** Low Frequency Peaking filter control */ 85 int8_t pf2_ctrl; 86 /** Variable Gain Amplifier settings */ 87 int8_t vga; 88 /** DC offset DAC control value */ 89 int8_t dc_offset; 90 /** P1 eyediag status */ 91 int8_t p1_lvl_ctrl; 92 /** DFE tap 1 value */ 93 int8_t dfe1; 94 /** DFE tap 2 value */ 95 int8_t dfe2; 96 /** DFE tap 3 value */ 97 int8_t dfe3; 98 /** DFE tap 4 value */ 99 int8_t dfe4; 100 /** DFE tap 5 value */ 101 int8_t dfe5; 102 /** DFE tap 6 value */ 103 int8_t dfe6; 104 /** DFE tap 1 Duty Cycle Distortion */ 105 int8_t dfe1_dcd; 106 /** DFE tap 2 Duty Cycle Distortion */ 107 int8_t dfe2_dcd; 108 /** Slicer calibration control codes (p1 even) */ 109 int8_t pe; 110 /** Slicer calibration control codes (data even) */ 111 int8_t ze; 112 /** Slicer calibration control codes (m1 even) */ 113 int8_t me; 114 /** Slicer calibration control codes (p1 odd) */ 115 int8_t po; 116 /** Slicer calibration control codes (data odd) */ 117 int8_t zo; 118 /** Slicer calibration control codes (m1 odd) */ 119 int8_t mo; 120 /** Frequency offset of local reference clock with respect to TX data in ppm */ 121 int16_t tx_ppm; 122 /** TX equalization FIR pre tap weight */ 123 int8_t txfir_pre; 124 /** TX equalization FIR main tap weight */ 125 int8_t txfir_main; 126 /** TX equalization FIR post1 tap weight */ 127 int8_t txfir_post1; 128 /** TX equalization FIR post2 tap weight */ 129 int8_t txfir_post2; 130 /** TX equalization FIR post3 tap weight */ 131 int8_t txfir_post3; 132 /** TX equalization FIR rpara tap weight */ 133 int8_t txfir_rpara; 134 /** Horizontal left eye margin @ 1e-5 as seen by internal diagnostic slicer in mUI and mV */ 135 uint16_t heye_left; 136 /** Horizontal right eye margin @ 1e-5 as seen by internal diagnostic slicer in mUI and mV */ 137 uint16_t heye_right; 138 /** Vertical upper eye margin @ 1e-5 as seen by internal diagnostic slicer in mUI and mV */ 139 uint16_t veye_upper; 140 /** Vertical lower eye margin @ 1e-5 as seen by internal diagnostic slicer in mUI and mV */ 141 uint16_t veye_lower; 142 /** Baud Rate Phase Detector enable */ 143 uint8_t br_pd_en; 144 /** lane_reset_state **/ 145 uint8_t reset_state; 146 /** lane_tx_reset_state **/ 147 uint8_t tx_reset_state; 148 /** uC stopped state **/ 149 uint8_t stop_state; 150 /** Sigdet offset correction - positive **/ 151 uint8_t soc_pos; 152 /** Sigdet offset correction - negative **/ 153 uint8_t soc_neg; 154 } merlin16_lane_state_st; 155 156 /*------------------------------*/ 157 /** Serdes Core State Structure */ 158 /*------------------------------*/ 159 typedef struct { 160 /** Core DP Reset State */ 161 uint8_t core_reset; 162 /** PLL Powerdown enable */ 163 uint8_t pll_pwrdn; 164 /** Micro active enable */ 165 uint8_t uc_active; 166 /** Comclk Frequency in Mhz */ 167 uint16_t comclk_mhz; 168 /** uCode Major Version number */ 169 uint16_t ucode_version; 170 /** uCode Minor Version number */ 171 uint8_t ucode_minor_version; 172 /** API Version number */ 173 uint32_t api_version; 174 /** AFE Hardware version */ 175 uint8_t afe_hardware_version; 176 /** uC Die Temperature Index */ 177 uint8_t temp_idx; 178 /** Average Die Temperature (13-bit format) */ 179 int16_t avg_tmon; 180 /** Analog Resistor Calibration value */ 181 uint8_t rescal; 182 /** VCO Rate in MHz */ 183 uint16_t vco_rate_mhz; 184 /** Analog VCO Range */ 185 uint8_t analog_vco_range; 186 /** PLL Divider value. (Same encoding as enum #merlin16_pll_div_enum.) */ 187 uint32_t pll_div; 188 /** PLL Lock */ 189 uint8_t pll_lock; 190 uint8_t pll_lock_chg; 191 /** Live die temperature in Celsius */ 192 int16_t die_temp; 193 /** Core Status Variable */ 194 uint8_t core_status; 195 } merlin16_core_state_st; 196 197 /**************************************************************************** 198 * @name Direct RAM Access 199 * 200 * Cores/chips with a built-in microcontroller afford direct, memory-mapped 201 * access to the firmware control/status RAM variables. 202 */ 203 /**@{*/ 204 205 206 /** Base of core variable block, MERLIN16 variant. */ 207 #define CORE_VAR_RAM_BASE (0x400) 208 /** Base of lane variable block, MERLIN16 variant. */ 209 #define LANE_VAR_RAM_BASE (0x500) 210 /** Size of lane variable block, MERLIN16 variant. */ 211 #define LANE_VAR_RAM_SIZE (0x100) 212 213 214 /**@}*/ 215 216 typedef struct { 217 uint32_t signature; 218 uint32_t diag_mem_ram_base; 219 uint32_t diag_mem_ram_size; 220 uint32_t core_var_ram_base; /* Must be the same as CORE_VAR_RAM_BASE */ 221 uint32_t core_var_ram_size; 222 uint32_t lane_var_ram_base; /* Must be the same as LANE_VAR_RAM_BASE */ 223 uint32_t lane_var_ram_size; /* Must be the same as LANE_VAR_RAM_SIZE */ 224 uint32_t trace_mem_ram_base; 225 uint32_t trace_mem_ram_size; 226 uint32_t micro_var_ram_base; 227 uint8_t lane_count; 228 uint8_t trace_memory_descending_writes; 229 uint8_t micro_count; 230 uint8_t micro_var_ram_size; 231 uint16_t grp_ram_size; 232 uint32_t ucode_version; 233 uint32_t valid; 234 } merlin16_info_t; 235 236 #define SRDS_INFO_SIGNATURE (0x50c1ab1e) 237 238 239 /** Retrieve the num_bits_per_ms useful for BER calculations 240 * There is some Error in the calculation because only VCO rate in Mhz is stored. 241 * @param sa__ is an opaque state vector passed through to device access functions. 242 * @param *num_bits_per_ms is pointer to uint64_t which is used to store the num_bits_per_ms 243 * @return Serdes Info pointer 244 */ 245 err_code_t merlin16_INTERNAL_get_num_bits_per_ms(srds_access_t *sa__, uint32_t *num_bits_per_ms); 246 247 /** Check PRBS status and print BER 248 * @param sa__ is an opaque state vector passed through to device access functions. 249 * @param time_ms is the amount of time to delay for BER calculation 250 * @return Serdes Info pointer 251 */ 252 err_code_t merlin16_INTERNAL_display_BER(srds_access_t *sa__, uint16_t time_ms); 253 254 /** Check PRBS status and print BER 255 * @param sa__ is an opaque state vector passed through to device access functions. 256 * @param time_ms is the amount of time to delay for BER calculation 257 * @param string is a pointer to char array of length >=10 in which to place string. 258 * @return Serdes Info pointer 259 */ 260 err_code_t merlin16_INTERNAL_get_BER_string(srds_access_t *sa__, uint16_t time_ms, char *string); 261 262 /** Check PRBS status and provide number of errors and number of bits for BER calculation 263 * @param sa__ is an opaque state vector passed through to device access functions. 264 * @param time_ms is the amount of time to delay for BER calculation 265 * @param ber_data is a struct that contains number of errors and number of bits as elements 266 * @return Error code, if generated (returns ERR_CODE_NONE if no errors) 267 */ 268 err_code_t merlin16_INTERNAL_get_BER_data(srds_access_t *sa__, uint16_t time_ms, struct ber_data_st *ber_data); 269 270 271 272 /** Get Serdes Info pointer 273 * @return Serdes Info pointer 274 */ 275 merlin16_info_t *merlin16_INTERNAL_get_merlin16_info_ptr(void); 276 277 /** Checks to see if the stored ucode_version in merlin16_info is matching with the current thread ucode 278 * @param sa__ is an opaque state vector passed through to device access functions. 279 * @return Error Code generated if uC does not become active (returns ERR_CODE_NONE if no errors) 280 */ 281 err_code_t merlin16_INTERNAL_match_ucode_from_info(srds_access_t *sa__); 282 283 /** Verify the internal merlin16_info. 284 * @param *test_info Info_table to be verified 285 * @param sa__ is an opaque state vector passed through to device access functions. 286 * @return Error code, if generated (returns ERR_CODE_NONE if no errors) 287 */ 288 err_code_t merlin16_INTERNAL_verify_merlin16_info(merlin16_info_t const *test_info, srds_access_t *sa__); 289 290 /** Read AFE HW Version. 291 * @param sa__ is an opaque state vector passed through to device access functions. 292 * @param *afe_hw_version AFE HW Version used 293 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 294 */ 295 err_code_t merlin16_INTERNAL_get_afe_hw_version(srds_access_t *sa__, uint8_t *afe_hw_version); 296 297 /** Check if the micro's operations on that lane are stopped. 298 * @param sa__ is an opaque state vector passed through to device access functions. 299 * @return err_code Error Code "ERR_CODE_UC_NOT_STOPPED" returned if micro NOT stopped 300 */ 301 err_code_t merlin16_INTERNAL_check_uc_lane_stopped(srds_access_t *sa__); 302 303 /** Calculate the mode_sel parameter for tx pattern generator. 304 * @param *mode_sel Mode select to be used for generating required pattern 305 * @param *zero_pad_len Length of zero padding to be used for generating required pattern 306 * @param patt_length Desired Pattern length 307 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 308 */ 309 err_code_t merlin16_INTERNAL_calc_patt_gen_mode_sel(uint8_t *mode_sel, uint8_t *zero_pad_len, uint8_t patt_length); 310 311 /*-----------------------------------------*/ 312 /* Write Core Config variables to uC RAM */ 313 /*-----------------------------------------*/ 314 315 /** Write to core_config uC RAM variable. 316 * @param sa__ is an opaque state vector passed through to device access functions. 317 * @param struct_val Value to be written into core_config RAM variable. 318 * (Note that struct_val.word must be = 0, only the fields are used) 319 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 320 */ 321 err_code_t merlin16_INTERNAL_set_uc_core_config(srds_access_t *sa__, struct merlin16_uc_core_config_st struct_val); 322 323 /*---------------------*/ 324 /* PLL Configuration */ 325 /*---------------------*/ 326 327 /** Return whether the fraction portion of a #merlin16_pll_div_enum value is nonzero. */ 328 #define SRDS_INTERNAL_IS_PLL_DIV_FRACTIONAL(div_) (((uint32_t)(div_) & 0xFFFFF000UL) != 0) 329 330 /** Extract the integer portion of a #merlin16_pll_div_enum value. */ 331 #define SRDS_INTERNAL_GET_PLL_DIV_INTEGER(div_) (((uint32_t)(div_)) & 0x00000FFFUL) 332 333 /** Extract the fraction portion of a #merlin16_pll_div_enum value. 334 * The result would be suitable for the numerator of a fraction whose denominator is 2^(width_). 335 * width_ must be less than 32. 336 */ 337 #define SRDS_INTERNAL_GET_PLL_DIV_FRACTION_NUM(div_, width_) \ 338 (((((uint32_t)(div_) & 0xFFFFF000UL) >> (32-(width_)-1)) + 1) >> 1) 339 340 /** Compose a value in the same format as a #merlin16_pll_div_enum value. 341 * (Though it's the same format, a U32 is used, because rounding may yield a non-enumerated result.) 342 * The fractional portion is fraction_num / (2^fraction_num_width_). 343 * fraction_num_width_ must be 32 or less. 344 */ 345 #define SRDS_INTERNAL_COMPOSE_PLL_DIV(integer_, fraction_num_, fraction_num_width_) \ 346 (((uint32_t)(integer_) & 0xFFFUL) \ 347 | ((((((uint32_t)(fraction_num_) << (32-(fraction_num_width_))) >> (32-20-1)) + 1) >> 1) << 12)) 348 349 350 /** Resolve PLL parameters. 351 * PLL configuration requires two out of the three parameters: refclk frequency, divider value, and VCO output frequency. 352 * @param refclk Reference clock frequency (enumerated), or MERLIN16_PLL_REFCLK_UNKNOWN to auto-compute. 353 * @param *refclk_freq_hz Resultant reference clock frequency, in Hz. 354 * @param *div Divider value (enumerated), or MERLIN16_PLL_DIV_UNKNOWN to auto-compute. 355 * The final divider value will be filled in if MERLIN16_PLL_DIV_UNKNOWN. 356 * @param *vco_freq_khz VCO output frequency, in kHz, or 0 to auto-compute. 357 * The final VCO output frequency will be filled in if 0. 358 * @param pll_option Select PLL configuration option from enum #merlin16_pll_option_enum. 359 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 360 */ 361 err_code_t merlin16_INTERNAL_resolve_pll_parameters(enum merlin16_pll_refclk_enum refclk, 362 uint32_t *refclk_freq_hz, 363 enum merlin16_pll_div_enum *div, 364 uint32_t *vco_freq_khz, 365 enum merlin16_pll_option_enum pll_option); 366 367 /** Configure PLL. 368 * 369 * Use core_s_rstb to re-initialize all registers to default before calling this function. 370 * 371 * Configures PLL registers to obtain the required configuration. 372 * PLL configuration requires two out of the three parameters: refclk frequency, divider value, and VCO output frequency. 373 * @param sa__ is an opaque state vector passed through to device access functions. 374 * @param refclk Reference clock frequency (enumerated), or MERLIN16_PLL_REFCLK_UNKNOWN to auto-compute. 375 * @param div Divider value (enumerated), or MERLIN16_PLL_DIV_UNKNOWN to auto-compute. 376 * @param vco_freq_khz VCO output frequency, in kHz, or 0 to auto-compute. 377 * @param pll_option Select PLL configuration option from enum #merlin16_pll_option_enum. 378 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 379 */ 380 381 err_code_t merlin16_INTERNAL_configure_pll(srds_access_t *sa__, 382 enum merlin16_pll_refclk_enum refclk, 383 enum merlin16_pll_div_enum div, 384 uint32_t vco_freq_khz, 385 enum merlin16_pll_option_enum pll_option); 386 387 388 /** Read the programmed PLL div value from the SERDES. 389 * Due to rounding when writing the div value to the PLL, 390 * the returned result may be slightly different from what was written. 391 * @param sa__ is an opaque state vector passed through to device access functions. 392 * @param *div Divider value, in the same encoding as enum #merlin16_pll_div_enum. 393 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 394 */ 395 err_code_t merlin16_INTERNAL_read_pll_div(srds_access_t *sa__, uint32_t *div); 396 397 /** Convert the PLL_DIV to actual PLL divider value and display 398 * as part of merlin16_display_core_state_line() 399 * @param sa__ is an opaque state vector passed through to device access functions. 400 * @param div Divider value, in the same encoding as enum #merlin16_pll_div_enum. 401 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 402 */ 403 err_code_t merlin16_INTERNAL_display_pll_to_divider(srds_access_t *sa__, uint32_t div); 404 405 /** Get the VCO frequency in kHz, based on the reference clock frequency and divider value 406 * @param refclk_freq_hz Reference clock frequency, in Hz. 407 * @param div Divider value, in the same encoding as enum #merlin16_pll_div_enum. 408 * @param *vco_freq_khz VCO output frequency, in kHz, obtained based on reference clock frequency and dic value 409 * @param pll_option Select PLL configuration option from enum #merlin16_pll_option_enum. 410 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 411 */ 412 err_code_t merlin16_INTERNAL_get_vco_from_refclk_div(uint32_t refclk_freq_hz, enum merlin16_pll_div_enum div, uint32_t *vco_freq_khz, enum merlin16_pll_option_enum pll_option); 413 414 415 /*-------------------*/ 416 /* Ladder controls */ 417 /*-------------------*/ 418 /** Converts a ladder setting to mV, given the range. 419 * @param sa__ is an opaque state vector passed through to device access functions. 420 * @param ctrl is the threshold control (-31..31) maps to -RANGE to RANGE in non-uniform steps 421 * @param range_250 determines the range 0 = +/-150mV, 1 = +/-250mV 422 * @return ladder threshold voltage in mV 423 */ 424 int16_t merlin16_INTERNAL_ladder_setting_to_mV(srds_access_t *sa__, int8_t ctrl, uint8_t range_250); 425 426 /** Get the P1 slicer vertical level. 427 * @param sa__ is an opaque state vector passed through to device access functions. 428 * @param *val 8 bit signed value 429 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 430 */ 431 err_code_t merlin16_INTERNAL_get_p1_threshold(srds_access_t *sa__, int8_t *val); 432 433 434 /*-----------------------*/ 435 /* TX_PI and ULL Setup */ 436 /*-----------------------*/ 437 438 /** Safe multiply - multiplies 2 numbers and checks for overflow. 439 * @param a First input 440 * @param b Second input 441 * @param *of Pointer to overflow indicator 442 * @return value of a * b 443 */ 444 uint32_t merlin16_INTERNAL_mult_with_overflow_check(uint32_t a, uint32_t b, uint8_t *of); 445 446 /*-----------------------------------------*/ 447 /* APIs used in Config Shared TX Pattern */ 448 /*-----------------------------------------*/ 449 450 /** Compute Binary string for a Hex value ['0' to 'F']. 451 * @param var Hex value to be converted to Binary (eg: '6', 'A', ...) 452 * @param bin Binary string returned by API (eg: '0110', '1010', ...) 453 * @return Error Code generated by invalid hex variable (returns ERR_CODE_NONE if no errors) 454 */ 455 err_code_t merlin16_INTERNAL_compute_bin(char var, char bin[]); 456 457 /** Compute Hex value for a Binary string ['0000' to '1111']. 458 * @param bin Binary string to be coverted (eg: '0110', '1010', ...) 459 * @param *hex Hex value calculated from the input Binary string 460 * @return Error Code generated by invalid Binary string (returns ERR_CODE_NONE if no errors) 461 */ 462 err_code_t merlin16_INTERNAL_compute_hex(char bin[], uint8_t *hex); 463 464 /** Check micro state and request micro to stop 465 * @param sa__ is an opaque state vector passed through to device access functions. 466 * @param graceful select the method for stopping (1=graceful stop; 0=Immediate) 467 * @param *err_code_p pointer to err_code variable which will be returned. 468 */ 469 uint8_t merlin16_INTERNAL_stop_micro(srds_access_t *sa__, uint8_t graceful, err_code_t *err_code_p); 470 /*-----------------------------------*/ 471 /* APIs used in Read Event Logger */ 472 /*-----------------------------------*/ 473 474 /* State variable for dumping event log. 475 * This must be initialized with zeros. 476 */ 477 typedef struct { 478 uint16_t index, line_start_index; 479 } merlin16_INTERNAL_event_log_dump_state_t; 480 481 /** Callback function for dumping event log, intended to be called by merlin16_INTERNAL_read_event_log_with_callback. 482 * It must also be called once after, with a byte count of 0, to finish printing. 483 * @param *arg is a merlin16_INTERNAL_event_log_dump_state_t pointer for holding state. 484 * @param byte_count is the number of bytes to dump. 485 * -# This function is called repeatedly with a byte count of 2 with U16 values to dump. 486 * -# This function may then be called with a byte count of 1 if the event log has an odd number of bytes. 487 * -# Finally, this function must be called with a byte count of 0 to finish up. 488 * @param data is the event log data to dump. 489 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 490 */ 491 err_code_t merlin16_INTERNAL_event_log_dump_callback(void *arg, uint8_t byte_count, uint16_t data); 492 493 /** Get Event Log from uC, and call callback for every two bytes. 494 * @param sa__ is an opaque state vector passed through to device access functions. 495 * @param micro_num is the number of the microcontroller whose event log should be read. 496 * @param bypass_micro is 1 if the micro should not be involved (by stopping event log). 497 * This mode works even when the micro is hung, and it does not consume the event log. 498 * @param *arg is passed as the first argument to callback 499 * @param *callback is called with all of the data read, two bytes at a time. 500 * The last call of callback may have one byte; in that case, the upper byte is undefined. 501 * The call is in the form: callback(arg, byte_count, data) 502 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 503 */ 504 err_code_t merlin16_INTERNAL_read_event_log_with_callback(srds_access_t *sa__, 505 uint8_t micro_num, 506 uint8_t bypass_micro, 507 void *arg, 508 err_code_t (*callback)(void *, uint8_t, uint16_t)); 509 510 /** Convert float8 to usigned int32. 511 * uint32 = 1.XXX * 2^Y where float8 bits are XXXYYYYY 512 * @param input Float8 number 513 * @return Usigned 32bit number 514 */ 515 uint32_t merlin16_INTERNAL_float8_to_int32(float8_t input); 516 517 518 519 #ifdef TO_FLOATS 520 /*-----------------------------------*/ 521 /* APIs used in uC data conversion */ 522 /*-----------------------------------*/ 523 524 /** Convert usigned int32 to float8. 525 * uint32 = 1.XXX * 2^Y where float8 bits are XXXYYYYY 526 * @param input Unsigned int 527 * @return Float8 8 bit representations of 32bit number 528 */ 529 float8_t merlin16_INTERNAL_int32_to_float8(uint32_t input); 530 #endif 531 532 /** Convert float12 to usigned int32. 533 * uint32 = XXXXXXXX * 2^YYYY where float12 bits X=byte and Y=multi 534 * @param byte Float8 8bit 535 * @param multi 4 bit multipier 536 * @return Usigned 32bit number 537 */ 538 uint32_t merlin16_INTERNAL_float12_to_uint32(uint8_t byte, uint8_t multi); 539 540 #ifdef TO_FLOATS 541 /** Convert usigned int32 to float12. 542 * uint32 = XXXXXXXX * 2^YYYY where float12 bits X=byte and Y=multi 543 * @param input Unsigned int32 544 * @param *multi Pointer to byte and the multiplier is returned 545 * @return Float12 8 bit representations of 32bit number 546 */ 547 uint8_t merlin16_INTERNAL_uint32_to_float12(uint32_t input, uint8_t *multi); 548 #endif 549 550 /*-----------------------------*/ 551 /* Read / Display Core state */ 552 /*-----------------------------*/ 553 /** Read current merlin16 core status. 554 * @param sa__ is an opaque state vector passed through to device access functions. 555 * @param *istate Current merlin16 core status read back and populated by the API 556 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 557 */ 558 err_code_t merlin16_INTERNAL_read_core_state(srds_access_t *sa__, merlin16_core_state_st *istate); 559 560 561 /** Display current core state. 562 * Reads and displays all important core state values. 563 * @param sa__ is an opaque state vector passed through to device access functions. 564 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 565 */ 566 err_code_t merlin16_INTERNAL_display_core_state_no_newline(srds_access_t *sa__); 567 568 /*-----------------------------*/ 569 /* Read / Display Lane state */ 570 /*-----------------------------*/ 571 /** Read current merlin16 lane status. 572 * @param sa__ is an opaque state vector passed through to device access functions. 573 * @param *istate Current merlin16 lane status read back and populated by the API 574 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 575 */ 576 err_code_t merlin16_INTERNAL_read_lane_state(srds_access_t *sa__, merlin16_lane_state_st *istate); 577 578 579 /*-----------------*/ 580 /* Get OSR mode */ 581 /*-----------------*/ 582 /** Read current merlin16 lane status. 583 * @param sa__ is an opaque state vector passed through to device access functions. 584 * @param *mode Returns with the osr mode structure 585 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 586 */ 587 err_code_t merlin16_INTERNAL_get_osr_mode(srds_access_t *sa__, merlin16_osr_mode_st *mode); 588 589 590 /*-------------------*/ 591 /* Get LCK status */ 592 /*-------------------*/ 593 /** Read current PMD Lock and PMD Lock change status of a lane. 594 * @param sa__ is an opaque state vector passed through to device access functions. 595 * @param *pmd_lock Current merlin16 lane pmd_rx_lock status read back and populated by the API 596 * @param *pmd_lock_chg Current merlin16 lane pmd_rx_lock_change status read back and populated by the API 597 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 598 */ 599 err_code_t merlin16_INTERNAL_pmd_lock_status(srds_access_t *sa__, uint8_t *pmd_lock, uint8_t *pmd_lock_chg); 600 601 /** Read current Signal_detect and Signal_detect change status of a lane. 602 * @param sa__ is an opaque state vector passed through to device access functions. 603 * @param *sig_det Current merlin16 lane signal_detect status read back and populated by the API 604 * @param *sig_det_chg Current merlin16 lane signal_detect_change status read back and populated by the API 605 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 606 */ 607 err_code_t merlin16_INTERNAL_sigdet_status(srds_access_t *sa__, uint8_t *sig_det, uint8_t *sig_det_chg); 608 609 /** Read current PLL Lock and PLL Lock change status of a core. 610 * @param sa__ is an opaque state vector passed through to device access functions. 611 * @param *pll_lock Current merlin16 lane pll_lock status read back and populated by the API 612 * @param *pll_lock_chg Current merlin16 lane pll_lock_change status read back and populated by the API 613 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 614 */ 615 err_code_t merlin16_INTERNAL_pll_lock_status(srds_access_t *sa__, uint8_t *pll_lock, uint8_t *pll_lock_chg); 616 617 /** Display current lane state. 618 * Reads and displays all important lane state values. 619 * @param sa__ is an opaque state vector passed through to device access functions. 620 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 621 */ 622 err_code_t merlin16_INTERNAL_display_lane_state_no_newline(srds_access_t *sa__); 623 624 /*-----------------------------------------------*/ 625 /* Get dynamic eye margin estimation values */ 626 /*-----------------------------------------------*/ 627 /** Get dynamic eye estimation values 628 * Reads and converts the Eye margin estimation from the uC. 629 * @param sa__ is an opaque state vector passed through to device access functions. 630 * @param *left_eye_mUI a pointer to integer with return value of eye margin in units of mUI 631 * @param *right_eye_mUI a pointer to integer with return value of eye margin in units of mUI 632 * @param *upper_eye_mV a pointer to integer with return value of eye margin in units of mV 633 * @param *lower_eye_mV a pointer to integer with return value of eye margin in units of mV 634 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 635 */ 636 err_code_t merlin16_INTERNAL_get_eye_margin_est(srds_access_t *sa__, uint16_t *left_eye_mUI, uint16_t *right_eye_mUI, uint16_t *upper_eye_mV, uint16_t *lower_eye_mV); 637 638 /** Convert eye margin to mV. 639 * Takes in the ladder setting with 3 fractional bits and converts to mV. 640 * @param sa__ is an opaque state vector passed through to device access functions. 641 * @param var Ladder setting with 3 fractional bits 642 * @param ladder_range Specified if ladder is configured for 150mV or 250mV range 643 * @return Eye opening in mV 644 */ 645 uint16_t merlin16_INTERNAL_eye_to_mV(srds_access_t *sa__, uint8_t var, uint8_t ladder_range); 646 647 /** Convert eye margin to mUI. 648 * Takes in a horizontal margin in Phase Interpolator codes and converts it to mUI. 649 * @param sa__ is an opaque state vector passed through to device access functions. 650 * @param var Horizontal margin in Phase Interpolator codes with 3 fractional bits 651 * @return Eye opening in mV 652 */ 653 uint16_t merlin16_INTERNAL_eye_to_mUI(srds_access_t *sa__, uint8_t var); 654 655 /** Serdes Core ClockGate. 656 * Along with merlin16_core_clkgate(), all lanes should also be clock gated using merlin16_lane_clkgate() to complete a Core Clockgate 657 * @param sa__ is an opaque state vector passed through to device access functions. 658 * @param enable Enable clockgate (1 = Enable clokgate; 0 = Disable clockgate) 659 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 660 */ 661 err_code_t merlin16_INTERNAL_core_clkgate(srds_access_t *sa__, uint8_t enable); 662 663 /** Serdes Lane ClockGate. 664 * @param sa__ is an opaque state vector passed through to device access functions. 665 * @param enable Enable lane clockgate (1 = Enable clockgate; 0 = Disable clockgate) 666 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 667 */ 668 err_code_t merlin16_INTERNAL_lane_clkgate(srds_access_t *sa__, uint8_t enable); 669 670 /*--------------------*/ 671 /* Get/Set PF status */ 672 /*--------------------*/ 673 /** Set function for PF. 674 * @param sa__ is an opaque state vector passed through to device access functions. 675 * @param val Signed input value 676 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 677 */ 678 err_code_t merlin16_INTERNAL_set_rx_pf_main(srds_access_t *sa__, uint8_t val); 679 680 /** Get function for PF 681 * @param sa__ is an opaque state vector passed through to device access functions. 682 * @param *val PF read value 683 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 684 */ 685 err_code_t merlin16_INTERNAL_get_rx_pf_main(srds_access_t *sa__, int8_t *val); 686 687 /** Set function for PF2. 688 * @param sa__ is an opaque state vector passed through to device access functions. 689 * @param val signed input value 690 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 691 */ 692 err_code_t merlin16_INTERNAL_set_rx_pf2(srds_access_t *sa__, uint8_t val); 693 694 /** Get function for PF2. 695 * @param sa__ is an opaque state vector passed through to device access functions. 696 * @param *val PF2 read value 697 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 698 */ 699 err_code_t merlin16_INTERNAL_get_rx_pf2(srds_access_t *sa__, int8_t *val); 700 701 702 703 /*-------------------*/ 704 /* Get/Set VGA/DFE */ 705 /*-------------------*/ 706 /** Set function for VGA. 707 * @param sa__ is an opaque state vector passed through to device access functions. 708 * @param val signed input value 709 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 710 */ 711 err_code_t merlin16_INTERNAL_set_rx_vga(srds_access_t *sa__, uint8_t val); 712 713 /** Get function for VGA. 714 * @param sa__ is an opaque state vector passed through to device access functions. 715 * @param *val VGA read value 716 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 717 */ 718 err_code_t merlin16_INTERNAL_get_rx_vga(srds_access_t *sa__, int8_t *val); 719 720 721 /** Set function for DFE Tap1. 722 * @param sa__ is an opaque state vector passed through to device access functions. 723 * @param val signed input value 724 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 725 */ 726 err_code_t merlin16_INTERNAL_set_rx_dfe1(srds_access_t *sa__, int8_t val); 727 728 /** Get function for DFE Tap1. 729 * @param sa__ is an opaque state vector passed through to device access functions. 730 * @param *val DFE1 read value 731 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 732 */ 733 err_code_t merlin16_INTERNAL_get_rx_dfe1(srds_access_t *sa__, int8_t *val); 734 735 /** Set function for DFE Tap2. 736 * @param sa__ is an opaque state vector passed through to device access functions. 737 * @param val signed input value 738 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 739 */ 740 err_code_t merlin16_INTERNAL_set_rx_dfe2(srds_access_t *sa__, int8_t val); 741 742 /** Get function for DFE Tap2. 743 * @param sa__ is an opaque state vector passed through to device access functions. 744 * @param *val DFE2 read value 745 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 746 */ 747 err_code_t merlin16_INTERNAL_get_rx_dfe2(srds_access_t *sa__, int8_t *val); 748 749 /** Set function for DFE Tap3. 750 * @param sa__ is an opaque state vector passed through to device access functions. 751 * @param val signed input value 752 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 753 */ 754 err_code_t merlin16_INTERNAL_set_rx_dfe3(srds_access_t *sa__, int8_t val); 755 756 /** Get function for DFE Tap3. 757 * @param sa__ is an opaque state vector passed through to device access functions. 758 * @param *val DFE3 read value 759 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 760 */ 761 err_code_t merlin16_INTERNAL_get_rx_dfe3(srds_access_t *sa__, int8_t *val); 762 763 /** Set function for DFE Tap4. 764 * @param sa__ is an opaque state vector passed through to device access functions. 765 * @param val signed input value 766 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 767 */ 768 err_code_t merlin16_INTERNAL_set_rx_dfe4(srds_access_t *sa__, int8_t val); 769 770 /** Get function for DFE Tap4. 771 * @param sa__ is an opaque state vector passed through to device access functions. 772 * @param *val DFE4 read value 773 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 774 */ 775 err_code_t merlin16_INTERNAL_get_rx_dfe4(srds_access_t *sa__, int8_t *val); 776 777 /** Set function for DFE Tap5. 778 * @param sa__ is an opaque state vector passed through to device access functions. 779 * @param val signed input value 780 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 781 */ 782 err_code_t merlin16_INTERNAL_set_rx_dfe5(srds_access_t *sa__, int8_t val); 783 784 /** Get function for DFE Tap5 785 * @param sa__ is an opaque state vector passed through to device access functions. 786 * @param *val DFE5 read value 787 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 788 */ 789 err_code_t merlin16_INTERNAL_get_rx_dfe5(srds_access_t *sa__, int8_t *val); 790 791 792 /*----------------------*/ 793 /* Get/Set TXFIR Taps */ 794 /*----------------------*/ 795 err_code_t merlin16_INTERNAL_get_tx_pre(srds_access_t *sa__, int8_t *val); 796 err_code_t merlin16_INTERNAL_get_tx_main(srds_access_t *sa__, int8_t *val); 797 err_code_t merlin16_INTERNAL_get_tx_post1(srds_access_t *sa__, int8_t *val); 798 err_code_t merlin16_INTERNAL_get_tx_post2(srds_access_t *sa__, int8_t *val); 799 800 /* Lane Config Struct */ 801 err_code_t merlin16_INTERNAL_update_uc_lane_config_st(struct merlin16_uc_lane_config_st *st); 802 err_code_t merlin16_INTERNAL_update_uc_lane_config_word(struct merlin16_uc_lane_config_st *st); 803 804 /* Lane User Control Disable Startup Function Struct */ 805 err_code_t merlin16_INTERNAL_update_usr_ctrl_disable_functions_st(struct merlin16_usr_ctrl_disable_functions_st *st); 806 err_code_t merlin16_INTERNAL_update_usr_ctrl_disable_functions_byte(struct merlin16_usr_ctrl_disable_functions_st *st); 807 808 /* Lane User Control Disable Startup DFE Function Struct */ 809 err_code_t merlin16_INTERNAL_update_usr_ctrl_disable_dfe_functions_st(struct merlin16_usr_ctrl_disable_dfe_functions_st *st); 810 err_code_t merlin16_INTERNAL_update_usr_ctrl_disable_dfe_functions_byte(struct merlin16_usr_ctrl_disable_dfe_functions_st *st); 811 812 /* Core Config Struct */ 813 err_code_t merlin16_INTERNAL_update_uc_core_config_st(struct merlin16_uc_core_config_st *st); 814 err_code_t merlin16_INTERNAL_update_uc_core_config_word(struct merlin16_uc_core_config_st *st); 815 816 uint8_t merlin16_INTERNAL_rdb_uc_var(srds_access_t *sa__, err_code_t *err_code_p, uint16_t addr); 817 uint16_t merlin16_INTERNAL_rdw_uc_var(srds_access_t *sa__, err_code_t *err_code_p, uint16_t addr); 818 err_code_t merlin16_INTERNAL_wrb_uc_var(srds_access_t *sa__, uint16_t addr, uint8_t wr_val); 819 err_code_t merlin16_INTERNAL_wrw_uc_var(srds_access_t *sa__, uint16_t addr, uint16_t wr_val); 820 821 /*--------------------------*/ 822 /* Register field polling */ 823 /*--------------------------*/ 824 825 err_code_t merlin16_INTERNAL_print_uc_dsc_error(srds_access_t *sa__, enum srds_pmd_uc_cmd_enum cmd); 826 827 /** Polls lane variable "usr_diag_status" to verify data is available in uC diag buffer. 828 * Define macro CUSTOM_REG_POLLING to replace the default implementation provided in merlin16_internal.c. 829 * 830 * @param sa__ is an opaque state vector passed through to device access functions. 831 * @param *status returns a status byte \n 832 * bit 15 - indicates the ey scan is complete \n 833 * bit 14-0 - reserved for debug 834 * 835 * @param timeout_ms Maximum time interval in milliseconds for which the polling is done 836 * @return Error code generated by polling function (returns ERR_CODE_NONE if no errors) 837 */ 838 err_code_t merlin16_INTERNAL_poll_diag_done(srds_access_t *sa__, uint16_t *status, uint32_t timeout_ms); 839 840 /** Polls for register field "uc_dsc_ready_for_cmd" to be 1 within the time interval specified by timeout_ms. 841 * Function returns 0 if polling passes, else it returns error code. 842 * Define macro CUSTOM_REG_POLLING to replace the default implementation provided in merlin16_internal.c. 843 * @param sa__ is an opaque state vector passed through to device access functions. 844 * @param timeout_ms Maximum time interval in milliseconds for which the polling is done 845 * @param cmd The command that was issued; this is used for error reporting. 846 * @return Error code generated by polling function (returns ERR_CODE_NONE if no errors) 847 */ 848 err_code_t merlin16_INTERNAL_poll_uc_dsc_ready_for_cmd_equals_1(srds_access_t *sa__, uint32_t timeout_ms, enum srds_pmd_uc_cmd_enum cmd); 849 850 /** Polls for register field "dsc_state" to be "DSC_STATE_UC_TUNE" 851 * within the time interval specified by timeout_ms. 852 * Function returns 0 if polling passes, else it returns error code. 853 * Define macro CUSTOM_REG_POLLING to replace the default implementation provided in merlin16_internal.c. 854 * @param sa__ is an opaque state vector passed through to device access functions. 855 * @param timeout_ms Maximum time interval in milliseconds for which the polling is done 856 * @return Error code generated by polling function (returns ERR_CODE_NONE if no errors) 857 */ 858 err_code_t merlin16_INTERNAL_poll_dsc_state_equals_uc_tune(srds_access_t *sa__, uint32_t timeout_ms); 859 860 /** Polls for register field "st_afe_tx_fifo_resetb" to be 1 within the time interval specified by timeout_ms. 861 * Function returns 0 if polling passes, else it returns error code. 862 * Define macro CUSTOM_REG_POLLING to replace the default implementation provided in merlin16_internal.c. 863 * @param sa__ is an opaque state vector passed through to device access functions. 864 * @param timeout_ms Maximum time interval in milliseconds for which the polling is done 865 * @return Error code generated by polling function (returns ERR_CODE_NONE if no errors) 866 */ 867 err_code_t merlin16_INTERNAL_poll_st_afe_tx_fifo_resetb_equals_1(srds_access_t *sa__, uint32_t timeout_ms); 868 869 /** Polls for register field "micro_ra_initdone" to be 1 within the time interval specified by timeout_ms. 870 * Function returns 0 if polling passes, else it returns error code. 871 * Define macro CUSTOM_REG_POLLING to replace the default implementation provided in merlin16_internal.c. 872 * @param sa__ is an opaque state vector passed through to device access functions. 873 * @param timeout_ms Maximum time interval in milliseconds for which the polling is done 874 * @return Error code generated by polling function (returns ERR_CODE_NONE if no errors) 875 */ 876 err_code_t merlin16_INTERNAL_poll_micro_ra_initdone(srds_access_t *sa__, uint32_t timeout_ms); 877 878 879 /*--------------------------------*/ 880 /* RAM Block Read with Callback */ 881 /*--------------------------------*/ 882 883 /* Utility to account for endianness when reading from uc RAM */ 884 int merlin16_INTERNAL_get_endian_offset(uint8_t *addr); 885 886 typedef struct { 887 uint8_t *mem_ptr; 888 } merlin16_INTERNAL_rdblk_callback_arg_t; 889 890 /** Callback function for reading uc RAM memory by merlin16_INTERNAL_rdblk_uc_generic_ram(). 891 * @param *arg is a merlin16_INTERNAL_rdblk_callback_arg_t pointer for holding state. 892 * @param byte_count is the number of bytes to store. 893 * -# This function is called repeatedly with a byte count of 2 with U16 values to store. 894 * -# This function may then be called with a byte count of 1 if there are an odd number of bytes. 895 * @param data is the RAM data to store. 896 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 897 */ 898 err_code_t merlin16_INTERNAL_rdblk_callback(void *arg, uint8_t byte_count, uint16_t data); 899 900 /** Block RAM read through Micro Register Interface, suitable for program RAM or non-program RAM. 901 * This reads a block of RAM, possibly starting midway through it and wrapping back to the beginning. 902 * The order of operations is: 903 * -# RAM will be read from (block_addr+start_offset) to (block_addr+block_size-1), 904 * up to cnt bytes. 905 * -# RAM will be read from block_addr to (block_addr+block_size-1), repeating 906 * indefinitely, until cnt bytes total are read. 907 * @param sa__ is an opaque state vector passed through to device access functions. 908 * @param block_addr Address of RAM block to be read. 909 * For program RAM, the upper 16 bits are 0x0000. Otherwise, the upper 16 bits are 0x2000. 910 * @param block_size Length of RAM block to read. 911 * @param start_offset Offset within RAM block to start reading 912 * @param cnt Number of bytes to be read 913 * @param *arg is passed as the first argument to callback 914 * @param *callback is called with all of the data read, two bytes at a time. 915 * The last call of callback may have one byte; in that case, the upper byte is undefined. 916 * The call is in the form: callback(arg, byte_count, data) 917 * @return Error Code generated by API or the callback (returns ERR_CODE_NONE if no errors) 918 */ 919 err_code_t merlin16_INTERNAL_rdblk_uc_generic_ram(srds_access_t *sa__, 920 uint32_t block_addr, 921 uint16_t block_size, 922 uint16_t start_offset, 923 uint16_t cnt, 924 void *arg, 925 err_code_t (*callback)(void *, uint8_t, uint16_t)); 926 927 /** Block RAM read through Micro Register Interface, suitable for program RAM or non-program RAM. 928 * This reads a block of RAM, possibly starting midway through it and wrapping back to the beginning. 929 * The order of operations is: 930 * -# RAM will be read from (block_addr+start_offset) down to block_addr, up to cnt bytes. 931 * -# RAM will be read from (block_addr+block_size-1) down to block_addr, repeating 932 * indefinitely, until cnt bytes total are read. 933 * In other words, this is the same as merlin16_INTERNAL_rdblk_uc_generic_ram(), but reading in descending address order. 934 * @param sa__ is an opaque state vector passed through to device access functions. 935 * @param block_addr Address of RAM block to be read. 936 * For program RAM, the upper 16 bits are 0x0000. Otherwise, the upper 16 bits are 0x2000. 937 * @param block_size Length of RAM block to read. 938 * @param start_offset Offset within RAM block to start reading 939 * @param cnt Number of bytes to be read 940 * @param *arg is passed as the first argument to callback 941 * @param *callback is called with all of the data read, two bytes at a time. 942 * The last call of callback may have one byte; in that case, the upper byte is undefined. 943 * The call is in the form: callback(arg, byte_count, data) 944 * @return Error Code generated by API or the callback (returns ERR_CODE_NONE if no errors) 945 */ 946 err_code_t merlin16_INTERNAL_rdblk_uc_generic_ram_descending(srds_access_t *sa__, 947 uint32_t block_addr, 948 uint16_t block_size, 949 uint16_t start_offset, 950 uint16_t cnt, 951 void *arg, 952 err_code_t (*callback)(void *, uint8_t, uint16_t)); 953 954 /** Retrieve micro index based on lane index. 955 * @param lane Lane index 956 * @return Micro index 957 */ 958 uint8_t merlin16_INTERNAL_grp_idx_from_lane(uint8_t lane); 959 960 961 962 /** Extract the refclk frequency in Hz, based on a merlin16_pll_refclk_enum value. */ 963 err_code_t _merlin16_get_refclk_in_hz(enum merlin16_pll_refclk_enum refclk, uint32_t *refclk_in_hz); 964 965 /** Retrieve LMS threshold value. */ 966 967 /*-------------------*/ 968 /* Name resolution */ 969 /*-------------------*/ 970 971 /* For bitfields that differ for different cores, these macros are defined to resolve the bitfield. */ 972 973 #if defined(wr_rx_pf_ctrl) 974 # define WR_RX_PF_CTRL wr_rx_pf_ctrl 975 # define RD_RX_PF_CTRL rd_rx_pf_ctrl 976 # define WR_RX_PF2_CTRL wr_rx_pf2_ctrl 977 # define RD_RX_PF2_CTRL rd_rx_pf2_ctrl 978 #elif defined(wr_rx_pf_ctrl_val) 979 # define WR_RX_PF_CTRL wr_rx_pf_ctrl_val 980 # define RD_RX_PF_CTRL rd_rx_pf_ctrl_val 981 # define WR_RX_PF2_CTRL wr_rx_pf2_ctrl_val 982 # define RD_RX_PF2_CTRL rd_rx_pf2_ctrl_val 983 #elif defined(wr_pf_ctrl) 984 # define WR_RX_PF_CTRL wr_pf_ctrl 985 # define RD_RX_PF_CTRL rd_pf_ctrl 986 # define WR_RX_PF2_CTRL wr_pf2_lowp_ctrl 987 # define RD_RX_PF2_CTRL rd_pf2_lowp_ctrl 988 #else 989 # error "Could not find write to pf_ctrl bitfield." 990 #endif 991 992 #if defined(reg_rd_TLB_RX_RXPRBS_CHK_ERR_CNT_MSB_STATUS) 993 # define REG_RD_TLB_RX_PRBS_CHK_ERR_CNT_MSB_STATUS reg_rd_TLB_RX_RXPRBS_CHK_ERR_CNT_MSB_STATUS 994 # define REG_RD_TLB_RX_PRBS_CHK_ERR_CNT_LSB_STATUS reg_rd_TLB_RX_RXPRBS_CHK_ERR_CNT_LSB_STATUS 995 #elif defined(reg_rd_TLB_RX_PRBS_CHK_ERR_CNT_MSB_STATUS) 996 # define REG_RD_TLB_RX_PRBS_CHK_ERR_CNT_MSB_STATUS reg_rd_TLB_RX_PRBS_CHK_ERR_CNT_MSB_STATUS 997 # define REG_RD_TLB_RX_PRBS_CHK_ERR_CNT_LSB_STATUS reg_rd_TLB_RX_PRBS_CHK_ERR_CNT_LSB_STATUS 998 #else 999 # error "Could not find PRBS_CHK_ERR_CNT_MSB_STATUS." 1000 #endif 1001 1002 #endif