summaryrefslogtreecommitdiffstats
path: root/cfe/cfe/arch/mips/board/bcm63xx_ram/src/bcm63xx_devs.c
diff options
context:
space:
mode:
Diffstat (limited to 'cfe/cfe/arch/mips/board/bcm63xx_ram/src/bcm63xx_devs.c')
-rwxr-xr-xcfe/cfe/arch/mips/board/bcm63xx_ram/src/bcm63xx_devs.c734
1 files changed, 734 insertions, 0 deletions
diff --git a/cfe/cfe/arch/mips/board/bcm63xx_ram/src/bcm63xx_devs.c b/cfe/cfe/arch/mips/board/bcm63xx_ram/src/bcm63xx_devs.c
new file mode 100755
index 0000000..ac75083
--- /dev/null
+++ b/cfe/cfe/arch/mips/board/bcm63xx_ram/src/bcm63xx_devs.c
@@ -0,0 +1,734 @@
+/* *********************************************************************
+ * Broadcom Common Firmware Environment (CFE)
+ *
+ * Board device initialization File: bcm94710_devs.c
+ *
+ * This is the "C" part of the board support package. The
+ * routines to create and initialize the console, wire up
+ * device drivers, and do other customization live here.
+ *
+ * Author: Mitch Lichtenberg (mpl@broadcom.com)
+ *
+ *********************************************************************
+ *
+ * XX Copyright 2000,2001
+ * Broadcom Corporation. All rights reserved.
+ *
+ * BROADCOM PROPRIETARY AND CONFIDENTIAL
+ *
+ * This software is furnished under license and may be used and
+ * copied only in accordance with the license.
+ ********************************************************************* */
+
+#include "lib_types.h"
+#include "lib_printf.h"
+
+/* Foxconn add start by Cliff Wang, 03/23/2010 */
+#include "lib_string.h"
+/* Foxconn add end by Cliff Wang, 03/23/2010 */
+
+#include "cfe_timer.h"
+#include "cfe.h"
+#include "bcm_map.h"
+#include "bcm_hwdefs.h"
+#include "bcmTag.h"
+#include "dev_bcm63xx_flash.h"
+#include "bcm63xx_util.h"
+#include "flash_api.h"
+
+/* Foxconn add start by Cliff Wang, 03/23/2010 */
+#include "tftpd.h"
+/* Foxconn add end by Cliff Wang, 03/23/2010 */
+
+static int checkForResetToDefaultHold( unsigned short rstToDfltIrq );
+
+/* Foxconn added start , 1/29/2010 */
+#include "gpio_drv.h"
+#include "foxconnCfg.h"
+
+typedef enum
+{
+ kGpioInactive,
+ kGpioActive
+} GPIO_STATE_t;
+static int test_led_control(int on_off);
+int power_led_toggle(int state);
+int nmrp_led_toggle(void);
+int verify_board_id(char *buf);
+int verify_checksum(char *buf, unsigned long buf_len, unsigned long chksum);
+#define NR_LED 24
+/* Foxconn added end , 1/29/2010 */
+
+/* *********************************************************************
+ * Devices we're importing
+ ********************************************************************* */
+
+extern cfe_driver_t bcm63xx_uart;
+extern cfe_driver_t bcm63xx_enet;
+
+/* *********************************************************************
+ * board_console_init()
+ *
+ * Add the console device and set it to be the primary
+ * console.
+ *
+ * Input parameters:
+ * nothing
+ *
+ * Return value:
+ * nothing
+ ********************************************************************* */
+
+void board_console_init(void)
+{
+ /* Add the serial port driver. */
+ cfe_add_device(&bcm63xx_uart,0,0,0);
+
+ cfe_set_console( "uart0" );
+}
+
+
+/* *********************************************************************
+ * board_device_init()
+ *
+ * Initialize and add other devices. Add everything you need
+ * for bootstrap here, like disk drives, flash memory, UARTs,
+ * network controllers, etc.
+ *
+ * Input parameters:
+ * nothing
+ *
+ * Return value:
+ * nothing
+ ********************************************************************* */
+
+void board_device_init(void)
+{
+ unsigned short GPIOOverlays;
+
+ kerSysFlashInit();
+
+#if defined (_BCM96328_)
+ if( BpGetGPIOverlays(&GPIOOverlays) == BP_SUCCESS ) {
+ /* Start with all HW LEDs disabled */
+ LED->ledHWDis |= 0xFFFFFF;
+ if (GPIOOverlays & BP_OVERLAY_SERIAL_LEDS) {
+ GPIO->PinMuxSel |= PINMUX_SERIAL_LED_DATA;
+ GPIO->PinMuxSel |= PINMUX_SERIAL_LED_CLK;
+ LED->ledInit |= LED_SERIAL_LED_EN;
+ }
+ /* Enable LED controller to drive GPIO */
+ /* foxconn modified start to let hardware control only act LEDs, Bob, 08/04/2010 */
+ if (GPIOOverlays & BP_OVERLAY_EPHY_LED_0) {
+ GPIO->PinMuxSel |= PINMUX_EPHY0_ACT_LED;
+ //GPIO->GPIOMode |= (1 << EPHY0_SPD_LED);
+ //LED->ledHWDis &= ~(1 << EPHY0_SPD_LED);
+ }
+ if (GPIOOverlays & BP_OVERLAY_EPHY_LED_1) {
+ GPIO->PinMuxSel |= PINMUX_EPHY1_ACT_LED;
+ //GPIO->GPIOMode |= (1 << EPHY1_SPD_LED);
+ //LED->ledHWDis &= ~(1 << EPHY1_SPD_LED);
+ }
+ if (GPIOOverlays & BP_OVERLAY_EPHY_LED_2) {
+ GPIO->PinMuxSel |= PINMUX_EPHY2_ACT_LED;
+ //GPIO->GPIOMode |= (1 << EPHY2_SPD_LED);
+ //LED->ledHWDis &= ~(1 << EPHY2_SPD_LED);
+ }
+ if (GPIOOverlays & BP_OVERLAY_EPHY_LED_3) {
+ GPIO->PinMuxSel |= PINMUX_EPHY3_ACT_LED;
+ //GPIO->GPIOMode |= (1 << EPHY3_SPD_LED);
+ //LED->ledHWDis &= ~(1 << EPHY3_SPD_LED);
+ }
+ /* foxconn modified end, Bob, 08/04/2010 */
+ }
+#endif
+
+#if defined (_BCM96362_)
+ if( BpGetGPIOverlays(&GPIOOverlays) == BP_SUCCESS ) {
+ /* Start with all HW LEDs disabled */
+ LED->ledHWDis |= 0xFFFFFF;
+ if (GPIOOverlays & BP_OVERLAY_SERIAL_LEDS) {
+ GPIO->GPIOMode |= (GPIO_MODE_SERIAL_LED_CLK | GPIO_MODE_SERIAL_LED_DATA);
+ LED->ledInit |= LED_SERIAL_LED_EN;
+ }
+ /* Map HW LEDs to LED controller inputs and enable LED controller to drive GPIO */
+ if (GPIOOverlays & BP_OVERLAY_EPHY_LED_0) {
+ LED->ledLinkActSelHigh |= ((1 << (LED_ENET0 - 4)) << LED_4_LINK_SHIFT);
+ GPIO->LEDCtrl |= (1 << LED_ENET0);
+ LED->ledHWDis &= ~(1 << LED_ENET0);
+ }
+ if (GPIOOverlays & BP_OVERLAY_EPHY_LED_1) {
+ LED->ledLinkActSelHigh |= ((1 << (LED_ENET1 - 4)) << LED_5_LINK_SHIFT);
+ GPIO->LEDCtrl |= (1 << LED_ENET1);
+ LED->ledHWDis &= ~(1 << LED_ENET1);
+ }
+ if (GPIOOverlays & BP_OVERLAY_EPHY_LED_2) {
+ LED->ledLinkActSelHigh |= ((1 << (LED_ENET2 - 4)) << LED_6_LINK_SHIFT);
+ GPIO->LEDCtrl |= (1 << LED_ENET2);
+ LED->ledHWDis &= ~(1 << LED_ENET2);
+ }
+ if (GPIOOverlays & BP_OVERLAY_EPHY_LED_3) {
+ LED->ledLinkActSelHigh |= ((1 << (LED_ENET3 - 4)) << LED_7_LINK_SHIFT);
+ GPIO->LEDCtrl |= (1 << LED_ENET3);
+ LED->ledHWDis &= ~(1 << LED_ENET3);
+ }
+ }
+#endif
+
+#if defined (_BCM96368_)
+ TIMER->WDResetCount = 50000; // Assert reset for 1ms only. If reset asserted for too
+ // long chip reboots twice
+ if( BpGetGPIOverlays(&GPIOOverlays) == BP_SUCCESS ) {
+ if (GPIOOverlays & BP_OVERLAY_EPHY_LED_0) {
+ GPIO->GPIOMode |= GPIO_MODE_EPHY0_LED;
+ GPIO->GPIODir |= GPIO_MODE_EPHY0_LED;
+ }
+
+ if (GPIOOverlays & BP_OVERLAY_EPHY_LED_1) {
+ GPIO->GPIOMode |= GPIO_MODE_EPHY1_LED;
+ GPIO->GPIODir |= GPIO_MODE_EPHY1_LED;
+ }
+
+ if (GPIOOverlays & BP_OVERLAY_EPHY_LED_2) {
+ GPIO->GPIOMode |= GPIO_MODE_EPHY2_LED;
+ GPIO->GPIODir |= GPIO_MODE_EPHY2_LED;
+ }
+
+ if (GPIOOverlays & BP_OVERLAY_EPHY_LED_3) {
+ GPIO->GPIOMode |= GPIO_MODE_EPHY3_LED;
+ GPIO->GPIODir |= GPIO_MODE_EPHY3_LED;
+ }
+
+ if (GPIOOverlays & BP_OVERLAY_SERIAL_LEDS) {
+ GPIO->GPIOMode |= (GPIO_MODE_SERIAL_LED_CLK | GPIO_MODE_SERIAL_LED_DATA);
+ GPIO->GPIODir |= (GPIO_MODE_SERIAL_LED_CLK | GPIO_MODE_SERIAL_LED_DATA);
+ GPIO->SerialLed = 0xffffffff;
+ }
+ }
+
+ /* These blocks will be enabled by the appropriate driver if they are
+ * compiled into a router image.
+ */
+ PERF->blkEnables &= ~(USBH_CLK_EN | PCM_CLK_EN | SAR_CLK_EN | USBD_CLK_EN);
+#endif
+
+#if defined (_BCM96816_)
+ TIMER->WDResetCount = 50000; // Assert reset for 1ms only. If reset asserted for too
+ // long chip reboots twice
+
+ if( BpGetGPIOverlays(&GPIOOverlays) == BP_SUCCESS ) {
+ if (GPIOOverlays & BP_OVERLAY_GPHY_LED_0) {
+ GPIO->GPIOMode |= GPIO_MODE_GPHY0_LED;
+ GPIO->GPIODir |= GPIO_MODE_GPHY0_LED;
+ }
+
+ if (GPIOOverlays & BP_OVERLAY_GPHY_LED_1) {
+ GPIO->GPIOMode |= GPIO_MODE_GPHY1_LED;
+ GPIO->GPIODir |= GPIO_MODE_GPHY1_LED;
+ }
+
+ if (GPIOOverlays & BP_OVERLAY_SERIAL_LEDS) {
+ GPIO->GPIOMode |= (GPIO_MODE_SERIAL_LED_CLK | GPIO_MODE_SERIAL_LED_DATA);
+ GPIO->GPIODir |= (GPIO_MODE_SERIAL_LED_CLK | GPIO_MODE_SERIAL_LED_DATA);
+ GPIO->SerialLed = 0xffffffff;
+ }
+
+ if (GPIOOverlays & BP_OVERLAY_MOCA_LED) {
+ GPIO->GPIOMode |= GPIO_MODE_MOCA_LED;
+ GPIO->GPIODir |= GPIO_MODE_MOCA_LED;
+ }
+ }
+
+ MISC->miscMoCARst &= ~(MISC_MOCA_RST_REF_DIV2RST | MISC_MOCA_RST_REF_FBDIVRST);
+ MISC->miscMoCARst &= ~MISC_MOCA_RST_REF_VCRST;
+ MISC->miscMoCARst &= ~(MISC_MOCA_RST_REF_OUTDIV_RESET_M_MASK | MISC_MOCA_RST_REF_MDIV2RST);
+ MISC->miscMoCACtl |= (7 << MISC_MOCA_CTL_REF_QP_ICTRL_SHIFT);
+ MISC->miscMoCARst &= ~MISC_MOCA_RST_REF_LD_RESET_STRT;
+ PERF->softResetB &= ~(SOFT_RST_MOCA_CPU | SOFT_RST_MOCA_SYS | SOFT_RST_MOCA);
+#endif
+
+#if defined (_BCM96328_) || defined (_BCM96362_)
+ LED->ledInit &= ~LED_FAST_INTV_MASK;
+ LED->ledInit |= (LED_INTERVAL_20MS * 4) << LED_FAST_INTV_SHIFT;
+#else
+ /* Set blink rate for hardware LEDs. */
+ GPIO->LEDCtrl &= ~LED_INTERVAL_SET_MASK;
+ GPIO->LEDCtrl |= LED_INTERVAL_SET_80MS;
+#endif
+
+ /* Add the ethernet driver. */
+ cfe_add_device( &bcm63xx_enet, 0, 0, 0);
+}
+
+
+void setGpio (unsigned short led_gpio, unsigned short led_state)
+{
+#if 0
+ unsigned short gpio_state;
+
+ if (((led_gpio & BP_ACTIVE_LOW) && (led_state == LED_ON)) ||
+ (!(led_gpio & BP_ACTIVE_LOW) && (led_state == LED_OFF)))
+ gpio_state = 0;
+ else
+ gpio_state = 1;
+#endif
+
+ GPIO->GPIODir |= GPIO_NUM_TO_MASK(led_gpio);
+ if( led_state )
+ GPIO->GPIOio |= GPIO_NUM_TO_MASK(led_gpio);
+ else
+ GPIO->GPIOio &= ~GPIO_NUM_TO_MASK(led_gpio);
+}
+
+
+/* *********************************************************************
+ * board_final_init()
+ *
+ * Do any final initialization, such as adding commands to the
+ * user interface.
+ *
+ * If you don't want a user interface, put the startup code here.
+ * This routine is called just before CFE starts its user interface.
+ *
+ * Input parameters:
+ * nothing
+ *
+ * Return value:
+ * nothing
+ ********************************************************************* */
+
+void board_final_init(void)
+{
+ unsigned short rstToDfltIrq;
+ int breakIntoCfe = 0;
+
+ /* Foxconn add start by Cliff Wang, 03/23/2010 */
+ int goAuto;
+ /* Foxconn add end by Cliff Wang, 03/23/2010 */
+
+ setAllLedsOff();
+ setPowerOnLedOn();
+ setGpio(GPIO_POWER_RED_LED, GPIO_POWER_RED_LED_ON);
+#if (INC_SPI_PROG_NAND==1)
+ rstToDfltIrq = 1 ;
+ breakIntoCfe = rstToDfltIrq;
+#else
+ if( (bootInfo.runFrom == 'f') && getBootImageTag() == NULL ) {
+ setBreakIntoCfeLed();
+ printf("** Flash image not found. **\n\n");
+ kerSysErasePsi();
+ breakIntoCfe = 1;
+ }
+
+ if( BpGetResetToDefaultExtIntr( &rstToDfltIrq ) == BP_SUCCESS ) {
+ if (checkForResetToDefaultHold( rstToDfltIrq )) {
+ kerSysErasePsi();
+ /* Reset the default bootline if the board IP address has changed. */
+ if (strcmp(bootInfo.boardIp, DEFAULT_BOARD_IP) != 0) {
+ setDefaultBootline();
+ }
+ /* Foxconn modified start pling 09/09/2008 */
+ /* just load default, don't break into console */
+ //breakIntoCfe = 1;
+ printf("\n** Load default! **\n\n");
+ /* Foxconn modified end pling 09/09/2008 */
+ }
+ }
+#endif
+ /* Foxconn add start by Cliff Wang, 03/23/2010 */
+ goAuto = bcm63xx_run(breakIntoCfe);
+ setBreakIntoCfeLed();
+ if(goAuto)
+ {
+ ui_docommand("tftpd");
+ }
+ /* Foxconn add end by Cliff Wang, 03/23/2010 */
+}
+
+/* *********************************************************************
+ * Miscellaneous Board Functions
+ ********************************************************************* */
+
+/* *********************************************************************
+ * checkForResetToDefaultHold()
+ *
+ * Determines if the user is holding the reset to default button.
+ *
+ * Input parameters:
+ * Reset to default irq#
+ *
+ * Return value:
+ * 1 - break into the CFE, 0 - continue boot sequence
+ ********************************************************************* */
+#if (INC_SPI_PROG_NAND==0)
+static int checkForResetToDefaultHold( unsigned short rstToDfltIrq )
+{
+ const int nBreakIntoCfeDelay = 5;
+ int ret = 0;
+ int i;
+ uint32 irqBit;
+ volatile uint32 *extIrqReg;
+
+ extIrqReg = &PERF->ExtIrqCfg;
+ irqBit = 1 << (rstToDfltIrq + EI_STATUS_SHFT);
+
+#if defined(_BCM96368_)
+ if (rstToDfltIrq >= BP_EXT_INTR_4 && rstToDfltIrq <= BP_EXT_INTR_5) {
+ extIrqReg = &PERF->ExtIrqCfg1;
+ irqBit = 1 << (rstToDfltIrq - BP_EXT_INTR_4 + EI_STATUS_SHFT);
+ }
+#endif
+
+ /* Loop while the reset to default button is depressed. */
+ for(i = 0; !(*extIrqReg & irqBit); i++) {
+ if (i == nBreakIntoCfeDelay) {
+ setBreakIntoCfeLed();
+ printf("\n*** Break into CFE console ***\n\n");
+ ret = 1;
+ break;
+ }
+ cfe_sleep(CFE_HZ);
+ }
+
+ return( ret );
+}
+#endif
+/* *********************************************************************
+ * setLed(led_gpio, led_state)
+ *
+ * Turns on an LED.
+ *
+ * Input parameters:
+ * LED purpose
+ * LED State
+ *
+ * Return value:
+ * nothing
+ ********************************************************************* */
+
+void setLed (unsigned short led_gpio, unsigned short led_state)
+{
+ unsigned short gpio_state;
+
+ if (((led_gpio & BP_ACTIVE_LOW) && (led_state == LED_ON)) ||
+ (!(led_gpio & BP_ACTIVE_LOW) && (led_state == LED_OFF)))
+ gpio_state = 0;
+ else
+ gpio_state = 1;
+
+#if defined(_BCM96328_)
+ /* Enable LED controller to drive this GPIO */
+ if (!(led_gpio & BP_GPIO_SERIAL))
+ GPIO->GPIOMode |= GPIO_NUM_TO_MASK(led_gpio);
+#endif
+
+#if defined(_BCM96362_)
+ /* Enable LED controller to drive this GPIO */
+ if (!(led_gpio & BP_GPIO_SERIAL))
+ GPIO->LEDCtrl |= GPIO_NUM_TO_MASK(led_gpio);
+#endif
+
+#if defined(_BCM96328_) || defined(_BCM96362_)
+ LED->ledMode &= ~(LED_MODE_MASK << GPIO_NUM_TO_LED_MODE_SHIFT(led_gpio));
+ if( gpio_state )
+ LED->ledMode |= (LED_MODE_OFF << GPIO_NUM_TO_LED_MODE_SHIFT(led_gpio));
+ else
+ LED->ledMode |= (LED_MODE_ON << GPIO_NUM_TO_LED_MODE_SHIFT(led_gpio));
+
+#else
+ if (led_gpio & BP_GPIO_SERIAL) {
+ while (GPIO->SerialLedCtrl & SER_LED_BUSY);
+ if( gpio_state )
+ GPIO->SerialLed |= GPIO_NUM_TO_MASK(led_gpio);
+ else
+ GPIO->SerialLed &= ~GPIO_NUM_TO_MASK(led_gpio);
+ }
+ else {
+ GPIO->GPIODir |= GPIO_NUM_TO_MASK(led_gpio);
+ if( gpio_state )
+ GPIO->GPIOio |= GPIO_NUM_TO_MASK(led_gpio);
+ else
+ GPIO->GPIOio &= ~GPIO_NUM_TO_MASK(led_gpio);
+ }
+#endif
+}
+
+/* *********************************************************************
+ * setAllLedsOff()
+ *
+ * Turns off all board LEDs on init
+ *
+ * Input parameters:
+ * LED purpose
+ *
+ * Return value:
+ * nothing
+ ********************************************************************* */
+
+void setAllLedsOff(void)
+{
+ unsigned short gpio;
+
+ if( BpGetAdslLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetAdslFailLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetSecAdslLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetSecAdslFailLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetWirelessSesLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetHpnaLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetWanDataLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetWanErrorLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetBootloaderPowerOnLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetBootloaderStopLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetVoipLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetVoip1LedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetVoip2LedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetPotsLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetGponLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetMoCALedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetGponFailLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetMoCAFailLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+}
+
+/* *********************************************************************
+ * setPowerOnLedOn()
+ *
+ * Turns on the Power LED.
+ *
+ * Input parameters:
+ * LED purpose
+ *
+ * Return value:
+ * nothing
+ ********************************************************************* */
+
+void setPowerOnLedOn(void)
+{
+ unsigned short gpio;
+ if( BpGetBootloaderStopLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ if( BpGetBootloaderPowerOnLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_ON );
+}
+
+
+/* *********************************************************************
+ * setBreakIntoCfeLed()
+ *
+ * Turns on the alarm LED.
+ *
+ * Input parameters:
+ * LED purpose
+ *
+ * Return value:
+ * nothing
+ ********************************************************************* */
+
+void setBreakIntoCfeLed(void)
+{
+ unsigned short gpio;
+ if( BpGetBootloaderStopLedGpio( &gpio ) == BP_SUCCESS ) {
+ setLed( gpio, LED_ON );
+ if( BpGetBootloaderPowerOnLedGpio( &gpio ) == BP_SUCCESS )
+ setLed( gpio, LED_OFF );
+ }
+}
+
+/* *********************************************************************
+ * softReset()
+ *
+ * Resets the board.
+ *
+ * Input parameters:
+ * nothing
+ *
+ * Return value:
+ * nothing
+ ********************************************************************* */
+
+void softReset(void)
+{
+ printf( "\nResetting board...\n" );
+#if defined (_BCM96816_)
+ /* Work around reset issues */
+ HVG->reg_hvg_cha_misc |= HVG_SOFT_INIT_0;
+ HVG->reg_hvg_chb_misc |= HVG_SOFT_INIT_0;
+#endif
+
+#if defined(_BCM96328_)
+ TIMER->SoftRst |= SOFT_RESET;
+#else
+ PERF->pll_control |= SOFT_RESET; // soft reset mips
+#if defined(_BCM96368_) || defined(_BCM96816_)
+ PERF->pll_control = 0;
+#endif
+#endif
+ while (1);
+}
+
+/* Foxconn added start , 1/29/2010 */
+extern int nmrp_server_detected;
+
+int test_led_control(int on_off)
+{
+ // unsigned short gpio;
+ int tftpd_state = get_tftpd_state();
+
+ if (tftpd_state == TFTPD_STATE_OFF)
+ {
+ setGpio(GPIO_POWER_RED_LED, GPIO_POWER_RED_LED_ON); //turn red power led
+ }
+ else if ( (tftpd_state == TFTPD_STATE_WAIT_IMAGE) || (tftpd_state == TFTPD_STATE_WRITE_IMAGE) )
+ {
+ if (on_off==1)
+ {
+ setGpio(GPIO_POWER_RED_LED, GPIO_POWER_RED_LED_ON);
+ }
+ else
+ {
+ setGpio(GPIO_POWER_RED_LED, GPIO_POWER_RED_LED_OFF);
+ }
+ }
+
+ return 0;
+}
+
+int power_led_toggle(int state)
+{
+ test_led_control(state);
+ return 0;
+}
+
+int nmrp_led_toggle(void)
+{
+ static int led_state = 0;
+
+ /* Foxconn added end for U12H154 */
+
+ if (led_state == 0)
+ {
+ led_state = 1;
+ setGpio(18, 1);
+ }
+ else
+ {
+ led_state = 0;
+ setGpio(18, 0);
+ }
+
+ return 0;
+}
+
+
+static unsigned long calculate_checksum (int action, char *s, int size)
+{
+ static unsigned long c0, c1;
+ unsigned long checksum, b;
+ int i;
+ switch (action)
+ {
+ case 0:
+ c0 = c1 = 0;
+ break;
+
+ case 1:
+ for (i = 0; i < size; i++)
+ {
+ c0 += s[i] & 0xff;
+ c1 += c0;
+ /* check the lan/wan ports status, Foxconn added by EricHuang, 10/24/2006 */
+ if ((i % 90000) == 0)
+ {
+ printf(".");
+// bcm_robo_check_link_status();
+ }
+ }
+ break;
+
+ case 2:
+ b = (c0 & 65535) + ((c0 >> 16) & 65535);
+ c0 = ((b >> 16) + b) & 65535;
+
+ b = (c1 & 65535) + ((c1 >> 16) & 65535);
+ c1 = ((b >> 16) + b) & 65535;
+
+ checksum = ((c1 << 16) | c0);
+
+ return checksum;
+ }
+ return 0;
+}
+
+int verify_checksum(char *buf, unsigned long buf_len, unsigned long chksum)
+{
+ unsigned long cal_chksum = 0;
+
+ xprintf("Loading .");
+ calculate_checksum (0, NULL, 0);
+ calculate_checksum (1, buf, buf_len);
+ cal_chksum = calculate_checksum (2, NULL, 0);
+ printf("\n");
+
+
+ if (cal_chksum != chksum) {
+ xprintf("Image chksum: 0x%08X\n", chksum);
+ xprintf("Calc chksum: 0x%08X\n", cal_chksum);
+ return -1;
+ }
+
+#ifdef _DEBUG
+ //printf("verify_checksum calculate_checksum = 0x%08X\n", cal_chksum);
+ //printf("verify_checksum image_chksum = 0x%08X\n", chksum);
+#endif
+
+ return 0;
+}
+
+int verify_board_id(char *buf)
+{
+ /* char *board_id = ( char *)BOARD_DATA_ADDR; */
+ char board_id[PROJECT_ID_LEN];
+
+ kerSysReadFromFlash(board_id, BOARD_DATA_ADDR, PROJECT_ID_LEN);
+
+ if(nmrp_server_detected==1) // in NMRP mode
+ {
+ if (strncmp(buf, board_id, PROJECT_ID_LEN) != 0)
+ {
+ printf("verify_board_id failed: (%s)\n", buf);
+ return -1;
+ }
+ }
+ else
+ {
+ if (strcmp(buf, board_id) != 0)
+ {
+ /* Foxconn removed start pling 12/10/2008 */
+ /* Don't check board ID in 'tftpd' mode */
+ printf("verify_board_id failed: (%s)\n", buf);
+ //return -1;
+ /* Foxconn removed end pling 12/10/2008 */
+ }
+ }
+ return 0;
+}
+
+/* Foxconn added end , 1/29/2010 */
+