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

merlin16_dependencies.h (7484B)


      1 /**************************************************************************************
      2  **************************************************************************************
      3  *                                                                                    *
      4  *  Revision      :   *
      5  *                                                                                    *
      6  *  Description   :  API Dependencies to be provided by IP user                       *
      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_dependencies.h
     22  * Dependencies to be provided by IP User
     23  */
     24 
     25 #ifndef MERLIN16_API_DEPENDENCIES_H
     26 #define MERLIN16_API_DEPENDENCIES_H
     27 
     28 #include "common/srds_api_err_code.h"
     29 #include "common/srds_api_types.h"
     30 
     31 /** Read a register from the currently selected Serdes IP Lane.
     32  * @param sa__ is an opaque state vector passed through to device access functions.
     33  * @param address Address of register to be read
     34  * @param *val value read out from the register
     35  * @return Error code generated by read function (returns ERR_CODE_NONE if no errors)
     36  */
     37 err_code_t merlin16_pmd_rdt_reg(srds_access_t *sa__, uint16_t address, uint16_t *val);
     38 
     39 /** Write to a register from the currently selected Serdes IP Lane.
     40  * @param sa__ is an opaque state vector passed through to device access functions.
     41  * @param address Address of register to be written
     42  * @param val Value to be written to the register
     43  * @return Error code generated by write function (returns ERR_CODE_NONE if no errors)
     44  */
     45 err_code_t merlin16_pmd_wr_reg(srds_access_t *sa__, uint16_t address, uint16_t val);
     46 
     47 /** Masked Register Write to the currently selected Serdes IP core/lane.
     48  * If using Serdes MDIO controller to access the registers, implement this function using merlin16_pmd_mdio_mwr_reg(..)
     49  *
     50  * If NOT using a Serdes MDIO controller or the Serdes PMI Masked write feature, please use the following code to
     51  * implement this function
     52  *
     53  *    merlin16_pmd_wr_reg(addr, ((merlin16_pmd_rd_reg(addr) & ~mask) | (mask & (val << lsb))));
     54  *
     55  * @param sa__ is an opaque state vector passed through to device access functions.
     56  * @param addr Address of register to be written
     57  * @param mask 16-bit mask indicating the position of the field with bits of 1s
     58  * @param lsb  LSB of the field
     59  * @param val  16bit value to be written
     60  * @return Error code generated by write function (returns ERR_CODE_NONE if no errors)
     61  */
     62 err_code_t merlin16_pmd_mwr_reg(srds_access_t *sa__, uint16_t addr, uint16_t mask, uint8_t lsb, uint16_t val);
     63 
     64 /** Write to a PRAM location for the currently selected Serdes IP Core.
     65  *  The address is auto-incrementing, per the PRAM interface specification.
     66  * @param sa__ is an opaque state vector passed through to device access functions.
     67  * @param val Value to be written
     68  * @return Error code generated by write function (returns ERR_CODE_NONE if no errors)
     69  */
     70 err_code_t merlin16_pmd_wr_pram(srds_access_t *sa__, uint8_t val);
     71 
     72 /** Write message to the logger with the designated verbose level.
     73  * Output is sent to stdout and a logfile
     74  * @param message_verbose_level   Verbose level for the current message
     75  * @param *format Format string as in printf
     76  * @param ... Additional variables used as in printf
     77  * @return Error code generated by function (returns ERR_CODE_NONE if no errors)
     78  */
     79 #ifdef SRDS_API_ALL_FUNCTIONS_HAVE_ACCESS_STRUCT
     80 int logger_write(srds_access_t *sa__, int message_verbose_level, const char *format, ...);
     81 #else
     82 int logger_write(int message_verbose_level, const char *format, ...);
     83 #endif
     84 
     85 /** Delay the execution of the code for atleast specified amount of time in nanoseconds.
     86  * This function is used ONLY for delays less than 1 microsecond, non-zero error code may be returned otherwise.
     87  * The user can implement this as an empty function if their register access latency exceeds 1 microsecond.
     88  * @param delay_ns Delay in nanoseconds
     89  * @return Error code generated by delay function (returns ERR_CODE_NONE if no errors)
     90  */
     91 #ifdef SRDS_API_ALL_FUNCTIONS_HAVE_ACCESS_STRUCT
     92 err_code_t merlin16_delay_ns(srds_access_t *sa__, uint16_t delay_ns);
     93 #else
     94 err_code_t merlin16_delay_ns(uint16_t delay_ns);
     95 #endif
     96 
     97 /** Delay the execution of the code for atleast specified amount of time in microseconds.
     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 microsecond.
    101  * @param delay_us Delay in microseconds
    102  * @return Error code generated by delay function (returns ERR_CODE_NONE if no errors)
    103  */
    104 #ifdef SRDS_API_ALL_FUNCTIONS_HAVE_ACCESS_STRUCT
    105 err_code_t merlin16_delay_us(srds_access_t *sa__, uint32_t delay_us);
    106 #else
    107 err_code_t merlin16_delay_us(uint32_t delay_us);
    108 #endif
    109 
    110 /** Delay the execution of the code for atleast specified amount of time in milliseconds.
    111  * For longer delays, accuracy is required. When requested delay is > 100ms, the implemented delay is assumed
    112  * to be < 10% bigger than requested.
    113  * This function is used ONLY for delays greater than or equal to 1 millisecond.
    114  * @param delay_ms Delay in milliseconds
    115  * @return Error code generated by delay function (returns ERR_CODE_NONE if no errors)
    116  */
    117 #ifdef SRDS_API_ALL_FUNCTIONS_HAVE_ACCESS_STRUCT
    118 err_code_t merlin16_delay_ms(srds_access_t *sa__, uint32_t delay_ms);
    119 #else
    120 err_code_t merlin16_delay_ms(uint32_t delay_ms);
    121 #endif
    122 
    123 /** Return the address of current selected Serdes IP Core.
    124  * @param sa__ is an opaque state vector passed through to device access functions.
    125  * @return the IP level address of the current core.
    126  */
    127 uint8_t merlin16_get_core(srds_access_t *sa__);
    128 
    129 /** Return the logical address of current selected Serdes IP lane.
    130  * @param sa__ is an opaque state vector passed through to device access functions.
    131  * @return the IP level address of the current lane. 0 to N-1, for an N lane IP
    132  */
    133 uint8_t merlin16_get_lane(srds_access_t *sa__);
    134 
    135 #define merlin16_get_physical_lane merlin16_get_lane
    136 
    137 /** Set the logical address of current selected Serdes IP lane.  Used in diagnostic
    138  * and core-level management functions.
    139  * @param sa__ is an opaque state vector passed through to device access functions.
    140  * @param lane_index is the lane index
    141  * @return Any error code generated during execution; ERR_CODE NONE otherwise.
    142  */
    143 err_code_t merlin16_set_lane(srds_access_t *sa__, uint8_t lane_index);
    144 
    145 #define merlin16_set_physical_lane merlin16_set_lane
    146 
    147 
    148 #endif