/*************************************************************************** * Copyright (c) 2003-2013, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. * * $brcm_Workfile: $ * $brcm_Revision: $ * $brcm_Date: $ * * Module Description: * * Revision History: * * $brcm_Log: $ * * ***************************************************************************/ #include "ministd.h" #include "serial.h" #include "bos.h" #include "cache_util.h" #include "bstd.h" #include "bkni.h" #include "ucos_ii.h" #include "gist.h" #include "bos_task_priorities.h" #include "bcmuart.h" #include "bchp_timer.h" #include "bmem_debug.h" #include "zlib.h" #include "bfds.h" #include "bchp_sun_top_ctrl.h" #include "bstd_defs.h" #include "bkni_print.h" #include "ramheader.h" #ifdef PROFILE #include "bapp_util.h" #endif #if (CONFIG_ENABLE_SCM == 1) #include "scm_low.h" #endif #include "bapp.h" #include "zlib.h" #ifdef CONFIG_MRC /* memory checker */ #include "bmrc.h" #include "bmrc_monitor.h" BMRC_Handle mrc_handle; BMRC_Monitor_Handle mrc_monitor_handle; #endif #ifdef TUNER_DEBUG #include "bchp_ds_topm.h" #endif #define CONSOLE_STK_SIZE 512 /* in words, changed from 1024 */ #define REG_RW_STK_SIZE 128 /* in words */ #define TEST_TASKINFO_STK_SIZE 256 /* in words, changed from 512 */ #define APP_STK_SIZE 1024 /* in words, changed from 2048 */ #ifdef CONFIG_ENABLE_EMU #define TASKINFO_SLEEP_ms 100 #else #define TASKINFO_SLEEP_ms 2000 #endif BDBG_MODULE(ram_init); extern unsigned int _fbss; extern unsigned int _end; extern unsigned long ram1_start_address; void console_main(void *data); void test_taskinfo_main(void *data); unsigned get_opt(void); void bprint_flush(void); extern void ram_start(void); extern void mvd_debug_out(void); extern bresult image_flash_install(uint32_t base, uint32_t offset, uint8_t * data, uint32_t size); extern bresult image_flash_install_fupdate(uint32_t base, uint32_t offset, uint8_t * data, uint32_t size); void flash_erase(uint32_t base, uint32_t offset); #ifdef CONFIG_DTA_CABLE static void download_signed(void); #endif void chip_reset(void); int get_opt_int(void); static b_task_t app_task_h; static b_task_t info_task_h; static unsigned int *info_stack; /* XMODEM download support */ #define MAX_COMPRESSED_SIZE (4 * 1024 * 1024) #define MAX_DECOMPRESSED_SIZE (8 * 1024 * 1024) #if 0 #if defined(CONFIG_BOOT_ROM) #define ROM_TEXT_BASE 0x9EC00000 #else #define ROM_TEXT_BASE 0x9FC00000 #endif #define FLASH_BASE (ROM_TEXT_BASE + 0x20000000) #endif #ifdef CONFIG_SMARTCARD_TEST extern void bsettop_smartcard_test(void); #endif bool s_printing_enabled = true; extern unsigned int xmodem_receive(volatile UartChannel *uart, unsigned char* buf); // [JPF] #include "bchp_vcxo_ctl_config_fsm.h" #ifndef BCHP_K0_OFFSET #define BCHP_K0_OFFSET (0xA0000000 | 0x10000000) #endif #ifndef WriteReg32 #define WriteReg32(x,v) { *((volatile unsigned int*)(BCHP_K0_OFFSET + (unsigned int)(x))) = (v); } #endif #ifndef ReadReg32 #define ReadReg32(x) *((volatile unsigned int*)(BCHP_K0_OFFSET + (unsigned int)(x))) #endif #if (BCHP_CHIP==7550) /* Summary: Set the CPU frequency using the PLL divider value. freq = 1296Hz/pll_div. The frequency should be set before OS is initialized. */ static void set_cpu_frequency(unsigned int pll_div) { unsigned int reg; reg = ReadReg32( BCHP_VCXO_CTL_CONFIG_FSM_PLL_NEXT_CFG_3B); reg &= ~BCHP_VCXO_CTL_CONFIG_FSM_PLL_NEXT_CFG_3B_m5div_MASK; reg |= (pll_div << BCHP_VCXO_CTL_CONFIG_FSM_PLL_NEXT_CFG_3B_m5div_SHIFT); /* 3: for MIPS channel gives: 432 MHz */ WriteReg32( BCHP_VCXO_CTL_CONFIG_FSM_PLL_NEXT_CFG_3B, reg); reg = ReadReg32( BCHP_VCXO_CTL_CONFIG_FSM_PLL_NEXT_CFG_3A); reg &= ~BCHP_VCXO_CTL_CONFIG_FSM_PLL_NEXT_CFG_3A_en_reg_ctrl_cfg_3_MASK; reg |= (1 << BCHP_VCXO_CTL_CONFIG_FSM_PLL_NEXT_CFG_3A_en_reg_ctrl_cfg_3_SHIFT); WriteReg32( BCHP_VCXO_CTL_CONFIG_FSM_PLL_NEXT_CFG_3A, reg); /* Issue the PLL update command */ reg = ReadReg32( BCHP_VCXO_CTL_CONFIG_FSM_PLL_UPDATE); reg |= BCHP_VCXO_CTL_CONFIG_FSM_PLL_UPDATE_update_MASK; WriteReg32( BCHP_VCXO_CTL_CONFIG_FSM_PLL_UPDATE, reg); } #endif /***********************************************************************/ /* static inline void s_do_putc(volatile UartChannel *uart, int c) */ /***********************************************************************/ static inline void s_do_putc(volatile UartChannel *uart, int c) { while (!(uart->sdw_lsr & THRE)); uart->sdw_rbr_thr_dll = (unsigned char)c; } /***********************************************************************/ /* serial_putc(UartChannel *uart, unsigned int c)*/ /***********************************************************************/ void print_string(char *str) { unsigned int idx = 0; while(str[idx]) serial_putc(CONSOLE_UART,str[idx++]); } #define inflateInit2(strm, windowBits) \ inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) /* used to verify the compressed binary to make sure it is right */ #if 0 static int decompress(unsigned char *in_buf, unsigned int in_size, unsigned char * out_buf, unsigned int out_size) { z_stream strm; int ret; memset(&strm,0,sizeof(strm)); strm.avail_in = in_size; strm.next_in = in_buf; strm.avail_out = out_size; strm.next_out = out_buf; ret = inflateInit2(&strm, 15+32); if (ret == Z_OK) { ret = inflate(&strm, Z_FINISH); inflateEnd(&strm); if ((ret == Z_STREAM_END) || (ret == Z_OK)) { return strm.total_out; } else if (ret > 0) { return -ret; } } return ret; } #endif #define FLASH_BASE_dst 0x9fc00000 + 0x30000 extern unsigned char block_signal; void fupdate(void) { int rc; unsigned char *cmp_data; unsigned char *data; unsigned int flags; cmp_data = malloc(MAX_COMPRESSED_SIZE); data = malloc(MAX_DECOMPRESSED_SIZE); block_signal=true; //ir , kpd block print_string("\r\nStart XModem download of compressed binary...\r\n"); /* Write stop sequence */ BREG_Write32(GetREG(), BCHP_TIMER_WDCMD,0xee00); BREG_Write32(GetREG(), BCHP_TIMER_WDCMD,0x00ee); flags = bos_enter_critical(); OSSchedLock(); rc = xmodem_receive(CONSOLE_UART,cmp_data); if (rc <= 0) { print_string("\r\nDownload failed\r\n"); OSSchedUnlock(); bos_exit_critical(flags); free(cmp_data); free(data); block_signal=false; return; } OSSchedUnlock(); bos_exit_critical(flags); print_string("\n === start image flash === \n"); flags = bos_enter_critical(); rc = image_flash_install_fupdate(FLASH_BASE_dst, 0, cmp_data, rc); bos_exit_critical(flags); free(data); free(cmp_data); //have to check image_flash_install if (rc) { print_string("\r\nProgram flash is failed. Reset the chip\n\r"); } else { print_string("\r\nProgram flash completed. Reset the chip\n\r"); } chip_reset(); } #define BPRINT_STK_SIZE 256 /* 256 should be enough */ static unsigned int bprint_stack[BPRINT_STK_SIZE]; static b_task_t print_task_h; static void bprint_entry(void *data); extern int get_fm_deviation_value(); extern void set_fm_deviation_value(int value); extern void put_str(char *s); void bcm_main(void) { b_task_params console_params; b_task_t console_task_h; BERR_Code berr; /* initialize RAC and calc_cache_sizes */ calc_cache_sizes(); #if 1 { uint32_t reg; #include "bmips3300.h" #include "bchp_misb_bridge.h" /* enable write gathering mode */ reg = ReadReg32(BCHP_MISB_BRIDGE_WG_MODE_N_TIMEOUT); reg &= ~(BCHP_MISB_BRIDGE_WG_MODE_N_TIMEOUT_MODE_MASK | BCHP_MISB_BRIDGE_WG_MODE_N_TIMEOUT_TIMEOUT_MASK); reg |= (BCHP_MISB_BRIDGE_WG_MODE_N_TIMEOUT_MODE_MODE_2 << BCHP_MISB_BRIDGE_WG_MODE_N_TIMEOUT_MODE_SHIFT) | MISB_BRIDGE_WG_MODE_TIMEOUT; /* enable slipt transaction mode */ reg = ReadReg32(BCHP_MISB_BRIDGE_MISB_SPLIT_MODE); reg |= BCHP_MISB_BRIDGE_MISB_SPLIT_MODE_SPLIT_MODE_ENABLE; WriteReg32(BCHP_MISB_BRIDGE_MISB_SPLIT_MODE, reg); } #endif #if (BCHP_CHIP==7550) set_cpu_frequency(6); #endif bos_init(); /* kni and dbg must be initialized after os since they use os primitives */ berr = BKNI_Init(); BKNI_Print_Init(); berr = BDBG_Init(); console_params.name="console"; console_params.priority = CONSOLE_PRIORITY; console_params.stack_size = CONSOLE_STK_SIZE; console_params.stack = (unsigned int*)malloc(console_params.stack_size * sizeof(unsigned int)); BDBG_ASSERT(console_params.stack); bos_start_task(&console_task_h,&console_params,console_main,&console_task_h); console_params.name="bprint"; console_params.priority = BPRINT_PRIORITY; console_params.stack_size = BPRINT_STK_SIZE; console_params.stack = bprint_stack; bos_start_task(&print_task_h, &console_params, bprint_entry,&print_task_h); bos_start(); printf("%s..SHOULD NEVER GET HERE.\n",__FUNCTION__); __asm__("break 2"); } #define COMPRESSED_4M 0x400000 #define USE_BCM_DEFAULT_CODE 0 void console_main(void *data) { b_task_params params; unsigned int cmd; BERR_Code berr; #if (CONFIG_ENABLE_SCM == 1) uint32_t scm_id; #endif #ifdef CONFIG_NXP_TDA182I4 #define DEV_NUM 20 // unsigned char powerlevel; // int npowerSum; // int i; #endif bos_calibrate(); gist_init(); #ifndef BCM_DEBUG /* workaround for "slow booting" issue in release build */ { #include "bcm_mips_defs.h" unsigned int count; cmd = bos_enter_critical(); count = bcm_read_cp0($9,0); count += 2000; /* moving compare register so that it will not slip and ended up to wrap 22 seconds */ bcm_write_cp0($11,0,count); bos_exit_critical(cmd); } #endif /* reuse cmd as flags. Need to disable interrupt when calling the serial_init function in release version */ //cmd = bos_enter_critical(); serial_init(CONSOLE_UART,115200); //bos_exit_critical(cmd); #if (CONFIG_ENABLE_SCM == 1) /* scm id must be read from flash for now we assume it is MOT*/ scm_id = 0x4749; berr = gist_rap_open(scm_id, scml_otp_callback); #else berr = gist_rap_open(0, NULL); /* if raptor fails in this case dsp loader did not run */ #endif print_cache_sizes(); #ifdef CONFIG_PCM_TEST extern void bpcm_play_test(void); { bpcm_play_test(); while(1) bos_sleep(100); } #endif #ifdef CONFIG_BSD TestBSD(); #endif #ifdef CONFIG_MEM2MEM_TEST TestM2M(); #endif #ifndef CONFIG_TUNER_TEST params.priority = APP_PRIORITY; params.stack_size = APP_STK_SIZE; params.name = "ram_start"; params.stack = (unsigned int*)malloc(params.stack_size * sizeof(unsigned int)); BDBG_ASSERT(params.stack); bos_start_task(&app_task_h, ¶ms, (void*)ram_start, &app_task_h); info_task_h = 0; #else /* defined in bsettop_tuner_vsb.c for VSB tuner test */ /* defined in bsettop_tuner_isdb.c for ISDB-T tuner test */ extern void TunerTest(); TunerTest(); #endif printf("Calculated MIPS = %dHz:\n", 2 * g_running_clock.clock_freq); while (1) { #if USE_BCM_DEFAULT_CODE printf("Console Menu:\n"); #ifdef BCM_DEBUG printf("1) Memory Use...\n"); #endif #ifdef PROFILE printf("2) Profiling Start...\n"); printf("3) Profiling Stop...\n"); #endif printf("4) Download and update signed image\n"); printf("5) Download and update software in flash\n"); printf("6) Toggle TASKINFO periodic display\n"); #ifdef CONFIG_SMARTCARD_TEST printf("7) Smartcard test\n"); #endif printf("8) Print system status...\n"); printf("9) Enter FM deviation factor...\n"); printf("11) Reboot\n"); #ifdef BCM_DEBUG printf("12) MVD Debug Info\n"); printf("13) Scratch Info\n"); #endif printf("21) Erase second image\n"); printf("22) Invoke debug stub\n"); #ifdef CONFIG_DTA_CABLE #ifdef FOR_DOLBY_CERTIFICATION printf("30) Toggle Dolby operational mode or disable\n"); printf("31) Change Audio parameters\n"); #endif #endif /* ACB615 has HDMI output */ #ifdef ACB615 printf("91) Set deinterlacer output affinity\n"); printf("92) Set HD H_SCL Coefficient Index\n"); printf("93) Set SD H_SCL Coefficient Index\n"); printf("94) Set HD V_SCL Coefficient Index\n"); printf("95) Set SD V_SCL Coefficient Index\n"); #endif printf("96) Set AVL configuration\n"); #ifdef CONFIG_NXP_TDA182I4 printf("97) NXP_TDA182I4_DupReg\n"); printf("98) NXP_TDA182I4_SetScanfreqForTest (Mhz)\n"); #endif printf("99) Power,Channel up/down\n"); #ifdef TUNER_DEBUG printf("100) Scan and Tune a Frequency\n"); printf("101) Get Tuner Status\n"); printf("102) Tune a Frequency assigned from within BBS\n"); #endif printf("110) Enable AVL\n"); #ifdef CONFIG_NXP_TDA182I4 printf("120) Get Power Level from NXP TDA182I4\n"); #endif #endif printf("Enter Command: "); cmd = get_opt(); switch (cmd) { case 1: #ifdef BCM_DEBUG m_report(); BDBG_SetModuleLevel("BMEM",BDBG_eMsg); BMEM_Dbg_DumpHeap(GetHEAP()); BDBG_SetModuleLevel("BMEM",BDBG_eWrn); #endif break; #ifdef PROFILE case 2: bapp_util_start_profiling(); break; case 3: bapp_util_stop_profiling(); break; #endif #ifdef CONFIG_DTA_CABLE case 4: { console_shutdown(); download_signed(); break; } #endif case 5: { fupdate(); break; } case 6: if (0 == info_task_h) { printf("TASKinfo periodic dump every %d ms.....................\n", TASKINFO_SLEEP_ms); info_stack = malloc(TEST_TASKINFO_STK_SIZE * sizeof(unsigned int)); if (NULL != info_stack) { params.name="TASKinfo"; params.priority = 55; //TASK_INFO_PRIORITY-> 55 params.stack_size = TEST_TASKINFO_STK_SIZE; params.stack = info_stack; bos_start_task(&info_task_h, ¶ms,test_taskinfo_main,&info_task_h); BDBG_ASSERT(info_task_h); } } else { bos_stop_task(info_task_h); free(info_stack); info_task_h = 0; } break; #ifdef CONFIG_SMARTCARD_TEST case 7: bsettop_smartcard_test(); break; #endif case 8: { b_cpu_load load; bos_print_taskinfo(); bos_getload(&load); printf("LOAD: %u ms IDLE:%u ISR:%u:%u %u us CSW:%u\n", load.duration, load.idle, load.isr_rate, load.isr, load.isr_us, load.ctxsw_rate); #if 0 bint_print_stats(); #endif break; } case 9: { int value; printf("Enter FM deviation factor(current = %d):",get_fm_deviation_value()); value = (int)get_opt(); printf("\n"); set_fm_deviation_value(value); } break; case 11: #if 0 b_irw_power_off(); #endif break; #if defined(BCM_DEBUG) && defined(CONFIG_HAS_VIDEO) case 12: mvd_debug_out(); break; #endif #if defined(BCM_DEBUG) case 13: #if 0 printf("SCRATCH_UCOS_INFO = 0x%08x\n",ReadReg32(SCRATCH_UCOS_INFO)); printf("SCRATCH_THREAD_SCHED = 0x%08x\n",ReadReg32(SCRATCH_THREAD_SCHED)); printf("SCRATCH_RDC_GFD = 0x%08x\n",ReadReg32(SCRATCH_RDC_GFD)); printf("SCRATCH_RDC_MFD = 0x%08x\n",ReadReg32(SCRATCH_RDC_MFD)); printf("SCRATCH_RDC_SCL = 0x%08x\n",ReadReg32(SCRATCH_RDC_SCL)); printf("SCRATCH_RDC_CMP = 0x%08x\n",ReadReg32(SCRATCH_RDC_CMP)); #endif break; #endif case 21: printf("Erasing second image header...\n"); console_shutdown(); OSSchedLock(); #if 0 flash_erase(FLASH_BASE, ((unsigned long)&ram1_start_address - ROM_TEXT_BASE)); #endif OSSchedUnlock(); printf("Done.\n"); break; case 22: __asm__("break 2"); break; #ifdef CONFIG_DTA_CABLE #ifdef FOR_DOLBY_CERTIFICATION case 30: { int cmd; if (g_p_dsp->system_state.audio) { baudio_decode_config config; /* we can read value, but failed to set. */ baudio_decode_get_config(g_p_dsp->system_state.audio, &config); printf("Current operational mode: "); switch (config.comp_mode) { case 1: printf("disabled\n"); break; case 2: printf("Line Mode\n"); break; case 3: printf("RF Mode\n"); break; default: printf("Custom mode, analog dialnorm\n"); break; } } printf("Toggle operational mode/Disable (1/0)? \n"); cmd = get_opt(); if (!cmd) /* if disabled, then toggle will be back to RF mode */ bapp_audio_toggle_comp_mode(false); else { bapp_audio_toggle_comp_mode(true); } } break; case 31: { int cmd = 0, mode = 3/* RF */, mono = 0; /* stereo */ uint32_t cut = RANGE_10, boost = RANGE_10, mono_mode = 0, stereo_mode = 2; #ifdef BCM_DEBUG #if USE_BCM_DEFAULT_CODE /* if conduct a Dolby test, then disable all printout, TODO to resume them again? */ if (!debug_out) { debug_out = true; /* can't reuse mvd_debug_out since it dumps too much */ //mvd_debug_out(); BDBG_SetModuleLevel("chan_mgr",BDBG_P_eLastEntry); BDBG_SetModuleLevel("bac3_pcm",BDBG_P_eLastEntry); BDBG_SetModuleLevel("decode_audio",BDBG_P_eLastEntry); BDBG_SetModuleLevel("bprofile",BDBG_P_eLastEntry); BDBG_SetModuleLevel("bac3_pcm",BDBG_P_eLastEntry); BDBG_SetModuleLevel("bsmart",BDBG_P_eLastEntry); BDBG_SetModuleLevel("bscreen",BDBG_P_eLastEntry); BDBG_SetModuleLevel("bapp_cable",BDBG_P_eLastEntry); BDBG_SetModuleLevel("bdemux_audio",BDBG_P_eLastEntry); BDBG_SetModuleLevel("pcm",BDBG_P_eLastEntry); } #endif #endif if (g_p_dsp->system_state.audio) { baudio_decode_config config; /* we can read value, but failed to set. */ baudio_decode_get_config(g_p_dsp->system_state.audio, &config); mode = config.comp_mode; cut = config.dynsclh; boost = config.dynscll; mono = config.mono; mono_mode = config.mono_mode % 4; stereo_mode = config.stereo_mode % 3; printf("Current mode=%d, cut=%d\%, boost=%d\%, mono = %s, mono_mode=%s, downmix=%s\n", mode, range_map(cut), range_map(boost), mono ? "Mono" : "Stereo", dualmonomode[mono_mode], stereomode[stereo_mode]); } printf("Set compression mode [0 - Custom mode (analog dialnorm), 1 - Custom mode (analog dialnorm), 2 - Line mode, 3 - RF mode (def) [ 0 - 3 ]? \n"); mode = get_opt(); if (mode < 0 || mode > 3) mode = 3; /* RF mode */ printf("Set Cut range in percent [ 0 - 100 (def)]? \n"); cmd = get_opt(); if (cmd < 0 || cmd > 100) cmd = 100; cut = dynamic_range_percent[cmd]; printf("Set Boost range in percent [ 0 - 100 (def)]? \n"); cmd = get_opt(); if (cmd < 0 || cmd > 100) cmd = 100; boost = dynamic_range_percent[cmd]; printf("Mono/Stereo [1/0 (def)]? \n"); mono = get_opt(); if (mono < 0 || mono > 1) mono = 0; /* default stereo for DTA cable */ if (mono) { printf("Set downmixing mode 0 - Stereo, 1 - Left mono, 2 - Right mono, 3 - Mixed mono [ 0 (def) - 3 ]? \n"); } else { printf("Set downmixing mode 0 - Auto, 1 - Lt/Rt, 2 - Lo/Ro [ 0 - 2 (def)]? \n"); } cmd = get_opt(); if (cmd < 0 || cmd > (2 + (mono ? 1: 0))) { if (mono) { cmd = 0; /* Stereo */ } else { cmd = 2; /* Lo/Ro */ } } if (mono) mono_mode = cmd; else stereo_mode = cmd; bapp_set_dynamic_range_parameters(mode, cut, boost, mono, mono_mode, stereo_mode); break; } #endif #endif #if USE_BCM_DEFAULT_CODE #ifdef ACB615 case 91: { int mode; printf("Select deinterlacer output affinity (1:HD, 2:SD)\n"); mode = get_opt(); if (mode == 1 || mode == 2) bapp_select_primary_output(NULL, mode); break; } case 92: { int coeff_idx; printf("Select H_SCL coefficient Index of HD path (1-26, which is softness->sharpness)\n"); coeff_idx = get_opt(); if (coeff_idx >=1 && coeff_idx <=26) bapp_select_scaler_coefficient(NULL,true,0,coeff_idx); break; } case 93: { int coeff_idx; printf("Select H_SCL coefficient Index of SD path (1-26, which is softness->sharpness)\n"); coeff_idx = get_opt(); if (coeff_idx >=1 && coeff_idx <=26) bapp_select_scaler_coefficient(NULL,true,1,coeff_idx); break; } case 94: { int coeff_idx; printf("Select V_SCL coefficient Index of HD path (1-26, which is softness->sharpness)\n"); coeff_idx = get_opt(); if (coeff_idx >=1 && coeff_idx <=26) bapp_select_scaler_coefficient(NULL,false,0,coeff_idx); break; } case 95: { int coeff_idx; printf("Select V_SCL coefficient Index of SD path (1-26, which is softness->sharpness)\n"); coeff_idx = get_opt(); if (coeff_idx >=1 && coeff_idx <=26) bapp_select_scaler_coefficient(NULL,false,1,coeff_idx); break; } #endif case 96: { int target, lowbound, fixedboost, opt; bapp_get_avl_settings(&target, &lowbound, &fixedboost); printf("Enter target level (%d dB) : ", target); opt = get_opt_int(); if (opt != 0) target = opt; printf("Enter lowerBound : (%d dB) : ", lowbound); opt = get_opt_int(); if (opt != 0) lowbound = opt; printf("Enter fixedBoost : (%d dB) : ", fixedboost); opt = get_opt_int(); if (opt != 0) fixedboost = opt; bapp_set_avl_settings(target, lowbound, fixedboost); break; } #ifdef CONFIG_NXP_TDA182I4 case 97: printf("Max Address =? "); cmd = get_opt(); NXP_TDA182I4_DupReg(cmd); break; case 98: printf("Mhz =? "); cmd = get_opt(); NXP_TDA182I4_SetScanfreqForTest(cmd); break; #endif #endif case 99: printf("2=power),Channel 1=down,0=up =? "); cmd = get_opt(); aov_Set_Button_CHUpDown(cmd); break; #if USE_BCM_DEFAULT_CODE #ifdef TUNER_DEBUG case 100: { unsigned int freq; RETRY1: printf("Please input ATSC frequency in MHZ to tune (57 - 803): \n"); freq = get_opt(); if (freq < 57 || freq > 803) { printf("ATSC frequency given is out of range\n"); goto RETRY1; } bapp_scan_psi_a_freq(freq * 1000); } break; case 101: bapp_get_tuner_status(); break; case 102: { unsigned int freq; do { freq = ReadReg32(BCHP_DS_TOPM_SW_SPARE1); /* frequency in MHz to tune set from BBS */ if (freq >= 57 && freq <= 803) { WriteReg32(BCHP_DS_TOPM_SW_SPARE2, 0); bapp_scan_psi_a_freq(freq * 1000); /* do we need to check lock status? */ bos_sleep(1000); /* clear it per request */ WriteReg32(BCHP_DS_TOPM_SW_SPARE1, 0); /* block I2C read/write */ WriteReg32(BCHP_DS_TOPM_SW_SPARE2, 1); } bos_sleep(1000); } while (0xffffffff != freq); /* clear registers */ WriteReg32(BCHP_DS_TOPM_SW_SPARE1, 0); WriteReg32(BCHP_DS_TOPM_SW_SPARE2, 0); } break; #endif case 110: { printf("Enable AVL (0/1?) \n"); cmd = get_opt(); printf("%s AVL\n", cmd ? "Enabled" : "Disabled"); bapp_enable_avl((bool)cmd); } break; #ifdef CONFIG_NXP_TDA182I4 case 120: npowerSum = 0; for(i=0;isize = xmodem_receive(CONSOLE_UART, new_image->data); OSSchedUnlock(); /* Use "restore ram97572_sig.bin binary &new_image->data" command in gdb to load data using ejtag. Then set new_image->size to size of the image file. Suggested method is to restore only 10K or so to get headers in. Loading complete image using gdb is painfully slow. */ if (0 == new_image->size) { BDBG_ERR(("xmodem error")); goto ExitFunc; } image_write(new_image); chip_reset(); ExitFunc: return; } #endif #endif void chip_reset(void) { uint32_t value; value = ReadReg32(BCHP_SUN_TOP_CTRL_RESET_SOURCE_ENABLE); value &= ~BCHP_SUN_TOP_CTRL_RESET_SOURCE_ENABLE_sw_master_reset_enable_MASK; WriteReg32(BCHP_SUN_TOP_CTRL_RESET_SOURCE_ENABLE, value); value |= BCHP_SUN_TOP_CTRL_RESET_SOURCE_ENABLE_sw_master_reset_enable_MASK; WriteReg32(BCHP_SUN_TOP_CTRL_RESET_SOURCE_ENABLE, value); value = ReadReg32(BCHP_SUN_TOP_CTRL_RESET_CTRL); value |= BCHP_SUN_TOP_CTRL_RESET_CTRL_clear_reset_history_MASK; WriteReg32(BCHP_SUN_TOP_CTRL_RESET_CTRL, value); value &= ~BCHP_SUN_TOP_CTRL_RESET_CTRL_clear_reset_history_MASK; WriteReg32(BCHP_SUN_TOP_CTRL_RESET_CTRL, value); value = ReadReg32(BCHP_SUN_TOP_CTRL_SW_MASTER_RESET); value &= ~BCHP_SUN_TOP_CTRL_RESET_SOURCE_ENABLE_sw_master_reset_enable_MASK; WriteReg32(BCHP_SUN_TOP_CTRL_SW_MASTER_RESET, value); value |= BCHP_SUN_TOP_CTRL_RESET_SOURCE_ENABLE_sw_master_reset_enable_MASK; WriteReg32(BCHP_SUN_TOP_CTRL_SW_MASTER_RESET, value); } /* this two functions probably should be moved somewhere more suitable */ static size_t out_string(const void * buf, size_t count) { size_t i; const unsigned char * pc = buf; for(i = 0; i < count; i++){ if (pc[i]=='\n') { serial_putc(CONSOLE_UART, '\r'); } serial_putc(CONSOLE_UART, pc[i]); } return count; } void bprint_entry(void *data) { BDBG_MSG(("PRINT TASK ONLINE")); s_printing_enabled = true; while (1) { if (s_printing_enabled) { BKNI_Print_Worker(out_string); } else { bos_sleep(200); } } __asm__("sdbbp"); } void bprint_flush(void) { BKNI_Print_Flush(out_string); } /* Please do not remove! */ /* Local Variables: */ /* mode: C */ /* indent-tabs-mode: true */ /* End: */