rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2001 |
| 8 | * |
| 9 | *******************************************************************************/ |
| 10 | |
| 11 | /******************************************************************************* |
| 12 | * |
| 13 | * Filename: |
| 14 | * --------- |
| 15 | * nvram_mml1_default.c |
| 16 | * |
| 17 | * Project: |
| 18 | * -------- |
| 19 | * MT7206RF |
| 20 | * |
| 21 | * Description: |
| 22 | * ------------ |
| 23 | * |
| 24 | * |
| 25 | * Author: |
| 26 | * ------- |
| 27 | * |
| 28 | * |
| 29 | *******************************************************************************/ |
| 30 | /*===============================================================================================*/ |
| 31 | |
| 32 | #include "kal_general_types.h" |
| 33 | #include "kal_public_api.h" |
| 34 | #include "kal_public_defs.h" |
| 35 | #include "nvram_data_items.h" |
| 36 | |
| 37 | #include "mml1_rf_global.h" |
| 38 | |
| 39 | #include "mml1_custom_drdi.h" |
| 40 | |
| 41 | #include "mml1_fe_public.h" |
| 42 | #include "mml1_nvram_def.h" |
| 43 | |
| 44 | kal_bool mmrf_drdiHadDone = KAL_FALSE; |
| 45 | |
| 46 | void nvram_mmrf_drdiPointerInit(kal_uint16 setIdx) |
| 47 | { |
| 48 | #ifdef __MTK_TARGET__ |
| 49 | mmrf_mipiData_ptr = &(mml1CustomMipiData[setIdx]); |
| 50 | mmrf_rfData_ptr = &(mml1CustomRfData[setIdx]); |
| 51 | mmrf_feData_ptr = &(mml1CustomFeData[setIdx]); |
| 52 | |
| 53 | #if defined(__TX_POWER_OFFSET_SUPPORT__) || defined(__SAR_TX_POWER_BACKOFF_SUPPORT__) |
| 54 | mml1_sar_swtp_data_info_ptr = &(mml1CustomRfSarSwtpData[setIdx]); |
| 55 | #endif |
| 56 | |
| 57 | #if __IS_MML1_ETM_SUPPORT__ |
| 58 | mmrf_mipiEtmData_ptr = &( mml1CustomMipiEtmData[ setIdx ] ); |
| 59 | #endif // #if __IS_MML1_ET_SUPPORT__ |
| 60 | #endif |
| 61 | } |
| 62 | |
| 63 | void nvram_mmrf_drdi(void) |
| 64 | { |
| 65 | #ifdef __MTK_TARGET__ |
| 66 | #if (IS_MML1_RF_DRDI_CAPABILITY_SUPPORT) |
| 67 | if(mml1_custom_drdiEnable) |
| 68 | { |
| 69 | kal_uint16 setIdx; |
| 70 | |
| 71 | setIdx = MML1_RF_DRDI_Dynamic_GetParamAddr(MML1_RF_MMRF); |
| 72 | if (!mmrf_drdiHadDone) |
| 73 | { |
| 74 | /* set the pointer to RF custom data by set index */ |
| 75 | nvram_mmrf_drdiPointerInit(setIdx); |
| 76 | mmrf_drdiHadDone = KAL_TRUE; |
| 77 | } |
| 78 | } |
| 79 | else |
| 80 | { |
| 81 | /* set the pointer to default RF custom data, set0*/ |
| 82 | nvram_mmrf_drdiPointerInit(0); |
| 83 | } |
| 84 | #else |
| 85 | /* set the pointer to default RF custom data, set0*/ |
| 86 | nvram_mmrf_drdiPointerInit(0); |
| 87 | #endif |
| 88 | #endif |
| 89 | } |
| 90 | #if IS_MML1_SUPPORT_UTAS |
| 91 | MML1_FE_UTAS_NVRAM_T utas_nvram_data; |
| 92 | #endif |
| 93 | |
| 94 | void nvram_get_mmL1_default_value_to_write(nvram_lid_core_enum lid, kal_uint8 *buffer, kal_uint16 buffer_size) |
| 95 | { |
| 96 | #ifdef __MTK_TARGET__ |
| 97 | |
| 98 | nvram_mmrf_drdi(); |
| 99 | |
| 100 | switch (lid) |
| 101 | { |
| 102 | case NVRAM_EF_MML1_RF_PARAMETER_LID: |
| 103 | { |
| 104 | //kal_mem_cpy(buffer, &MML1_RF_CUSTOM_INPUT_DATA, NVRAM_EF_MML1_RF_PARAMETER_SIZE); |
| 105 | kal_mem_cpy(buffer, &mmrf_rfData_ptr->rfInputData, NVRAM_EF_MML1_RF_PARAMETER_SIZE); |
| 106 | } |
| 107 | break; |
| 108 | case NVRAM_EF_MML1_ABB_CAL_LID: |
| 109 | { |
| 110 | kal_mem_cpy(buffer, &mml1_rf_abb_cal_data_pcore, NVRAM_EF_MML1_ABB_CAL_SIZE); |
| 111 | } |
| 112 | break; |
| 113 | case NVRAM_EF_MML1_PMIC_SLT_VOLTAGE_CONTROL_LID: |
| 114 | { |
| 115 | kal_mem_cpy(buffer, &mml1_rf_pmic_slt_data_pcore, NVRAM_EF_MML1_PMIC_SLT_VOLTAGE_CONTROL_SIZE); |
| 116 | } |
| 117 | break; |
| 118 | case NVRAM_EF_MML1_RF_POC_DATA_LID: |
| 119 | { |
| 120 | kal_mem_cpy(buffer, &MML1_RF_POC_DATA, NVRAM_EF_MML1_RF_POC_DATA_SIZE); |
| 121 | } |
| 122 | break; |
| 123 | case NVRAM_EF_MML1_MIPI_INITIAL_CW_LID: |
| 124 | { |
| 125 | kal_mem_cpy(buffer, mmrf_mipiData_ptr->initTable_p, NVRAM_EF_MML1_MIPI_INITIAL_CW_SIZE); |
| 126 | } |
| 127 | break; |
| 128 | case NVRAM_EF_MML1_MIPI_USID_CHANGE_LID: |
| 129 | { |
| 130 | kal_mem_cpy(buffer, mmrf_mipiData_ptr->changeUsidTable_p, NVRAM_EF_MML1_MIPI_USID_CHANGE_SIZE); |
| 131 | } |
| 132 | break; |
| 133 | #if IS_MMRF_MIPI_HW_CHECK_SUPPORT |
| 134 | case NVRAM_EF_MML1_MIPI_HW_CHECK_LID: |
| 135 | { |
| 136 | kal_mem_cpy(buffer, mmrf_mipiData_ptr->checkHwTable_p, NVRAM_EF_MML1_MIPI_HW_CHECK_SIZE); |
| 137 | } |
| 138 | break; |
| 139 | #endif |
| 140 | #ifdef __RF_DRDI_CAPABILITY_SUPPORT__ |
| 141 | case NVRAM_EF_MML1_CUSTOM_DYNAMIC_INIT_LID: |
| 142 | { |
| 143 | kal_mem_cpy(buffer, &mml1_rf_drdi_dynamic_init_param, NVRAM_EF_MML1_CUSTOM_DYNAMIC_INIT_SIZE); |
| 144 | } |
| 145 | break; |
| 146 | #endif |
| 147 | case NVRAM_EF_MML1_CRYSTAL_LID: |
| 148 | { |
| 149 | kal_mem_cpy(buffer, &MML1_CRYSTAL_CTRL, NVRAM_EF_MML1_CRYSTAL_SIZE); |
| 150 | } |
| 151 | break; |
| 152 | case NVRAM_EF_MML1_GPS_CO_TMS_DATA_LID: |
| 153 | { |
| 154 | kal_mem_cpy(buffer, &MML1_CoTMS_ConfigTbl_ToAP, NVRAM_EF_MML1_GPS_CO_TMS_DATA_SIZE); |
| 155 | } |
| 156 | break; |
| 157 | case NVRAM_EF_MML1_TEMPERATURE_DAC_LID: |
| 158 | { |
| 159 | kal_mem_cpy(buffer, &MML1_TempDacTable, NVRAM_EF_MML1_TEMPERATURE_DAC_SIZE); |
| 160 | } |
| 161 | break; |
| 162 | #if defined(__TX_POWER_OFFSET_SUPPORT__) |
| 163 | case NVRAM_EF_MML1_TXPOWEROFFSET_LID: |
| 164 | { |
| 165 | kal_mem_cpy(buffer, &mml1_sar_swtp_data_info_ptr->swtp, NVRAM_EF_MML1_TXPOWEROFFSET_SIZE); |
| 166 | } |
| 167 | break; |
| 168 | #endif |
| 169 | #if defined(__SAR_TX_POWER_BACKOFF_SUPPORT__) |
| 170 | case NVRAM_EF_MML1_SAR_TXPOWEROFFSET_LID: |
| 171 | { |
| 172 | kal_mem_cpy(buffer, &mml1_sar_swtp_data_info_ptr->sar, NVRAM_EF_MML1_SAR_TXPOWEROFFSET_SIZE); |
| 173 | } |
| 174 | break; |
| 175 | #endif |
| 176 | case NVRAM_EF_MML1_MIPI_LPM_CW_LID: |
| 177 | { |
| 178 | kal_mem_cpy(buffer, mmrf_mipiData_ptr->lpmTable_p, NVRAM_EF_MML1_MIPI_LPM_CW_SIZE); |
| 179 | } |
| 180 | break; |
| 181 | case NVRAM_EF_MML1_ELNA_DATABASE_LID: |
| 182 | { |
| 183 | kal_uint32 i; |
| 184 | MML1_FE_ELNA_NVRAM_T elna_nvram_data = {{0}}; |
| 185 | const MML1_FE_ELNA_RAW_T *elna_rawdata_p; |
| 186 | |
| 187 | elna_rawdata_p = &(mmrf_feData_ptr->feComponentsList.elna_raw_database[0]); |
| 188 | |
| 189 | for(i = 0; i < MML1_FE_ELNA_NUM; i++) |
| 190 | { |
| 191 | elna_nvram_data.elna_settling_time[i] = elna_rawdata_p->elna_config_data.elna_settling_time; |
| 192 | elna_rawdata_p++; |
| 193 | } |
| 194 | kal_mem_cpy(buffer, &(elna_nvram_data), NVRAM_EF_MML1_ELNA_DATABASE_SIZE); |
| 195 | } |
| 196 | break; |
| 197 | case NVRAM_EF_MML1_EXT_VPA_INITIAL_CW_LID: |
| 198 | { |
| 199 | kal_mem_cpy(buffer, mmrf_mipiData_ptr->extVpaTable_p, NVRAM_EF_MML1_EXT_VPA_INITIAL_CW_SIZE); |
| 200 | } |
| 201 | break; |
| 202 | case NVRAM_EF_MML1_MIPI_ETM_INFORMATION_LID: |
| 203 | { |
| 204 | #if __IS_MML1_ETM_SUPPORT__ |
| 205 | kal_mem_cpy( buffer, mmrf_mipiEtmData_ptr->infoTable_p, NVRAM_EF_MML1_MIPI_ETM_INFORMATION_SIZE ); |
| 206 | #endif // #if __IS_MML1_ETM_SUPPORT__ |
| 207 | } |
| 208 | break; |
| 209 | case NVRAM_EF_MML1_MIPI_ETM_INITIAL_CW_LID: |
| 210 | { |
| 211 | #if __IS_MML1_ETM_SUPPORT__ |
| 212 | kal_mem_cpy( buffer, mmrf_mipiEtmData_ptr->initTable_p, NVRAM_EF_MML1_MIPI_ETM_INITIAL_CW_SIZE ); |
| 213 | #endif // #if __IS_MML1_ETM_SUPPORT__ |
| 214 | } |
| 215 | break; |
| 216 | case NVRAM_EF_MML1_GPS_CO_TMS_DATA_MD_LID: |
| 217 | { |
| 218 | kal_mem_cpy(buffer, MML1_CoTMSTbl[0], NVRAM_EF_MML1_GPS_CO_TMS_DATA_MD_SIZE); |
| 219 | } |
| 220 | break; |
| 221 | case NVRAM_EF_MML1_UTAS_DATABASE_LID: |
| 222 | { |
| 223 | #if IS_MML1_SUPPORT_UTAS |
| 224 | kal_uint32 i,event_count, data_count; |
| 225 | //MML1_FE_UTAS_NVRAM_T utas_nvram_data={{{{0}}}}; |
| 226 | kal_mem_set(&utas_nvram_data,0,sizeof(MML1_FE_UTAS_NVRAM_T)); |
| 227 | for(i=0; i<MMRFD_TAS_MAX_STATE_NUM; i++) |
| 228 | { |
| 229 | utas_nvram_data.utas_switch_raw_database.utas_switch_fe_setting[i] = *(((mmrf_feData_ptr->feComponentsList).utas_switch_raw_database.utas_switch_fe_setting)+i); |
| 230 | for(event_count=0; event_count<MMRFD_MIPI_ANT_EVENT_NUM; event_count++) |
| 231 | { |
| 232 | utas_nvram_data.utas_switch_raw_database.utas_switch_mipi_event_custom_table[i][event_count] = *(*((mmrf_feData_ptr->feComponentsList).utas_switch_raw_database.utas_switch_mipi_event_custom_table[i])+event_count); |
| 233 | } |
| 234 | for(data_count=0; data_count<MMRFD_MIPI_ANT_DATA_NUM; data_count++) |
| 235 | { |
| 236 | utas_nvram_data.utas_switch_raw_database.utas_switch_mipi_data_custom_table[i][data_count] = *(*((mmrf_feData_ptr->feComponentsList).utas_switch_raw_database.utas_switch_mipi_data_custom_table[i])+data_count); |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | for(i=0; i<MMRFD_TAS_MAX_TUNER_DATA_NUM; i++) |
| 241 | { |
| 242 | utas_nvram_data.utas_tuner_raw_database.utas_tuner_fe_setting[i] = *(((mmrf_feData_ptr->feComponentsList).utas_tuner_raw_database.utas_tuner_fe_setting)+i); |
| 243 | for(event_count=0; event_count<MMRFD_MIPI_ANT_EVENT_NUM; event_count++) |
| 244 | { |
| 245 | utas_nvram_data.utas_tuner_raw_database.utas_tuner_mipi_event_custom_table[i][event_count] = *(*((mmrf_feData_ptr->feComponentsList).utas_tuner_raw_database.utas_tuner_mipi_event_custom_table[i])+event_count); |
| 246 | } |
| 247 | for(data_count=0; data_count<MMRFD_MIPI_ANT_DATA_NUM; data_count++) |
| 248 | { |
| 249 | utas_nvram_data.utas_tuner_raw_database.utas_tuner_mipi_data_custom_table[i][data_count] = *(*((mmrf_feData_ptr->feComponentsList).utas_tuner_raw_database.utas_tuner_mipi_data_custom_table[i])+data_count); |
| 250 | } |
| 251 | } |
| 252 | for(i=0; i<MMRFD_TAS_MAX_TUNER_CONTROL_SETTING_NUM; i++) |
| 253 | { |
| 254 | utas_nvram_data.utas_tuner_raw_database.utas_ant_tuner_control_database.tas_tuner_db[i] = (((mmrf_feData_ptr->feComponentsList).utas_tuner_raw_database.utas_ant_tuner_control_database)->tas_tuner_db[i]); |
| 255 | } |
| 256 | kal_mem_cpy(buffer, &utas_nvram_data, NVRAM_EF_MML1_UTAS_DATABASE_SIZE); |
| 257 | #endif |
| 258 | } |
| 259 | break; |
| 260 | default: |
| 261 | ASSERT(KAL_FALSE); |
| 262 | break; |
| 263 | } |
| 264 | #endif |
| 265 | } |
| 266 | |