bondoptions.c (2691B)
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_MAVERICK2_SUPPORT 17 18 #include <shared/bitop.h> 19 #include <soc/iproc.h> 20 #include <soc/maverick2.h> 21 #include <soc/bondoptions.h> 22 23 /* 24 * Function to initialize the bondoptions cache based on the 25 * Bond Info read from the relevant registers. 26 */ 27 int 28 soc_maverick2_bond_info_init(int unit) 29 { 30 soc_bond_info_t *bond_info = SOC_BOND_INFO(unit); 31 uint32 addr, val; 32 int i; 33 34 soc_reg_t soc_mv2_bond_info_regs[] = { 35 DMU_PCU_OTP_CONFIG_0r, 36 DMU_PCU_OTP_CONFIG_1r, 37 DMU_PCU_OTP_CONFIG_2r, 38 DMU_PCU_OTP_CONFIG_3r, 39 DMU_PCU_OTP_CONFIG_4r, 40 DMU_PCU_OTP_CONFIG_5r, 41 DMU_PCU_OTP_CONFIG_6r, 42 DMU_PCU_OTP_CONFIG_7r, 43 DMU_PCU_OTP_CONFIG_8r, 44 DMU_PCU_OTP_CONFIG_9r, 45 DMU_PCU_OTP_CONFIG_10r, 46 DMU_PCU_OTP_CONFIG_11r, 47 DMU_PCU_OTP_CONFIG_12r, 48 DMU_PCU_OTP_CONFIG_13r, 49 DMU_PCU_OTP_CONFIG_14r, 50 DMU_PCU_OTP_CONFIG_15r, 51 DMU_PCU_OTP_CONFIG_16r, 52 DMU_PCU_OTP_CONFIG_17r, 53 DMU_PCU_OTP_CONFIG_18r, 54 DMU_PCU_OTP_CONFIG_19r, 55 DMU_PCU_OTP_CONFIG_20r, 56 DMU_PCU_OTP_CONFIG_21r, 57 DMU_PCU_OTP_CONFIG_22r, 58 DMU_PCU_OTP_CONFIG_23r, 59 DMU_PCU_OTP_CONFIG_24r, 60 DMU_PCU_OTP_CONFIG_25r, 61 DMU_PCU_OTP_CONFIG_26r, 62 DMU_PCU_OTP_CONFIG_27r, 63 DMU_PCU_OTP_CONFIG_28r, 64 DMU_PCU_OTP_CONFIG_29r, 65 DMU_PCU_OTP_CONFIG_30r, 66 DMU_PCU_OTP_CONFIG_31r 67 }; 68 int reg_num = COUNTOF(soc_mv2_bond_info_regs); 69 SHR_BITDCL bond_info_regval[_SHR_BITDCLSIZE(COUNTOF(soc_mv2_bond_info_regs) * 32)] = {0}; 70 71 for (i = 0; i < reg_num; i++) { 72 addr = soc_reg_addr(unit, soc_mv2_bond_info_regs[i], REG_PORT_ANY, 0); 73 soc_iproc_getreg(unit, addr, &val); 74 SHR_BITCOPY_RANGE(bond_info_regval, i * 32, &val, 0, 32); 75 } 76 77 SOC_BOND_OPTIONS_COPY(bond_info->rev_id, uint16, bond_info_regval, 0, 7); 78 SOC_BOND_OPTIONS_COPY(bond_info->dev_id, uint16, bond_info_regval, 8, 23); 79 SOC_BOND_OPTIONS_COPY(bond_info->device_skew, uint32, bond_info_regval, 24, 27); 80 SOC_BOND_OPTIONS_COPY(bond_info->mb_bank_num, uint32, bond_info_regval, 28, 33); 81 SHR_BITCOPY_RANGE(bond_info->tsc_max_speed, 0, bond_info_regval, 304, 40); 82 83 return SOC_E_NONE; 84 } 85 86 #endif /* BCM_MAVERICK2_SUPPORT */ 87