phy8806x_tsc_dependencies.h (7415B)
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 phy8806x_tsc_dependencies.h 21 * Dependencies to be provided by IP User 22 */ 23 24 #ifndef PHY8806X_TSC_API_DEPENDENCIES_H 25 #define PHY8806X_TSC_API_DEPENDENCIES_H 26 #include <phymod/phymod.h> 27 28 #include "phy8806x_tsc_usr_includes.h" 29 #include "phy8806x_tsc_common_err_code.h" 30 #include "phy8806x_tsc_ipconfig.h" 31 32 /** Read a register from the currently selected Serdes IP Lane. 33 * @param pa phymod_access_t struct 34 * @param address Address of register to be read 35 * @param *val value read out from the register 36 * @return Error code generated by read function (returns ERR_CODE_NONE if no errors) 37 */ 38 err_code_t phy8806x_tsc_pmd_rdt_reg (const phymod_access_t *pa, uint16_t address, uint16_t *val); 39 40 /** Write to a register from the currently selected Serdes IP Lane. 41 * @param pa phymod_access_t struct 42 * @param address Address of register to be written 43 * @param val Value to be written to the register 44 * @return Error code generated by write function (returns ERR_CODE_NONE if no errors) 45 */ 46 err_code_t phy8806x_tsc_pmd_wr_reg (const phymod_access_t *pa, uint16_t address, uint16_t val); 47 48 /** Masked Register Write to the currently selected Serdes IP core/lane. 49 * If using Serdes MDIO controller to access the registers, implement this function using phy8806x_tsc_pmd_mdio_mwr_reg(..) 50 * 51 * If NOT using a Serdes MDIO controller or the Serdes PMI Masked write feature, please use the following code to 52 * implement this function 53 * 54 * phy8806x_tsc_pmd_wr_reg (const phymod_access_t *pa, addr, ((phy8806x_tsc_pmd_rdt_reg (const phymod_access_t *pa, addr) & ~mask) | (mask & (val << lsb)))); 55 * 56 * @param pa phymod_access_t struct 57 * @param addr Address of register to be written 58 * @param mask 16-bit mask indicating the position of the field with bits of 1s 59 * @param lsb LSB of the field 60 * @param val 16bit value to be written 61 * @return Error code generated by write function (returns ERR_CODE_NONE if no errors) 62 */ 63 err_code_t phy8806x_tsc_pmd_mwr_reg (const phymod_access_t *pa, uint16_t addr, uint16_t mask, uint8_t lsb, uint16_t val); 64 65 66 /** Write message to the logger with the designated verbose level. 67 * Output is sent to stdout and a logfile 68 * @param pa phymod_access_t struct 69 * @param message_verbose_level Verbose level for the current message 70 * @param *format Format string as in printf 71 * @param ... Additional variables used as in printf 72 * @return Error code generated by function (returns ERR_CODE_NONE if no errors) 73 */ 74 int logger_write(int message_verbose_level, const char *format, ...); 75 76 /** Delay the execution of the code for atleast specified amount of time in nanoseconds. 77 * This function is used ONLY for delays less than 1 microsecond, non-zero error code may be returned otherwise. 78 * The user can implement this as an empty function if their register access latency exceeds 1 microsecond. 79 * @param pa phymod_access_t struct 80 * @param delay_ns Delay in nanoseconds 81 * @return Error code generated by delay function (returns ERR_CODE_NONE if no errors) 82 */ 83 err_code_t phy8806x_tsc_delay_ns(uint16_t delay_ns); 84 85 /** Delay the execution of the code for atleast specified amount of time in microseconds. 86 * For longer delays, accuracy is required. When requested delay is > 100ms, the implemented delay is assumed 87 * to be < 10% bigger than requested. 88 * This function is used ONLY for delays greater than or equal to 1 microsecond. 89 * @param pa phymod_access_t struct 90 * @param delay_us Delay in microseconds 91 * @return Error code generated by delay function (returns ERR_CODE_NONE if no errors) 92 */ 93 err_code_t phy8806x_tsc_delay_us(uint32_t delay_us); 94 95 /** Delay the execution of the code for atleast specified amount of time in milliseconds. 96 * For longer delays, accuracy is required. When requested delay is > 100ms, the implemented delay is assumed 97 * to be < 10% bigger than requested. 98 * This function is used ONLY for delays greater than or equal to 1 millisecond. 99 * @param pa phymod_access_t struct 100 * @param delay_ms Delay in milliseconds 101 * @return Error code generated by delay function (returns ERR_CODE_NONE if no errors) 102 */ 103 err_code_t phy8806x_tsc_delay_ms(uint32_t delay_ms); 104 105 /** Return the address of current selected Serdes IP Core. 106 * @param pa phymod_access_t struct 107 * @return the IP level address of the current core. 108 */ 109 uint8_t phy8806x_tsc_get_core(void); 110 111 /** Return the address of current selected Serdes IP lane. 112 * @param pa phymod_access_t struct 113 * @return the IP level address of the current lane. 0 to N-1, for an N lane IP 114 */ 115 uint8_t phy8806x_tsc_get_lane (const phymod_access_t *pa); 116 117 118 /** Return the address of current selected Serdes IP PLL. 119 * @param pa phymod_access_t struct 120 * @return the IP level address of the current PLL. 0 to N-1, for an N-PLL IP 121 */ 122 uint8_t phy8806x_tsc_get_pll(const phymod_access_t *pa); 123 124 /** Set the address of current selected Serdes IP PLL. Used in disgnoztic 125 * and core-level management functions. 126 * @param pa phymod_access_t struct 127 * @return Any error code generated during execution; ERR_CODE NONE otherwise. 128 */ 129 err_code_t phy8806x_tsc_set_pll(const phymod_access_t *pa, uint8_t pll_index); 130 131 /** Set the address of current selected Serdes IP lane. Used in disgnoztic 132 * and core-level management functions. 133 * @param pa phymod_access_t struct 134 * @return Any error code generated during execution; ERR_CODE NONE otherwise. 135 */ 136 err_code_t phy8806x_tsc_set_lane(uint8_t lane_index); 137 138 /** Convert uC lane index. 139 * Convert uC lane index to system ID string. 140 * @param pa phymod_access_t struct 141 * @param string a 16-byte output buffer to receive system ID 142 * @param uc_lane_idx uC lane index 143 * @return Error Code generated by API (returns ERR_CODE_NONE if no errors) 144 * The textual identifier is pre-filled with a default: implementors may 145 * safely return without modifying it if the default text is sufficient. 146 */ 147 err_code_t phy8806x_tsc_uc_lane_idx_to_system_id(char string[16], uint8_t uc_lane_idx); 148 149 150 #endif