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

viper_dependencies.c (2320B)


      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 #include <phymod/phymod.h>
      9 #include <phymod/phymod_system.h>
     10 #include "viper_common.h"
     11 #include "viper_err_code.h"
     12 #include <phymod/acc/phymod_tsc_iblk.h>
     13 
     14 err_code_t viper_delay_us(uint32_t delay_us){
     15 	PHYMOD_USLEEP(delay_us);
     16 	return ( 0 );
     17 }
     18 
     19 err_code_t viper_delay_ns(uint16_t delay_ns) {
     20 	uint32_t delay;
     21 	delay = delay_ns / 1000; 
     22 	if (!delay ) {
     23 		delay = 1;
     24 	}
     25 	PHYMOD_USLEEP(delay);
     26 	return ( 0 );
     27 }
     28 
     29 uint8_t viper_get_lane(const phymod_access_t *pa) {
     30     if (pa->lane_mask == 0x1) {
     31 	    return ( 0 );
     32     } else if (pa->lane_mask == 0x2) {
     33 	    return ( 1 );
     34     } else if (pa->lane_mask == 0x4) {
     35 	    return ( 2 );
     36     } else if (pa->lane_mask == 0x8) {
     37 	    return ( 3 );
     38     } else {
     39 	    return ( 0 );
     40     }
     41 }
     42 
     43 void viper_pmd_mwr_reg (PHYMOD_ST *pa, uint16_t address, 
     44                         uint16_t mask, uint8_t lsb, uint16_t val) {
     45 
     46     PHYMOD_ST pa_copy;	
     47     uint32_t  mymask  = (uint32_t)mask;
     48     uint32_t  i, data = ((mymask << 16) & 0xffff0000) | val << lsb;
     49 
     50     PHYMOD_MEMCPY((void*)&pa_copy, (void*)pa, sizeof(phymod_access_t));
     51     for(i=1; i <= 0x8; i = i << 1) {
     52         if ( i & pa->lane_mask ) {
     53             pa_copy.lane_mask = i;
     54             phymod_tsc_iblk_write(&pa_copy, 
     55                    (PHYMOD_REG_ACC_TSC_IBLK | 0x10000 | (uint32_t) address), data);
     56         }
     57     }
     58 }
     59 
     60 
     61 uint16_t viper_pmd_rd_reg(PHYMOD_ST *pa, uint16_t address){
     62 
     63 	uint32_t data;
     64 	phymod_tsc_iblk_read(pa, (PHYMOD_REG_ACC_TSC_IBLK | 0x10000 
     65                               | (uint32_t) address), &data);
     66 	data = data & 0xffff; 
     67 	return ( (uint16_t)data);
     68 }
     69 
     70 
     71 err_code_t viper_pmd_rdt_reg(PHYMOD_ST *pa, uint16_t address, uint16_t *val) {
     72 	uint32_t data;
     73 	phymod_tsc_iblk_read(pa, (PHYMOD_REG_ACC_TSC_IBLK | 0x10000 | 
     74                                         (uint32_t) address), &data);
     75 	data = data & 0xffff; 
     76 	*val = (uint16_t)data;
     77 	return ( 0 );
     78 }
     79 
     80 void viper_pmd_wr_reg(const phymod_access_t *pa, uint16_t address, uint16_t val){
     81 	uint32_t data = 0xffff & val;
     82 	phymod_tsc_iblk_write(pa, (PHYMOD_REG_ACC_TSC_IBLK | 0x10000 
     83                                      | (uint32_t) address), data);
     84 }