| #!/usr/bin/perl |
| # |
| # Copyright Statement: |
| # -------------------- |
| # This software is protected by Copyright and the information contained |
| # herein is confidential. The software may not be copied and the information |
| # contained herein may not be used or disclosed except with the written |
| # permission of MediaTek Inc. (C) 2006 |
| # |
| # BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| # THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| # RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| # AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| # NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| # SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| # SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| # THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| # NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| # SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| # |
| # BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| # LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| # AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| # OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| # MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| # |
| # THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| # WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| # LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| # RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| # THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| # |
| #***************************************************************************** |
| #* |
| #* Filename: |
| #* --------- |
| #* cfgGen_EMI.pl |
| #* |
| #* Project: |
| #* -------- |
| #* |
| #* |
| #* Description: |
| #* ------------ |
| #* This script generates EMI part in the CFG file for flash tool for SV5 |
| #* |
| #* Author: |
| #* ------- |
| #* Marvin Lin (mtk03483) |
| #* |
| #*============================================================================ |
| #* HISTORY |
| #* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| #*------------------------------------------------------------------------------ |
| #* $Revision$ |
| #* $Modtime$ |
| #* $Log$ |
| #* |
| #* 09 21 2015 holmes.lin |
| #* [MOLY00140089] Bach bootloader emi init for Elbrus FPGA (base on TK6291) |
| #* support emi cfg on Elbrus FPGA (not official platform, quick workaround). |
| #* |
| #* 09 02 2015 holmes.lin |
| #* [MOLY00140089] Bach bootloader emi init for Elbrus FPGA (base on TK6291) |
| #* support Elbrus FPGA (platfrom=MT6292) |
| #* |
| #* 08 23 2013 guo-huei.chang |
| #* [MOLY00034592] [MT6290][Combo Memory Support] Enable Combo Memory Feature |
| #* 1. Update Memory Device List for MT6290(m) |
| #* 2. Update/re-arch cfggen |
| #* 3. Update/re-arch emigen |
| #* 4. remove emigen/cfggen legacy |
| #* 5. Add combo memory supporting |
| #* 6. auto-generate all header files that emigen related |
| #* |
| #* 04 16 2013 guo-huei.chang |
| #* [MOLY00013409] [MT6290 Bring-up] DRAMC/EMI related Code Update |
| #* 1. update emigen to auto-gen all header files |
| #* 2. update init mempll |
| #* 3. update cfggen |
| #* |
| #* 03 22 2013 guo-huei.chang |
| #* [MOLY00012511] update auto-k for MT6290 FPGA, MT6290 EVB, and MT6290M EVB |
| #* 1. add custom folder for MT6290M |
| #* 2. update custom_EMI.h and custom_EMI_release.h with emigen |
| #* 3. update custom_EMI_INFO.h with manual check in |
| #* 4. update cfggen |
| #* |
| #* 03 19 2013 guo-huei.chang |
| #* [MOLY00011607] update custom_EMI function and cfggen EMI part |
| #* integrate CBr that update emigen and cfggen |
| #* |
| #* 03 08 2013 guo-huei.chang |
| #* [MOLY00011607] update custom_EMI function and cfggen EMI part |
| #* update custom_EMI function into custom_EMI_MT6290.c and remove it in devdrv_fakeapi.c |
| #* update cfgGen_EMI.pl for MT6290 |
| #* |
| #* 08 16 2012 marvin.lin |
| #* [MOLY00002193] [MemoryStorage][Auto-Gen][EMI Gen/CFG Gen][Request For Design Change] support MT6280 combo memory |
| #* . |
| #* |
| #* |
| #*------------------------------------------------------------------------------ |
| #* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| #*============================================================================ |
| #****************************************************************************/ |
| |
| #**************************************************************************** |
| # Included Modules |
| #**************************************************************************** |
| use strict; |
| use warnings; |
| use File::Spec (); |
| no warnings 'redefine'; |
| local $| = 1; # auto flush print function |
| |
| #**************************************************************************** |
| # Constants |
| #**************************************************************************** |
| my $CFGGEN_EMI_VERNO = "v0.04"; |
| # v0.04, modify for MT6297 |
| # v0.03, Fix compile error when $PLATFORM is not found |
| # v0.02, Support MT6255 SF+DDR or DISCRETE_NAND case |
| # v0.01, Fix unable to pre-compie custom_EMI_MT6256.c when make new issue |
| # v0.00, initial version |
| |
| #**************************************************************************** |
| # Input Parameters and Global Variables |
| #**************************************************************************** |
| my $DebugPrint = 0; |
| |
| #**************************************************************************** |
| # subroutine: error_handler |
| # input: $error_msg: error message |
| #**************************************************************************** |
| sub error_handler |
| { |
| my ($error_msg, $file, $line_no) = @_; |
| my $final_error_msg = "CFGGEN ERROR: $error_msg at $file line $line_no\n"; |
| print $final_error_msg; |
| die $final_error_msg; |
| } |
| |
| #**************************************************************************** |
| # subroutine: get_mem_dev_h_value |
| # input: $str_BB_path: BB folder path |
| # input: $href_mem_dev: reference of hash of custom_MemoryDevice.h configurations |
| #**************************************************************************** |
| sub get_mem_dev_h_value |
| { |
| print((caller(0))[3], "\n"); |
| my ($str_BB_path, $href_makefile_options) = @_; |
| my %mem_dev_options; |
| my $CUSTOM_MEM_DEV_H = $str_BB_path . "\/custom_MemoryDevice.h"; |
| |
| open (MEMDEVH_HANDLE, "<$CUSTOM_MEM_DEV_H") or &error_handler("$CUSTOM_MEM_DEV_H: $!", __FILE__, __LINE__); |
| while (<MEMDEVH_HANDLE>) { |
| if (/^#define\s+(\w+)\s+\(?(\w*)\)?/) |
| { |
| my $option = $1; |
| my $value = $2; |
| &error_handler("$CUSTOM_MEM_DEV_H: $option redefined in custom_MemoryDevice.h!", __FILE__, __LINE__) if defined($mem_dev_options{$option}); |
| $mem_dev_options{$option} = ((!defined $value) or ($value eq ''))? 'TRUE': $value; |
| } |
| } |
| close (MEMDEVH_HANDLE); |
| |
| if ((!defined $href_makefile_options->{'combo_memory_support'}) or ($href_makefile_options->{'combo_memory_support'} eq 'FALSE')) |
| { |
| $mem_dev_options{COMBO_MEM_ENTRY_COUNT} = 1; |
| } |
| |
| return %mem_dev_options; |
| } |
| |
| #**************************************************************************** |
| # subroutine: get_emi_settings |
| # return: EMI settings |
| #**************************************************************************** |
| sub get_emi_settings_for_91 |
| { |
| my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_; |
| my @emi_settings; |
| |
| ### Pre-compile custom_EMI.c |
| my ($custom_EMI_c_file); |
| my $custom_emi_command; |
| $custom_EMI_c_file = $str_BB_path . "\/custom_EMI_INFO.c"; |
| |
| print "custom_EMI.c = $custom_EMI_c_file\n"; |
| $custom_emi_command = "$cc_cmd $via_cmd$option_tmp_file -E $custom_EMI_c_file > " . $custom_emi_temp_local . "\/" . "~custom_EMI_c.tmp"; |
| print "$custom_emi_command\n"; |
| |
| my $status = system($custom_emi_command); |
| &error_handler("\/tools\/cfgGen_EMI.pl: pre-compile $custom_EMI_c_file erro!", __FILE__, __LINE__) if ($status != 0); |
| |
| ### Get Memory Type |
| my ($emi_clk, $emi_dev_type, $memory_type); |
| my $CUSTOM_EMI_RELEASE_H; |
| $CUSTOM_EMI_RELEASE_H = $str_BB_path . "\/custom_EMI_release.h"; |
| |
| open (CUSTOM_EMI_RELEASE_H, "<$CUSTOM_EMI_RELEASE_H") or &error_handler("$CUSTOM_EMI_RELEASE_H: file error!", __FILE__, __LINE__); |
| while (<CUSTOM_EMI_RELEASE_H>) |
| { |
| if (/#define __EMI_CLK_(\d+)MHZ__/) |
| { |
| $emi_clk = $1; |
| } |
| elsif (/#define __EMI_DEVICE_(\w+)__/) |
| { |
| $emi_dev_type = $1; |
| } |
| } |
| close CUSTOM_EMI_RELEASE_H; |
| if($href_MAKEFILE_OPTIONS->{'sip_ram_size'} ne "NONE") |
| { |
| $memory_type = "SIP_"; |
| } |
| $memory_type .= $emi_dev_type . "_" . $emi_clk . "MHZ"; |
| |
| ### Read EMI settings from ~custom_EMI_c.tmp |
| my $file_content; |
| my $custom_emi_path; |
| $custom_emi_path = "<" . $custom_emi_temp_local . "\/~custom_EMI_c.tmp"; |
| |
| print "path:$custom_emi_path\n"; |
| open (CUSTOM_EMI_C_TMP, $custom_emi_path) or &error_handler("~custom_EMI_c.tmp: file error!", __FILE__, __LINE__); |
| { |
| local $/; |
| $file_content = <CUSTOM_EMI_C_TMP>; |
| } |
| close CUSTOM_EMI_C_TMP; |
| |
| ### Get EMI_INFO type declaration |
| my $EMI_INFO_decl_str; |
| my %EMI_INFO_decl_hash; # key: EMI register; value: index |
| my $EMI_INFO_decl_count = 0; |
| if ($file_content =~ /typedef\s*struct\s*\{([\S|\s]+?)\}\s*MTK_EMI_Info/) |
| { |
| $EMI_INFO_decl_str = $1; |
| } |
| while ($EMI_INFO_decl_str =~ /\{/) # Skip all other contents between the beginning { and the real EMI info |
| { |
| $EMI_INFO_decl_str = $'; |
| } |
| while ($EMI_INFO_decl_str =~ /unsigned int (\w+)\;/) |
| { |
| $EMI_INFO_decl_hash{$1} = $EMI_INFO_decl_count; |
| $EMI_INFO_decl_count++; |
| $EMI_INFO_decl_str = $'; |
| } |
| print "EMI_INFO_decl_hash:\n" if ($DebugPrint == 1); |
| foreach my $idx (keys %EMI_INFO_decl_hash) |
| { |
| print "$idx\n" if ($DebugPrint == 1); |
| } |
| |
| ### Trim EMI Info contents string |
| my $EMI_INFO_value_str; |
| if ($file_content =~ /MTK_EMI_Info\s*EMI_INFO\[\]\s*\=\s*\{([\s|\S]+?)\}\;/) |
| { |
| $EMI_INFO_value_str = $1; |
| } |
| $EMI_INFO_value_str =~ s/\s//g; # EMI_INFO_value_str becomes {EMI_INFO set 1},{EMI_INFO set 2},......,{EMI_INFO set n} |
| |
| my @EMI_INFO_value_array; |
| @EMI_INFO_value_array = split(/\},\{/,$EMI_INFO_value_str); |
| |
| for my $idx (0..$#EMI_INFO_value_array) |
| { |
| $EMI_INFO_value_array[$idx] =~ s/^,//; # Remove the beginning , |
| $EMI_INFO_value_array[$idx] =~ s/^{//; # Remove the beginning { |
| $EMI_INFO_value_array[$idx] =~ s/,$//; # Remove the last , |
| $EMI_INFO_value_array[$idx] =~ s/,}$//; # Remove the last ,} |
| print "\$EMI_INFO_value_array[$idx]:\n$EMI_INFO_value_array[$idx]\n" if ($DebugPrint == 1); |
| } |
| |
| for my $combo_idx (1..$href_mem_dev_options->{COMBO_MEM_ENTRY_COUNT}) |
| { |
| ### Get EMI Info contents |
| my %cur_emi_info_value_list; |
| foreach (split(/,/, $EMI_INFO_value_array[$combo_idx-1])) |
| { |
| if ((/\.(\w+)=\((0x[\w]{1,8})\)/) or (/\.(\w+)=(0x[\w]{1,8})/)) |
| { |
| $cur_emi_info_value_list{$1} = $2; |
| } |
| } |
| $emi_settings[$combo_idx] = <<"__TEMPLATE"; |
| memory_type: $memory_type |
| EMI_Setting: |
| __TEMPLATE |
| foreach my $key (sort keys %cur_emi_info_value_list) |
| { |
| if ($key =~ /(\w+)_val/) |
| { |
| $emi_settings[$combo_idx] .= " " . uc($1) . ": " . $cur_emi_info_value_list{$key} . "\n"; |
| } |
| else |
| { |
| $emi_settings[$combo_idx] .= " " . uc($key) . ": " . $cur_emi_info_value_list{$key} . "\n"; |
| } |
| } |
| print "combo_mem_idx:$combo_idx\n" if ($DebugPrint == 1); |
| print "$emi_settings[$combo_idx]\n" if ($DebugPrint == 1); |
| } |
| |
| return @emi_settings; |
| } |
| |
| sub get_emi_settings_for_92 |
| { |
| my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_; |
| my @emi_settings; |
| |
| $emi_settings[1] = <<"__TEMPLATE"; |
| memory_type: LPDDR2_166MHZ |
| EMI_Setting: |
| DRAM_AC_DERATING: 0x20300431 |
| DRAM_LPDDR2_MR2: 0x00000003 |
| DRAM_LPDDR2_MR3: 0x00000002 |
| DRAMC_ACTIM0: 0x3315C140 |
| DRAMC_ACTIM1: 0x00000000 |
| DRAMC_ADDRODLY: 0x00000000 |
| DRAMC_CLKODLY: 0x00000000 |
| DRAMC_CONF1: 0x00008281 |
| DRAMC_CONF2: 0x03000027 |
| DRAMC_DDR2CTL: 0x200011D1 |
| DRAMC_DQODLY: 0x00000000 |
| DRAMC_DQSODLY: 0x00000000 |
| DRAMC_DRVCTL0: 0xAA22AA22 |
| DRAMC_DRVCTL1: 0xAA22AA22 |
| DRAMC_GDDR3CTL1: 0x01000000 |
| DRAMC_MISCTL0: 0x07100000 |
| DRAMC_PADCTL4: 0x00000000 |
| DRAMC_PD_CTRL: 0x00641542 |
| DRAMC_TEST2_3: 0xBF0C0080 |
| EMI_CONA: 0x00002122 |
| EMI_TESTD: 0x00000100 |
| __TEMPLATE |
| return @emi_settings; |
| } |
| |
| sub get_emi_settings_for_98 |
| { |
| my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_; |
| my $emi_custom_h = File::Spec->catfile($str_BB_path, "custom_emi.h"); |
| my @emi_settings; |
| |
| $emi_settings[1] = <<"__TEMPLATE"; |
| memory_type: $href_mem_dev_options->{'MEMORY_DEVICE_TYPE'} |
| EMI_Setting: |
| __TEMPLATE |
| |
| open FHL, "<", $emi_custom_h or error_handler("$emi_custom_h: $!", __FILE__, __LINE__); |
| while (<FHL>) { |
| s/\/\*.*\*\///; |
| s/,$//; |
| if (/\s*\.(\w+)\s*\=\s*([\{0-9A-Fa-fx, \}]+)/) { |
| my $k = $1; |
| my $v = $2; |
| $v =~ s/\{/\[/; |
| $v =~ s/\}/\]/; |
| print "-> $k = $v\n" if ($DebugPrint == 1); |
| $emi_settings[1] .= <<"__TEMPLATE"; |
| $k: $v |
| __TEMPLATE |
| } |
| } |
| close FHL; |
| |
| return @emi_settings; |
| } |
| |
| sub get_emi_settings |
| { |
| print((caller(0))[3], "\n"); |
| my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_; |
| my @emi_settings; |
| |
| if ($bb eq 'MT6291') { |
| return &get_emi_settings_for_91(@_); |
| } elsif ($bb =~ /^MT629[2357]$/) { |
| return &get_emi_settings_for_92(@_); |
| } elsif ($bb eq 'MT6298' and $href_MAKEFILE_OPTIONS->{'board_ver'} eq 'FPGA') { |
| return &get_emi_settings_for_92(@_); |
| } elsif ($bb =~ /^MT6298$/) { |
| return &get_emi_settings_for_98(@_); |
| } else { |
| error_handler("not support $bb", __FILE__, __LINE__); |
| } |
| } |
| |
| #**************************************************************************** |
| # subroutine: get_flash_settings |
| # return: Flash settings |
| #**************************************************************************** |
| sub get_flash_settings_for_91 |
| { |
| my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_; |
| my @flash_settings; |
| |
| ### Read flash ID from combo_flash_id.h |
| my (@flash_id_str_list, @flash_id, @valid_id_length_list); |
| my $flash_id_template; |
| my $decide_flash_type = "NAND"; |
| my $mcp_count = 0; |
| my $COMBO_FLASH_ID_H; |
| $COMBO_FLASH_ID_H = $str_BB_path . "\/combo_flash_id.h"; |
| |
| open (COMBO_FLASH_ID_H, "<$COMBO_FLASH_ID_H") or &error_handler("$COMBO_FLASH_ID_H: file error!", __FILE__, __LINE__); |
| while (<COMBO_FLASH_ID_H>) |
| { |
| if (/\s+(\d+),\s*\/\/\s*Valid\s+ID\s+length/) |
| { |
| $valid_id_length_list[$mcp_count] = $1; |
| } |
| elsif (/\s+\{(.+)\}\s*\/\/\s*Flash\s+ID/) |
| { |
| $flash_id_str_list[$mcp_count] = $1; |
| ##$mcp_count++; |
| if($href_MAKEFILE_OPTIONS->{'serial_flash_support'} eq 'TRUE')##SF align with NAND, restruct 16bit type ID string |
| { |
| $flash_id_template = undef; |
| $decide_flash_type = "SF"; |
| $flash_id_str_list[$mcp_count] =~ s/\{//; |
| $flash_id_str_list[$mcp_count] =~ s/\}//; |
| $flash_id_str_list[$mcp_count] =~ s/\s+//g; |
| print "Before restruct id string is : $flash_id_str_list[$mcp_count]\n"; |
| @flash_id = split /\,/, $flash_id_str_list[$mcp_count]; |
| my $cur_flash_id = "0xFFFF"; |
| for (0..7) # there are totally 8 flash ID |
| { |
| $cur_flash_id = sprintf("0x%04X", hex($flash_id[$_])); |
| print "cur_flash_id is : $cur_flash_id\n"; |
| if(7 == $_) |
| { |
| $flash_id_template .= "$cur_flash_id\n"; |
| ###$block_info_lines .= " \{$tmp_start, $tmp_size\},\n"; |
| } |
| else |
| { |
| $flash_id_template .= "$cur_flash_id, \n"; |
| } |
| print "After restruct template id string is : $flash_id_template\n"; |
| chomp($flash_id_template); |
| } |
| $flash_id_str_list[$mcp_count] = $flash_id_template; |
| print "After restruct id string is : $flash_id_template\n"; |
| } |
| $mcp_count++; |
| } |
| } |
| close COMBO_FLASH_ID_H; |
| |
| |
| #Parse combo_nfi_config.h to gen NAND Parameters for Flashtool Download |
| my @combo_nfi_info_struct; |
| if($href_MAKEFILE_OPTIONS->{'nand_support'} eq 'TRUE') |
| { |
| my $COMBO_FLASH_CONFIG_H;##NAND Flash Config File |
| $COMBO_FLASH_CONFIG_H = $str_BB_path . "\/combo_nfi_config.h"; |
| |
| my $combo_flash_idx = -1; |
| print "$COMBO_FLASH_CONFIG_H\n"; |
| open (COMBO_FLASH_CONFIG_H, "<$COMBO_FLASH_CONFIG_H") or &error_handler("$COMBO_FLASH_CONFIG_H: file error!", __FILE__, __LINE__); |
| while (<COMBO_FLASH_CONFIG_H>) |
| { |
| if (/\s*0x(\w+),\s*\/\/\s*NFI_(\w+)_(\w+)/) |
| { |
| #print "1-[$combo_flash_idx]: $1, $2, $3\n"; |
| $combo_nfi_info_struct[$combo_flash_idx] .= "\n " ."NFI_" ."$2_" . "$3" .": " ."0x$1"; |
| } |
| elsif (/\s*(\w+),\s*\/\/\s*NFI_(\w+)_(\w+)/) |
| { |
| #print "2-[$combo_flash_idx]: $1, $2, $3\n"; |
| $combo_nfi_info_struct[$combo_flash_idx] .= "\n " ."NFI_" ."$2_" . "$3" .": " ."$1"; |
| } |
| elsif (/\s*\{(.+)\},\s*\/\/\s*NFI_(\w+)_(\w+)/) |
| { |
| #print "3-[$combo_flash_idx]: $1, $2, $3\n"; |
| if($2 eq 'BB') |
| { |
| $combo_nfi_info_struct[$combo_flash_idx] .= "\n " ."NFI_" ."$2_" . "$3" .": " ."[$1]"; |
| } |
| else |
| { |
| $combo_flash_idx++;#to calculate combo idx |
| $combo_nfi_info_struct[$combo_flash_idx] .= "\n " ."NFI_" ."$2_" . "$3" .": " ."$1";#NFI_DeviceName is the first parse line of combo flash |
| } |
| } |
| } |
| } |
| |
| for (0..($mcp_count-1)) |
| { |
| my $combo_idx = $_ + 1; |
| |
| |
| $flash_settings[$combo_idx] .= <<"__TEMPLATE"; |
| - flash_info: |
| flash_type: $decide_flash_type |
| id_length: $valid_id_length_list[$_] |
| __TEMPLATE |
| if (defined $combo_nfi_info_struct[$_]) |
| { |
| $flash_settings[$combo_idx] .= <<"__TEMPLATE"; |
| flash_id: [$flash_id_str_list[$_]]$combo_nfi_info_struct[$_] |
| __TEMPLATE |
| } |
| else |
| { |
| $flash_settings[$combo_idx] .= <<"__TEMPLATE"; |
| flash_id: [$flash_id_str_list[$_]] |
| __TEMPLATE |
| } |
| } |
| |
| return @flash_settings; |
| } |
| |
| sub get_flash_settings_for_92 |
| { |
| my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_; |
| my @flash_settings; |
| |
| $flash_settings[1] = <<"__TEMPLATE"; |
| - flash_info: |
| flash_type: NAND |
| id_length: 5 |
| flash_id: [0x002C, 0x00A3, 0x0090, 0x0026, 0x0064, 0x0000, 0x0000, 0x0000] |
| NFI_Device_Name: "MICRON MT29F8G08ABBCA" |
| NFI_Device_Size: 1024 |
| NFI_Block_Size: 0x40000 |
| NFI_ACCCON_VAL: 0x00001111 |
| NFI_RDYTO_VAL: 0x0003ffff |
| NFI_ADNOB_VAL: 0x00000032 |
| NFI_BB_MARK: [0x00AD0000, 0x00EE0000, 0x00EE0000, 0x00EE0000] |
| NFI_DC_VAL: 0x2 |
| NFI_DRV_SET: 0xAD |
| NFI_PGFMT_VAL: 0x00008832 |
| NFI_TNUM_VAL: 0x4 |
| __TEMPLATE |
| |
| return @flash_settings; |
| } |
| |
| sub get_flash_settings |
| { |
| print((caller(0))[3], "\n"); |
| my ($str_BB_path, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS, $href_mem_dev_options) = @_; |
| |
| if ($bb eq "MT6291") { |
| return &get_flash_settings_for_91(@_); |
| } elsif ($bb =~ /^MT629[2357]$|^MT6298$/) { |
| return &get_flash_settings_for_92(@_); |
| } else { |
| error_handler("not support $bb", __FILE__, __LINE__); |
| } |
| } |
| |
| #**************************************************************************** |
| # subroutine: gen_external_memory_setting |
| # input: $str_BB_path: BB folder path |
| # return: External Memory Setting |
| #**************************************************************************** |
| sub gen_external_memory_setting |
| { |
| print((caller(0))[3], "\n"); |
| my ($str_BB_path, $str_board_ver, $bb, $cc_cmd, $via_cmd, $option_tmp_file, $custom_emi_temp_local, $href_MAKEFILE_OPTIONS) = @_; |
| my (@emi_settings, @flash_settings); |
| my %custom_mem_dev_options; |
| |
| %custom_mem_dev_options = &get_mem_dev_h_value($str_BB_path, $href_MAKEFILE_OPTIONS); |
| |
| @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); |
| @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); |
| |
| my $combo_mem_param = ""; |
| for my $combo_idx (1..$custom_mem_dev_options{COMBO_MEM_ENTRY_COUNT}) |
| { |
| $combo_mem_param .= <<"__TEMPLATE"; |
| # EMI $combo_idx |
| $flash_settings[$combo_idx] |
| $emi_settings[$combo_idx] |
| __TEMPLATE |
| } |
| |
| my $para_ver = ($bb eq 'MT6280')? "v2": |
| ($bb eq 'MT6290')? "v3.1": |
| ($bb eq 'MT6291')? "v3.2": |
| ($bb =~ /^MT629[2357]$/)? "v3.1": |
| ($bb eq 'MT6298' and $href_MAKEFILE_OPTIONS->{'board_ver'} eq "FPGA")? "v3.1": |
| ($bb =~ /^MT6298$/)? "v4.0": "v4.0"; |
| |
| my $template = <<"__TEMPLATE"; |
| ############################################################################################################ |
| # |
| # External Memory Setting |
| # |
| ############################################################################################################ |
| |
| external_memory: |
| parameters_version: $para_ver |
| PMIC: $href_MAKEFILE_OPTIONS->{'pmic'} |
| parameters: |
| $combo_mem_param |
| __TEMPLATE |
| } |
| |
| return 1; |