openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

eagle_tsc_dependencies.h (9529B)


      1 /**************************************************************************************
      2  **************************************************************************************
      3  *                                                                                    *
      4   *                                                                                    *
      5  *  Description   :  API Dependencies to be provided by IP user                       *
      6  *                                                                                    *
      7  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      8  * 
      9  * Copyright 2007-2019 Broadcom Inc. All rights reserved.                                                              *
     10  *  No portions of this material may be reproduced in any form without                *
     11  *  the written permission of:                                                        *
     12  *      Broadcom Corporation                                                          *
     13  *      5300 California Avenue                                                        *
     14  *      Irvine, CA  92617                                                             *
     15  *                                                                                    *
     16  *  All information contained in this document is Broadcom Corporation                *
     17  *  company private proprietary, and trade secret.                                    *
     18  */
     19 
     20 /** @file eagle_tsc_dependencies.h
     21  * Dependencies to be provided by IP User
     22  */
     23 
     24 #ifndef EAGLE_TSC_API_DEPENDENCIES_H
     25 #define EAGLE_TSC_API_DEPENDENCIES_H
     26 
     27 #include "eagle_tsc_usr_includes.h"
     28 #include "common/srds_api_err_code.h"
     29 #include <phymod/phymod.h>
     30 /* #include "eagle_tsc_ipconfig.h" */
     31 
     32 
     33 uint16_t eagle_tsc_pmd_rd_reg(const phymod_access_t *pa, uint16_t address);
     34 
     35 /** Read a register from the currently selected Serdes IP Lane.
     36  * @param pa phymod_access_t struct
     37  * @param address Address of register to be read
     38  * @param *val value read out from the register
     39  * @return Error code generated by read function (returns ERR_CODE_NONE if no errors)
     40  */
     41 err_code_t eagle_tsc_pmd_rdt_reg(const phymod_access_t *pa,uint16_t address, uint16_t *val);
     42 
     43 /** Write to a register from the currently selected Serdes IP Lane.
     44  * @param pa phymod_access_t struct
     45  * @param address Address of register to be written
     46  * @param val Value to be written to the register
     47  * @return Error code generated by write function (returns ERR_CODE_NONE if no errors)
     48  */
     49 err_code_t eagle_tsc_pmd_wr_reg(const phymod_access_t *pa,uint16_t address, uint16_t val);
     50 
     51 /** Masked Register Write to the currently selected Serdes IP core/lane.
     52  * If using Serdes MDIO controller to access the registers, implement this function using eagle_tsc_pmd_mdio_mwr_reg(..)
     53  *
     54  * If NOT using a Serdes MDIO controller or the Serdes PMI Masked write feature, please use the following code to
     55  * implement this function
     56  *
     57  *    eagle_tsc_pmd_wr_reg(const phymod_access_t *pa,addr, ((eagle_tsc_pmd_rd_reg(addr) & ~mask) | (mask & (val << lsb))));
     58  *
     59  * @param pa phymod_access_t struct
     60  * @param addr Address of register to be written
     61  * @param mask 16-bit mask indicating the position of the field with bits of 1s
     62  * @param lsb  LSB of the field
     63  * @param val  16bit value to be written
     64  * @return Error code generated by write function (returns ERR_CODE_NONE if no errors)
     65  */
     66 err_code_t eagle_tsc_pmd_mwr_reg(const phymod_access_t *pa,uint16_t addr, uint16_t mask, uint8_t lsb, uint16_t val);
     67 
     68 /** Write message to the logger with the designated verbose level.
     69  * Output is sent to stdout and a logfile
     70  * @param pa phymod_access_t struct
     71  * @param message_verbose_level   Verbose level for the current message
     72  * @param *format Format string as in printf
     73  * @param ... Additional variables used as in printf
     74  * @return Error code generated by function (returns ERR_CODE_NONE if no errors)
     75  */
     76 int logger_write(int message_verbose_level, const char *format, ...);
     77 
     78 /** Delay the execution of the code for atleast specified amount of time in nanoseconds.
     79  * This function is used ONLY for delays less than 1 microsecond, non-zero error code may be returned otherwise.
     80  * The user can implement this as an empty function if their register access latency exceeds 1 microsecond.
     81  * @param pa phymod_access_t struct
     82  * @param delay_ns Delay in nanoseconds
     83  * @return Error code generated by delay function (returns ERR_CODE_NONE if no errors)
     84  */
     85 err_code_t eagle_tsc_delay_ns(uint16_t delay_ns);
     86 
     87 /** Delay the execution of the code for atleast specified amount of time in microseconds.
     88  * For longer delays, accuracy is required. When requested delay is > 100ms, the implemented delay is assumed
     89  * to be < 10% bigger than requested.
     90  * This function is used ONLY for delays greater than or equal to 1 microsecond.
     91  * @param pa phymod_access_t struct
     92  * @param delay_us Delay in microseconds
     93  * @return Error code generated by delay function (returns ERR_CODE_NONE if no errors)
     94  */
     95 err_code_t eagle_tsc_delay_us(uint32_t delay_us);
     96 
     97 /** Delay the execution of the code for atleast specified amount of time in milliseconds.
     98  * For longer delays, accuracy is required. When requested delay is > 100ms, the implemented delay is assumed
     99  * to be < 10% bigger than requested.
    100  * This function is used ONLY for delays greater than or equal to 1 millisecond.
    101  * @param pa phymod_access_t struct
    102  * @param delay_ms Delay in milliseconds
    103  * @return Error code generated by delay function (returns ERR_CODE_NONE if no errors)
    104  */
    105 err_code_t eagle_tsc_delay_ms(uint32_t delay_ms);
    106 
    107 /** Return the address of current selected Serdes IP Core.
    108  * @param pa phymod_access_t struct
    109  * @return the IP level address of the current core.
    110  */
    111 uint8_t eagle_tsc_get_core(void);
    112 
    113 /** Return the address of current selected Serdes IP lane.
    114  * @param pa phymod_access_t struct
    115  * @return the IP level address of the current lane. 0 to N-1, for an N lane IP
    116  */
    117 uint8_t eagle_tsc_get_lane(const phymod_access_t *pa);
    118 
    119 
    120 /** Polls for register field "uc_dsc_ready_for_cmd" to be 1 within the time interval specified by timeout_ms.
    121  * Function returns 0 if polling passes, else it returns error code.
    122  * Define macro CUSTOM_REG_POLLING to replace the default implementation provided in eagle_tsc_functions.c.
    123  * @param pa phymod_access_t struct
    124  * @param timeout_ms Maximum time interval in milliseconds for which the polling is done
    125  * @return Error code generated by polling function (returns ERR_CODE_NONE if no errors)
    126  */
    127 err_code_t eagle_tsc_poll_uc_dsc_ready_for_cmd_equals_1( const phymod_access_t *pa, uint32_t timeout_ms);
    128 
    129 /** Polls lane variable "usr_diag_status" to verify data is available in uC diag buffer.
    130  * It then reads a WORD of data wich is 2 float8_t samples, it converts them to uint32_t
    131  * and returns them in the memory pointed to by *data.
    132  *
    133  * @param pa phymod_access_t struct
    134  * @param *data is pointer to 2 element array of uint32_tpassed from uC through dsc_data
    135  * @param *status returns a status byte           \n
    136  *    bit 15 - indicates the ey scan is complete \n
    137  *    bit 14 - indicates uC is slower than read access \n
    138  *    bit 13 - indicates uC is faster than read access \n
    139  *    bit 7-0 - indicates amount of data in the uC buffer
    140  *
    141  * @param pa phymod_access_t struct
    142  * @param timeout_ms Maximum time interval in milliseconds for which the polling is done
    143  * @return Error code generated by polling function (returns ERR_CODE_NONE if no errors)
    144  */
    145 err_code_t eagle_tsc_poll_diag_eye_data(const phymod_access_t *pa,uint32_t *data,uint16_t *status, uint32_t timeout_ms);
    146 
    147 /** Polls lane variable "usr_diag_status" to verify data is available in uC diag buffer.
    148  *
    149  * @param pa phymod_access_t struct
    150  * @param *status returns a status byte \n
    151  *    bit 15 - indicates the ey scan is complete \n
    152  *    bit 14-0 - reserved for debug
    153  *
    154  * @param pa phymod_access_t struct
    155  * @param timeout_ms Maximum time interval in milliseconds for which the polling is done
    156  * @return Error code generated by polling function (returns ERR_CODE_NONE if no errors)
    157  */
    158 err_code_t eagle_tsc_poll_diag_done( const phymod_access_t *pa, uint16_t *status, uint32_t timeout_ms);
    159 
    160 /** Polls for register field "dsc_state" to be "DSC_STATE_UC_TUNE"
    161  * within the time interval specified by timeout_ms.
    162  * Function returns 0 if polling passes, else it returns error code.
    163  * Define macro CUSTOM_REG_POLLING to replace the default implementation provided in
    164  * eagle_tsc_functions.c.
    165  * @param pa phymod_access_t struct
    166  * @param timeout_ms Maximum time interval in milliseconds for which the polling is done
    167  * @return Error code generated by polling function (returns ERR_CODE_NONE if no errors)
    168  */
    169 err_code_t eagle_tsc_poll_dsc_state_equals_uc_tune( const phymod_access_t *pa, uint32_t timeout_ms);
    170 
    171 /** Convert uC lane index.
    172 * Convert uC lane index to system ID string.
    173  * @param pa phymod_access_t struct
    174 * @param *string a 256-byte output buffer to receive system ID
    175 * @param uc_lane_idx uC lane index
    176 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors)
    177 * The textual identifier is pre-filled with a default:  implementors may
    178 * safely return without modifying it if the default text is sufficient.
    179 */
    180 err_code_t eagle_tsc_uc_lane_idx_to_system_id(char *string , uint8_t uc_lane_idx);
    181 
    182 
    183 
    184 /***********************************************/
    185 /*  Microcode Load into Program RAM Functions  */
    186 /***********************************************/
    187 
    188 #endif