1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
4 * Board device initialization File: bcm94710_devs.c
6 * This is the "C" part of the board support package. The
7 * routines to create and initialize the console, wire up
8 * device drivers, and do other customization live here.
10 * Author: Mitch Lichtenberg (mpl@broadcom.com)
12 *********************************************************************
14 * XX Copyright 2000,2001
15 * Broadcom Corporation. All rights reserved.
17 * BROADCOM PROPRIETARY AND CONFIDENTIAL
19 * This software is furnished under license and may be used and
20 * copied only in accordance with the license.
21 ********************************************************************* */
23 #include "lib_types.h"
24 #include "lib_printf.h"
25 #include "cfe_timer.h"
30 #include "dev_bcm63xx_flash.h"
31 #include "bcm63xx_util.h"
34 void checkForResetHold(void);
35 void kerSysMipsSoftReset(void);
36 int sysGetBoardId(void);
37 const char *get_system_type(void);
38 PFILE_TAG
kerSysImageTagGet(void);
40 /* *********************************************************************
41 * Devices we're importing
42 ********************************************************************* */
44 extern cfe_driver_t bcm63xx_uart
;
45 extern cfe_driver_t bcm6345_enet
;
46 extern cfe_driver_t flashdrv
;
48 /* *********************************************************************
49 * Some board-specific parameters
50 ********************************************************************* */
53 /* *********************************************************************
54 * board_console_init()
56 * Add the console device and set it to be the primary
64 ********************************************************************* */
66 void board_console_init(void)
68 /* Add the serial port driver. */
69 cfe_add_device(&bcm63xx_uart
,0xFFFE0300,0,0);
71 cfe_set_console( "uart0" );
75 /* *********************************************************************
78 * Initialize and add other devices. Add everything you need
79 * for bootstrap here, like disk drives, flash memory, UARTs,
80 * network controllers, etc.
87 ********************************************************************* */
89 void board_device_init(void)
91 PFILE_TAG pTag
= NULL
;
93 /* Add the ethernet driver. */
94 cfe_add_device( &bcm6345_enet
, 0, 0, 0);
98 if ((pTag
= kerSysImageTagGet()))
100 int flash_addr_kernel
= atoi(pTag
->kernelAddress
) + TAG_LEN
;
101 int flash_len_kernel
= atoi(pTag
->kernelLen
);
102 if( flash_len_kernel
> 0 )
103 cfe_add_device(&flashdrv
, flash_addr_kernel
, flash_len_kernel
, NULL
);
105 printf( "Kernel image not found on flash.\n" );
109 // Used to load an RTEMS image.
110 cfe_add_device(&flashdrv
, FLASH45_IMAGE_START_ADDR
, 0x100000, NULL
);
111 printf("\r\n** Using flash start address 0x%8.8lx **\r\n\r\n",
112 FLASH45_IMAGE_START_ADDR
);
118 /* *********************************************************************
119 * board_device_reset()
121 * Reset devices. This call is done when the firmware is restarted,
122 * as might happen when an operating system exits, just before the
123 * "reset" command is applied to the installed devices. You can
124 * do whatever board-specific things are here to keep the system
125 * stable, like stopping DMA sources, interrupts, etc.
132 ********************************************************************* */
134 void board_device_reset(void)
139 /* *********************************************************************
142 * Do any final initialization, such as adding commands to the
145 * If you don't want a user interface, put the startup code here.
146 * This routine is called just before CFE starts its user interface.
153 ********************************************************************* */
155 void board_final_init(void)
161 /* *********************************************************************
162 * Miscellaneous Board Functions
163 ********************************************************************* */
165 /* *********************************************************************
166 * checkForResetHold()
168 * Determines if the user is holding the reset button in a depressed
169 * state for 3 seconds. If it is, default settings are restored.
176 ********************************************************************* */
178 void checkForResetHold(void)
180 const int nResetHoldDelay
= 3;
183 for (i
= 0; i
< nResetHoldDelay
; i
++)
185 if ((GPIO
->GPIOio
& (unsigned short) GPIO_PRESS_AND_HOLD_RESET
))
189 if (i
== nResetHoldDelay
)
191 printf("\n*** Restore to Factory Default Setting ***\n\n");
194 setDefaultBootline();
200 /* *********************************************************************
201 * kerSysMipsSoftReset()
210 ********************************************************************* */
211 void kerSysMipsSoftReset(void)
213 INTC
->pll_control
|= SOFT_RESET
; // soft reset mips
216 /* *********************************************************************
217 * kerSysImageTagGet()
222 * point to tag in flash -- Found
224 ********************************************************************* */
225 PFILE_TAG
kerSysImageTagGet(void)
228 int totalBlks
= flash_get_numsectors();
230 unsigned char *sectAddr
;
233 // start from 2nd blk, assume 1st one is always CFE
234 for (i
= 2; i
< totalBlks
; i
++)
236 sectAddr
= flash_get_memptr((byte
) i
);
237 crc
= CRC32_INIT_VALUE
;
238 crc
= getCrc32(sectAddr
, (UINT32
)TAG_LEN
-TOKEN_LEN
, crc
);
239 pTag
= (PFILE_TAG
) sectAddr
;
240 if (crc
== (UINT32
)(*(UINT32
*)(pTag
->tagValidationToken
)))
244 return (PFILE_TAG
) NULL
;
247 /* *********************************************************************
250 * Returns board id constant.
257 ********************************************************************* */
259 int sysGetBoardId( void )
261 GPIO
->GPIODir
&= (unsigned short) ~BOARD_ID_BCM9634X_MASK
;
262 return( (int) (GPIO
->GPIOio
& BOARD_ID_BCM9634X_MASK
) );
263 } /* sysGetBoardId */