blackhawk_tsc_internal.h (56993B)
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 blackhawk_tsc_internal.h 22 * Internal API functions 23 */ 24 25 #ifndef BLACKHAWK_TSC_API_INTERNAL_H 26 #define BLACKHAWK_TSC_API_INTERNAL_H 27 28 #include "blackhawk_tsc_ipconfig.h" 29 #include "blackhawk_tsc_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 "blackhawk_tsc_enum.h" 34 #include "blackhawk_tsc_types.h" 35 #include "blackhawk_tsc_usr_includes.h" 36 #include "blackhawk_tsc_prbs.h" 37 38 #ifdef SERDES_MULTI_INFO_TABLE_EN 39 /* 40 * In order to support coexistence of A0 and B0 variants of same IP, and still be able to use same API sources 41 * we need to populate info_tables for both a0 and b0 ondemand. The decision of using A0 info_table or other is based on a 42 * hardware version register value, which is 0xA0 for A0 hardware. 43 */ 44 # define A0_VERSION_ID (0xA0) 45 # define NUM_SERDES_INFO_TABLES (2) 46 #else 47 # define NUM_SERDES_INFO_TABLES (1) 48 #endif 49 50 #define CHECK_AND_RETURN_IF_NULL(__arg1__, __ret_val__) \ 51 if (__arg1__ == NULL) { \ 52 EFUN_PRINTF(("ERROR: %s Invalid %s \n", API_FUNCTION_NAME, #__arg1__));\ 53 return __ret_val__; \ 54 } 55 56 /*--------------------------*/ 57 /** Serdes RX PAM Mode Enum */ 58 /*--------------------------*/ 59 enum blackhawk_tsc_rx_pam_mode_enum { 60 NRZ, 61 PAM4_NS, 62 PAM4_ES 63 }; 64 65 /*---------------------------------------*/ 66 /** Serdes prbs chk timer selection Enum */ 67 /*---------------------------------------*/ 68 enum blackhawk_tsc_prbs_chk_timer_selection_enum { 69 USE_HW_TIMERS = 0, 70 USE_SW_TIMERS = 1 71 }; 72 73 /*------------------------------*/ 74 /** Serdes OSR Mode Structure */ 75 /*------------------------------*/ 76 typedef struct { 77 /** TX OSR Mode */ 78 uint8_t tx; 79 /** RX OSR Mode */ 80 uint8_t rx; 81 /** OSR Mode for TX and RX (used when both TX and RX should have same OSR Mode) */ 82 uint8_t tx_rx; 83 }blackhawk_tsc_osr_mode_st; 84 85 /*------------------------------*/ 86 /** Serdes Lane State Structure */ 87 /*------------------------------*/ 88 typedef struct { 89 /** uC lane configuration */ 90 uint16_t ucv_config; 91 /** uC lane status */ 92 uint8_t ucv_status; 93 /** Frequency offset of local reference clock with respect to RX data in ppm */ 94 int16_t rx_ppm; 95 /** Vertical threshold voltage of p1 slicer (mV) */ 96 int16_t p1_lvl; 97 /** Vertical threshold voltage of m1 slicer (mV) [Used to read out 'channel loss hint' in PAM4 mode] */ 98 int16_t m1_lvl; 99 /** blind ctle ctrl */ 100 uint8_t blind_ctle_ctrl; 101 /** blind_ctle_trnsum */ 102 int16_t blind_ctle_trnsum; 103 /** Tuning Parameter 2 */ 104 uint8_t afe_bw; 105 /** afe_bw_metric */ 106 int16_t afe_bw_metric; 107 /** Tuning parameter 3 */ 108 int8_t usr_status_eq_debug1; 109 /** TP metric prec1 */ 110 int8_t tp_metric_prec1; 111 /** Link time in milliseconds */ 112 uint16_t link_time; 113 /** OSR Mode */ 114 blackhawk_tsc_osr_mode_st osr_mode; 115 /** Signal Detect */ 116 uint8_t sig_det; 117 /** Signal Detect Change */ 118 uint8_t sig_det_chg; 119 /** PMD RX Lock */ 120 uint8_t rx_lock; 121 /** PMD RX Lock Change */ 122 uint8_t rx_lock_chg; 123 /** Delay of zero crossing slicer, m1, wrt to data in PI codes */ 124 int8_t clk90; 125 /** Delay of diagnostic/lms slicer, p1, wrt to data in PI codes */ 126 int8_t clkp1; 127 /** Peaking Filter Main Settings */ 128 int8_t pf_main; 129 /** Peaking Filter Hiz mode enable */ 130 int8_t pf_hiz; 131 /** Low Frequency Peaking filter control */ 132 int8_t pf2_ctrl; 133 /** High Frequency Peaking filter control */ 134 int8_t pf3_ctrl; 135 /** BW Reduction control */ 136 int8_t bwr_ctrl; 137 /** Variable Gain Amplifier settings */ 138 int8_t vga; 139 /** DC offset DAC control value */ 140 int8_t dc_offset; 141 /** P1 eyediag status */ 142 int8_t p1_lvl_ctrl; 143 /** DFE tap 1 value */ 144 int8_t dfe1; 145 /** DFE tap 2 value */ 146 int8_t dfe2; 147 /** DFE tap 3 value */ 148 int8_t dfe3; 149 /** DFE tap 4 value */ 150 int8_t dfe4; 151 /** DFE tap 5 value */ 152 int8_t dfe5; 153 /** DFE tap 6 value */ 154 int8_t dfe6; 155 /** DFE tap 1 Duty Cycle Distortion */ 156 int8_t dfe1_dcd; 157 /** DFE tap 2 Duty Cycle Distortion */ 158 int8_t dfe2_dcd; 159 /** RX PAM4 Mode */ 160 uint8_t rx_pam_mode; 161 /** Frequency offset of local reference clock with respect to TX data in ppm */ 162 int16_t tx_ppm; 163 /** TX Precoder Enable */ 164 uint8_t tx_prec_en; 165 /** TX Link Training Enable */ 166 uint8_t linktrn_en; 167 /** TX equalization FIR tap range */ 168 uint8_t txfir_use_pam4_range; 169 /** TX equalization FIR tap weights */ 170 blackhawk_tsc_txfir_st txfir; 171 /** Horizontal left eye margin @ 1e-5 as seen by internal diagnostic slicer in mUI and mV */ 172 uint16_t heye_left; 173 /** Horizontal right eye margin @ 1e-5 as seen by internal diagnostic slicer in mUI and mV */ 174 uint16_t heye_right; 175 /** Vertical upper eye margin @ 1e-5 as seen by internal diagnostic slicer in mUI and mV */ 176 uint16_t veye_upper; 177 /** Vertical lower eye margin @ 1e-5 as seen by internal diagnostic slicer in mUI and mV */ 178 uint16_t veye_lower; 179 /** Baud Rate Phase Detector enable */ 180 uint8_t br_pd_en; 181 /** lane_reset_state **/ 182 uint8_t reset_state; 183 /** lane_tx_reset_state **/ 184 uint8_t tx_reset_state; 185 /** uC stopped state **/ 186 uint8_t stop_state; 187 /** Selected PLL index for TX **/ 188 uint8_t tx_pll_select; 189 /** Selected PLL index for RX **/ 190 uint8_t rx_pll_select; 191 /** Sigdet offset correction - positive **/ 192 uint8_t soc_pos; 193 /** Sigdet offset correction - negative **/ 194 uint8_t soc_neg; 195 } blackhawk_tsc_lane_state_st; 196 197 /*------------------------------*/ 198 /** Serdes Core State Structure */ 199 /*------------------------------*/ 200 typedef struct { 201 /** Core DP Reset State */ 202 uint8_t core_reset; 203 /** PLL Powerdown enable */ 204 uint8_t pll_pwrdn; 205 /** Micro active enable */ 206 uint8_t uc_active; 207 /** Comclk Frequency in Mhz */ 208 uint16_t comclk_mhz; 209 /** uCode Major Version number */ 210 uint16_t ucode_version; 211 /** uCode Minor Version number */ 212 uint8_t ucode_minor_version; 213 /** API Version number */ 214 uint32_t api_version; 215 /** AFE Hardware version */ 216 uint8_t afe_hardware_version; 217 /** uC Die Temperature Index */ 218 uint8_t temp_idx; 219 /** Average Die Temperature (13-bit format) */ 220 int16_t avg_tmon; 221 /** Analog Resistor Calibration value */ 222 uint8_t rescal; 223 /** VCO Rate in MHz */ 224 uint16_t vco_rate_mhz; 225 /** Analog VCO Range */ 226 uint8_t analog_vco_range; 227 /** PLL Divider value. (Same encoding as enum #blackhawk_tsc_pll_div_enum.) */ 228 uint32_t pll_div; 229 /** PLL Lock */ 230 uint8_t pll_lock; 231 /** PLL Lock Change */ 232 uint8_t pll_lock_chg; 233 /** Live die temperature in Celsius */ 234 int16_t die_temp; 235 /** Core Status Variable */ 236 uint8_t core_status; 237 /** Refclk doubler enable */ 238 uint8_t refclk_doubler; 239 /** PLL comparator threshold */ 240 int16_t pll_comp_thresh; 241 } blackhawk_tsc_core_state_st; 242 243 /**************************************************************************** 244 * @name Direct RAM Access 245 * 246 * Cores/chips with a built-in microcontroller afford direct, memory-mapped 247 * access to the firmware control/status RAM variables. 248 */ 249 /**@{*/ 250 251 252 /**@}*/ 253 254 255 #define SRDS_INFO_SIGNATURE (0x50c1ab1e) 256 257 /* SW Limits for TXFIR Taps in PAM4 mode */ 258 #define TXFIR_PAM4_SW_TAP_MIN (-170) 259 #define TXFIR_PAM4_SW_TAP_MAX ( 170) 260 #define TXFIR_PAM4_SW_SUM_LIMIT ( 170) 261 262 /** Retrieve the num_bits_per_ms useful for BER calculations 263 * There is some Error in the calculation because only VCO rate in Mhz is stored. 264 * @param sa__ is an opaque state vector passed through to device access functions. 265 * @param *num_bits_per_ms is pointer to uint64_t which is used to store the num_bits_per_ms 266 * @return Serdes Info pointer 267 */ 268 err_code_t blackhawk_tsc_INTERNAL_get_num_bits_per_ms(srds_access_t *sa__, uint32_t *num_bits_per_ms); 269 270 /** Check PRBS status and print BER 271 * @param sa__ is an opaque state vector passed through to device access functions. 272 * @param time_ms is the amount of time to delay for BER calculation 273 * @return Serdes Info pointer 274 */ 275 err_code_t blackhawk_tsc_INTERNAL_display_BER(srds_access_t *sa__, uint16_t time_ms); 276 277 /** Check PRBS status and print BER 278 * @param sa__ is an opaque state vector passed through to device access functions. 279 * @param time_ms is the amount of time to delay for BER calculation 280 * @param string is a pointer to char array of length >=10 in which to place string. 281 * @return Serdes Info pointer 282 */ 283 err_code_t blackhawk_tsc_INTERNAL_get_BER_string(srds_access_t *sa__, uint16_t time_ms, char *string); 284 285 /** Check PRBS status and provide number of errors and number of bits for BER calculation 286 * @param sa__ is an opaque state vector passed through to device access functions 287 * @param time_ms is the amount of time to delay for BER calculation 288 * @param ber_data is a struct that contains number of errors and number of bits as elements 289 * @param timer_sel allows to measure BER using host computer time instead of using hardware timers 290 * @return Error code, if generated (returns ERR_CODE_NONE if no errors) 291 */ 292 err_code_t blackhawk_tsc_INTERNAL_get_BER_data(srds_access_t *sa__, uint16_t time_ms, struct ber_data_st *ber_data, enum blackhawk_tsc_prbs_chk_timer_selection_enum timer_sel); 293 294 #define PRBS_MAX_HW_TIMER_TIMEOUT 448 295 #define PRBS_HW_LUT_MAX_MINUS_1 384 296 #define PRBS_MAX_TIMER_SETTING 31 297 #define PRBS_CHK_EN_TIMER_MODE_1US 0x2 298 #define PRBS_CHK_EN_TIMER_MODE_1MS 0x3 299 300 /** Get timeout register value from time in ms value 301 * @param time_ms is the amount of time to delay for BER calculation requested by a user 302 * @param time_ms_adjusted is the amount of time to delay for BER calculation available by design (>= time_ms) 303 * @param *prbs_chk_hw_timer_ctrl Structure to store PRBS checker's hardware timers configuration 304 * @return Error code, if generated (returns ERR_CODE_NONE if no errors) 305 */ 306 err_code_t blackhawk_tsc_INTERNAL_get_prbs_timeout_count_from_time(uint16_t time_ms, uint16_t * time_ms_adjusted, struct prbs_chk_hw_timer_ctrl_st * const prbs_chk_hw_timer_ctrl) ; 307 308 309 /** Find out if IP is a B0 version 310 * @param sa__ is an opaque state vector passed through to devide access functions. 311 * @param i_am_b0 is the variable that will be set by this function is IP is B0, else it will be 0. 312 * @return Error code, if generated (returns ERR_CODE_NONE if no errors) 313 */ 314 err_code_t blackhawk_tsc_INTERNAL_ip_version_check(srds_access_t *sa__, uint8_t * i_am_b0); 315 /** Get Serdes Info pointer 316 * @param sa__ is an opaque state vector passed through to device access functions. 317 * @return Serdes Info pointer 318 */ 319 srds_info_t *blackhawk_tsc_INTERNAL_get_blackhawk_tsc_info_ptr(srds_access_t *sa__); 320 321 /** Get Serdes Info pointer and initialize it if signature doesn't match 322 * @param sa__ is an opaque state vector passed through to device access functions. 323 * @return Serdes Info pointer 324 */ 325 srds_info_t *blackhawk_tsc_INTERNAL_get_blackhawk_tsc_info_ptr_with_check(srds_access_t *sa__); 326 327 /** Checks to see if the stored ucode_version in blackhawk_tsc_info is matching with the current thread ucode 328 * @param sa__ is an opaque state vector passed through to device access functions. 329 * @return Error Code generated if uC does not become active (returns ERR_CODE_NONE if no errors) 330 */ 331 err_code_t blackhawk_tsc_INTERNAL_match_ucode_from_info(srds_access_t *sa__); 332 333 /** Verify the internal blackhawk_tsc_info. 334 * @param *blackhawk_tsc_info_ptr Info_table to be verified 335 * @param sa__ is an opaque state vector passed through to device access functions. 336 * @return Error code, if generated (returns ERR_CODE_NONE if no errors) 337 */ 338 err_code_t blackhawk_tsc_INTERNAL_verify_blackhawk_tsc_info(srds_info_t *blackhawk_tsc_info_ptr, srds_access_t *sa__); 339 340 341 /** Check if the micro's operations on that lane are stopped. 342 * @param sa__ is an opaque state vector passed through to device access functions. 343 * @return err_code Error Code "ERR_CODE_UC_NOT_STOPPED" returned if micro NOT stopped 344 */ 345 err_code_t blackhawk_tsc_INTERNAL_check_uc_lane_stopped(srds_access_t *sa__); 346 347 /** Calculate the mode_sel parameter for tx pattern generator. 348 * @param sa__ is an opaque state vector passed through to device access functions. 349 * @param *mode_sel Mode select to be used for generating required pattern 350 * @param *zero_pad_len Length of zero padding to be used for generating required pattern 351 * @param patt_length Desired Pattern length 352 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 353 */ 354 err_code_t blackhawk_tsc_INTERNAL_calc_patt_gen_mode_sel(srds_access_t *sa__, uint8_t *mode_sel, uint8_t *zero_pad_len, uint8_t patt_length); 355 356 /*-----------------------------------------*/ 357 /* Write Core Config variables to uC RAM */ 358 /*-----------------------------------------*/ 359 360 /** Write to core_config uC RAM variable. 361 * @param sa__ is an opaque state vector passed through to device access functions. 362 * @param struct_val Value to be written into core_config RAM variable. 363 * (Note that struct_val.word must be = 0, only the fields are used) 364 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 365 */ 366 err_code_t blackhawk_tsc_INTERNAL_set_uc_core_config(srds_access_t *sa__, struct blackhawk_tsc_uc_core_config_st struct_val); 367 368 /*---------------------*/ 369 /* PLL Configuration */ 370 /*---------------------*/ 371 372 /** Return whether the fraction portion of a #blackhawk_tsc_pll_div_enum value is nonzero. */ 373 #define SRDS_INTERNAL_IS_PLL_DIV_FRACTIONAL(div_) (((uint32_t)(div_) & 0xFFFFF000UL) != 0) 374 375 /** Extract the integer portion of a #blackhawk_tsc_pll_div_enum value. */ 376 #define SRDS_INTERNAL_GET_PLL_DIV_INTEGER(div_) (((uint32_t)(div_)) & 0x00000FFFUL) 377 378 /** Extract the fraction portion of a #blackhawk_tsc_pll_div_enum value. 379 * The result would be suitable for the numerator of a fraction whose denominator is 2^(width_). 380 * width_ must be less than 32. 381 */ 382 #define SRDS_INTERNAL_GET_PLL_DIV_FRACTION_NUM(div_, width_) \ 383 (((((uint32_t)(div_) & 0xFFFFF000UL) >> (32-(width_)-1)) + 1) >> 1) 384 385 /** Compose a value in the same format as a #blackhawk_tsc_pll_div_enum value. 386 * (Though it's the same format, a U32 is used, because rounding may yield a non-enumerated result.) 387 * The fractional portion is fraction_num / (2^fraction_num_width_). 388 * fraction_num_width_ must be 32 or less. 389 */ 390 #define SRDS_INTERNAL_COMPOSE_PLL_DIV(integer_, fraction_num_, fraction_num_width_) \ 391 (((uint32_t)(integer_) & 0xFFFUL) \ 392 | ((((((uint32_t)(fraction_num_) << (32-(fraction_num_width_))) >> (32-20-1)) + 1) >> 1) << 12)) 393 394 395 /** Resolve PLL parameters. 396 * PLL configuration requires two out of the three parameters: refclk frequency, divider value, and VCO output frequency. 397 * @param sa__ is an opaque state vector passed through to device access functions. 398 * @param refclk Reference clock frequency (enumerated), or BLACKHAWK_TSC_PLL_REFCLK_UNKNOWN to auto-compute. 399 * @param *refclk_freq_hz Resultant reference clock frequency, in Hz. 400 * @param *srds_div Divider value (enumerated), or BLACKHAWK_TSC_PLL_DIV_UNKNOWN to auto-compute. 401 * The final divider value will be filled in if BLACKHAWK_TSC_PLL_DIV_UNKNOWN. 402 * @param *vco_freq_khz VCO output frequency, in kHz, or 0 to auto-compute. 403 * The final VCO output frequency will be filled in if 0. 404 * @param pll_option Select PLL configuration option from enum #blackhawk_tsc_pll_option_enum. 405 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 406 */ 407 err_code_t blackhawk_tsc_INTERNAL_resolve_pll_parameters(srds_access_t *sa__, 408 enum blackhawk_tsc_pll_refclk_enum refclk, 409 uint32_t *refclk_freq_hz, 410 enum blackhawk_tsc_pll_div_enum *srds_div, 411 uint32_t *vco_freq_khz, 412 enum blackhawk_tsc_pll_option_enum pll_option); 413 414 /** Configure PLL. 415 * 416 * Use core_s_rstb to re-initialize all registers to default before calling this function. 417 * 418 * Configures PLL registers to obtain the required configuration. 419 * PLL configuration requires two out of the three parameters: refclk frequency, divider value, and VCO output frequency. 420 * @param sa__ is an opaque state vector passed through to device access functions. 421 * @param refclk Reference clock frequency (enumerated), or BLACKHAWK_TSC_PLL_REFCLK_UNKNOWN to auto-compute. 422 * @param srds_div Divider value (enumerated), or BLACKHAWK_TSC_PLL_DIV_UNKNOWN to auto-compute. 423 * @param vco_freq_khz VCO output frequency, in kHz, or 0 to auto-compute. 424 * @param pll_option Select PLL configuration option from enum #blackhawk_tsc_pll_option_enum. 425 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 426 */ 427 err_code_t blackhawk_tsc_INTERNAL_configure_pll(srds_access_t *sa__, 428 enum blackhawk_tsc_pll_refclk_enum refclk, 429 enum blackhawk_tsc_pll_div_enum srds_div, 430 uint32_t vco_freq_khz, 431 enum blackhawk_tsc_pll_option_enum pll_option); 432 433 434 /** Read the programmed PLL div value from the SERDES. 435 * Due to rounding when writing the div value to the PLL, 436 * the returned result may be slightly different from what was written. 437 * @param sa__ is an opaque state vector passed through to device access functions. 438 * @param *srds_div Divider value, in the same encoding as enum #blackhawk_tsc_pll_div_enum. 439 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 440 */ 441 err_code_t blackhawk_tsc_INTERNAL_read_pll_div(srds_access_t *sa__, uint32_t *srds_div); 442 443 /** Convert the PLL_DIV to actual PLL divider value and display 444 * as part of blackhawk_tsc_display_core_state_line() 445 * @param sa__ is an opaque state vector passed through to device access functions. 446 * @param srds_div Divider value, in the same encoding as enum #blackhawk_tsc_pll_div_enum. 447 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 448 */ 449 err_code_t blackhawk_tsc_INTERNAL_display_pll_to_divider(srds_access_t *sa__, uint32_t srds_div); 450 451 /** Get the VCO frequency in kHz, based on the reference clock frequency and divider value 452 * @param sa__ is an opaque state vector passed through to device access functions. 453 * @param refclk_freq_hz Reference clock frequency, in Hz. 454 * @param srds_div Divider value, in the same encoding as enum #blackhawk_tsc_pll_div_enum. 455 * @param *vco_freq_khz VCO output frequency, in kHz, obtained based on reference clock frequency and dic value 456 * @param pll_option Select PLL configuration option from enum #blackhawk_tsc_pll_option_enum. 457 * @return Error Code, if generated (returns ERR_CODE_NONE if no errors) 458 */ 459 err_code_t blackhawk_tsc_INTERNAL_get_vco_from_refclk_div(srds_access_t *sa__, 460 uint32_t refclk_freq_hz, 461 enum blackhawk_tsc_pll_div_enum srds_div, 462 uint32_t *vco_freq_khz, 463 enum blackhawk_tsc_pll_option_enum pll_option); 464 465 466 /*-------------------*/ 467 /* Ladder controls */ 468 /*-------------------*/ 469 /** Converts a ladder setting to mV, given the range. 470 * @param sa__ is an opaque state vector passed through to device access functions. 471 * @param ctrl is the threshold control (-31..31) maps to -RANGE to RANGE in non-uniform steps 472 * @param range_250 determines the range 0 = +/-150mV, 1 = +/-250mV 473 * @return ladder threshold voltage in mV 474 */ 475 int16_t blackhawk_tsc_INTERNAL_ladder_setting_to_mV(srds_access_t *sa__, int8_t ctrl, uint8_t range_250); 476 477 478 479 /*-----------------------*/ 480 /* TX_PI and ULL Setup */ 481 /*-----------------------*/ 482 483 /** Safe multiply - multiplies 2 numbers and checks for overflow. 484 * @param a First input 485 * @param b Second input 486 * @param *of Pointer to overflow indicator 487 * @return value of a * b 488 */ 489 uint32_t blackhawk_tsc_INTERNAL_mult_with_overflow_check(uint32_t a, uint32_t b, uint8_t *of); 490 491 /*-----------------------------------------*/ 492 /* APIs used in Config Shared TX Pattern */ 493 /*-----------------------------------------*/ 494 /** Compute Binary string for a PAM4 symbol ['0'to '3']. 495 * @param sa__ is an opaque state vector passed through to device access functions. 496 * @param var PAM4 symbol to be converted to Binary ('0', '1', '2', or '3') 497 * @param bin Binary string returned by API ('00', '01', '10' or '11') 498 * @return Error Code generated by invalid hex variable (returns ERR_CODE_NONE if no errors) 499 */ 500 err_code_t blackhawk_tsc_INTERNAL_pam4_to_bin(srds_access_t *sa__, char var, char bin[]); 501 502 /** Compute Binary string for a Hex value ['0' to 'F']. 503 * @param sa__ is an opaque state vector passed through to device access functions. 504 * @param var Hex value to be converted to Binary (eg: '6', 'A', ...) 505 * @param bin Binary string returned by API (eg: '0110', '1010', ...) 506 * @return Error Code generated by invalid hex variable (returns ERR_CODE_NONE if no errors) 507 */ 508 err_code_t blackhawk_tsc_INTERNAL_compute_bin(srds_access_t *sa__, char var, char bin[]); 509 510 /** Compute Hex value for a Binary string ['0000' to '1111']. 511 * @param sa__ is an opaque state vector passed through to device access functions. 512 * @param bin Binary string to be coverted (eg: '0110', '1010', ...) 513 * @param *hex Hex value calculated from the input Binary string 514 * @return Error Code generated by invalid Binary string (returns ERR_CODE_NONE if no errors) 515 */ 516 err_code_t blackhawk_tsc_INTERNAL_compute_hex(srds_access_t *sa__, char bin[], uint8_t *hex); 517 518 /** Check micro state and request micro to stop 519 * @param sa__ is an opaque state vector passed through to device access functions. 520 * @param graceful select the method for stopping (1=graceful stop; 0=Immediate) 521 * @param *err_code_p pointer to err_code variable which will be returned. 522 */ 523 uint8_t blackhawk_tsc_INTERNAL_stop_micro(srds_access_t *sa__, uint8_t graceful, err_code_t *err_code_p); 524 /*-----------------------------------*/ 525 /* APIs used in Read Event Logger */ 526 /*-----------------------------------*/ 527 528 /* State variable for dumping event log. 529 * This must be initialized with zeros. 530 */ 531 typedef struct { 532 uint16_t index, line_start_index; 533 } blackhawk_tsc_INTERNAL_event_log_dump_state_t; 534 535 /** Callback function for dumping event log, intended to be called by blackhawk_tsc_INTERNAL_read_event_log_with_callback. 536 * It must also be called once after, with a byte count of 0, to finish printing. 537 * @param *arg is a blackhawk_tsc_INTERNAL_event_log_dump_state_t pointer for holding state. 538 * @param byte_count is the number of bytes to dump. 539 * -# This function is called repeatedly with a byte count of 2 with U16 values to dump. 540 * -# This function may then be called with a byte count of 1 if the event log has an odd number of bytes. 541 * -# Finally, this function must be called with a byte count of 0 to finish up. 542 * @param data is the event log data to dump. 543 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 544 */ 545 err_code_t blackhawk_tsc_INTERNAL_event_log_dump_callback(void *arg, uint8_t byte_count, uint16_t data); 546 547 /** Get Event Log from uC, and call callback for every two bytes. 548 * @param sa__ is an opaque state vector passed through to device access functions. 549 * @param micro_num is the number of the microcontroller whose event log should be read. 550 * @param bypass_micro is 1 if the micro should not be involved (by stopping event log). 551 * This mode works even when the micro is hung, and it does not consume the event log. 552 * @param *arg is passed as the first argument to callback 553 * @param *callback is called with all of the data read, two bytes at a time. 554 * The last call of callback may have one byte; in that case, the upper byte is undefined. 555 * The call is in the form: callback(arg, byte_count, data) 556 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 557 */ 558 err_code_t blackhawk_tsc_INTERNAL_read_event_log_with_callback(srds_access_t *sa__, 559 uint8_t micro_num, 560 uint8_t bypass_micro, 561 void *arg, 562 err_code_t (*callback)(void *, uint8_t, uint16_t)); 563 564 /** Convert float8 to usigned int32. 565 * uint32 = 1.XXX * 2^Y where float8 bits are XXXYYYYY 566 * @param input Float8 number 567 * @return Usigned 32bit number 568 */ 569 uint32_t blackhawk_tsc_INTERNAL_float8_to_int32(float8_t input); 570 571 /** Convert uint8_t to 8-bit gray code. 572 * @param input Unsigned 8-bit number 573 * @return 8-bit gray code number 574 */ 575 uint8_t blackhawk_tsc_INTERNAL_uint8_to_gray(uint8_t input); 576 577 /** Convert 8-bit gray code to uint8_t. 578 * @param input 8-bit gray code number 579 * @return Unsigned 8-bit number 580 */ 581 uint8_t blackhawk_tsc_INTERNAL_gray_to_uint8(uint8_t input); 582 583 /** Convert seconds to hr:min:sec format. 584 * @param seconds 32bit input for time in seconds 585 * @param *hrs Number of hours 586 * @param *mins Number of minutes 587 * @param *secs Number of seconds 588 * @return Unsigned 8-bit number 589 */ 590 uint8_t blackhawk_tsc_INTERNAL_seconds_to_displayformat(uint32_t seconds, uint8_t *hrs, uint8_t *mins, uint8_t *secs); 591 592 #ifdef TO_FLOATS 593 /*-----------------------------------*/ 594 /* APIs used in uC data conversion */ 595 /*-----------------------------------*/ 596 597 /** Convert usigned int32 to float8. 598 * uint32 = 1.XXX * 2^Y where float8 bits are XXXYYYYY 599 * @param input Unsigned int 600 * @return Float8 8 bit representations of 32bit number 601 */ 602 float8_t blackhawk_tsc_INTERNAL_int32_to_float8(uint32_t input); 603 #endif 604 605 /** Convert float12 to usigned int32. 606 * uint32 = XXXXXXXX * 2^YYYY where float12 bits X=byte and Y=multi 607 * @param input Float8 8bit 608 * @param multi 4 bit multipier 609 * @return Usigned 32bit number 610 */ 611 uint32_t blackhawk_tsc_INTERNAL_float12_to_uint32(uint8_t input, uint8_t multi); 612 613 614 /*-----------------------------*/ 615 /* Read / Display Core state */ 616 /*-----------------------------*/ 617 /** Read current blackhawk_tsc core status. 618 * @param sa__ is an opaque state vector passed through to device access functions. 619 * @param *istate Current blackhawk_tsc core status read back and populated by the API 620 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 621 */ 622 err_code_t blackhawk_tsc_INTERNAL_read_core_state(srds_access_t *sa__, blackhawk_tsc_core_state_st *istate); 623 624 /** Measure PLL comparator threshold. 625 * @param sa__ is an opaque state vector passed through to device access functions. 626 * @param *thresh Measured PLL comparator threshold 627 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 628 */ 629 err_code_t blackhawk_tsc_INTERNAL_measure_pll_comp_thresh(srds_access_t *sa__, int16_t *thresh); 630 631 /** Display current core state. 632 * Reads and displays all important core state values. 633 * @param sa__ is an opaque state vector passed through to device access functions. 634 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 635 */ 636 err_code_t blackhawk_tsc_INTERNAL_display_core_state_no_newline(srds_access_t *sa__); 637 638 /*-----------------------------*/ 639 /* Read / Display Lane state */ 640 /*-----------------------------*/ 641 /** Read current blackhawk_tsc lane status. 642 * @param sa__ is an opaque state vector passed through to device access functions. 643 * @param *istate Current blackhawk_tsc lane status read back and populated by the API 644 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 645 */ 646 err_code_t blackhawk_tsc_INTERNAL_read_lane_state(srds_access_t *sa__, blackhawk_tsc_lane_state_st *istate); 647 648 649 /*-----------------*/ 650 /* Get OSR mode */ 651 /*-----------------*/ 652 /** Read current blackhawk_tsc lane status. 653 * @param sa__ is an opaque state vector passed through to device access functions. 654 * @param *mode Returns with the osr mode structure 655 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 656 */ 657 err_code_t blackhawk_tsc_INTERNAL_get_osr_mode(srds_access_t *sa__, blackhawk_tsc_osr_mode_st *mode); 658 659 /*-------------------*/ 660 /* Get RX_PAM mode */ 661 /*-------------------*/ 662 /** Read current RX PAM mode. 663 * @param sa__ is an opaque state vector passed through to device access functions. 664 * @param *pmode Returns the current RX PAM mode 665 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 666 */ 667 err_code_t blackhawk_tsc_INTERNAL_get_rx_pam_mode(srds_access_t *sa__, enum blackhawk_tsc_rx_pam_mode_enum *pmode); 668 669 /*-------------------*/ 670 /* Decode BR/OS mode */ 671 /*-------------------*/ 672 /** For PAM mode, read os_pattern_enhanced and os_all_edges. 673 * @param sa__ is an opaque state vector passed through to device access functions. 674 * @param *br_pd_en Returns the decoded BR/OS mode 675 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 676 */ 677 err_code_t blackhawk_tsc_INTERNAL_decode_br_os_mode(srds_access_t *sa__, uint8_t *br_pd_en); 678 679 /*-------------------*/ 680 /* Get LCK status */ 681 /*-------------------*/ 682 /** Read current PMD Lock and PMD Lock change status of a lane. 683 * @param sa__ is an opaque state vector passed through to device access functions. 684 * @param *pmd_lock Current blackhawk_tsc lane pmd_rx_lock status read back and populated by the API 685 * @param *pmd_lock_chg Current blackhawk_tsc lane pmd_rx_lock_change status read back and populated by the API 686 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 687 */ 688 err_code_t blackhawk_tsc_INTERNAL_pmd_lock_status(srds_access_t *sa__, uint8_t *pmd_lock, uint8_t *pmd_lock_chg); 689 690 /** Read current Signal_detect and Signal_detect change status of a lane. 691 * @param sa__ is an opaque state vector passed through to device access functions. 692 * @param *sig_det Current blackhawk_tsc lane signal_detect status read back and populated by the API 693 * @param *sig_det_chg Current blackhawk_tsc lane signal_detect_change status read back and populated by the API 694 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 695 */ 696 err_code_t blackhawk_tsc_INTERNAL_sigdet_status(srds_access_t *sa__, uint8_t *sig_det, uint8_t *sig_det_chg); 697 698 /** Read current PLL Lock and PLL Lock change status of a core. 699 * @param sa__ is an opaque state vector passed through to device access functions. 700 * @param *pll_lock Current blackhawk_tsc lane pll_lock status read back and populated by the API 701 * @param *pll_lock_chg Current blackhawk_tsc lane pll_lock_change status read back and populated by the API 702 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 703 */ 704 err_code_t blackhawk_tsc_INTERNAL_pll_lock_status(srds_access_t *sa__, uint8_t *pll_lock, uint8_t *pll_lock_chg); 705 706 /** Display current lane state. 707 * Reads and displays all important lane state values. 708 * @param sa__ is an opaque state vector passed through to device access functions. 709 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 710 */ 711 err_code_t blackhawk_tsc_INTERNAL_display_lane_state_no_newline(srds_access_t *sa__); 712 713 /*-----------------------------------------------*/ 714 /* Get dynamic eye margin estimation values */ 715 /*-----------------------------------------------*/ 716 /** Get dynamic eye estimation values 717 * Reads and converts the Eye margin estimation from the uC. 718 * @param sa__ is an opaque state vector passed through to device access functions. 719 * @param *left_eye_mUI a pointer to integer with return value of eye margin in units of mUI 720 * @param *right_eye_mUI a pointer to integer with return value of eye margin in units of mUI 721 * @param *upper_eye_mV a pointer to integer with return value of eye margin in units of mV 722 * @param *lower_eye_mV a pointer to integer with return value of eye margin in units of mV 723 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 724 */ 725 err_code_t blackhawk_tsc_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); 726 727 /** Convert eye margin to mV. 728 * Takes in the ladder setting with 3 fractional bits and converts to mV. 729 * @param sa__ is an opaque state vector passed through to device access functions. 730 * @param var Ladder setting with 3 fractional bits 731 * @param ladder_range Specified if ladder is configured for 150mV or 250mV range 732 * @return Eye opening in mV 733 */ 734 uint16_t blackhawk_tsc_INTERNAL_eye_to_mV(srds_access_t *sa__, uint8_t var, uint8_t ladder_range); 735 736 /** Convert eye margin to mUI. 737 * Takes in a horizontal margin in Phase Interpolator codes and converts it to mUI. 738 * @param sa__ is an opaque state vector passed through to device access functions. 739 * @param var Horizontal margin in Phase Interpolator codes with 3 fractional bits 740 * @return Eye opening in mV 741 */ 742 uint16_t blackhawk_tsc_INTERNAL_eye_to_mUI(srds_access_t *sa__, uint8_t var); 743 744 #define NUM_PAM_EYES 3 745 /*-------------------------*/ 746 /** PAM eye margin struct */ 747 /*-------------------------*/ 748 typedef struct { 749 uint16_t left_eye_mUI [NUM_PAM_EYES]; 750 uint16_t right_eye_mUI[NUM_PAM_EYES]; 751 uint16_t upper_eye_mV [NUM_PAM_EYES]; 752 uint16_t lower_eye_mV [NUM_PAM_EYES]; 753 } eye_margin_t; 754 755 /*----------------------------------------------------*/ 756 /* Get dynamic eye margin estimation values (PAM) */ 757 /*----------------------------------------------------*/ 758 /** Get dynamic eye estimation values for PAM mode 759 * Reads and converts the Eye margin estimation from the uC. 760 * @param sa__ is an opaque state vector passed through to device access functions. 761 * @param *eye_margin is a struct that contains all four corners - left(mUI), right(mUI), upper(mV) and lower(mV) for 3 eyes 762 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 763 */ 764 err_code_t blackhawk_tsc_INTERNAL_get_pam_eye_margin_est(srds_access_t *sa__, eye_margin_t *eye_margin); 765 766 /*------------------------------------------------------*/ 767 /* Print dynamic eye margin estimation values (PAM) */ 768 /*------------------------------------------------------*/ 769 /** Print dynamic eye estimation values for PAM mode 770 * Reads, converts and prints the Eye margin estimation from the uC. 771 * @param sa__ is an opaque state vector passed through to device access functions. 772 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 773 */ 774 err_code_t blackhawk_tsc_display_pam_eye_margin_est(srds_access_t *sa__); 775 776 /** Serdes Core ClockGate. 777 * Along with blackhawk_tsc_core_clkgate(), all lanes should also be clock gated using blackhawk_tsc_lane_clkgate() to complete a Core Clockgate 778 * @param sa__ is an opaque state vector passed through to device access functions. 779 * @param enable Enable clockgate (1 = Enable clokgate; 0 = Disable clockgate) 780 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 781 */ 782 err_code_t blackhawk_tsc_INTERNAL_core_clkgate(srds_access_t *sa__, uint8_t enable); 783 784 /** Serdes Lane ClockGate. 785 * @param sa__ is an opaque state vector passed through to device access functions. 786 * @param enable Enable lane clockgate (1 = Enable clockgate; 0 = Disable clockgate) 787 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 788 */ 789 err_code_t blackhawk_tsc_INTERNAL_lane_clkgate(srds_access_t *sa__, uint8_t enable); 790 791 /*--------------------*/ 792 /* Get/Set PF status */ 793 /*--------------------*/ 794 /** Set function for PF. 795 * @param sa__ is an opaque state vector passed through to device access functions. 796 * @param val Signed input value 797 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 798 */ 799 err_code_t blackhawk_tsc_INTERNAL_set_rx_pf_main(srds_access_t *sa__, uint8_t val); 800 801 /** Get function for PF 802 * @param sa__ is an opaque state vector passed through to device access functions. 803 * @param *val PF read value 804 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 805 */ 806 err_code_t blackhawk_tsc_INTERNAL_get_rx_pf_main(srds_access_t *sa__, uint8_t *val); 807 808 /** Set function for PF2. 809 * @param sa__ is an opaque state vector passed through to device access functions. 810 * @param val signed input value 811 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 812 */ 813 err_code_t blackhawk_tsc_INTERNAL_set_rx_pf2(srds_access_t *sa__, uint8_t val); 814 815 /** Get function for PF2. 816 * @param sa__ is an opaque state vector passed through to device access functions. 817 * @param *val PF2 read value 818 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 819 */ 820 err_code_t blackhawk_tsc_INTERNAL_get_rx_pf2(srds_access_t *sa__, uint8_t *val); 821 822 /** Set function for PF3. 823 * @param sa__ is an opaque state vector passed through to device access functions. 824 * @param val signed input value 825 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 826 */ 827 err_code_t blackhawk_tsc_INTERNAL_set_rx_pf3(srds_access_t *sa__, uint8_t val); 828 829 /** Get function for PF3. 830 * @param sa__ is an opaque state vector passed through to device access functions. 831 * @param *val PF3 read value 832 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 833 */ 834 err_code_t blackhawk_tsc_INTERNAL_get_rx_pf3(srds_access_t *sa__, uint8_t *val); 835 836 837 /*-------------------*/ 838 /* Get/Set VGA/DFE */ 839 /*-------------------*/ 840 /** Set function for VGA. 841 * @param sa__ is an opaque state vector passed through to device access functions. 842 * @param val signed input value 843 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 844 */ 845 err_code_t blackhawk_tsc_INTERNAL_set_rx_vga(srds_access_t *sa__, uint8_t val); 846 847 /** Get function for VGA. 848 * @param sa__ is an opaque state vector passed through to device access functions. 849 * @param *val VGA read value 850 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 851 */ 852 err_code_t blackhawk_tsc_INTERNAL_get_rx_vga(srds_access_t *sa__, uint8_t *val); 853 854 855 /** Set function for DFE Tap1. 856 * @param sa__ is an opaque state vector passed through to device access functions. 857 * @param val signed input value 858 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 859 */ 860 err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe1(srds_access_t *sa__, int8_t val); 861 862 /** Get function for DFE Tap1. 863 * @param sa__ is an opaque state vector passed through to device access functions. 864 * @param *val DFE1 read value 865 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 866 */ 867 err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe1(srds_access_t *sa__, int8_t *val); 868 869 /** Set function for DFE Tap2. 870 * @param sa__ is an opaque state vector passed through to device access functions. 871 * @param val signed input value 872 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 873 */ 874 err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe2(srds_access_t *sa__, int8_t val); 875 876 /** Get function for DFE Tap2. 877 * @param sa__ is an opaque state vector passed through to device access functions. 878 * @param *val DFE2 read value 879 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 880 */ 881 err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe2(srds_access_t *sa__, int8_t *val); 882 883 /** Set function for DFE Tap3. 884 * @param sa__ is an opaque state vector passed through to device access functions. 885 * @param val signed input value 886 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 887 */ 888 err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe3(srds_access_t *sa__, int8_t val); 889 890 /** Get function for DFE Tap3. 891 * @param sa__ is an opaque state vector passed through to device access functions. 892 * @param *val DFE3 read value 893 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 894 */ 895 err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe3(srds_access_t *sa__, int8_t *val); 896 897 /** Set function for DFE Tap4. 898 * @param sa__ is an opaque state vector passed through to device access functions. 899 * @param val signed input value 900 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 901 */ 902 err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe4(srds_access_t *sa__, int8_t val); 903 904 /** Get function for DFE Tap4. 905 * @param sa__ is an opaque state vector passed through to device access functions. 906 * @param *val DFE4 read value 907 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 908 */ 909 err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe4(srds_access_t *sa__, int8_t *val); 910 911 /** Set function for DFE Tap5. 912 * @param sa__ is an opaque state vector passed through to device access functions. 913 * @param val signed input value 914 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 915 */ 916 err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe5(srds_access_t *sa__, int8_t val); 917 918 /** Get function for DFE Tap5 919 * @param sa__ is an opaque state vector passed through to device access functions. 920 * @param *val DFE5 read value 921 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 922 */ 923 err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe5(srds_access_t *sa__, int8_t *val); 924 /* Set/Get DFE tap values */ 925 err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe6(srds_access_t *sa__, int8_t val); 926 err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe6(srds_access_t *sa__, int8_t *val); 927 err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe7(srds_access_t *sa__, int8_t val); 928 err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe7(srds_access_t *sa__, int8_t *val); 929 err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe8(srds_access_t *sa__, int8_t val); 930 err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe8(srds_access_t *sa__, int8_t *val); 931 err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe9(srds_access_t *sa__, int8_t val); 932 err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe9(srds_access_t *sa__, int8_t *val); 933 err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe10(srds_access_t *sa__, int8_t val); 934 err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe10(srds_access_t *sa__, int8_t *val); 935 err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe11(srds_access_t *sa__, int8_t val); 936 err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe11(srds_access_t *sa__, int8_t *val); 937 err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe12(srds_access_t *sa__, int8_t val); 938 err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe12(srds_access_t *sa__, int8_t *val); 939 err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe13(srds_access_t *sa__, int8_t val); 940 err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe13(srds_access_t *sa__, int8_t *val); 941 err_code_t blackhawk_tsc_INTERNAL_set_rx_dfe14(srds_access_t *sa__, int8_t val); 942 err_code_t blackhawk_tsc_INTERNAL_get_rx_dfe14(srds_access_t *sa__, int8_t *val); 943 944 945 /*----------------------*/ 946 /* Get/Set TXFIR Taps */ 947 /*----------------------*/ 948 err_code_t blackhawk_tsc_INTERNAL_load_txfir_taps(srds_access_t *sa__); 949 err_code_t blackhawk_tsc_INTERNAL_set_tx_tap(srds_access_t *sa__, uint8_t tap_num, int16_t val); 950 err_code_t blackhawk_tsc_INTERNAL_get_tx_tap(srds_access_t *sa__, uint8_t tap_num, int16_t *val); 951 952 /* Lane Config Struct */ 953 err_code_t blackhawk_tsc_INTERNAL_update_uc_lane_config_st(struct blackhawk_tsc_uc_lane_config_st *st); 954 err_code_t blackhawk_tsc_INTERNAL_update_uc_lane_config_word(struct blackhawk_tsc_uc_lane_config_st *st); 955 956 /* Lane User Control Disable Startup Function Struct */ 957 err_code_t blackhawk_tsc_INTERNAL_update_usr_ctrl_disable_functions_st(struct blackhawk_tsc_usr_ctrl_disable_functions_st *st); 958 err_code_t blackhawk_tsc_INTERNAL_update_usr_ctrl_disable_functions_byte(struct blackhawk_tsc_usr_ctrl_disable_functions_st *st); 959 960 /* Lane User Control Disable Startup DFE Function Struct */ 961 err_code_t blackhawk_tsc_INTERNAL_update_usr_ctrl_disable_dfe_functions_st(struct blackhawk_tsc_usr_ctrl_disable_dfe_functions_st *st); 962 err_code_t blackhawk_tsc_INTERNAL_update_usr_ctrl_disable_dfe_functions_byte(struct blackhawk_tsc_usr_ctrl_disable_dfe_functions_st *st); 963 964 /* Core Config Struct */ 965 err_code_t blackhawk_tsc_INTERNAL_update_uc_core_config_st(struct blackhawk_tsc_uc_core_config_st *st); 966 err_code_t blackhawk_tsc_INTERNAL_update_uc_core_config_word(struct blackhawk_tsc_uc_core_config_st *st); 967 968 uint8_t blackhawk_tsc_INTERNAL_rdb_uc_var(srds_access_t *sa__, err_code_t *err_code_p, uint16_t addr); 969 uint16_t blackhawk_tsc_INTERNAL_rdw_uc_var(srds_access_t *sa__, err_code_t *err_code_p, uint16_t addr); 970 err_code_t blackhawk_tsc_INTERNAL_wrb_uc_var(srds_access_t *sa__, uint16_t addr, uint8_t wr_val); 971 err_code_t blackhawk_tsc_INTERNAL_wrw_uc_var(srds_access_t *sa__, uint16_t addr, uint16_t wr_val); 972 973 /*--------------------------*/ 974 /* Register field polling */ 975 /*--------------------------*/ 976 977 err_code_t blackhawk_tsc_INTERNAL_print_uc_dsc_error(srds_access_t *sa__, enum srds_pmd_uc_cmd_enum cmd); 978 979 /** Polls lane variable "usr_diag_status" to verify data is available in uC diag buffer. 980 * Define macro CUSTOM_REG_POLLING to replace the default implementation provided in blackhawk_tsc_internal.c. 981 * 982 * @param sa__ is an opaque state vector passed through to device access functions. 983 * @param *status returns a status byte \n 984 * bit 15 - indicates the ey scan is complete \n 985 * bit 14-0 - reserved for debug 986 * 987 * @param timeout_ms Maximum time interval in milliseconds for which the polling is done 988 * @return Error code generated by polling function (returns ERR_CODE_NONE if no errors) 989 */ 990 err_code_t blackhawk_tsc_INTERNAL_poll_diag_done(srds_access_t *sa__, uint16_t *status, uint32_t timeout_ms); 991 992 /** Polls for register field "uc_dsc_ready_for_cmd" to be 1 within the time interval specified by timeout_ms. 993 * Function returns 0 if polling passes, else it returns error code. 994 * Define macro CUSTOM_REG_POLLING to replace the default implementation provided in blackhawk_tsc_internal.c. 995 * @param sa__ is an opaque state vector passed through to device access functions. 996 * @param timeout_ms Maximum time interval in milliseconds for which the polling is done 997 * @param cmd The command that was issued; this is used for error reporting. 998 * @return Error code generated by polling function (returns ERR_CODE_NONE if no errors) 999 */ 1000 err_code_t blackhawk_tsc_INTERNAL_poll_uc_dsc_ready_for_cmd_equals_1(srds_access_t *sa__, uint32_t timeout_ms, enum srds_pmd_uc_cmd_enum cmd); 1001 1002 /** Polls for register field "dsc_state" to be "DSC_STATE_UC_TUNE" 1003 * within the time interval specified by timeout_ms. 1004 * Function returns 0 if polling passes, else it returns error code. 1005 * Define macro CUSTOM_REG_POLLING to replace the default implementation provided in blackhawk_tsc_internal.c. 1006 * @param sa__ is an opaque state vector passed through to device access functions. 1007 * @param timeout_ms Maximum time interval in milliseconds for which the polling is done 1008 * @return Error code generated by polling function (returns ERR_CODE_NONE if no errors) 1009 */ 1010 err_code_t blackhawk_tsc_INTERNAL_poll_dsc_state_equals_uc_tune(srds_access_t *sa__, uint32_t timeout_ms); 1011 1012 1013 /** Polls for register field "micro_ra_initdone" to be 1 within the time interval specified by timeout_ms. 1014 * Function returns 0 if polling passes, else it returns error code. 1015 * Define macro CUSTOM_REG_POLLING to replace the default implementation provided in blackhawk_tsc_internal.c. 1016 * @param sa__ is an opaque state vector passed through to device access functions. 1017 * @param timeout_ms Maximum time interval in milliseconds for which the polling is done 1018 * @return Error code generated by polling function (returns ERR_CODE_NONE if no errors) 1019 */ 1020 err_code_t blackhawk_tsc_INTERNAL_poll_micro_ra_initdone(srds_access_t *sa__, uint32_t timeout_ms); 1021 1022 /** Maps AFE slicer offset adjustment values. 1023 * @param x Signed 8bit number 1024 * @return Signed 8bit number 1025 */ 1026 int8_t blackhawk_tsc_INTERNAL_afe_slicer_offset_mapping(int8_t x); 1027 1028 /** Utility to figure out if running platform is big endian. 1029 * @return value of 1 if big endian else 0 1030 */ 1031 uint8_t blackhawk_tsc_INTERNAL_is_big_endian(void); 1032 1033 /*--------------------------------*/ 1034 /* RAM Block Read with Callback */ 1035 /*--------------------------------*/ 1036 1037 /* Utility to account for endianness when reading from uc RAM */ 1038 int blackhawk_tsc_INTERNAL_get_endian_offset(uint8_t *addr); 1039 1040 typedef struct { 1041 uint8_t *mem_ptr; 1042 srds_access_t *sa; 1043 } blackhawk_tsc_INTERNAL_rdblk_callback_arg_t; 1044 1045 /** Callback function for reading uc RAM memory by blackhawk_tsc_INTERNAL_rdblk_uc_generic_ram(). 1046 * @param *arg is a blackhawk_tsc_INTERNAL_rdblk_callback_arg_t pointer for holding state. 1047 * @param byte_count is the number of bytes to store. 1048 * -# This function is called repeatedly with a byte count of 2 with U16 values to store. 1049 * -# This function may then be called with a byte count of 1 if there are an odd number of bytes. 1050 * @param data is the RAM data to store. 1051 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 1052 */ 1053 err_code_t blackhawk_tsc_INTERNAL_rdblk_callback(void *arg, uint8_t byte_count, uint16_t data); 1054 1055 /** Block RAM read through Micro Register Interface, suitable for program RAM or non-program RAM. 1056 * This reads a block of RAM, possibly starting midway through it and wrapping back to the beginning. 1057 * The order of operations is: 1058 * -# RAM will be read from (block_addr+start_offset) to (block_addr+block_size-1), 1059 * up to cnt bytes. 1060 * -# RAM will be read from block_addr to (block_addr+block_size-1), repeating 1061 * indefinitely, until cnt bytes total are read. 1062 * @param sa__ is an opaque state vector passed through to device access functions. 1063 * @param block_addr Address of RAM block to be read. 1064 * For program RAM, the upper 16 bits are 0x0000. Otherwise, the upper 16 bits are 0x2000. 1065 * @param block_size Length of RAM block to read. 1066 * @param start_offset Offset within RAM block to start reading 1067 * @param cnt Number of bytes to be read 1068 * @param *arg is passed as the first argument to callback 1069 * @param *callback is called with all of the data read, two bytes at a time. 1070 * The last call of callback may have one byte; in that case, the upper byte is undefined. 1071 * The call is in the form: callback(arg, byte_count, data) 1072 * @return Error Code generated by API or the callback (returns ERR_CODE_NONE if no errors) 1073 */ 1074 err_code_t blackhawk_tsc_INTERNAL_rdblk_uc_generic_ram(srds_access_t *sa__, 1075 uint32_t block_addr, 1076 uint16_t block_size, 1077 uint16_t start_offset, 1078 uint16_t cnt, 1079 void *arg, 1080 err_code_t (*callback)(void *, uint8_t, uint16_t)); 1081 1082 /** Block RAM read through Micro Register Interface, suitable for program RAM or non-program RAM. 1083 * This reads a block of RAM, possibly starting midway through it and wrapping back to the beginning. 1084 * The order of operations is: 1085 * -# RAM will be read from (block_addr+start_offset) down to block_addr, up to cnt bytes. 1086 * -# RAM will be read from (block_addr+block_size-1) down to block_addr, repeating 1087 * indefinitely, until cnt bytes total are read. 1088 * In other words, this is the same as blackhawk_tsc_INTERNAL_rdblk_uc_generic_ram(), but reading in descending address order. 1089 * @param sa__ is an opaque state vector passed through to device access functions. 1090 * @param block_addr Address of RAM block to be read. 1091 * For program RAM, the upper 16 bits are 0x0000. Otherwise, the upper 16 bits are 0x2000. 1092 * @param block_size Length of RAM block to read. 1093 * @param start_offset Offset within RAM block to start reading 1094 * @param cnt Number of bytes to be read 1095 * @param *arg is passed as the first argument to callback 1096 * @param *callback is called with all of the data read, two bytes at a time. 1097 * The last call of callback may have one byte; in that case, the upper byte is undefined. 1098 * The call is in the form: callback(arg, byte_count, data) 1099 * @return Error Code generated by API or the callback (returns ERR_CODE_NONE if no errors) 1100 */ 1101 err_code_t blackhawk_tsc_INTERNAL_rdblk_uc_generic_ram_descending(srds_access_t *sa__, 1102 uint32_t block_addr, 1103 uint16_t block_size, 1104 uint16_t start_offset, 1105 uint16_t cnt, 1106 void *arg, 1107 err_code_t (*callback)(void *, uint8_t, uint16_t)); 1108 1109 /** Retrieve micro index based on lane index. 1110 * @param lane Lane index 1111 * @return Micro index 1112 */ 1113 uint8_t blackhawk_tsc_INTERNAL_grp_idx_from_lane(uint8_t lane); 1114 1115 1116 1117 /** Extract the refclk frequency in Hz, based on a blackhawk_tsc_pll_refclk_enum value. */ 1118 err_code_t _blackhawk_tsc_get_refclk_in_hz(srds_access_t *sa__, enum blackhawk_tsc_pll_refclk_enum refclk, uint32_t *refclk_in_hz); 1119 1120 /** Retrieve LMS threshold value. */ 1121 err_code_t blackhawk_tsc_INTERNAL_get_lms_thresh_bin(srds_access_t *sa__, int8_t *lms_thresh_bin); 1122 1123 /** Polls for the dbgfb idx lock 1124 * @param sa__ is an opaque state vector passed through to device access functions. 1125 * @param timeout_ms polling timeout value in ms . 1126 */ 1127 err_code_t blackhawk_tsc_INTERNAL_poll_dbgfb_idx_lock(srds_access_t *sa__, uint8_t timeout_ms); 1128 /** Reads dbgfb counters. 1129 * @param sa__ is an opaque state vector passed through to device access functions. 1130 * @param *dbgfb_cfg pointer to dbgfb_cfg_st 1131 * @return Error Code generated by API (ERR_CODE_NONE if no errors) 1132 */ 1133 err_code_t blackhawk_tsc_get_dbgfb_summary(srds_access_t *sa__, dbgfb_cfg_st *dbgfb_cfg); 1134 1135 /** collects dbgfb stats for all 1136 * @param sa__ is an opaque state vector passed through to device access functions. 1137 * @param time_in_us 32 bit field that carries the run time for fb stats accumulation . 1138 * @param *dbgfb_stats pointer of type dbgfb_stats_st. 1139 * @return Error Code generated by API (ERR_CODE_NONE if no errors) 1140 */ 1141 err_code_t blackhawk_tsc_collect_dbgfb_stats(srds_access_t *sa__, uint32_t time_in_us, dbgfb_stats_st *dbgfb_stats); 1142 1143 /*-------------------*/ 1144 /* Name resolution */ 1145 /*-------------------*/ 1146 1147 /* For bitfields that differ for different cores, these macros are defined to resolve the bitfield. */ 1148 1149 #if defined(wr_rx_pf_ctrl) 1150 # define WR_RX_PF_CTRL wr_rx_pf_ctrl 1151 # define RD_RX_PF_CTRL rd_rx_pf_ctrl 1152 # define WR_RX_PF2_CTRL wr_rx_pf2_ctrl 1153 # define RD_RX_PF2_CTRL rd_rx_pf2_ctrl 1154 #elif defined(wr_rx_pf_ctrl_val) 1155 # define WR_RX_PF_CTRL wr_rx_pf_ctrl_val 1156 # define RD_RX_PF_CTRL rd_rx_pf_ctrl_val 1157 # define WR_RX_PF2_CTRL wr_rx_pf2_ctrl_val 1158 # define RD_RX_PF2_CTRL rd_rx_pf2_ctrl_val 1159 #elif defined(wr_pf_ctrl) 1160 # define WR_RX_PF_CTRL wr_pf_ctrl 1161 # define RD_RX_PF_CTRL rd_pf_ctrl 1162 # define WR_RX_PF2_CTRL wr_pf2_lowp_ctrl 1163 # define RD_RX_PF2_CTRL rd_pf2_lowp_ctrl 1164 #else 1165 # error "Could not find write to pf_ctrl bitfield." 1166 #endif 1167 1168 #if defined(reg_rd_TLB_RX_RXPRBS_CHK_ERR_CNT_MSB_STATUS) 1169 # define REG_RD_TLB_RX_PRBS_CHK_ERR_CNT_MSB_STATUS reg_rd_TLB_RX_RXPRBS_CHK_ERR_CNT_MSB_STATUS 1170 # define REG_RD_TLB_RX_PRBS_CHK_ERR_CNT_LSB_STATUS reg_rd_TLB_RX_RXPRBS_CHK_ERR_CNT_LSB_STATUS 1171 #elif defined(reg_rd_TLB_RX_PRBS_CHK_ERR_CNT_MSB_STATUS) 1172 # define REG_RD_TLB_RX_PRBS_CHK_ERR_CNT_MSB_STATUS reg_rd_TLB_RX_PRBS_CHK_ERR_CNT_MSB_STATUS 1173 # define REG_RD_TLB_RX_PRBS_CHK_ERR_CNT_LSB_STATUS reg_rd_TLB_RX_PRBS_CHK_ERR_CNT_LSB_STATUS 1174 #else 1175 # error "Could not find PRBS_CHK_ERR_CNT_MSB_STATUS." 1176 #endif 1177 1178 #endif