1 /*
2 *
3 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
38 /********************************************************************************************************
39 * FILE PURPOSE: IBL configuration and control definitions
40 ********************************************************************************************************
41 * FILE NAME: ibl.h
42 *
43 * DESCRIPTION: Defines the data structure used to handle initial configuration and control
44 * of the ibl. This data structure resides at a fixed location in the device memory
45 * map. It is initially populated either during the rom boot. The table can be
46 * over-written during the ibl process to redirect the boot. For example the ibl
47 * can initially load from an i2c which repopulates this table with parameters
48 * for an ethernet boot.
49 *
50 * @file ibl.h
51 *
52 * @brief
53 * This file defines the configuration and control of the IBL
54 *
55 *
56 ********************************************************************************************************/
57 #ifndef IBL_H
58 #define IBL_H
60 #include "types.h"
62 /* Information used to make generate a bootp request */
63 /**
64 * @brief
65 * Defines parameters used for making a bootp request
66 *
67 * @details
68 * The bootp request parameters are created from these fields
69 */
70 typedef struct iblBootp_s
71 {
72 uint8 hwAddress[6]; /**< The hardware (mac) address of this device. If set to 0
73 the ibl will values from e-fuse */
75 uint8 ipDest[4]; /**< The IP address of this device. This is typically set
76 to IP broadcast */
78 } iblBootp_t;
81 /**
82 * @brief
83 * This structure contains information used for tftp boot.
84 *
85 * @details These fields are typically filled in by the bootp packet, but
86 * can be provided if bootp will not be used.
87 */
88 typedef struct iblEthBootInfo_s
89 {
90 uint8 ipAddr[4]; /**< The IP address of this device */
91 uint8 serverIp[4]; /**< The IP address of the tftp server */
92 uint8 gatewayIp[4]; /**< The IP address of the gateway */
93 uint8 netmask[4]; /**< The IP netmask */
94 uint8 hwAddress[6]; /**< The hardware (mac) address of this device */
95 char8 fileName[128]; /**< The file name to load */
97 } iblEthBootInfo_t;
100 /**
101 * @def ibl_ETH_PORT_FROM_RBL
102 */
103 #define ibl_ETH_PORT_FROM_RBL -1 /**< The ethernet port used is the same one used
104 during the ROM boot load process. */
107 /**
108 * @defgroup iblBootFormats
109 *
110 * @ingroup iblBootFormats
111 * @{
112 */
113 #define ibl_BOOT_FORMAT_AUTO 0 /**< Auto determine the boot format from the data */
114 #define ibl_BOOT_FORMAT_NAME 1 /**< Determines the boot format based on file name (bootp/tftp only) */
115 #define ibl_BOOT_FORMAT_BIS 2 /**< Boot TI AIS format */
116 #define ibl_BOOT_FORMAT_COFF 3 /**< Boot a COFF file */
117 #define ibl_BOOT_FORMAT_ELF 4 /**< Boot an ELF file */
118 #define ibl_BOOT_FORMAT_BBLOB 5 /**< Boot a binary blob */
119 #define ibl_BOOT_FORMAT_BTBL 6 /**< Boot a TI boot table file */
121 /* @} */
123 /**
124 * @defgroup iblPeriphPriority Defines the boot sequence
125 *
126 * @ingroup iblPeriphPriority
127 * @{
128 * @def ibl_LOWEST_PRIORITY
129 */
130 #define ibl_LOWEST_PRIORITY 10 /**< The lowest priority assignable to a peripheral for boot */
132 /**
133 * @def ibl_HIGHEST_PRIORITY
134 */
135 #define ibl_HIGHEST_PRIORITY 1 /**< The highest priority assignable to a peripheral for boot */
137 /**
138 * @def ibl_DEVICE_NOBOOT
139 */
140 #define ibl_DEVICE_NOBOOT 20 /**< Indicates that the device is not to be used for boot */
142 /* @} */
145 /**
146 * @brief
147 * Emif controller 3.1 configuration
148 *
149 * @details
150 * The paramters are directly placed into the emif controller
151 */
152 typedef struct iblEmif3p1_s
153 {
154 uint32 sdcfg; /**< SD configuration register */
155 uint32 sdrfc; /**< Refresh timing register */
156 uint32 sdtim1; /**< DDR timing register 1 */
157 uint32 sdtim2; /**< DDR timing register 2 */
158 uint32 dmcctl; /**< CAS match timing */
160 } iblEmif3p1_t;
163 /**
164 * @brief
165 * Emif controller 4.0 configuration
166 *
167 * @details
168 * The parameters are placed directly into the emif controller
169 */
170 typedef struct iblEmif4p0_s
171 {
172 uint32 dummy; /**< placeholder */
174 } iblEmif4p0_t;
176 /**
177 * @brief
178 * This structure is used to configure the DDR interface
179 *
180 * @details
181 * The DDR configuration parameters are setup
182 *
183 */
184 typedef struct idblDdr_s
185 {
186 bool configDdr; /**< Set to non-zero to enable EMIF configuration */
188 union {
190 iblEmif3p1_t emif3p1; /**< Configuration of devices with emif controller version 3.1 */
191 iblEmif4p0_t emif4p0; /**< Configuration of devices with emif controller version 4.0 */
192 } uEmif;
194 } iblDdr_t;
196 /**
197 * @brief
198 * This structure is used to identify binary blob load parameters.
199 *
200 * @details
201 * Since binary blob is formatless the start address, size and branch to address
202 * can be specified. In the case of network boot, boot will terminate when no
203 * more data is received (or timed out), even if the size is not reached.
204 */
205 typedef struct iblBinBlob_s
206 {
207 uint32 startAddress; /**< Where the loaded data is placed */
208 uint32 sizeBytes; /**< How much data to load */
209 uint32 branchAddress; /**< Where to branch to when the load is complete */
211 } iblBinBlob_t;
213 /**
214 * @brief
215 * This structure is used to control the operation of the ibl ethernet boot.
216 *
217 * @details
218 * The ethernet port and bootp request are controlled through this structure.
219 */
220 typedef struct iblEth_s
221 {
222 uint32 ethPriority; /**< The ethernet boot priority. @ref iblPeriphPriority */
223 int32 port; /**< The ethernet port to use, or @ref ibl_ETH_PORT_FROM_RBL */
224 bool doBootp; /**< If true a bootp request is generated. If false the @ref iblEthBootInfo_t
225 table must be populated before the ibl begins execution */
226 bool useBootpServerIp; /**< If TRUE then the server IP received from the bootp server
227 is used, if FALSE the one in the ethInfo field is used */
228 bool useBootpFileName; /**< If TRUE then the file name received from the bootp server
229 is used, if FALSE the one in the ethInfo field is used */
230 int32 bootFormat; /**< The format of the boot data file. @ref iblBootFormats */
232 iblBinBlob_t blob; /**< Used only if the format is ibl_BOOT_FORMAT_BBLOB */
234 iblEthBootInfo_t ethInfo; /**< Low level ethernet information */
236 } iblEth_t;
239 /**
240 * @brief
241 * This structure is used to control the operation of the ibl sgmii ports
242 *
243 * @details
244 * The physical register configuration is provided
245 */
246 typedef struct iblSgmii_s
247 {
248 uint32 adviseAbility; /**< The advise ability register */
249 uint32 control; /**< The control register */
250 uint32 txConfig; /**< Serdes Tx config */
251 uint32 rxConfig; /**< Serdes Rx config */
252 uint32 auxConfig; /**< Serdes Aux config */
254 } iblSgmii_t;
257 /**
258 * @def ibl_N_ETH_PORTS
259 */
260 #define ibl_N_ETH_PORTS 2 /**< The number of ethernet port configurations available */
262 /**
263 * @def ibl_N_MDIO_CFGS
264 */
265 #define ibl_N_MDIO_CFGS 16 /**< The maximum number of mdio configurations */
268 /**
269 * @brief
270 * This structure is used to configure phys through the mdio interface
271 *
272 * @details
273 * Defines optional configuration through MDIO.
274 *
275 * The mdio transaction values are mapped as follows:
276 *
277 * /-------------------------------------------------------------\
278 * | 31 | 30 | 29 26 | 25 21 | 20 16 | 15 0|
279 * | rsvd | write | rsvd | register | phy addr | data |
280 * \-------------------------------------------------------------/
281 */
282 typedef struct iblMdio_s
283 {
284 int16 nMdioOps; /**< The number of mdio writes to perform */
285 uint16 mdioClkDiv; /**< The divide down of the mac clock which drives the mdio */
287 uint32 interDelay; /**< The number of cpu cycles to wait between mdio writes */
289 uint32 mdio[ibl_N_MDIO_CFGS]; /* The MDIO transactions */
291 } iblMdio_t;
294 /**
295 * @brief
296 * This structure defines the physical parameters of the NAND device
297 */
298 typedef struct nandDevInfo_s
299 {
300 uint32 busWidthBits; /**< 8 or 16 bit bus width */
301 uint32 pageSizeBytes; /**< The size of each page */
302 uint32 pageEccBytes; /**< Number of ecc bytes in each page */
303 uint32 pagesPerBlock; /**< The number of pages in each block */
304 uint32 totalBlocks; /**< The total number of blocks in a device */
306 uint32 addressBytes; /**< Number of bytes in the address */
307 bool lsbFirst; /**< Set to true if the LSB is output first, otherwise msb is first */
308 uint32 blockOffset; /**< Address bits which specify the block number */
309 uint32 pageOffset; /**< Address bits which specify the page number */
310 uint32 columnOffset; /**< Address bits which specify the column number */
312 uint8 resetCommand; /**< The command to reset the flash */
313 uint8 readCommandPre; /**< The read command sent before the address */
314 uint8 readCommandPost; /**< The read command sent after the address */
315 bool postCommand; /**< If TRUE the post command is sent */
317 } nandDevInfo_t;
320 /**
321 * @brief
322 * This structure is used to control the operation of the NAND boot
323 *
324 */
325 typedef struct iblNand_s
326 {
328 uint32 nandPriority; /**< The nand boot priority. @ref iblPeriphPriority */
329 int32 bootFormat; /**< The format of the boot data file. @ref iblBootFormats */
330 iblBinBlob_t blob; /**< Used only if the format is ibl_BOOT_FORMAT_BBLOB */
333 nandDevInfo_t nandInfo; /** Low level device info */
335 } iblNand_t;
338 /**
339 * @brief
340 * This structure is used to control the programming of the device PLL
341 *
342 * @details
343 * The system PLLs are optionally configured
344 */
345 typedef struct iblPll_s {
347 bool doEnable; /**< If true the PLL is configured */
349 Uint32 prediv; /**< The pll pre-divisor */
350 Uint32 mult; /**< The pll multiplier */
351 Uint32 postdiv; /**< The pll post divider */
353 Uint32 pllOutFreqMhz; /**< The resulting output frequency, required for timer setup */
355 } iblPll_t;
358 /**
359 * @defgroup iblPllNum
360 *
361 * @ingroup iblPllNum
362 * @{
363 *
364 * @def ibl_MAIN_PLL
365 */
366 #define ibl_MAIN_PLL 0 /**< The main cpu pll */
368 /**
369 * @def ibl_DDR_PLL
370 */
371 #define ibl_DDR_PLL 1 /**< The ddr pll */
373 /**
374 * @def ibl_NET_PLL
375 */
376 #define ibl_NET_PLL 2 /**< The network pll */
378 /**
379 * @def the number of PLL configuration entries in the table
380 */
381 #define ibl_N_PLL_CFGS (ibl_NET_PLL + 1)
383 /* @} */
388 /**
389 * @def ibl_MAGIC_VALUE
390 */
391 #define ibl_MAGIC_VALUE 0xCEC11EBB /**< Indicates that the configuration table is valid */
393 /**
394 * @brief
395 * The main configuration/control structure for the ibl
396 *
397 * @details
398 * The operation of the ibl is configured/controlled based on the values in this structure.
399 * This structure resides at a fixed location in the memory map. It can be changed during
400 * the boot operation itself by loading new values into it, but these changes must occur
401 * as part of the boot process itself (not through an asynchronous write through a master
402 * peripheral).
403 *
404 * Each boot mode is assigned a priority, with lower values indicating a higher
405 * priority. The lowest valid priority is @ref ibl_LOWEST_BOOT_PRIORITY, and the value
406 * @ref ibl_DEVICE_NOBOOT indicates no boot will be attempted on that peripheral.
407 */
408 typedef struct ibl_s
409 {
410 uint32 iblMagic; /**< @ref ibl_MAGIC_VALUE */
412 iblPll_t pllConfig[ibl_N_PLL_CFGS]; /**< PLL Configuration. @ref iblPll_t */
414 iblDdr_t ddrConfig; /**< DDR configuration @ref iblDdr_t */
416 iblEth_t ethConfig[ibl_N_ETH_PORTS]; /**< Ethernet boot configuration. @ref iblEth_t */
418 iblSgmii_t sgmiiConfig[ibl_N_ETH_PORTS]; /**< SGMII boot configuration. @ref iblSgmii_t */
420 iblMdio_t mdioConfig; /**< MDIO configuration. @ref iblMdio_t */
422 iblNand_t nandConfig; /**< NAND configuration @ref iblNand_t */
425 /* iblI2c_t i2cConfig; */
426 /* iblSpi_t spiConfig; */
429 } ibl_t;
432 extern ibl_t ibl;
436 /**
437 * @defgroup iblActivePeriph
438 *
439 * @ingroup iblActivePeriph
440 * @{
441 * @def ibl_ACTIVE_PERIPH_ETH
442 */
443 #define ibl_ACTIVE_PERIPH_ETH 100 /**< An ethernet boot in progress */
445 /**
446 * @def ibl_ACTIVE_PERIPH_NAND
447 */
448 #define ibl_ACTIVE_PERIPH_NAND 101 /**< A nand boot in progress */
450 /**
451 * @def ibl_ACTIVE_PERIPH_I2C
452 */
453 #define ibl_ACTIVE_PERIPH_I2C 102 /**< An i2c boot in progress */
455 /**
456 * @def ibl_ACTIVE_PERIPH_SPI
457 */
458 #define ibl_ACTIVE_PERIPH_SPI 103 /**< An SPI boot in progress */
460 /* @} */
463 /**
464 * @brief
465 * Provide status on the boot operation
466 *
467 * @details
468 * Run time status of the IBL is provided to aid in debugging
469 *
470 */
471 typedef struct iblStatus_s
472 {
473 uint32 iblMagic; /**< The @ref ibl_MAGIC_VALUE is placed here to indicate the boot has begun */
475 int32 tableLoadFail; /**< If non-zero then the load of the parameter table from i2c failed */
477 int32 heartBeat; /**< An increasing value as long as the boot code is running */
478 int32 noMagic; /**< A non-zero value here indicates that @ref ibl_MAGIC_VALUE was not found
479 in the @ref ibl_t magic field, and default values were loaded. */
480 int32 activePeriph; /**< Describes the active boot peripheral @ref iblActivePeriph */
481 int32 activeFormat; /**< Describes the format being decoded */
483 int32 autoDetectFailCnt; /**< Counts the number of times an auto detect of the data format failed */
484 int32 nameDetectFailCnt; /**< Counts the number of times an name detect of the data format failed */
486 int32 invalidDataFormatSpec; /**< Counts the number of times the main boot found an invalid boot format request */
488 uint32 exitAddress; /**< If non-zero the IBL exited and branched to this address */
490 iblEthBootInfo_t ethParams; /**< Last ethernet boot attemp parameters */
492 } iblStatus_t;
494 extern iblStatus_t iblStatus;
504 #endif /* IBL_H */