yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | #!/usr/bin/perl
|
| 2 | #
|
| 3 | # Copyright Statement:
|
| 4 | # --------------------
|
| 5 | # This software is protected by Copyright and the information contained
|
| 6 | # herein is confidential. The software may not be copied and the information
|
| 7 | # contained herein may not be used or disclosed except with the written
|
| 8 | # permission of MediaTek Inc. (C) 2006
|
| 9 | #
|
| 10 | # BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
|
| 11 | # THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
|
| 12 | # RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
|
| 13 | # AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
|
| 14 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
|
| 15 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
|
| 16 | # NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
|
| 17 | # SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
|
| 18 | # SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
|
| 19 | # THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
|
| 20 | # NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
|
| 21 | # SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
|
| 22 | #
|
| 23 | # BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
|
| 24 | # LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
|
| 25 | # AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
|
| 26 | # OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
|
| 27 | # MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
|
| 28 | #
|
| 29 | # THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
|
| 30 | # WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
|
| 31 | # LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
|
| 32 | # RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
|
| 33 | # THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
|
| 34 | #
|
| 35 | #*****************************************************************************
|
| 36 | #*
|
| 37 | #* Filename:
|
| 38 | #* ---------
|
| 39 | #* cfgGen_EMI.pl
|
| 40 | #*
|
| 41 | #* Project:
|
| 42 | #* --------
|
| 43 | #*
|
| 44 | #*
|
| 45 | #* Description:
|
| 46 | #* ------------
|
| 47 | #* This script generates EMI part in the CFG file for flash tool for SV5
|
| 48 | #*
|
| 49 | #* Author:
|
| 50 | #* -------
|
| 51 | #* Marvin Lin (mtk03483)
|
| 52 | #*
|
| 53 | #*============================================================================
|
| 54 | #* HISTORY
|
| 55 | #* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
|
| 56 | #*------------------------------------------------------------------------------
|
| 57 | #* $Revision$
|
| 58 | #* $Modtime$
|
| 59 | #* $Log$
|
| 60 | #*
|
| 61 | #* 05 22 2014 tafang.chen
|
| 62 | #* [MOLY00062786] [UMOLY][SM]
|
| 63 | #* Initial MoDIS build env - fix path problem.
|
| 64 | #*
|
| 65 | #* 08 23 2013 guo-huei.chang
|
| 66 | #* [MOLY00034592] [MT6290][Combo Memory Support] Enable Combo Memory Feature
|
| 67 | #* 1. Update Memory Device List for MT6290(m)
|
| 68 | #* 2. Update/re-arch cfggen
|
| 69 | #* 3. Update/re-arch emigen
|
| 70 | #* 4. remove emigen/cfggen legacy
|
| 71 | #* 5. Add combo memory supporting
|
| 72 | #* 6. auto-generate all header files that emigen related
|
| 73 | #*
|
| 74 | #* 04 16 2013 guo-huei.chang
|
| 75 | #* [MOLY00013409] [MT6290 Bring-up] DRAMC/EMI related Code Update
|
| 76 | #* 1. update emigen to auto-gen all header files
|
| 77 | #* 2. update init mempll
|
| 78 | #* 3. update cfggen
|
| 79 | #*
|
| 80 | #* 03 22 2013 guo-huei.chang
|
| 81 | #* [MOLY00012511] update auto-k for MT6290 FPGA, MT6290 EVB, and MT6290M EVB
|
| 82 | #* 1. add custom folder for MT6290M
|
| 83 | #* 2. update custom_EMI.h and custom_EMI_release.h with emigen
|
| 84 | #* 3. update custom_EMI_INFO.h with manual check in
|
| 85 | #* 4. update cfggen
|
| 86 | #*
|
| 87 | #* 03 19 2013 guo-huei.chang
|
| 88 | #* [MOLY00011607] update custom_EMI function and cfggen EMI part
|
| 89 | #* integrate CBr that update emigen and cfggen
|
| 90 | #*
|
| 91 | #* 03 08 2013 guo-huei.chang
|
| 92 | #* [MOLY00011607] update custom_EMI function and cfggen EMI part
|
| 93 | #* update custom_EMI function into custom_EMI_MT6290.c and remove it in devdrv_fakeapi.c
|
| 94 | #* update cfgGen_EMI.pl for MT6290
|
| 95 | #*
|
| 96 | #* 08 16 2012 marvin.lin
|
| 97 | #* [MOLY00002193] [MemoryStorage][Auto-Gen][EMI Gen/CFG Gen][Request For Design Change] support MT6280 combo memory
|
| 98 | #* .
|
| 99 | #*
|
| 100 | #*
|
| 101 | #*------------------------------------------------------------------------------
|
| 102 | #* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
|
| 103 | #*============================================================================
|
| 104 | #****************************************************************************/
|
| 105 |
|
| 106 | #****************************************************************************
|
| 107 | # Included Modules
|
| 108 | #****************************************************************************
|
| 109 | use strict;
|
| 110 | use warnings;
|
| 111 | no warnings 'redefine';
|
| 112 | # auto flush print function
|
| 113 | local $| = 1;
|
| 114 |
|
| 115 | #****************************************************************************
|
| 116 | # Constants
|
| 117 | #****************************************************************************
|
| 118 | my $CFGGEN_EMI_VERNO = " V0.03";
|
| 119 | # v0.03 , Fix compile error when $PLATFORM is not found
|
| 120 | # v0.02 , Support MT6255 SF+DDR or DISCRETE_NAND case
|
| 121 | # v0.01 , Fix unable to pre-compie custom_EMI_MT6256.c when make new issue
|
| 122 | # v0.00 , initial version
|
| 123 |
|
| 124 | #****************************************************************************
|
| 125 | # Input Parameters and Global Variables
|
| 126 | #****************************************************************************
|
| 127 | my $DebugPrint = 0;
|
| 128 |
|
| 129 | #****************************************************************************
|
| 130 | # subroutine: get_mem_dev_h_value
|
| 131 | # input: $str_BB_path: BB folder path
|
| 132 | # input: $href_mem_dev: reference of hash of custom_MemoryDevice.h configurations
|
| 133 | #****************************************************************************
|
| 134 | sub get_mem_dev_h_value
|
| 135 | {
|
| 136 | my ($str_BB_path, $href_makefile_options) = @_;
|
| 137 | my %mem_dev_options;
|
| 138 | my $CUSTOM_MEM_DEV_H = $str_BB_path . "\/custom_MemoryDevice.h";
|
| 139 |
|
| 140 | open (MEMDEVH_HANDLE, "<$CUSTOM_MEM_DEV_H") or &error_handler("$CUSTOM_MEM_DEV_H: file error!", __FILE__, __LINE__);
|
| 141 | while (<MEMDEVH_HANDLE>) {
|
| 142 | if (/^#define\s+(\w+)\s+\((\w*)\)/ || /^#define\s+(\w+)\s+(\w*)/)
|
| 143 | {
|
| 144 | my $option = $1;
|
| 145 | my $value = $2;
|
| 146 |
|
| 147 | &error_handler("$CUSTOM_MEM_DEV_H: $option redefined in custom_MemoryDevice.h!", __FILE__, __LINE__) if defined($mem_dev_options{$option});
|
| 148 | if ((!defined $value) or ($value eq ''))
|
| 149 | {
|
| 150 | $mem_dev_options{$option} = 'TRUE';
|
| 151 | }
|
| 152 | else
|
| 153 | {
|
| 154 | $mem_dev_options{$option} = $value;
|
| 155 | }
|
| 156 | }
|
| 157 | }
|
| 158 | if ((!defined $href_makefile_options->{'combo_memory_support'}) or ($href_makefile_options->{'combo_memory_support'} eq 'FALSE'))
|
| 159 | {
|
| 160 | $mem_dev_options{COMBO_MEM_ENTRY_COUNT} = 1;
|
| 161 | }
|
| 162 |
|
| 163 | close (MEMDEVH_HANDLE);
|
| 164 |
|
| 165 | return %mem_dev_options;
|
| 166 | }
|
| 167 |
|
| 168 | #****************************************************************************
|
| 169 | # subroutine: error_handler
|
| 170 | # input: $error_msg: error message
|
| 171 | #****************************************************************************
|
| 172 | sub error_handler
|
| 173 | {
|
| 174 | my ($error_msg, $file, $line_no) = @_;
|
| 175 |
|
| 176 | my $final_error_msg = "CFGGEN ERROR: $error_msg at $file line $line_no\n";
|
| 177 | print $final_error_msg;
|
| 178 | die $final_error_msg;
|
| 179 | }
|
| 180 |
|
| 181 | #****************************************************************************
|
| 182 | # subroutine: get_emi_settings
|
| 183 | # return: EMI settings
|
| 184 | #****************************************************************************
|
| 185 | sub get_emi_settings
|
| 186 | {
|
| 187 | my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_;
|
| 188 | my @emi_settings;
|
| 189 |
|
| 190 | ### Pre-compile custom_EMI.c
|
| 191 | my ($custom_EMI_c_file);
|
| 192 | my $custom_emi_command;
|
| 193 | $custom_EMI_c_file = ".\/pcore\/custom\/driver\/common\/custom_EMI_" . $bb . ".c";
|
| 194 |
|
| 195 | print "custom_EMI.c = $custom_EMI_c_file\n";
|
| 196 | $custom_emi_command = "$cc_cmd $via_cmd$option_tmp_file -E $custom_EMI_c_file > " . $custom_emi_temp_local . "\/" . "~custom_EMI_c.tmp";
|
| 197 | print "$custom_emi_command\n";
|
| 198 |
|
| 199 | my $status = system($custom_emi_command);
|
| 200 | &error_handler("\/pcore\/tools\/cfgGen_EMI.pl: pre-compile $custom_EMI_c_file erro!", __FILE__, __LINE__) if ($status != 0);
|
| 201 |
|
| 202 | ### Get Memory Type
|
| 203 | my ($emi_clk, $emi_dev_type, $memory_type);
|
| 204 | my $CUSTOM_EMI_RELEASE_H;
|
| 205 | $CUSTOM_EMI_RELEASE_H = $str_BB_path . "\/custom_EMI_release.h";
|
| 206 |
|
| 207 | open (CUSTOM_EMI_RELEASE_H, "<$CUSTOM_EMI_RELEASE_H") or &error_handler("$CUSTOM_EMI_RELEASE_H: file error!", __FILE__, __LINE__);
|
| 208 | while (<CUSTOM_EMI_RELEASE_H>)
|
| 209 | {
|
| 210 | if (/#define __EMI_CLK_(\d+)MHZ__/)
|
| 211 | {
|
| 212 | $emi_clk = $1;
|
| 213 | }
|
| 214 | elsif (/#define __EMI_DEVICE_(\w+)__/)
|
| 215 | {
|
| 216 | $emi_dev_type = $1;
|
| 217 | }
|
| 218 | }
|
| 219 | close CUSTOM_EMI_RELEASE_H;
|
| 220 | if($href_MAKEFILE_OPTIONS->{'sip_ram_size'} ne "NONE")
|
| 221 | {
|
| 222 | $memory_type = "SIP_";
|
| 223 | }
|
| 224 | $memory_type .= $emi_dev_type . "_" . $emi_clk . "MHZ";
|
| 225 |
|
| 226 | ### Read EMI settings from ~custom_EMI_c.tmp
|
| 227 | my $file_content;
|
| 228 | my $custom_emi_path;
|
| 229 | $custom_emi_path = "<" . $custom_emi_temp_local . "\/~custom_EMI_c.tmp";
|
| 230 |
|
| 231 | print "path:$custom_emi_path\n";
|
| 232 | open (CUSTOM_EMI_C_TMP, $custom_emi_path) or &error_handler("~custom_EMI_c.tmp: file error!", __FILE__, __LINE__);
|
| 233 | {
|
| 234 | local $/;
|
| 235 | $file_content = <CUSTOM_EMI_C_TMP>;
|
| 236 | }
|
| 237 | close CUSTOM_EMI_C_TMP;
|
| 238 |
|
| 239 | ### Get EMI_INFO type declaration
|
| 240 | my $EMI_INFO_decl_str;
|
| 241 | my %EMI_INFO_decl_hash; # key: EMI register; value: index
|
| 242 | my $EMI_INFO_decl_count = 0;
|
| 243 | if ($file_content =~ /typedef\s*struct\s*\{([\S|\s]+?)\}\s*MTK_EMI_Info/)
|
| 244 | {
|
| 245 | $EMI_INFO_decl_str = $1;
|
| 246 | }
|
| 247 | while ($EMI_INFO_decl_str =~ /\{/) # Skip all other contents between the beginning { and the real EMI info
|
| 248 | {
|
| 249 | $EMI_INFO_decl_str = $';
|
| 250 | }
|
| 251 | while ($EMI_INFO_decl_str =~ /unsigned int (\w+)\;/)
|
| 252 | {
|
| 253 | $EMI_INFO_decl_hash{$1} = $EMI_INFO_decl_count;
|
| 254 | $EMI_INFO_decl_count++;
|
| 255 | $EMI_INFO_decl_str = $';
|
| 256 | }
|
| 257 | print "EMI_INFO_decl_hash:\n" if ($DebugPrint == 1);
|
| 258 | foreach my $idx (keys %EMI_INFO_decl_hash)
|
| 259 | {
|
| 260 | print "$idx\n" if ($DebugPrint == 1);
|
| 261 | }
|
| 262 |
|
| 263 | ### Trim EMI Info contents string
|
| 264 | my $EMI_INFO_value_str;
|
| 265 | if ($file_content =~ /MTK_EMI_Info\s*EMI_INFO\[\]\s*\=\s*\{([\s|\S]+?)\}\;/)
|
| 266 | {
|
| 267 | $EMI_INFO_value_str = $1;
|
| 268 | }
|
| 269 | $EMI_INFO_value_str =~ s/\s//g; # EMI_INFO_value_str becomes {EMI_INFO set 1},{EMI_INFO set 2},......,{EMI_INFO set n}
|
| 270 |
|
| 271 | my @EMI_INFO_value_array;
|
| 272 | @EMI_INFO_value_array = split(/},{/,$EMI_INFO_value_str);
|
| 273 |
|
| 274 | for my $idx (0..$#EMI_INFO_value_array)
|
| 275 | {
|
| 276 | $EMI_INFO_value_array[$idx] =~ s/^,//; # Remove the beginning ,
|
| 277 | $EMI_INFO_value_array[$idx] =~ s/^{//; # Remove the beginning {
|
| 278 | $EMI_INFO_value_array[$idx] =~ s/,$//; # Remove the last ,
|
| 279 | $EMI_INFO_value_array[$idx] =~ s/,}$//; # Remove the last ,}
|
| 280 | print "\$EMI_INFO_value_array[$idx]:\n$EMI_INFO_value_array[$idx]\n" if ($DebugPrint == 1);
|
| 281 | }
|
| 282 |
|
| 283 | for my $combo_idx (1..$href_mem_dev_options->{COMBO_MEM_ENTRY_COUNT})
|
| 284 | {
|
| 285 | ### Get EMI Info contents
|
| 286 | my %cur_emi_info_value_list;
|
| 287 | foreach (split(/,/, $EMI_INFO_value_array[$combo_idx-1]))
|
| 288 | {
|
| 289 | if ((/\.(\w+)=\((0x[\w]{1,8})\)/) or (/\.(\w+)=(0x[\w]{1,8})/))
|
| 290 | {
|
| 291 | $cur_emi_info_value_list{$1} = $2;
|
| 292 | }
|
| 293 | }
|
| 294 | $emi_settings[$combo_idx] = <<"__TEMPLATE";
|
| 295 | memory_type: $memory_type
|
| 296 | EMI_Setting:
|
| 297 | __TEMPLATE
|
| 298 | foreach my $key (sort keys %cur_emi_info_value_list)
|
| 299 | {
|
| 300 | if ($key =~ /(\w+)_val/)
|
| 301 | {
|
| 302 | $emi_settings[$combo_idx] .= " " . uc($1) . ": " . $cur_emi_info_value_list{$key} . "\n";
|
| 303 | }
|
| 304 | else
|
| 305 | {
|
| 306 | $emi_settings[$combo_idx] .= " " . uc($key) . ": " . $cur_emi_info_value_list{$key} . "\n";
|
| 307 | }
|
| 308 | }
|
| 309 | print "combo_mem_idx:$combo_idx\n" if ($DebugPrint == 1);
|
| 310 | print "$emi_settings[$combo_idx]\n" if ($DebugPrint == 1);
|
| 311 | }
|
| 312 |
|
| 313 | return @emi_settings;
|
| 314 | }
|
| 315 |
|
| 316 | #****************************************************************************
|
| 317 | # subroutine: get_flash_settings
|
| 318 | # return: Flash settings
|
| 319 | #****************************************************************************
|
| 320 | sub get_flash_settings
|
| 321 | {
|
| 322 | my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_;
|
| 323 | my @flash_settings;
|
| 324 |
|
| 325 | ### Read flash ID from combo_flash_id.h
|
| 326 | my (@flash_id_str_list, @flash_id, @valid_id_length_list);
|
| 327 | my $flash_id_template;
|
| 328 | my $decide_flash_type = "NAND";
|
| 329 | my $mcp_count = 0;
|
| 330 | my $COMBO_FLASH_ID_H;
|
| 331 | $COMBO_FLASH_ID_H = $str_BB_path . "\/combo_flash_id.h";
|
| 332 |
|
| 333 | open (COMBO_FLASH_ID_H, "<$COMBO_FLASH_ID_H") or &error_handler("$COMBO_FLASH_ID_H: file error!", __FILE__, __LINE__);
|
| 334 | while (<COMBO_FLASH_ID_H>)
|
| 335 | {
|
| 336 | if (/\s+(\d+),\s*\/\/\s*Valid\s+ID\s+length/)
|
| 337 | {
|
| 338 | $valid_id_length_list[$mcp_count] = $1;
|
| 339 | }
|
| 340 | elsif (/\s+\{(.+)\}\s*\/\/\s*Flash\s+ID/)
|
| 341 | {
|
| 342 | $flash_id_str_list[$mcp_count] = $1;
|
| 343 | ##$mcp_count++;
|
| 344 | if($href_MAKEFILE_OPTIONS->{'serial_flash_support'} eq 'TRUE')##SF align with NAND, restruct 16bit type ID string
|
| 345 | {
|
| 346 | $flash_id_template = undef;
|
| 347 | $decide_flash_type = "SF";
|
| 348 | $flash_id_str_list[$mcp_count] =~ s/\{//;
|
| 349 | $flash_id_str_list[$mcp_count] =~ s/\}//;
|
| 350 | $flash_id_str_list[$mcp_count] =~ s/\s+//g;
|
| 351 | print "Before restruct id string is : $flash_id_str_list[$mcp_count]\n";
|
| 352 | @flash_id = split /\,/, $flash_id_str_list[$mcp_count];
|
| 353 | my $cur_flash_id = "0xFFFF";
|
| 354 | for (0..7) # there are totally 8 flash ID
|
| 355 | {
|
| 356 | $cur_flash_id = sprintf("0x%04X", hex($flash_id[$_]));
|
| 357 | print "cur_flash_id is : $cur_flash_id\n";
|
| 358 | if(7 == $_)
|
| 359 | {
|
| 360 | $flash_id_template .= "$cur_flash_id\n";
|
| 361 | ###$block_info_lines .= " \{$tmp_start, $tmp_size\},\n";
|
| 362 | }
|
| 363 | else
|
| 364 | {
|
| 365 | $flash_id_template .= "$cur_flash_id, \n";
|
| 366 | }
|
| 367 | print "After restruct template id string is : $flash_id_template\n";
|
| 368 | chomp($flash_id_template);
|
| 369 | }
|
| 370 | $flash_id_str_list[$mcp_count] = $flash_id_template;
|
| 371 | print "After restruct id string is : $flash_id_template\n";
|
| 372 | }
|
| 373 | $mcp_count++;
|
| 374 | }
|
| 375 | }
|
| 376 | close COMBO_FLASH_ID_H;
|
| 377 |
|
| 378 |
|
| 379 | #Parse combo_nfi_config.h to gen NAND Parameters for Flashtool Download
|
| 380 | my @combo_nfi_info_struct;
|
| 381 | if($href_MAKEFILE_OPTIONS->{'nand_support'} eq 'TRUE')
|
| 382 | {
|
| 383 | my $COMBO_FLASH_CONFIG_H;##NAND Flash Config File
|
| 384 | $COMBO_FLASH_CONFIG_H = $str_BB_path . "\/combo_nfi_config.h";
|
| 385 |
|
| 386 | my $combo_flash_idx = -1;
|
| 387 | print "$COMBO_FLASH_CONFIG_H\n";
|
| 388 | open (COMBO_FLASH_CONFIG_H, "<$COMBO_FLASH_CONFIG_H") or &error_handler("$COMBO_FLASH_CONFIG_H: file error!", __FILE__, __LINE__);
|
| 389 | while (<COMBO_FLASH_CONFIG_H>)
|
| 390 | {
|
| 391 | if (/\s*0x(\w+),\s*\/\/\s*NFI_(\w+)_(\w+)/)
|
| 392 | {
|
| 393 | #print "1-[$combo_flash_idx]: $1, $2, $3\n";
|
| 394 | $combo_nfi_info_struct[$combo_flash_idx] .= "\n " ."NFI_" ."$2_" . "$3" .": " ."0x$1";
|
| 395 | }
|
| 396 | elsif (/\s*(\w+),\s*\/\/\s*NFI_(\w+)_(\w+)/)
|
| 397 | {
|
| 398 | #print "2-[$combo_flash_idx]: $1, $2, $3\n";
|
| 399 | $combo_nfi_info_struct[$combo_flash_idx] .= "\n " ."NFI_" ."$2_" . "$3" .": " ."$1";
|
| 400 | }
|
| 401 | elsif (/\s*\{(.+)\},\s*\/\/\s*NFI_(\w+)_(\w+)/)
|
| 402 | {
|
| 403 | #print "3-[$combo_flash_idx]: $1, $2, $3\n";
|
| 404 | if($2 eq 'BB')
|
| 405 | {
|
| 406 | $combo_nfi_info_struct[$combo_flash_idx] .= "\n " ."NFI_" ."$2_" . "$3" .": " ."[$1]";
|
| 407 | }
|
| 408 | else
|
| 409 | {
|
| 410 | $combo_flash_idx++;#to calculate combo idx
|
| 411 | $combo_nfi_info_struct[$combo_flash_idx] .= "\n " ."NFI_" ."$2_" . "$3" .": " ."$1";#NFI_DeviceName is the first parse line of combo flash
|
| 412 | }
|
| 413 | }
|
| 414 | }
|
| 415 | }
|
| 416 |
|
| 417 | for (0..($mcp_count-1))
|
| 418 | {
|
| 419 | my $combo_idx = $_ + 1;
|
| 420 |
|
| 421 |
|
| 422 | $flash_settings[$combo_idx] .= <<"__TEMPLATE";
|
| 423 | - flash_info:
|
| 424 | flash_type: $decide_flash_type
|
| 425 | id_length: $valid_id_length_list[$_]
|
| 426 | __TEMPLATE
|
| 427 | if (defined $combo_nfi_info_struct[$_])
|
| 428 | {
|
| 429 | $flash_settings[$combo_idx] .= <<"__TEMPLATE";
|
| 430 | flash_id: [$flash_id_str_list[$_]]$combo_nfi_info_struct[$_]
|
| 431 | __TEMPLATE
|
| 432 | }
|
| 433 | else
|
| 434 | {
|
| 435 | $flash_settings[$combo_idx] .= <<"__TEMPLATE";
|
| 436 | flash_id: [$flash_id_str_list[$_]]
|
| 437 | __TEMPLATE
|
| 438 | }
|
| 439 | }
|
| 440 |
|
| 441 | return @flash_settings;
|
| 442 | }
|
| 443 |
|
| 444 | #****************************************************************************
|
| 445 | # subroutine: gen_external_memory_setting
|
| 446 | # input: $str_BB_path: BB folder path
|
| 447 | # return: External Memory Setting
|
| 448 | #****************************************************************************
|
| 449 | sub gen_external_memory_setting
|
| 450 | {
|
| 451 | my ($str_BB_path, $str_board_ver, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS) = @_;
|
| 452 | my (@emi_settings, @flash_settings);
|
| 453 | my %custom_mem_dev_options;
|
| 454 |
|
| 455 | %custom_mem_dev_options = &get_mem_dev_h_value($str_BB_path, $href_MAKEFILE_OPTIONS);
|
| 456 |
|
| 457 | ### Generate EMI settings from CFG file for chips which do not support Auto-Gen
|
| 458 | if (($bb ne 'MT6276') and ($bb ne 'MT6256') and ($bb ne 'MT6255') and ($bb ne 'MT6280') and ($bb ne 'MT6290'))
|
| 459 | {
|
| 460 | my $EMI_CFG_FILE;
|
| 461 | $EMI_CFG_FILE = $str_BB_path . "\/" . $str_board_ver . "\.cfg";
|
| 462 |
|
| 463 | open (EMI_CFG_FILE, "<$EMI_CFG_FILE") or &error_handler("$EMI_CFG_FILE: file error!", __FILE__, __LINE__);
|
| 464 | my $saved_sep = $/;
|
| 465 | undef $/;
|
| 466 | my $emi_cfg_file_content = <EMI_CFG_FILE>;
|
| 467 | close EMI_CFG_FILE;
|
| 468 | $/ = $saved_sep;
|
| 469 | my $template = <<"__TEMPLATE";
|
| 470 | ############################################################################################################
|
| 471 | #
|
| 472 | # External Memory Setting
|
| 473 | #
|
| 474 | ############################################################################################################
|
| 475 |
|
| 476 | $emi_cfg_file_content
|
| 477 |
|
| 478 | __TEMPLATE
|
| 479 |
|
| 480 | return $template;
|
| 481 | }
|
| 482 |
|
| 483 | @emi_settings = &get_emi_settings($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, \%custom_mem_dev_options);
|
| 484 | @flash_settings = &get_flash_settings($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, \%custom_mem_dev_options);
|
| 485 |
|
| 486 | ###
|
| 487 | my $combo_mem_param;
|
| 488 | for my $combo_idx (1..$custom_mem_dev_options{COMBO_MEM_ENTRY_COUNT})
|
| 489 | {
|
| 490 | $combo_mem_param .= <<"__TEMPLATE";
|
| 491 | # EMI $combo_idx
|
| 492 | $flash_settings[$combo_idx]
|
| 493 | $emi_settings[$combo_idx]
|
| 494 | __TEMPLATE
|
| 495 | }
|
| 496 |
|
| 497 | my $para_ver;
|
| 498 | if($bb eq 'MT6290')
|
| 499 | {
|
| 500 | $para_ver = "v3.1";
|
| 501 | }
|
| 502 | elsif($bb eq 'MT6280')
|
| 503 | {
|
| 504 | $para_ver = "v2";
|
| 505 | }
|
| 506 | else
|
| 507 | {
|
| 508 | $para_ver = "v1";
|
| 509 | }
|
| 510 |
|
| 511 | my $template = <<"__TEMPLATE";
|
| 512 | ############################################################################################################
|
| 513 | #
|
| 514 | # External Memory Setting
|
| 515 | #
|
| 516 | ############################################################################################################
|
| 517 |
|
| 518 | external_memory:
|
| 519 | parameters_version: $para_ver
|
| 520 | PMIC: $href_MAKEFILE_OPTIONS->{'pmic'}
|
| 521 | parameters:
|
| 522 | $combo_mem_param
|
| 523 | __TEMPLATE
|
| 524 | }
|
| 525 |
|
| 526 | return 1;
|