eagle_tsc_dependencies.c (3648B)
1 /* 2 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 3 * 4 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 5 * 6 */ 7 8 #ifdef LINUX 9 /* #include <stdint.h> */ 10 #endif 11 #include "common/srds_api_err_code.h" 12 #include "eagle_tsc_common.h" 13 #include <phymod/acc/phymod_tsc_iblk.h> 14 #include "eagle_tsc_dependencies.h" 15 #include <phymod/phymod.h> 16 #include <phymod/phymod_system.h> 17 18 19 err_code_t eagle_tsc_delay_us(uint32_t delay_us){ 20 PHYMOD_USLEEP(delay_us); 21 return ( 0 ); 22 } 23 24 err_code_t eagle_tsc_delay_ns(uint16_t delay_ns) { 25 uint32_t delay; 26 delay = delay_ns / 1000; 27 if (!delay ) { 28 delay = 1; 29 } 30 PHYMOD_USLEEP(delay); 31 return ( 0 ); 32 } 33 34 uint8_t eagle_tsc_get_lane(const phymod_access_t *pa) { 35 if (pa->lane_mask == 0x1) { 36 return ( 0 ); 37 } else if (pa->lane_mask == 0x2) { 38 return ( 1 ); 39 } else if (pa->lane_mask == 0x4) { 40 return ( 2 ); 41 } else if (pa->lane_mask == 0x8) { 42 return ( 3 ); 43 } else if (pa->lane_mask == 0xc) { 44 return ( 2 ); 45 } else { 46 return ( 0 ); 47 } 48 } 49 50 /** 51 @brief Eagle PMD Modify-Write 52 @param phymod access handle to current Eagle Context 53 @param address 54 @param mask 55 @param lsb 56 @param val 57 @returns The ERR_CODE_NONE upon successful completion, else returns ERR_CODE_DATA_NOTAVAIL 58 */ 59 err_code_t eagle_tsc_pmd_mwr_reg(const phymod_access_t *pa, uint16_t address, uint16_t mask, uint8_t lsb, uint16_t val) { 60 61 uint32_t mymask = ( uint32_t) mask; 62 phymod_access_t pa_copy; 63 uint32_t i; 64 int error_code; 65 66 uint32_t data = ((mymask << 16) & 0xffff0000) | val << lsb; 67 68 error_code = 0; 69 PHYMOD_MEMCPY(&pa_copy, pa, sizeof(phymod_access_t)); 70 for(i=1; i <= 0x8; i = i << 1) { 71 if ( i & pa->lane_mask ) { 72 pa_copy.lane_mask = i; 73 error_code+=phymod_tsc_iblk_write(&pa_copy, (PHYMOD_REG_ACC_TSC_IBLK | 0x10000 | (uint32_t) address), data); 74 } 75 } 76 if(error_code) 77 return ERR_CODE_DATA_NOTAVAIL; 78 return ERR_CODE_NONE; 79 } 80 81 82 /* phymod_tsc_iblk_read(const phymod_access_t *pa, uint32_t addr, uint32_t *data) */ 83 uint16_t eagle_tsc_pmd_rd_reg(const phymod_access_t *pa, uint16_t address){ 84 85 uint32_t data; 86 phymod_tsc_iblk_read(pa, (PHYMOD_REG_ACC_TSC_IBLK | 0x10000 | (uint32_t) address), &data); 87 data = data & 0xffff; 88 return ( (uint16_t)data ); 89 } 90 91 92 err_code_t eagle_tsc_pmd_rdt_reg(const phymod_access_t *pa, uint16_t address, uint16_t *val) { 93 uint32_t data; 94 phymod_tsc_iblk_read(pa, (PHYMOD_REG_ACC_TSC_IBLK | 0x10000 | (uint32_t) address), &data); 95 data = data & 0xffff; 96 *val = (uint16_t)data; 97 return ( 0 ); 98 } 99 100 /** 101 @brief Eagle PMD Write 102 @param phymod access handle to current Eagle Context 103 @param address 104 @param val 105 @returns The ERR_CODE_NONE upon successful completion, else returns ERR_CODE_DATA_NOTAVAIL 106 */ 107 err_code_t eagle_tsc_pmd_wr_reg(const phymod_access_t *pa, uint16_t address, uint16_t val){ 108 uint32_t data = 0xffff & val; 109 uint32_t error_code; 110 111 error_code = phymod_tsc_iblk_write(pa, (PHYMOD_REG_ACC_TSC_IBLK | 0x10000 | (uint32_t) address), data); 112 if(error_code) 113 return ERR_CODE_DATA_NOTAVAIL; 114 return ERR_CODE_NONE; 115 } 116 117 uint8_t eagle_tsc_get_core(void) { 118 return(0); 119 } 120 121 err_code_t eagle_tsc_uc_lane_idx_to_system_id(char *string , uint8_t uc_lane_idx) { 122 static char info[256]; 123 /* Indicates Eagle Core */ 124 PHYMOD_SPRINTF(info, "%s_%d", "FC_", uc_lane_idx); 125 /* PHYMOD_STRNCPY(string,info, PHYMOD_STRLEN(info)); */ 126 PHYMOD_STRCPY(string,info ); 127 return ERR_CODE_NONE; 128 } 129 130