bondoptions.c (3388B)
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 Tomahawk3 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_TOMAHAWK3_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_tomahawk3_bond_option_to_avs_status(int unit, int val) 30 { 31 int vol; 32 33 switch (val) { 34 case 0x70: 35 vol = 9125; 36 break; 37 case 0x73: 38 vol = 8937; 39 break; 40 case 0x76: 41 vol = 8750; 42 break; 43 case 0x79: 44 vol = 8562; 45 break; 46 case 0x7a: 47 vol = 8500; 48 break; 49 case 0x7e: 50 vol = 8250; 51 break; 52 case 0x82: 53 vol = 8000; 54 break; 55 case 0x86: 56 vol = 7750; 57 break; 58 default: 59 vol = 8937; 60 break; 61 } 62 63 return vol; 64 } 65 66 /* 67 * Function to initialize the bondoptions cache based on the 68 * Bond Info read from the relevant registers. 69 */ 70 int 71 soc_tomahawk3_bond_info_init(int unit) 72 { 73 soc_bond_info_t *bond_info = SOC_BOND_INFO(unit); 74 uint32 addr, val; 75 int i; 76 77 soc_reg_t soc_tomahawk3_bond_info_regs[] = { 78 DMU_PCU_OTP_CONFIG_0r, 79 DMU_PCU_OTP_CONFIG_1r, 80 DMU_PCU_OTP_CONFIG_2r, 81 DMU_PCU_OTP_CONFIG_3r, 82 DMU_PCU_OTP_CONFIG_4r, 83 DMU_PCU_OTP_CONFIG_5r, 84 DMU_PCU_OTP_CONFIG_6r, 85 DMU_PCU_OTP_CONFIG_7r, 86 DMU_PCU_OTP_CONFIG_8r, 87 DMU_PCU_OTP_CONFIG_9r, 88 DMU_PCU_OTP_CONFIG_10r, 89 DMU_PCU_OTP_CONFIG_11r, 90 DMU_PCU_OTP_CONFIG_12r, 91 DMU_PCU_OTP_CONFIG_13r, 92 DMU_PCU_OTP_CONFIG_14r, 93 DMU_PCU_OTP_CONFIG_15r, 94 DMU_PCU_OTP_CONFIG_16r, 95 DMU_PCU_OTP_CONFIG_17r, 96 DMU_PCU_OTP_CONFIG_18r, 97 DMU_PCU_OTP_CONFIG_19r, 98 DMU_PCU_OTP_CONFIG_20r, 99 DMU_PCU_OTP_CONFIG_21r, 100 DMU_PCU_OTP_CONFIG_22r, 101 DMU_PCU_OTP_CONFIG_23r, 102 DMU_PCU_OTP_CONFIG_24r, 103 DMU_PCU_OTP_CONFIG_25r, 104 DMU_PCU_OTP_CONFIG_26r, 105 DMU_PCU_OTP_CONFIG_27r, 106 DMU_PCU_OTP_CONFIG_28r, 107 DMU_PCU_OTP_CONFIG_29r, 108 DMU_PCU_OTP_CONFIG_30r, 109 DMU_PCU_OTP_CONFIG_31r 110 }; 111 int reg_num = COUNTOF(soc_tomahawk3_bond_info_regs); 112 SHR_BITDCL bond_info_regval[_SHR_BITDCLSIZE(COUNTOF(soc_tomahawk3_bond_info_regs) * 32)] = {0}; 113 114 for (i = 0; i < reg_num; i++) { 115 addr = soc_reg_addr(unit, soc_tomahawk3_bond_info_regs[i], REG_PORT_ANY, 0); 116 soc_iproc_getreg(unit, addr, &val); 117 SHR_BITCOPY_RANGE(bond_info_regval, i * 32, &val, 0, 32); 118 } 119 120 SOC_BOND_OPTIONS_COPY(bond_info->rev_id, uint16, bond_info_regval, 0, 7); 121 SOC_BOND_OPTIONS_COPY(bond_info->dev_id, uint16, bond_info_regval, 8, 23); 122 SOC_BOND_OPTIONS_COPY(bond_info->device_skew, uint32, bond_info_regval, 24, 27); 123 124 /* AVS Status */ 125 SOC_BOND_OPTIONS_COPY(val, uint32, bond_info_regval, 136, 143); 126 bond_info->avs_status = _soc_tomahawk3_bond_option_to_avs_status(unit, val); 127 128 return SOC_E_NONE; 129 } 130 131 #endif /* BCM_TOMAHAWK3_SUPPORT */ 132