viper_dependencies.h (5129B)
1 /**************************************************************************************/ 2 /**************************************************************************************/ 3 /* */ 4 /* Revision : viper_dependencies.h 366 2014-03-07 00:36:34Z hongc $ */ 5 /* */ 6 /* Description : API Dependencies to be provided by IP user */ 7 /* */ 8 /* Copyright: (c) 2014 Broadcom Corporation All Rights Reserved. */ 9 /* 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 /**************************************************************************************/ 21 /* 22 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 23 * 24 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 25 * 26 */ 27 28 /** @file viper_dependencies.h 29 * Dependencies to be provided by IP User 30 */ 31 32 #ifndef VIPER_API_DEPENDENCIES_H 33 #define VIPER_API_DEPENDENCIES_H 34 35 #include "viper_err_code.h" 36 37 /** Read a register from the currently selected Serdes IP Lane. 38 * @param pa phymod_access_t struct 39 * @param address Address of register to be read 40 * @param val read from the register 41 * @return Error code generated by delay function (returns ERR_CODE_NONE if no errors) 42 */ 43 err_code_t viper_pmd_rdt_reg(const phymod_access_t *pa,uint16_t address, uint16_t *val); 44 45 46 /** Write to a register from the currently selected Serdes IP Lane. 47 * @param pa phymod_access_t struct 48 * @param address Address of register to be written 49 * @param val Value to be written to the register 50 * @return Error code generated by delay function (returns ERR_CODE_NONE if no errors) 51 */ 52 err_code_t viper_pmd_wr_reg(const phymod_access_t *pa,uint16_t address, uint16_t val); 53 54 55 /** Masked Register Write to the currently selected Serdes IP core/lane. 56 * If using Serdes MDIO controller to access the registers, implement this function using viper_pmd_mdio_mwr_reg(..) 57 * 58 * If NOT using a Serdes MDIO controller or the Serdes PMI Masked write feature, please use the following code to 59 * implement this function 60 * 61 * viper_pmd_wr_reg(const phymod_access_t *pa,addr, ((viper_pmd_rd_reg(addr) & ~mask) | (mask & (val << lsb)))); 62 * 63 * @param pa phymod_access_t struct 64 * @param addr Address of register to be written 65 * @param mask 16-bit mask indicating the position of the field with bits of 1s 66 * @param lsb LSB of the field 67 * @param val 16bit value to be written 68 * @return Error code generated by delay function (returns ERR_CODE_NONE if no errors) 69 */ 70 err_code_t viper_pmd_mwr_reg(const phymod_access_t *pa,uint16_t addr, uint16_t mask, uint8_t lsb, uint16_t val); 71 72 73 /** Delay the execution of the code for atleast specified amount of time in nanoseconds. 74 * This function is used ONLY for delays less than 1 microsecond, non-zero error code may be returned otherwise. 75 * The user can implement this as an empty function if their register access latency exceeds 1 microsecond. 76 * @param pa phymod_access_t struct 77 * @param delay_ns Delay in nanoseconds 78 * @return Error code generated by delay function (returns ERR_CODE_NONE if no errors) 79 */ 80 err_code_t viper_delay_ns(uint16_t delay_ns); 81 82 83 /** Delay the execution of the code for atleast specified amount of time in microseconds. 84 * For longer delays, accuracy is required. When requested delay is > 100ms, the implemented delay is assumed 85 * to be < 10% bigger than requested. 86 * This function is used ONLY for delays greater than or equal to 1 microsecond. 87 * @param pa phymod_access_t struct 88 * @param delay_us Delay in microseconds 89 * @return Error code generated by delay function (returns ERR_CODE_NONE if no errors) 90 */ 91 err_code_t viper_delay_us(uint32_t delay_us); 92 93 94 /** Return the address of current selected Serdes IP lane. 95 * @param pa phymod_access_t struct 96 * @return the IP level address of the current lane. 0 to N-1, for an N lane IP 97 */ 98 uint8_t viper_get_lane(const phymod_access_t *pa); 99 100 101 #endif