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

falcon_tsc_dependencies.c (3613B)


      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 <phymod/phymod.h>
     12 #include <phymod/phymod_system.h>
     13 #include "common/srds_api_err_code.h"
     14 #include "falcon_tsc_common.h"
     15 #include <phymod/acc/phymod_tsc_iblk.h>
     16 #include "falcon_tsc_dependencies.h"
     17 
     18 
     19 /**
     20 @brief   Falcon PMD Modify-Write
     21 @param   phymod access handle to current Falcon Context
     22 @param   address
     23 @param   mask
     24 @param   lsb
     25 @param   val
     26 @returns The ERR_CODE_NONE upon successful completion, else returns ERR_CODE_DATA_NOTAVAIL
     27 */
     28 err_code_t  falcon_tsc_pmd_mwr_reg(const phymod_access_t *pa, uint16_t addr, uint16_t mask, uint8_t lsb, uint16_t val) { 
     29     uint32_t mymask = ( uint32_t) mask;
     30     phymod_access_t pa_copy;    
     31     uint32_t i;
     32     uint32_t error_code;
     33     
     34 
     35     uint32_t data = ((mymask << 16) & 0xffff0000) | val << lsb;
     36 
     37     error_code=0;
     38     PHYMOD_MEMCPY(&pa_copy, pa, sizeof(phymod_access_t));
     39     for(i=1; i <= 0x8; i = i << 1) {
     40         if ( i & pa->lane_mask ) {
     41             pa_copy.lane_mask = i;
     42             error_code+=phymod_tsc_iblk_write(&pa_copy, (PHYMOD_REG_ACC_TSC_IBLK | 0x10000 | (uint32_t) addr), data);
     43         }
     44     }
     45     if(error_code)
     46       return  ERR_CODE_DATA_NOTAVAIL; 
     47     return  ERR_CODE_NONE; 
     48 }
     49 
     50 /* uint8_t falcon_tsc_get_lane(const phymod_access_t *pa) { */
     51 uint8_t falcon_tsc_get_lane(const phymod_access_t *pa) {
     52     if (pa->lane_mask == 0x1) {
     53         return ( 0 );
     54     } else if (pa->lane_mask == 0x2) {
     55         return ( 1 );
     56     } else if (pa->lane_mask == 0x4) {
     57         return ( 2 );
     58     } else if (pa->lane_mask == 0x8) {
     59         return ( 3 );
     60     } else if (pa->lane_mask == 0xc) {
     61         return ( 2 );
     62     } else {
     63         return ( 0 );
     64     }
     65 }
     66 
     67 uint16_t falcon_tsc_pmd_rd_reg(const phymod_access_t *pa, uint16_t address){
     68 
     69     uint32_t data;
     70     phymod_tsc_iblk_read(pa, (PHYMOD_REG_ACC_TSC_IBLK | 0x10000 | (uint32_t) address), &data);
     71     data = data & 0xffff; 
     72     return ( (uint16_t)data );
     73 }
     74 
     75 err_code_t falcon_tsc_delay_ns(uint16_t delay_ns) {
     76     uint32_t delay;
     77     delay = delay_ns / 1000; 
     78     if (!delay ) {
     79         delay = 1;
     80     }
     81     PHYMOD_USLEEP(delay);
     82     return ( 0 );
     83 }
     84 
     85 /**
     86 @brief   Falcon PMD Write
     87 @param   phymod access handle to current Falcon Context
     88 @param   address
     89 @param   val
     90 @returns The ERR_CODE_NONE upon successful completion, else returns ERR_CODE_DATA_NOTAVAIL
     91 */
     92 err_code_t falcon_tsc_pmd_wr_reg(const phymod_access_t *pa, uint16_t address, uint16_t val){
     93     uint32_t data = 0xffff & val;
     94     uint32_t error_code;
     95     error_code = phymod_tsc_iblk_write(pa, (PHYMOD_REG_ACC_TSC_IBLK | 0x10000 | (uint32_t) address), data);
     96     if(error_code)
     97       return  ERR_CODE_DATA_NOTAVAIL; 
     98     return  ERR_CODE_NONE; 
     99 }
    100 
    101 err_code_t falcon_tsc_delay_us(uint32_t delay_us){
    102     PHYMOD_USLEEP(delay_us);
    103     return ( 0 );
    104 }
    105 
    106 err_code_t falcon_tsc_pmd_rdt_reg(const phymod_access_t *pa, uint16_t address, uint16_t *val) {
    107     uint32_t data;
    108     phymod_tsc_iblk_read(pa, (PHYMOD_REG_ACC_TSC_IBLK | 0x10000 | (uint32_t) address), &data);
    109     data = data & 0xffff; 
    110     *val = (uint16_t)data;
    111     return ( 0 );
    112 }
    113 
    114 uint8_t falcon_tsc_get_core(void) {
    115     return(0);
    116 }
    117 
    118 err_code_t falcon_tsc_uc_lane_idx_to_system_id(char *string , uint8_t uc_lane_idx) {
    119     static char info[256];
    120    /* Indicates Falcon Core */
    121     PHYMOD_SPRINTF(info, "%s_%d", "FC_", uc_lane_idx);
    122     PHYMOD_STRNCPY(string,info, PHYMOD_STRLEN(info)+1);
    123     return ERR_CODE_NONE;
    124 }
    125 
    126 
    127 
    128