1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2012 The Chromium OS Authors.
4 * (C) Copyright 2002-2010
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 #ifndef __ASM_GENERIC_GBL_DATA_H
9 #define __ASM_GENERIC_GBL_DATA_H
11 * The following data structure is placed in some memory which is
12 * available very early after boot (like DPRAM on MPC8xx/MPC82xx, or
13 * some locked parts of the data cache) to allow for a minimum set of
14 * global variables during system initialization (until we have set
15 * up the memory controller so that we can use RAM).
17 * Keep it *SMALL* and remember to set GENERATED_GBL_DATA_SIZE > sizeof(gd_t)
19 * Each architecture has its own private fields. For now all are private
25 #include <linux/list.h>
29 typedef struct global_data gd_t;
32 * struct global_data - global data structure
36 * @bd: board information
40 * @flags: global data flags
46 * @baudrate: baud rate of the serial interface
48 unsigned int baudrate;
50 * @cpu_clk: CPU clock rate in Hz
52 unsigned long cpu_clk;
54 * @bus_clk: platform clock rate in Hz
56 unsigned long bus_clk;
58 * @pci_clk: PCI clock rate in Hz
60 /* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
61 unsigned long pci_clk;
63 * @mem_clk: memory clock rate in Hz
65 unsigned long mem_clk;
66 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
68 * @fb_base: base address of frame buffer memory
70 unsigned long fb_base;
72 #if defined(CONFIG_POST)
74 * @post_log_word: active POST tests
76 * @post_log_word is a bit mask defining which POST tests are recorded
77 * (see constants POST_*).
79 unsigned long post_log_word;
81 * @post_log_res: POST results
83 * @post_log_res is a bit mask with the POST results. A bit with value 1
84 * indicates successful execution.
86 unsigned long post_log_res;
88 * @post_init_f_time: time in ms when post_init_f() started
90 unsigned long post_init_f_time;
92 #ifdef CONFIG_BOARD_TYPES
94 * @board_type: board type
96 * If a U-Boot configuration supports multiple board types, the actual
97 * board type may be stored in this field.
99 unsigned long board_type;
102 * @have_console: console is available
104 * A value of 1 indicates that serial_init() was called and a console
106 * A value of 0 indicates that console input and output drivers shall
109 unsigned long have_console;
110 #if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
112 * @precon_buf_idx: pre-console buffer index
114 * @precon_buf_idx indicates the current position of the buffer used to
115 * collect output before the console becomes available
117 unsigned long precon_buf_idx;
120 * @env_addr: address of environment structure
122 * @env_addr contains the address of the structure holding the
123 * environment variables.
125 unsigned long env_addr;
127 * @env_valid: environment is valid
129 * See &enum env_valid
131 unsigned long env_valid;
133 * @env_has_init: bit mask indicating environment locations
135 * &enum env_location defines which bit relates to which location
137 unsigned long env_has_init;
139 * @env_load_prio: priority of the loaded environment
143 * @ram_base: base address of RAM used by U-Boot
145 unsigned long ram_base;
147 * @ram_top: top address of RAM used by U-Boot
149 unsigned long ram_top;
151 * @relocaddr: start address of U-Boot in RAM
153 * After relocation this field indicates the address to which U-Boot
154 * has been relocated. It can be displayed using the bdinfo command.
155 * Its value is needed to display the source code when debugging with
156 * GDB using the 'add-symbol-file u-boot <relocaddr>' command.
158 unsigned long relocaddr;
160 * @ram_size: RAM size in bytes
162 phys_size_t ram_size;
164 * @mon_len: monitor length in bytes
166 unsigned long mon_len;
168 * @irq_sp: IRQ stack pointer
170 unsigned long irq_sp;
172 * @start_addr_sp: initial stack pointer address
174 unsigned long start_addr_sp;
176 * @reloc_off: relocation offset
178 unsigned long reloc_off;
180 * @new_gd: pointer to relocated global data
182 struct global_data *new_gd;
186 * @dm_root: root instance for Driver Model
188 struct udevice *dm_root;
190 * @dm_root_f: pre-relocation root instance
192 struct udevice *dm_root_f;
194 * @uclass_root: head of core tree
196 struct list_head uclass_root;
197 # if CONFIG_IS_ENABLED(OF_PLATDATA)
198 /** Dynamic info about the driver */
199 struct driver_rt *dm_driver_rt;
204 * @timer: timer instance for Driver Model
206 struct udevice *timer;
209 * @fdt_blob: U-Boot's own device tree, NULL if none
211 const void *fdt_blob;
213 * @new_fdt: relocated device tree
217 * @fdt_size: space reserved for relocated device space
219 unsigned long fdt_size;
220 #if CONFIG_IS_ENABLED(OF_LIVE)
222 * @of_root: root node of the live tree
224 struct device_node *of_root;
227 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
229 * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
231 const void *multi_dtb_fit;
236 * The jump table contains pointers to exported functions. A pointer to
237 * the jump table is passed to standalone applications.
241 * @env_buf: buffer for env_get() before reloc
246 * @trace_buff: trace buffer
248 * When tracing function in U-Boot this field points to the buffer
249 * recording the function calls.
253 #if defined(CONFIG_SYS_I2C)
255 * @cur_i2c_bus: currently used I2C bus
260 * @timebase_h: high 32 bits of timer
262 unsigned int timebase_h;
264 * @timebase_l: low 32 bits of timer
266 unsigned int timebase_l;
267 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
269 * @malloc_base: base address of early malloc()
271 unsigned long malloc_base;
273 * @malloc_limit: limit address of early malloc()
275 unsigned long malloc_limit;
277 * @malloc_ptr: current address of early malloc()
279 unsigned long malloc_ptr;
283 * @hose: PCI hose for early use
285 struct pci_controller *hose;
287 * @pci_ram_top: top of region accessible to PCI
289 phys_addr_t pci_ram_top;
291 #ifdef CONFIG_PCI_BOOTDELAY
293 * @pcidelay_done: delay time before scanning of PIC hose expired
295 * If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of
296 * milliseconds defined by environment variable pcidelay before
297 * scanning. Once this delay has expired the flag @pcidelay_done
303 * @cur_serial_dev: current serial device
305 struct udevice *cur_serial_dev;
307 * @arch: architecture-specific data
309 struct arch_global_data arch;
310 #ifdef CONFIG_CONSOLE_RECORD
312 * @console_out: output buffer for console recording
314 * This buffer is used to collect output during console recording.
316 struct membuff console_out;
318 * @console_in: input buffer for console recording
320 * If console recording is activated, this buffer can be used to
323 struct membuff console_in;
325 #ifdef CONFIG_DM_VIDEO
327 * @video_top: top of video frame buffer area
331 * @video_bottom: bottom of video frame buffer area
335 #ifdef CONFIG_BOOTSTAGE
337 * @bootstage: boot stage information
339 struct bootstage_data *bootstage;
341 * @new_bootstage: relocated boot stage information
343 struct bootstage_data *new_bootstage;
347 * @log_drop_count: number of dropped log messages
349 * This counter is incremented for each log message which can not
350 * be processed because logging is not yet available as signaled by
351 * flag %GD_FLG_LOG_READY in @flags.
355 * @default_log_level: default logging level
357 * For logging devices without filters @default_log_level defines the
358 * logging level, cf. &enum log_level_t.
360 int default_log_level;
362 * @log_head: list of logging devices
364 struct list_head log_head;
366 * @log_fmt: bit mask for logging format
368 * The @log_fmt bit mask selects the fields to be shown in log messages.
369 * &enum log_fmt defines the bits of the bit mask.
374 * @processing_msg: a log message is being processed
376 * This flag is used to suppress the creation of additional messages
377 * while another message is being processed.
381 * @logc_prev: logging category of previous message
383 * This value is used as logging category for continuation messages.
387 * @logl_prev: logging level of the previous message
389 * This value is used as logging level for continuation messages.
393 #if CONFIG_IS_ENABLED(BLOBLIST)
395 * @bloblist: blob list information
397 struct bloblist_hdr *bloblist;
399 * @new_bloblist: relocated blob list information
401 struct bloblist_hdr *new_bloblist;
404 * @spl_handoff: SPL hand-off information
406 struct spl_handoff *spl_handoff;
409 #if defined(CONFIG_TRANSLATION_OFFSET)
411 * @translation_offset: optional translation offset
413 * See CONFIG_TRANSLATION_OFFSET.
415 fdt_addr_t translation_offset;
417 #if CONFIG_IS_ENABLED(WDT)
419 * @watchdog_dev: watchdog device
421 struct udevice *watchdog_dev;
426 * gd_board_type() - retrieve board type
428 * Return: global board type
430 #ifdef CONFIG_BOARD_TYPES
431 #define gd_board_type() gd->board_type
433 #define gd_board_type() 0
436 /* These macros help avoid #ifdefs in the code */
437 #if CONFIG_IS_ENABLED(OF_LIVE)
438 #define gd_of_root() gd->of_root
439 #define gd_of_root_ptr() &gd->of_root
440 #define gd_set_of_root(_root) gd->of_root = (_root)
442 #define gd_of_root() NULL
443 #define gd_of_root_ptr() NULL
444 #define gd_set_of_root(_root)
447 #if CONFIG_IS_ENABLED(OF_PLATDATA)
448 #define gd_set_dm_driver_rt(dyn) gd->dm_driver_rt = dyn
449 #define gd_dm_driver_rt() gd->dm_driver_rt
451 #define gd_set_dm_driver_rt(dyn)
452 #define gd_dm_driver_rt() NULL
456 * enum gd_flags - global data flags
458 * See field flags of &struct global_data.
462 * @GD_FLG_RELOC: code was relocated to RAM
464 GD_FLG_RELOC = 0x00001,
466 * @GD_FLG_DEVINIT: devices have been initialized
468 GD_FLG_DEVINIT = 0x00002,
470 * @GD_FLG_SILENT: silent mode
472 GD_FLG_SILENT = 0x00004,
474 * @GD_FLG_POSTFAIL: critical POST test failed
476 GD_FLG_POSTFAIL = 0x00008,
478 * @GD_FLG_POSTSTOP: POST sequence aborted
480 GD_FLG_POSTSTOP = 0x00010,
482 * @GD_FLG_LOGINIT: log Buffer has been initialized
484 GD_FLG_LOGINIT = 0x00020,
486 * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
488 GD_FLG_DISABLE_CONSOLE = 0x00040,
490 * @GD_FLG_ENV_READY: environment imported into hash table
492 GD_FLG_ENV_READY = 0x00080,
494 * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
496 GD_FLG_SERIAL_READY = 0x00100,
498 * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
500 GD_FLG_FULL_MALLOC_INIT = 0x00200,
502 * @GD_FLG_SPL_INIT: spl_init() has been called
504 GD_FLG_SPL_INIT = 0x00400,
506 * @GD_FLG_SKIP_RELOC: don't relocate
508 GD_FLG_SKIP_RELOC = 0x00800,
510 * @GD_FLG_RECORD: record console
512 GD_FLG_RECORD = 0x01000,
514 * @GD_FLG_ENV_DEFAULT: default variable flag
516 GD_FLG_ENV_DEFAULT = 0x02000,
518 * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
520 GD_FLG_SPL_EARLY_INIT = 0x04000,
522 * @GD_FLG_LOG_READY: log system is ready for use
524 GD_FLG_LOG_READY = 0x08000,
526 * @GD_FLG_WDT_READY: watchdog is ready for use
528 GD_FLG_WDT_READY = 0x10000,
530 * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
532 GD_FLG_SKIP_LL_INIT = 0x20000,
534 * @GD_FLG_SMP_READY: SMP initialization is complete
536 GD_FLG_SMP_READY = 0x40000,
539 #endif /* __ASSEMBLY__ */
541 #endif /* __ASM_GENERIC_GBL_DATA_H */