blob: 75b84e7db77d91abcd98ea1311052e490ec58363 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001#!/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#* 09 21 2015 holmes.lin
62#* [MOLY00140089] Bach bootloader emi init for Elbrus FPGA (base on TK6291)
63#* support emi cfg on Elbrus FPGA (not official platform, quick workaround).
64#*
65#* 09 02 2015 holmes.lin
66#* [MOLY00140089] Bach bootloader emi init for Elbrus FPGA (base on TK6291)
67#* support Elbrus FPGA (platfrom=MT6292)
68#*
69#* 08 23 2013 guo-huei.chang
70#* [MOLY00034592] [MT6290][Combo Memory Support] Enable Combo Memory Feature
71#* 1. Update Memory Device List for MT6290(m)
72#* 2. Update/re-arch cfggen
73#* 3. Update/re-arch emigen
74#* 4. remove emigen/cfggen legacy
75#* 5. Add combo memory supporting
76#* 6. auto-generate all header files that emigen related
77#*
78#* 04 16 2013 guo-huei.chang
79#* [MOLY00013409] [MT6290 Bring-up] DRAMC/EMI related Code Update
80#* 1. update emigen to auto-gen all header files
81#* 2. update init mempll
82#* 3. update cfggen
83#*
84#* 03 22 2013 guo-huei.chang
85#* [MOLY00012511] update auto-k for MT6290 FPGA, MT6290 EVB, and MT6290M EVB
86#* 1. add custom folder for MT6290M
87#* 2. update custom_EMI.h and custom_EMI_release.h with emigen
88#* 3. update custom_EMI_INFO.h with manual check in
89#* 4. update cfggen
90#*
91#* 03 19 2013 guo-huei.chang
92#* [MOLY00011607] update custom_EMI function and cfggen EMI part
93#* integrate CBr that update emigen and cfggen
94#*
95#* 03 08 2013 guo-huei.chang
96#* [MOLY00011607] update custom_EMI function and cfggen EMI part
97#* update custom_EMI function into custom_EMI_MT6290.c and remove it in devdrv_fakeapi.c
98#* update cfgGen_EMI.pl for MT6290
99#*
100#* 08 16 2012 marvin.lin
101#* [MOLY00002193] [MemoryStorage][Auto-Gen][EMI Gen/CFG Gen][Request For Design Change] support MT6280 combo memory
102#* .
103#*
104#*
105#*------------------------------------------------------------------------------
106#* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
107#*============================================================================
108#****************************************************************************/
109
110#****************************************************************************
111# Included Modules
112#****************************************************************************
113use strict;
114use warnings;
115use File::Spec ();
116no warnings 'redefine';
117local $| = 1; # auto flush print function
118
119#****************************************************************************
120# Constants
121#****************************************************************************
122my $CFGGEN_EMI_VERNO = "v0.04";
123 # v0.04, modify for MT6297
124 # v0.03, Fix compile error when $PLATFORM is not found
125 # v0.02, Support MT6255 SF+DDR or DISCRETE_NAND case
126 # v0.01, Fix unable to pre-compie custom_EMI_MT6256.c when make new issue
127 # v0.00, initial version
128
129#****************************************************************************
130# Input Parameters and Global Variables
131#****************************************************************************
132my $DebugPrint = 0;
133
134#****************************************************************************
135# subroutine: error_handler
136# input: $error_msg: error message
137#****************************************************************************
138sub error_handler
139{
140 my ($error_msg, $file, $line_no) = @_;
141 my $final_error_msg = "CFGGEN ERROR: $error_msg at $file line $line_no\n";
142 print $final_error_msg;
143 die $final_error_msg;
144}
145
146#****************************************************************************
147# subroutine: get_mem_dev_h_value
148# input: $str_BB_path: BB folder path
149# input: $href_mem_dev: reference of hash of custom_MemoryDevice.h configurations
150#****************************************************************************
151sub get_mem_dev_h_value
152{
153 print((caller(0))[3], "\n");
154 my ($str_BB_path, $href_makefile_options) = @_;
155 my %mem_dev_options;
156 my $CUSTOM_MEM_DEV_H = $str_BB_path . "\/custom_MemoryDevice.h";
157
158 open (MEMDEVH_HANDLE, "<$CUSTOM_MEM_DEV_H") or &error_handler("$CUSTOM_MEM_DEV_H: $!", __FILE__, __LINE__);
159 while (<MEMDEVH_HANDLE>) {
160 if (/^#define\s+(\w+)\s+\(?(\w*)\)?/)
161 {
162 my $option = $1;
163 my $value = $2;
164 &error_handler("$CUSTOM_MEM_DEV_H: $option redefined in custom_MemoryDevice.h!", __FILE__, __LINE__) if defined($mem_dev_options{$option});
165 $mem_dev_options{$option} = ((!defined $value) or ($value eq ''))? 'TRUE': $value;
166 }
167 }
168 close (MEMDEVH_HANDLE);
169
170 if ((!defined $href_makefile_options->{'combo_memory_support'}) or ($href_makefile_options->{'combo_memory_support'} eq 'FALSE'))
171 {
172 $mem_dev_options{COMBO_MEM_ENTRY_COUNT} = 1;
173 }
174
175 return %mem_dev_options;
176}
177
178#****************************************************************************
179# subroutine: get_emi_settings
180# return: EMI settings
181#****************************************************************************
182sub get_emi_settings_for_91
183{
184 my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_;
185 my @emi_settings;
186
187 ### Pre-compile custom_EMI.c
188 my ($custom_EMI_c_file);
189 my $custom_emi_command;
190 $custom_EMI_c_file = $str_BB_path . "\/custom_EMI_INFO.c";
191
192 print "custom_EMI.c = $custom_EMI_c_file\n";
193 $custom_emi_command = "$cc_cmd $via_cmd$option_tmp_file -E $custom_EMI_c_file > " . $custom_emi_temp_local . "\/" . "~custom_EMI_c.tmp";
194 print "$custom_emi_command\n";
195
196 my $status = system($custom_emi_command);
197 &error_handler("\/tools\/cfgGen_EMI.pl: pre-compile $custom_EMI_c_file erro!", __FILE__, __LINE__) if ($status != 0);
198
199 ### Get Memory Type
200 my ($emi_clk, $emi_dev_type, $memory_type);
201 my $CUSTOM_EMI_RELEASE_H;
202 $CUSTOM_EMI_RELEASE_H = $str_BB_path . "\/custom_EMI_release.h";
203
204 open (CUSTOM_EMI_RELEASE_H, "<$CUSTOM_EMI_RELEASE_H") or &error_handler("$CUSTOM_EMI_RELEASE_H: file error!", __FILE__, __LINE__);
205 while (<CUSTOM_EMI_RELEASE_H>)
206 {
207 if (/#define __EMI_CLK_(\d+)MHZ__/)
208 {
209 $emi_clk = $1;
210 }
211 elsif (/#define __EMI_DEVICE_(\w+)__/)
212 {
213 $emi_dev_type = $1;
214 }
215 }
216 close CUSTOM_EMI_RELEASE_H;
217 if($href_MAKEFILE_OPTIONS->{'sip_ram_size'} ne "NONE")
218 {
219 $memory_type = "SIP_";
220 }
221 $memory_type .= $emi_dev_type . "_" . $emi_clk . "MHZ";
222
223 ### Read EMI settings from ~custom_EMI_c.tmp
224 my $file_content;
225 my $custom_emi_path;
226 $custom_emi_path = "<" . $custom_emi_temp_local . "\/~custom_EMI_c.tmp";
227
228 print "path:$custom_emi_path\n";
229 open (CUSTOM_EMI_C_TMP, $custom_emi_path) or &error_handler("~custom_EMI_c.tmp: file error!", __FILE__, __LINE__);
230 {
231 local $/;
232 $file_content = <CUSTOM_EMI_C_TMP>;
233 }
234 close CUSTOM_EMI_C_TMP;
235
236 ### Get EMI_INFO type declaration
237 my $EMI_INFO_decl_str;
238 my %EMI_INFO_decl_hash; # key: EMI register; value: index
239 my $EMI_INFO_decl_count = 0;
240 if ($file_content =~ /typedef\s*struct\s*\{([\S|\s]+?)\}\s*MTK_EMI_Info/)
241 {
242 $EMI_INFO_decl_str = $1;
243 }
244 while ($EMI_INFO_decl_str =~ /\{/) # Skip all other contents between the beginning { and the real EMI info
245 {
246 $EMI_INFO_decl_str = $';
247 }
248 while ($EMI_INFO_decl_str =~ /unsigned int (\w+)\;/)
249 {
250 $EMI_INFO_decl_hash{$1} = $EMI_INFO_decl_count;
251 $EMI_INFO_decl_count++;
252 $EMI_INFO_decl_str = $';
253 }
254 print "EMI_INFO_decl_hash:\n" if ($DebugPrint == 1);
255 foreach my $idx (keys %EMI_INFO_decl_hash)
256 {
257 print "$idx\n" if ($DebugPrint == 1);
258 }
259
260 ### Trim EMI Info contents string
261 my $EMI_INFO_value_str;
262 if ($file_content =~ /MTK_EMI_Info\s*EMI_INFO\[\]\s*\=\s*\{([\s|\S]+?)\}\;/)
263 {
264 $EMI_INFO_value_str = $1;
265 }
266 $EMI_INFO_value_str =~ s/\s//g; # EMI_INFO_value_str becomes {EMI_INFO set 1},{EMI_INFO set 2},......,{EMI_INFO set n}
267
268 my @EMI_INFO_value_array;
269 @EMI_INFO_value_array = split(/\},\{/,$EMI_INFO_value_str);
270
271 for my $idx (0..$#EMI_INFO_value_array)
272 {
273 $EMI_INFO_value_array[$idx] =~ s/^,//; # Remove the beginning ,
274 $EMI_INFO_value_array[$idx] =~ s/^{//; # Remove the beginning {
275 $EMI_INFO_value_array[$idx] =~ s/,$//; # Remove the last ,
276 $EMI_INFO_value_array[$idx] =~ s/,}$//; # Remove the last ,}
277 print "\$EMI_INFO_value_array[$idx]:\n$EMI_INFO_value_array[$idx]\n" if ($DebugPrint == 1);
278 }
279
280 for my $combo_idx (1..$href_mem_dev_options->{COMBO_MEM_ENTRY_COUNT})
281 {
282 ### Get EMI Info contents
283 my %cur_emi_info_value_list;
284 foreach (split(/,/, $EMI_INFO_value_array[$combo_idx-1]))
285 {
286 if ((/\.(\w+)=\((0x[\w]{1,8})\)/) or (/\.(\w+)=(0x[\w]{1,8})/))
287 {
288 $cur_emi_info_value_list{$1} = $2;
289 }
290 }
291 $emi_settings[$combo_idx] = <<"__TEMPLATE";
292 memory_type: $memory_type
293 EMI_Setting:
294__TEMPLATE
295 foreach my $key (sort keys %cur_emi_info_value_list)
296 {
297 if ($key =~ /(\w+)_val/)
298 {
299 $emi_settings[$combo_idx] .= " " . uc($1) . ": " . $cur_emi_info_value_list{$key} . "\n";
300 }
301 else
302 {
303 $emi_settings[$combo_idx] .= " " . uc($key) . ": " . $cur_emi_info_value_list{$key} . "\n";
304 }
305 }
306 print "combo_mem_idx:$combo_idx\n" if ($DebugPrint == 1);
307 print "$emi_settings[$combo_idx]\n" if ($DebugPrint == 1);
308 }
309
310 return @emi_settings;
311}
312
313sub get_emi_settings_for_92
314{
315 my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_;
316 my @emi_settings;
317
318 $emi_settings[1] = <<"__TEMPLATE";
319 memory_type: LPDDR2_166MHZ
320 EMI_Setting:
321 DRAM_AC_DERATING: 0x20300431
322 DRAM_LPDDR2_MR2: 0x00000003
323 DRAM_LPDDR2_MR3: 0x00000002
324 DRAMC_ACTIM0: 0x3315C140
325 DRAMC_ACTIM1: 0x00000000
326 DRAMC_ADDRODLY: 0x00000000
327 DRAMC_CLKODLY: 0x00000000
328 DRAMC_CONF1: 0x00008281
329 DRAMC_CONF2: 0x03000027
330 DRAMC_DDR2CTL: 0x200011D1
331 DRAMC_DQODLY: 0x00000000
332 DRAMC_DQSODLY: 0x00000000
333 DRAMC_DRVCTL0: 0xAA22AA22
334 DRAMC_DRVCTL1: 0xAA22AA22
335 DRAMC_GDDR3CTL1: 0x01000000
336 DRAMC_MISCTL0: 0x07100000
337 DRAMC_PADCTL4: 0x00000000
338 DRAMC_PD_CTRL: 0x00641542
339 DRAMC_TEST2_3: 0xBF0C0080
340 EMI_CONA: 0x00002122
341 EMI_TESTD: 0x00000100
342__TEMPLATE
343 return @emi_settings;
344}
345
346sub get_emi_settings_for_98
347{
348 my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_;
349 my $emi_custom_h = File::Spec->catfile($str_BB_path, "custom_emi.h");
350 my @emi_settings;
351
352 $emi_settings[1] = <<"__TEMPLATE";
353 memory_type: $href_mem_dev_options->{'MEMORY_DEVICE_TYPE'}
354 EMI_Setting:
355__TEMPLATE
356
357 open FHL, "<", $emi_custom_h or error_handler("$emi_custom_h: $!", __FILE__, __LINE__);
358 while (<FHL>) {
359 s/\/\*.*\*\///;
360 s/,$//;
361 if (/\s*\.(\w+)\s*\=\s*([\{0-9A-Fa-fx, \}]+)/) {
362 my $k = $1;
363 my $v = $2;
364 $v =~ s/\{/\[/;
365 $v =~ s/\}/\]/;
366 print "-> $k = $v\n" if ($DebugPrint == 1);
367 $emi_settings[1] .= <<"__TEMPLATE";
368 $k: $v
369__TEMPLATE
370 }
371 }
372 close FHL;
373
374 return @emi_settings;
375}
376
377sub get_emi_settings
378{
379 print((caller(0))[3], "\n");
380 my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_;
381 my @emi_settings;
382
383 if ($bb eq 'MT6291') {
384 return &get_emi_settings_for_91(@_);
385 } elsif ($bb =~ /^MT629[2357]$/) {
386 return &get_emi_settings_for_92(@_);
387 } elsif ($bb eq 'MT6298' and $href_MAKEFILE_OPTIONS->{'board_ver'} eq 'FPGA') {
388 return &get_emi_settings_for_92(@_);
389 } elsif ($bb =~ /^MT6298$/) {
390 return &get_emi_settings_for_98(@_);
391 } else {
392 error_handler("not support $bb", __FILE__, __LINE__);
393 }
394}
395
396#****************************************************************************
397# subroutine: get_flash_settings
398# return: Flash settings
399#****************************************************************************
400sub get_flash_settings_for_91
401{
402 my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_;
403 my @flash_settings;
404
405 ### Read flash ID from combo_flash_id.h
406 my (@flash_id_str_list, @flash_id, @valid_id_length_list);
407 my $flash_id_template;
408 my $decide_flash_type = "NAND";
409 my $mcp_count = 0;
410 my $COMBO_FLASH_ID_H;
411 $COMBO_FLASH_ID_H = $str_BB_path . "\/combo_flash_id.h";
412
413 open (COMBO_FLASH_ID_H, "<$COMBO_FLASH_ID_H") or &error_handler("$COMBO_FLASH_ID_H: file error!", __FILE__, __LINE__);
414 while (<COMBO_FLASH_ID_H>)
415 {
416 if (/\s+(\d+),\s*\/\/\s*Valid\s+ID\s+length/)
417 {
418 $valid_id_length_list[$mcp_count] = $1;
419 }
420 elsif (/\s+\{(.+)\}\s*\/\/\s*Flash\s+ID/)
421 {
422 $flash_id_str_list[$mcp_count] = $1;
423 ##$mcp_count++;
424 if($href_MAKEFILE_OPTIONS->{'serial_flash_support'} eq 'TRUE')##SF align with NAND, restruct 16bit type ID string
425 {
426 $flash_id_template = undef;
427 $decide_flash_type = "SF";
428 $flash_id_str_list[$mcp_count] =~ s/\{//;
429 $flash_id_str_list[$mcp_count] =~ s/\}//;
430 $flash_id_str_list[$mcp_count] =~ s/\s+//g;
431 print "Before restruct id string is : $flash_id_str_list[$mcp_count]\n";
432 @flash_id = split /\,/, $flash_id_str_list[$mcp_count];
433 my $cur_flash_id = "0xFFFF";
434 for (0..7) # there are totally 8 flash ID
435 {
436 $cur_flash_id = sprintf("0x%04X", hex($flash_id[$_]));
437 print "cur_flash_id is : $cur_flash_id\n";
438 if(7 == $_)
439 {
440 $flash_id_template .= "$cur_flash_id\n";
441 ###$block_info_lines .= " \{$tmp_start, $tmp_size\},\n";
442 }
443 else
444 {
445 $flash_id_template .= "$cur_flash_id, \n";
446 }
447 print "After restruct template id string is : $flash_id_template\n";
448 chomp($flash_id_template);
449 }
450 $flash_id_str_list[$mcp_count] = $flash_id_template;
451 print "After restruct id string is : $flash_id_template\n";
452 }
453 $mcp_count++;
454 }
455 }
456 close COMBO_FLASH_ID_H;
457
458
459 #Parse combo_nfi_config.h to gen NAND Parameters for Flashtool Download
460 my @combo_nfi_info_struct;
461 if($href_MAKEFILE_OPTIONS->{'nand_support'} eq 'TRUE')
462 {
463 my $COMBO_FLASH_CONFIG_H;##NAND Flash Config File
464 $COMBO_FLASH_CONFIG_H = $str_BB_path . "\/combo_nfi_config.h";
465
466 my $combo_flash_idx = -1;
467 print "$COMBO_FLASH_CONFIG_H\n";
468 open (COMBO_FLASH_CONFIG_H, "<$COMBO_FLASH_CONFIG_H") or &error_handler("$COMBO_FLASH_CONFIG_H: file error!", __FILE__, __LINE__);
469 while (<COMBO_FLASH_CONFIG_H>)
470 {
471 if (/\s*0x(\w+),\s*\/\/\s*NFI_(\w+)_(\w+)/)
472 {
473 #print "1-[$combo_flash_idx]: $1, $2, $3\n";
474 $combo_nfi_info_struct[$combo_flash_idx] .= "\n " ."NFI_" ."$2_" . "$3" .": " ."0x$1";
475 }
476 elsif (/\s*(\w+),\s*\/\/\s*NFI_(\w+)_(\w+)/)
477 {
478 #print "2-[$combo_flash_idx]: $1, $2, $3\n";
479 $combo_nfi_info_struct[$combo_flash_idx] .= "\n " ."NFI_" ."$2_" . "$3" .": " ."$1";
480 }
481 elsif (/\s*\{(.+)\},\s*\/\/\s*NFI_(\w+)_(\w+)/)
482 {
483 #print "3-[$combo_flash_idx]: $1, $2, $3\n";
484 if($2 eq 'BB')
485 {
486 $combo_nfi_info_struct[$combo_flash_idx] .= "\n " ."NFI_" ."$2_" . "$3" .": " ."[$1]";
487 }
488 else
489 {
490 $combo_flash_idx++;#to calculate combo idx
491 $combo_nfi_info_struct[$combo_flash_idx] .= "\n " ."NFI_" ."$2_" . "$3" .": " ."$1";#NFI_DeviceName is the first parse line of combo flash
492 }
493 }
494 }
495 }
496
497 for (0..($mcp_count-1))
498 {
499 my $combo_idx = $_ + 1;
500
501
502 $flash_settings[$combo_idx] .= <<"__TEMPLATE";
503 - flash_info:
504 flash_type: $decide_flash_type
505 id_length: $valid_id_length_list[$_]
506__TEMPLATE
507 if (defined $combo_nfi_info_struct[$_])
508 {
509 $flash_settings[$combo_idx] .= <<"__TEMPLATE";
510 flash_id: [$flash_id_str_list[$_]]$combo_nfi_info_struct[$_]
511__TEMPLATE
512 }
513 else
514 {
515 $flash_settings[$combo_idx] .= <<"__TEMPLATE";
516 flash_id: [$flash_id_str_list[$_]]
517__TEMPLATE
518 }
519 }
520
521 return @flash_settings;
522}
523
524sub get_flash_settings_for_92
525{
526 my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_;
527 my @flash_settings;
528
529 $flash_settings[1] = <<"__TEMPLATE";
530 - flash_info:
531 flash_type: NAND
532 id_length: 5
533 flash_id: [0x002C, 0x00A3, 0x0090, 0x0026, 0x0064, 0x0000, 0x0000, 0x0000]
534 NFI_Device_Name: "MICRON MT29F8G08ABBCA"
535 NFI_Device_Size: 1024
536 NFI_Block_Size: 0x40000
537 NFI_ACCCON_VAL: 0x00001111
538 NFI_RDYTO_VAL: 0x0003ffff
539 NFI_ADNOB_VAL: 0x00000032
540 NFI_BB_MARK: [0x00AD0000, 0x00EE0000, 0x00EE0000, 0x00EE0000]
541 NFI_DC_VAL: 0x2
542 NFI_DRV_SET: 0xAD
543 NFI_PGFMT_VAL: 0x00008832
544 NFI_TNUM_VAL: 0x4
545__TEMPLATE
546
547 return @flash_settings;
548}
549
550sub get_flash_settings
551{
552 print((caller(0))[3], "\n");
553 my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_;
554
555 if ($bb eq "MT6291") {
556 return &get_flash_settings_for_91(@_);
557 } elsif ($bb =~ /^MT629[2357]$|^MT6298$/) {
558 return &get_flash_settings_for_92(@_);
559 } else {
560 error_handler("not support $bb", __FILE__, __LINE__);
561 }
562}
563
564#****************************************************************************
565# subroutine: gen_external_memory_setting
566# input: $str_BB_path: BB folder path
567# return: External Memory Setting
568#****************************************************************************
569sub gen_external_memory_setting
570{
571 print((caller(0))[3], "\n");
572 my ($str_BB_path, $str_board_ver, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS) = @_;
573 my (@emi_settings, @flash_settings);
574 my %custom_mem_dev_options;
575
576 %custom_mem_dev_options = &get_mem_dev_h_value($str_BB_path, $href_MAKEFILE_OPTIONS);
577
578 @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);
579 @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);
580
581 my $combo_mem_param = "";
582 for my $combo_idx (1..$custom_mem_dev_options{COMBO_MEM_ENTRY_COUNT})
583 {
584 $combo_mem_param .= <<"__TEMPLATE";
585 # EMI $combo_idx
586$flash_settings[$combo_idx]
587$emi_settings[$combo_idx]
588__TEMPLATE
589 }
590
591 my $para_ver = ($bb eq 'MT6280')? "v2":
592 ($bb eq 'MT6290')? "v3.1":
593 ($bb eq 'MT6291')? "v3.2":
594 ($bb =~ /^MT629[2357]$/)? "v3.1":
595 ($bb eq 'MT6298' and $href_MAKEFILE_OPTIONS->{'board_ver'} eq "FPGA")? "v3.1":
596 ($bb =~ /^MT6298$/)? "v4.0": "v4.0";
597
598 my $template = <<"__TEMPLATE";
599############################################################################################################
600#
601# External Memory Setting
602#
603############################################################################################################
604
605external_memory:
606 parameters_version: $para_ver
607 PMIC: $href_MAKEFILE_OPTIONS->{'pmic'}
608 parameters:
609$combo_mem_param
610__TEMPLATE
611}
612
613return 1;