bondoptions.c (3284B)
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 Trident3 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_TRIDENT3_SUPPORT 17 18 #include <shared/bitop.h> 19 #include <soc/iproc.h> 20 #include <soc/trident3.h> 21 #include <soc/bondoptions.h> 22 23 /* 24 * Function to conver to AVS encodings to 25 * real voltages. 26 * unit is 0.1 mV. 27 */ 28 STATIC int 29 _soc_td3_bond_option_to_avs_status(int unit, int val) 30 { 31 int vol; 32 33 switch (val) { 34 case 0x62: 35 vol = 10000; 36 break; 37 case 0x66: 38 vol = 9750; 39 break; 40 case 0x6a: 41 vol = 9500; 42 break; 43 case 0x6e: 44 vol = 9250; 45 break; 46 case 0x72: 47 vol = 9000; 48 break; 49 default: 50 vol = 9500; 51 break; 52 } 53 54 return vol; 55 } 56 57 /* 58 * Function to initialize the bondoptions cache based on the 59 * Bond Info read from the relevant registers. 60 */ 61 int 62 soc_trident3_bond_info_init(int unit) 63 { 64 soc_bond_info_t *bond_info = SOC_BOND_INFO(unit); 65 uint32 addr, val; 66 int i; 67 68 soc_reg_t soc_td3_bond_info_regs[] = { 69 DMU_PCU_OTP_CONFIG_0r, 70 DMU_PCU_OTP_CONFIG_1r, 71 DMU_PCU_OTP_CONFIG_2r, 72 DMU_PCU_OTP_CONFIG_3r, 73 DMU_PCU_OTP_CONFIG_4r, 74 DMU_PCU_OTP_CONFIG_5r, 75 DMU_PCU_OTP_CONFIG_6r, 76 DMU_PCU_OTP_CONFIG_7r, 77 DMU_PCU_OTP_CONFIG_8r, 78 DMU_PCU_OTP_CONFIG_9r, 79 DMU_PCU_OTP_CONFIG_10r, 80 DMU_PCU_OTP_CONFIG_11r, 81 DMU_PCU_OTP_CONFIG_12r, 82 DMU_PCU_OTP_CONFIG_13r, 83 DMU_PCU_OTP_CONFIG_14r, 84 DMU_PCU_OTP_CONFIG_15r, 85 DMU_PCU_OTP_CONFIG_16r, 86 DMU_PCU_OTP_CONFIG_17r, 87 DMU_PCU_OTP_CONFIG_18r, 88 DMU_PCU_OTP_CONFIG_19r, 89 DMU_PCU_OTP_CONFIG_20r, 90 DMU_PCU_OTP_CONFIG_21r, 91 DMU_PCU_OTP_CONFIG_22r, 92 DMU_PCU_OTP_CONFIG_23r, 93 DMU_PCU_OTP_CONFIG_24r, 94 DMU_PCU_OTP_CONFIG_25r, 95 DMU_PCU_OTP_CONFIG_26r, 96 DMU_PCU_OTP_CONFIG_27r, 97 DMU_PCU_OTP_CONFIG_28r, 98 DMU_PCU_OTP_CONFIG_29r, 99 DMU_PCU_OTP_CONFIG_30r, 100 DMU_PCU_OTP_CONFIG_31r 101 }; 102 int reg_num = COUNTOF(soc_td3_bond_info_regs); 103 SHR_BITDCL bond_info_regval[_SHR_BITDCLSIZE(COUNTOF(soc_td3_bond_info_regs) * 32)] = {0}; 104 105 for (i = 0; i < reg_num; i++) { 106 addr = soc_reg_addr(unit, soc_td3_bond_info_regs[i], REG_PORT_ANY, 0); 107 soc_iproc_getreg(unit, addr, &val); 108 SHR_BITCOPY_RANGE(bond_info_regval, i * 32, &val, 0, 32); 109 } 110 111 SOC_BOND_OPTIONS_COPY(bond_info->rev_id, uint16, bond_info_regval, 0, 7); 112 SOC_BOND_OPTIONS_COPY(bond_info->dev_id, uint16, bond_info_regval, 8, 23); 113 SOC_BOND_OPTIONS_COPY(bond_info->device_skew, uint32, bond_info_regval, 24, 27); 114 SOC_BOND_OPTIONS_COPY(bond_info->mb_bank_num, uint32, bond_info_regval, 28, 33); 115 116 /* AVS Status */ 117 SOC_BOND_OPTIONS_COPY(val, uint32, bond_info_regval, 255, 262); 118 bond_info->avs_status = _soc_td3_bond_option_to_avs_status(unit, val); 119 120 return SOC_E_NONE; 121 } 122 123 #endif /* BCM_TRIDENT3_SUPPORT */ 124