1 #ifndef __TIBOOT_H__
2 #define __TIBOOT_H__
3 /******************************************************************************
4 * FILE PURPOSE: Define Structures, MACROs and etc for TI Shared ROM Boot
5 ******************************************************************************
6 * FILE NAME: tiboot.h
7 *
8 * DESCRIPTION: Define structures, macros and etc for the TI Shared ROM boot
9 * process.
10 *
11 * TABS: NONE
12 *
13 * $Id: $
14 *
15 * REVISION HISTORY:
16 *
17 * $Log: $
18 *
19 * (C) Copyright 2004 TELOGY Networks, Inc.
20 ******************************************************************************/
21 #include "types.h"
23 /*******************************************************************************
24 * Utility Macro definitions
25 ******************************************************************************/
26 #define HEX_DIGIT(digit) ((digit) + '0')
27 #define BOOT_BIT_TO_MASK(bit) (1 << (bit))
29 /*******************************************************************************
30 * Data Definition: Error Handling relatBOOT_ENTRY_POINT_ADDRed definition:
31 *******************************************************************************
32 * Description: Define Handling related macros, constants
33 *
34 ******************************************************************************/
35 /* Define Module IDs */
36 #define BOOT_MODULE_ID_MAIN 0
37 #define BOOT_MODULE_ID_BTBL 1
38 #define BOOT_MODULE_ID_BETH 2
39 #define BOOT_MODULE_ID_I2C 3
40 #define BOOT_MODULE_ID_CHIP 4
41 #define BOOT_MODULE_ID_HW 5
43 /* Boot error codes */
44 enum {
45 BOOT_NOERR = 0,
46 BOOT_ERROR = 1, /* General error */
47 BOOT_INVALID_BOOT_MODE = 2,
48 BOOT_INVALID_I2C_DEV_ADDR = 3,
49 BOOT_INVALID_CHECKSUM = 4, /* Invalid checksum of the boot parameters */
50 BOOT_INVALID_PARAMS_SIZE = 5, /* the size of boot parameters is too big */
51 BOOT_RX_ETH_QUEUE_FULL = 6, /* ethmain.c, hw_rxPacket */
52 BOOT_CACHE_INIT_FAIL = 7, /* rmain.c, cache init failed */
53 BOOT_CACHE_DISABLE_FAIL = 8, /* rmain.c, cache disable failed */
54 BOOT_INVALID_CPPI_SIZE = 9, /* ethmain.c, invalid compile sizes */
55 BOOT_INVALID_CORE_ID = 10, /* Invalid core ID in cold boot */
56 BOOT_INVALID_MAC_ADDR = 11, /* Invalid MAC address (all 0's) */
57 BOOT_ETH_TX_SCRATCH = 12, /* tx scratch size invalid */
58 BOOT_ETH_TX_PACKET = 13, /* tx packet formation failure */
59 BOOT_ETH_MAC_INIT = 14, /* ethmain.c - mac init failed */
60 BOOT_PERIPH_POWER = 15, /* peripheral failed to powerup */
61 BOOT_MAIN_FAIL = 16 /* Failed in initial boot setup (wrong core) */
62 };
64 /* Error tracking prototypes (functions in rmain.c)*/
65 void bootException (UINT16 errorCode);
66 void bootError (UINT16 errorCode);
68 /* Error code = (module ID * 100) + module specific error */
69 #define BOOT_ERROR_CODE(id, code) ((UINT16)((id<<8) + code))
70 #define BOOT_EXCEPTION(error_code) bootException(error_code)
71 #define BOOT_ERROR(error_code) bootError(error_code)
73 /*******************************************************************************
74 * Begin Boot Parameter definitions
75 ******************************************************************************/
77 /*******************************************************************************
78 * Boot Parameter Common
79 ******************************************************************************/
80 typedef struct boot_params_common_s{
81 UINT16 length; /* size of the entire boot parameters in bytes */
82 UINT16 checksum; /* non-zero: 1's complement checksum of the boot
83 * parameters
84 * zero: checksum is not applicable
85 */
86 UINT16 boot_mode;
87 UINT16 portNum;
88 UINT16 swPll; /* CPU PLL multiplier */
91 } BOOT_PARAMS_COMMON_T;
93 typedef struct boot_params_ethernet_s{
95 /* common portion of the Boot parameters */
96 UINT16 length;
97 UINT16 checksum;
98 UINT16 boot_mode;
99 UINT16 portNum;
100 UINT16 swPll; /* CPU PLL multiplier */
102 /* Etherent specific portion of the Boot Parameters */
103 UINT16 options;
104 /*
105 * Ethernet Specific Options
106 *
107 * Bits 2:0 interface
108 * 000 - MII
109 * 001 - RMII
110 * 010 - GMII
111 * 011 - RGMII
112 * 100 - SMII
113 * 101 - S3MII
114 * 110 - RMII 10Mbs
115 * 111 - RMII 100Mbs
116 *
117 * Bit 3: HD:
118 * 0 - Full Duplex
119 * 1 - Half Duplex
120 * Bit 4: SKIP TX
121 * 0 - Send the Ethernet Ready Frame
122 * 1 - Skip sending the Ethernet Ready Frame
123 * Bit 5: SKIP INIT
124 * 0 - Initialize the Ethernet MAC peripheral
125 * 1 - Skip initializing the Ethernet MAC peripheral
126 * Bit 6: FC
127 * 0 - Disable Flow Control
128 * 1 - Enable Flow Control
129 *
130 * Other bits: Reserved
131 */
132 #define BOOT_PARAMS_ETH_OPTIONS_MII 0x0000
133 #define BOOT_PARAMS_ETH_OPTIONS_RMII 0x0001
134 #define BOOT_PARAMS_ETH_OPTIONS_GMII 0x0002
135 #define BOOT_PARAMS_ETH_OPTIONS_RGMII 0x0003
136 #define BOOT_PARAMS_ETH_OPTIONS_SMII 0x0004
137 #define BOOT_PARAMS_ETH_OPTIONS_S3MII 0x0005
138 #define BOOT_PARAMS_ETH_OPTIONS_RMII_10 0x0006
139 #define BOOT_PARAMS_ETH_OPTIONS_RMII_100 0x0007
141 #define BOOT_PARAMS_ETH_OPTIONS_HD 0x0008
142 #define BOOT_PARAMS_ETH_OPTIONS_SKIP_TX 0x0010
143 #define BOOT_PARAMS_ETH_OPTIONS_SKIP_INIT 0x0020
144 #define BOOT_PARAMS_ETH_OPTIONS_FC 0x0040
146 /*
147 * he device MAC address to be used for Boot:
148 * All zero mac address indicates that the device E-fuse address should
149 * be used.
150 */
151 UINT16 mac_addr_h;
152 UINT16 mac_addr_m;
153 UINT16 mac_addr_l;
155 /*
156 * The multicast or broadcast MAC address which should be accepted as
157 * a destination MAC address for boot table frames
158 */
159 UINT16 mmac_addr_h;
160 UINT16 mmac_addr_m;
161 UINT16 mmac_addr_l;
163 UINT16 src_port; /* Source UDP port number to be used during boot process */
164 /* 0: allow any SRC UDP port */
165 UINT16 dest_port; /* Destination UDP port number to be used during boot process */
167 /* The Device ID to be included in the boot ready announcement frame */
168 UINT16 device_id_12;
169 UINT16 device_id_34;
170 #define BOOT_PARAMS_DEVICE_ID_HIGH_MASK 0xFF00
171 #define BOOT_PARAMS_DEVICE_ID_HIGH_SHIFT 8
172 #define BOOT_PARAMS_DEVICE_ID_LOW_MASK 0x00FF
173 #define BOOT_PARAMS_DEVICE_ID_LOW_SHIFT 0
174 #define BOOT_PARAMS_GET_DEVICE_ID_13(device_id) \
175 (((device_id) & BOOT_PARAMS_DEVICE_ID_HIGH_MASK) > BOOT_PARAMS_DEVICE_ID_HIGH_SHIFT)
176 #define BOOT_PARAMS_GET_DEVICE_ID_24(device_id) \
177 (((device_id) & BOOT_PARAMS_DEVICE_ID_LOW_MASK) > BOOT_PARAMS_DEVICE_ID_LOW_SHIFT)
179 /*
180 * The destination MAC address used for the boot ready announce frame
181 */
182 UINT16 hmac_addr_h;
183 UINT16 hmac_addr_m;
184 UINT16 hmac_addr_l;
186 } BOOT_PARAMS_ETHERNET_T;
188 /**************************************************************************************
189 * Utopia boot options
190 **************************************************************************************/
191 typedef struct boot_params_utopia_s{
193 /* common portion of the Boot parameters */
194 UINT16 length;
195 UINT16 checksum;
196 UINT16 boot_mode;
197 UINT16 portNum;
198 UINT16 swPll; /* CPU PLL multiplier */
200 /* Utopia specific portion of the Boot Parameters */
201 /* Options
202 * ---------------------------------------------------------------
203 * | 15 3 | 2 | 1 | 0 |
204 * ----------------------------------------------------------------
205 * reserved | | \-> 0 = multi phy
206 * | | 1 = single phy
207 * | \-> 0 = 8 bit utopia
208 * | 1 = 16 bit utopis
209 * \-> 0 = Init port
210 * 1 = skip port init
211 */
212 UINT16 options;
214 #define BOOT_PARAMS_UTOPIA_SINGLE_PHY (1<<0)
215 #define BOOT_PARAMS_UTOPIA_16BIT (1<<1)
216 #define BOOT_PARAMS_UTOPIA_SKIP_INIT (1<<2)
218 UINT16 cellSizeBytes; /* Cell Size */
219 UINT16 busWidthBits; /* Bus width (8 or 16) */
220 UINT16 slid; /* Slave ID */
221 UINT16 coreFreqMhz; /* CPU frequency after pll mult */
224 } BOOT_PARAMS_UTOPIA_T;
226 typedef struct boot_params_i2c_s{
228 /* common portion of the Boot parameters */
229 UINT16 length;
230 UINT16 checksum;
231 UINT16 boot_mode;
232 UINT16 portNum;
233 UINT16 swPll; /* CPU PLL multiplier */
235 /* I2C specific portion of the Boot Parameters */
236 UINT16 options;
237 /*
238 * I2C Specific Options
239 * Bit 01-00: BT:
240 * 00 - Boot Parameter Mode
241 * 01 - Boot Table Mode
242 * 10 - Boot Config mode
243 * 11 - Slave receive boot config
244 * Bit 04-02: EETYPE: EEPROM type
245 * Other bits: Reserved
246 */
247 #define BOOT_PARAMS_I2C_OPTIONS_BP 0x0000
248 #define BOOT_PARAMS_I2C_OPTIONS_BT 0x0001
249 #define BOOT_PARAMS_I2C_OPTIONS_BC 0x0002
250 #define BOOT_PARAMS_I2C_OPTIONS_SLVOPT 0x0003
252 #define BOOT_PARAMS_I2C_OPTIONS_MASK 0x0003
253 #define BOOT_PARAMS_I2C_OPTIONS_SHIFT 0
255 #define BOOT_PARAMS_I2C_OPTIONS_EETYPE_MASK 0x001C
256 #define BOOT_PARAMS_I2C_OPTIONS_EETYPE_SHIFT 2
258 #define BOOT_PARAMS_I2C_IS_BOOTTBL_MODE(options) \
259 (((options) & BOOT_PARAMS_I2C_OPTIONS_MASK) == BOOT_PARAMS_I2C_OPTIONS_BT)
261 #define BOOT_PARAMS_I2C_IS_BOOTCONFIG_MODE(options) \
262 (((options) & BOOT_PARAMS_I2C_OPTIONS_MASK) == BOOT_PARAMS_I2C_OPTIONS_BC)
264 #define BOOT_PARAMS_I2C_IS_SLAVE_RCV_OPTIONS_MODE(options) \
265 (((options) & BOOT_PARAMS_I2C_OPTIONS_MASK) == BOOT_PARAMS_I2C_OPTIONS_SLVOPT)
267 #define BOOT_PARAMS_I2C_IS_BOOTPARAM_MODE(options) \
268 (((options) & BOOT_PARAMS_I2C_OPTIONS_MASK) == BOOT_PARAMS_I2C_OPTIONS_BP)
270 #define BOOT_PARAMS_I2C_SET_BOOTTBL_MODE(options, mode) \
271 (options) = ((options) & ~BOOT_PARAMS_I2C_OPTIONS_MASK) | \
272 (((mode) & BOOT_PARAMS_I2C_OPTIONS_MASK) << \
273 BOOT_PARAMS_I2C_OPTIONS_SHIFT)
276 #define BOOT_PARAMS_I2C_GET_EETYPE(options) \
277 (((options) & BOOT_PARAMS_I2C_OPTIONS_EETYPE_MASK) >> BOOT_PARAMS_I2C_OPTIONS_EETYPE_SHIFT)
278 #define BOOT_PARAMS_I2C_SET_EETYPE(options, ee_type) \
279 (options) = (((options) & ~BOOT_PARAMS_I2C_OPTIONS_EETYPE_MASK) | \
280 (((ee_type) << BOOT_PARAMS_I2C_OPTIONS_EETYPE_SHIFT) & BOOT_PARAMS_I2C_OPTIONS_EETYPE_MASK))
282 /* The device address to be used for Boot */
283 UINT16 dev_addr; /* 16-bit device address (low) */
284 UINT16 dev_addr_ext; /* 16-bit extended device address (high)
285 * set to zero if not used
286 * Note: some I2C device requires 32-bit
287 * address
288 */
289 UINT16 multi_i2c_id; /* Multi device master write boot ID */
290 UINT16 my_i2c_id; /* This parts I2C address */
292 UINT16 core_freq_mhz; /* Core frequency, MHz */
293 UINT16 i2c_clk_freq_khz; /* Desired I2C clock frequency, kHz */
295 UINT16 next_dev_addr; /* Used only for the boot config mode. */
296 UINT16 next_dev_addr_ext; /* Copied into dev_addr* after config complete */
298 UINT16 address_delay; /* Rough number of cycles delay between address write
299 * and read to the i2c eeprom */
302 } BOOT_PARAMS_I2C_T;
305 typedef struct boot_params_rapidio_s{
307 /* common portion of the Boot parameters */
308 UINT16 length;
309 UINT16 checksum;
310 UINT16 boot_mode;
311 UINT16 portNum;
312 UINT16 swPll; /* CPU PLL multiplier */
314 /* Options */
315 UINT16 options;
317 #define BOOT_PARAMS_RIO_OPTIONS_TX_ENABLE (1<<0) /* set to enable transmit */
318 #define BOOT_PARAMS_RIO_OPTIONS_BOOT_TABLE (1<<1) /* set to use boot tables */
319 #define BOOT_PARAMS_RIO_OPTIONS_NO_CONFIG (1<<2) /* set to bypass port config */
321 UINT16 cfg_index; /* General configuration index to use */
322 UINT16 node_id; /* The node id for this device */
323 UINT16 serdes_ref_clk; /* The serdes reference clock freq, in hundredths
324 * of MHz (1 MHz would be 100) */
325 UINT16 link_rate; /* Data link rate (mega bits per second */
326 UINT16 pf_low; /* Packet forward range, low */
327 UINT16 pf_high; /* Packet forward range, high */
329 } BOOT_PARAMS_RIO_T;
331 /*
332 * UNION of boot parameter structures in all modes
333 * Note: We need to make sure that the structures genertaed by the C-compiler
334 * match with the boot parameter table data format i.e. a set of 16-bit
335 * data array.
336 */
337 #define BOOT_PARAMS_SIZE_IN_BYTES 128
338 typedef union {
339 BOOT_PARAMS_COMMON_T common;
340 BOOT_PARAMS_ETHERNET_T eth;
341 BOOT_PARAMS_I2C_T i2c;
342 BOOT_PARAMS_UTOPIA_T utopia;
343 BOOT_PARAMS_RIO_T rio;
344 UINT16 parameter[BOOT_PARAMS_SIZE_IN_BYTES/2];
345 } BOOT_PARAMS_T;
348 /*******************************************************************************
349 * Definition: The time stamp and version number are placed into the stats.
350 * This will be two characters packed per 16bits . The length
351 * value must be 32 bit divisible
352 *******************************************************************************/
353 #define BOOT_VERSION_LEN_UINT16 32
354 typedef struct BOOT_VERSION_S {
356 UINT16 vstring[BOOT_VERSION_LEN_UINT16];
358 } BOOT_VERSION_T;
359 extern BOOT_VERSION_T bootVersion;
362 /*******************************************************************************
363 * Definition: Runs time stats that are not initialized on cold boot entry
364 * !!!!!! boot.s assumes that the nonInit stats are at the top of the structure
365 * !!!!!! and that stage is the first element
366 *******************************************************************************/
367 typedef struct BOOT_STATS_NONINIT_S {
368 UINT16 stage; /* Record the SharedROM code execution stage */
369 #define BOOT_STAGE_ASM_START_UP 1
370 #define BOOT_STAGE_INIT_CACHE 2
371 #define BOOT_STAGE_CHCHE_INITED 3
372 #define BOOT_STAGE_ENTER_WARMBOOT 4
373 #define BOOT_STAGE_INIT_CPGMAC 5
374 #define BOOT_STAGE_SEND_ERA_FRAME 6
375 #define BOOT_STAGE_ETH_MAIN_LOOP 7
376 #define BOOT_STAGE_I2C_BOOTTBL_LOOP 8
377 #define BOOT_STAGE_I2C_BOOTPARAM_LOOP 9
378 #define BOOT_STAGE_DISABLE_CACHE 10
379 #define BOOT_STAGE_CHCHE_DISABLED 11
380 #define BOOT_STAGE_EXIT 12
381 #define BOOT_STAGE_ERROR_LOOP 13
382 #define BOOT_STAGE_I2C_BOOTCONFIG_LOOP 14
383 #define BOOT_STAGE_I2C_SLV_RCV_OPTIONS_LOOP 15
384 #define BOOT_STAGE_UTOPIA_MAIN_LOOP 16
385 UINT16 coldBootEntries;
387 } BOOT_STATS_NONINIT_T;
389 /*******************************************************************************
390 * Definition: Run time statistics and error counts. These stats are
391 * initialized on cold boot entry.
392 ******************************************************************************/
394 typedef struct BOOT_STATS_COMMON_S {
395 UINT32 bootStatus;
396 UINT16 nColdBootEntries;
397 UINT16 nBootReentries;
398 UINT16 nPllWarns;
399 UINT16 nResetWarns;
400 } BOOT_STATS_COMMON_T;
403 typedef struct BOOT_STATS_MAIN_S {
404 UINT16 errorCode; /* (module ID <<8 ) + module specific error */
406 /* I2C operation related statistics */
407 UINT16 numI2Cpkts; /* number of I2C boot table packets processed */
408 UINT16 numI2CchksumError;/* number of I2C checksum errors */
409 UINT16 numI2ClengthError;/* number of I2C block length errors */
410 UINT16 numI2CotherError; /* number of I2C section with invalid length and etc */
411 UINT16 numI2Cretrys; /* number of I2C retrys due to read access errors */
412 UINT16 numI2cWrites; /* number of I2C master writes to passive devices */
413 UINT16 numI2cWriteError; /* number of I2C master write errors */
415 UINT16 warmBootEntry; /* Count of entries into warm boot routine */
416 } BOOT_STATS_MAIN_T;
420 /*****************************************************************************
421 * Definition: I2C stats, Boot table and Ethernrt stats initialized
422 * on cold boot entry
423 *****************************************************************************/
424 typedef struct I2C_STATS_tag
425 {
426 UINT16 num_trans;
427 UINT16 num_trys;
428 UINT16 num_try_ok;
429 UINT16 num_try_lost_arb;
430 UINT16 num_try_idle_to;
431 UINT16 num_try_no_ack;
432 UINT16 num_try_other_err;
433 UINT32 extra_idle_waits;
434 UINT32 extra_clock_waits;
435 UINT32 tx_bytes;
436 UINT32 rx_bytes;
437 UINT32 data_re_reads;
438 } I2C_STATS_T;
440 typedef struct BTBL_STATS_tag
441 {
442 UINT16 num_sections; /* number of boot table sections received */
443 UINT16 num_pdma_copies; /* number of PDMA copies performed */
444 } BTBL_STATS_T;
446 typedef struct ETH_STATS_tag
447 {
448 /* MAC packets related statistics */
449 UINT16 uniMacPkts; /* Count of packets received with valid unicast mac
450 address */
451 UINT16 multiMacPkts; /* Count of packets received with valid multicast or
452 broadcast mac address */
453 UINT16 invalidMacPkts; /* Count of packets received with invalid mac
454 address */
455 UINT16 invalidLLCPkts; /* Count of 802.3 packets with wrong LLC/SNAP header */
456 UINT16 nonIpPkts; /* Count of non-IP packets received with valid
457 MAC address */
459 /* IP packets related statistics */
460 UINT16 nonIP4Pkts; /* Count of non-IP4 packets */
461 UINT16 ipfragments; /* Count of IP fragments received */
462 UINT16 ipTruncatedError; /* Count of truncated IP frame */
463 UINT16 nonUDPPkts; /* Count of IP packets with non-UDP paylaod */
465 /* UDP packets related statistics */
466 UINT16 udpSizeError; /* Count of UDP packet with invalid (odd) size */
467 UINT16 udpPortError; /* Count of UDP packets with invalid port number */
468 UINT16 udpChksumError; /* Count of UDP packets with checksum error */
470 /* Boot table packets related statistics */
471 UINT16 nonBtblPkts; /* Count of UDP packets with invalid boot table paylaod */
472 UINT16 outSeqPkts; /* Count of out of sequence boot table packets received
473 i.e. packets with unexpected seq_num */
474 UINT16 expSeqNum; /* Expected Sequence Number */
475 UINT16 lastSeqNum; /* Last sequence number received */
477 /* Driver errors */
478 UINT16 sizeZeroPackets; /* Count of packets arriving with 0 size */
479 } ETH_STATS_T;
481 typedef struct PCI_EEAI_STATS_tag
482 {
483 UINT16 pciI2cReads; /* Count of block reads of i2c eeprom */
484 UINT16 pciI2cRetries; /* Count of i2c read retries */
485 UINT16 pciChkSumErr; /* Count of block check sum errors */
486 UINT16 pciEeaiFail; /* Count of aborted pci attempts */
487 } PCI_EEAI_STATS_T;
489 /* Rapid I/O stats */
490 typedef struct RAPIDIO_STATS_tag
491 {
492 UINT16 rapidIoFailReady; /* If set rapid I/O peripheral failed to report ready */
493 UINT16 rapidIoBtblBlocks; /* Count of number of boot table blocks received */
494 UINT16 rapidIoBtblBadBlocks; /* Count of boot table blocks rejected */
495 } RAPIDIO_STATS_T;
497 typedef struct HPI_STATS_Tag
498 {
499 UINT16 hpiBtblBlocks; /* Count of boot table blocks received */
500 UINT16 hpiBtblBadBlocks; /* Count of boot table blocks rejected */
501 } HPI_STATS_T;
503 /* Utopia stats */
504 typedef struct UTOPIA_STATS_tag
505 {
506 UINT16 cellCount; /* Count of cells received */
507 UINT16 invalidPtr; /* Count of invalid pointers received in processing */
508 UINT16 invalidSize; /* Count of cells that were too small */
509 UINT16 cellMagicCount; /* Count of cells received with valid magic */
510 UINT16 cellMagicFailed; /* Count of cells received with invalid magic */
511 UINT16 trapNoCellMem; /* Trapped due to no cell space in memory */
512 UINT16 possibleOverrun; /* Count of possible cell buffer overruns */
513 } UTOPIA_STATS_T;
515 /*******************************************************************************
516 * Definition: The statistics
517 *
518 * !!!!!! boot.s assumes that the nonInit stats are at the top of the structure!
519 *******************************************************************************/
520 typedef struct BOOT_STATS_S {
522 BOOT_STATS_COMMON_T common;
523 BOOT_STATS_NONINIT_T nonInit;
524 BOOT_STATS_MAIN_T main;
525 I2C_STATS_T i2c;
526 BTBL_STATS_T btbl;
527 union {
528 ETH_STATS_T eth;
529 PCI_EEAI_STATS_T pci_eeai;
530 RAPIDIO_STATS_T rapidIo;
531 UTOPIA_STATS_T utopia;
532 HPI_STATS_T hpi;
533 } u;
534 } BOOT_STATS_T;
536 extern BOOT_STATS_T bootStats;
538 /*******************************************************************************
539 * Definition: The magic start address, known to all modules
540 *******************************************************************************/
541 extern volatile UINT32 *p_boot_entry_addr;
543 #endif /* __TIBOOT_H__ */
545 /* nothing past this point */