bondoptions.c (5912B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * File: bondoptions.c 8 * Purpose: Populates Apache Bond Options Info. 9 * Requires: SOC Common Bond Options Initializer. 10 */ 11 12 #include <shared/bsl.h> 13 14 #include <soc/defs.h> 15 16 #ifdef BCM_APACHE_SUPPORT 17 18 #include <soc/apache.h> 19 #include <soc/bondoptions.h> 20 21 #include <shared/bitop.h> 22 #include <soc/iproc.h> 23 24 /* 25 * Function to conver to Core Clock frequency encodings to 26 * real core clock frequencies. 27 */ 28 STATIC int 29 _soc_monterey_bond_option_to_core_clk_freq(int unit, int val, int rev_id) 30 { 31 int freq; 32 33 switch (val) { 34 case 0x0: 35 freq = 862; 36 break; 37 case 0x1: 38 if (rev_id == BCM56670_B0_REV_ID) { 39 freq = 817; 40 } else { 41 freq = 837; 42 } 43 break; 44 case 0x2: 45 if (rev_id == BCM56670_B0_REV_ID) { 46 freq = 667; 47 } else { 48 freq = 817; 49 } 50 break; 51 case 0x3: 52 freq = 550; 53 break; 54 case 0x4: 55 if (rev_id == BCM56670_B0_REV_ID) { 56 freq = 450; 57 } else { 58 freq = 550; 59 } 60 break; 61 default: 62 freq = 862; 63 /* unknown max frequency */ 64 break; 65 } 66 67 return freq; 68 } 69 70 71 /* 72 * Function to initialize the bondoptions cache based on the 73 * Bond Info read from the relevant registers. 74 */ 75 int 76 soc_monterey_bond_info_init(int unit) 77 { 78 79 int i, bit_val; 80 uint32 val, addr; 81 soc_bond_info_t *bond_info = SOC_BOND_INFO(unit); 82 soc_reg_t soc_monterey_bond_info_regs[] = { 83 USER_OTP_BONDOPTION_31_0_REGr, 84 USER_OTP_BONDOPTION_63_32_REGr, 85 USER_OTP_BONDOPTION_95_64_REGr, 86 USER_OTP_BONDOPTION_127_96_REGr, 87 USER_OTP_BONDOPTION_159_128_REGr, 88 USER_OTP_BONDOPTION_191_160_REGr, 89 USER_OTP_BONDOPTION_223_192_REGr, 90 USER_OTP_BONDOPTION_255_224_REGr, 91 USER_OTP_BONDOPTION_287_256_REGr, 92 USER_OTP_BONDOPTION_319_288_REGr, 93 USER_OTP_BONDOPTION_351_320_REGr, 94 USER_OTP_BONDOPTION_383_352_REGr, 95 USER_OTP_BONDOPTION_415_384_REGr, 96 USER_OTP_BONDOPTION_447_416_REGr, 97 USER_OTP_BONDOPTION_479_448_REGr, 98 USER_OTP_BONDOPTION_511_480_REGr 99 }; 100 101 int reg_num = COUNTOF(soc_monterey_bond_info_regs); 102 SHR_BITDCL bond_info_regval[_SHR_BITDCLSIZE(COUNTOF(soc_monterey_bond_info_regs) * 32)] = {0}; 103 104 int feature_enables[][3] = { 105 /* Bit */ /* Bool Invert? */ /* Feature Enum */ /* Desc */ 106 {424, 1, socBondInfoFeatureNoL3 }, /* L3_ENABLE */ 107 {425, 1, socBondInfoFeatureNoL3Tunnel }, /* L3_TUNNEL_ENABLE */ 108 {426, 1, socBondInfoFeatureNoVxlan }, /* VXLAN_ENABLE */ 109 {427, 1, socBondInfoFeatureNoMpls }, /* MPLS_ENABLE */ 110 {428, 1, socBondInfoFeatureNoMacsec }, /* MACSEC_ENABLE */ 111 {429, 1, socBondInfoFeatureNoReserveTunnel }, /* RESERVE_TUNNEL_ENABLE*/ 112 {430, 1, socBondInfoFeatureNoPreemption }, /* PREEMPTION_ENABLE */ 113 {433, 1, socBondInfoFeatureTs1588 }, /* TS_1588_BC_ENABLE */ 114 {-1, 0, -1 } /* Always last */ 115 }; 116 117 for (i = 0; i < reg_num; i++) { 118 addr = soc_reg_addr(unit, soc_monterey_bond_info_regs[i], REG_PORT_ANY, 0); 119 soc_iproc_getreg(unit, addr, &val); 120 SHR_BITCOPY_RANGE(bond_info_regval, (i * 32), &val, 0, 32); 121 } 122 123 SOC_BOND_OPTIONS_COPY(bond_info->rev_id, uint16, bond_info_regval, 0, 7); 124 SOC_BOND_OPTIONS_COPY(bond_info->dev_id, uint16, bond_info_regval, 8, 23); 125 SOC_BOND_OPTIONS_COPY(bond_info->device_skew, uint32, bond_info_regval, 24, 27); 126 /* Max Core Clock Frequency */ 127 SOC_BOND_OPTIONS_COPY(val, uint32, bond_info_regval, 34, 36); 128 bond_info->max_core_freq = _soc_monterey_bond_option_to_core_clk_freq(unit, val, 129 bond_info->rev_id); 130 131 /* Default Core Clock Frequency */ 132 SOC_BOND_OPTIONS_COPY(val, uint32, bond_info_regval, 37, 39); 133 bond_info->default_core_freq = _soc_monterey_bond_option_to_core_clk_freq(unit, val, 134 bond_info->rev_id); 135 136 137 /* RTS MC Enable */ 138 SOC_BOND_OPTIONS_COPY(val, uint32, bond_info_regval, 431,432 ); 139 if (val & 0x1) { 140 SOC_BOND_INFO_FEATURE_SET(unit, socBondInfoFeatureUc0Active); 141 } 142 if (val & 0x2) { 143 SOC_BOND_INFO_FEATURE_SET(unit, socBondInfoFeatureUc1Active); 144 } 145 146 147 148 149 SOC_BOND_OPTIONS_COPY(bond_info->efp_slice_map, uint32, bond_info_regval,416 , 419); 150 SOC_BOND_OPTIONS_COPY(bond_info->vfp_slice_map, uint32, bond_info_regval, 420, 423); 151 SOC_BOND_OPTIONS_COPY(bond_info->clmac_map, uint32, bond_info_regval, 173,178); 152 SOC_BOND_OPTIONS_COPY(bond_info->xlmac_map, uint32, bond_info_regval, 179, 188); 153 SOC_BOND_OPTIONS_COPY(bond_info->tsc_force_hg, uint32, bond_info_regval, 157, 172); 154 SOC_BOND_OPTIONS_COPY(bond_info->tsc_enable, uint32, bond_info_regval, 141, 156); 155 SHR_BITCOPY_RANGE(bond_info->tsc_sr_only, 0, bond_info_regval,189 ,9 ); 156 SHR_BITCOPY_RANGE(bond_info->cpri_enable, 0, bond_info_regval,199 ,48 ); 157 158 for(i = 0; i < COUNTOF(feature_enables); i++) { 159 bit_val = SHR_BITGET(bond_info_regval, feature_enables[i][0]); 160 if (feature_enables[i][1]) { 161 /* Boolean invert */ 162 bit_val = !bit_val; 163 } 164 165 if (bit_val) { 166 SOC_BOND_INFO_FEATURE_SET(unit, feature_enables[i][2]); 167 } 168 } 169 170 return SOC_E_NONE; 171 } 172 173 #endif /* BCM_MONTEREY_SUPPORT */ 174