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>
30 typedef struct global_data gd_t;
33 * struct global_data - global data structure
37 * @bd: board information
41 * @flags: global data flags
47 * @baudrate: baud rate of the serial interface
49 unsigned int baudrate;
51 * @cpu_clk: CPU clock rate in Hz
53 unsigned long cpu_clk;
55 * @bus_clk: platform clock rate in Hz
57 unsigned long bus_clk;
59 * @pci_clk: PCI clock rate in Hz
61 /* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
62 unsigned long pci_clk;
64 * @mem_clk: memory clock rate in Hz
66 unsigned long mem_clk;
67 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
69 * @fb_base: base address of frame buffer memory
71 unsigned long fb_base;
73 #if defined(CONFIG_POST)
75 * @post_log_word: active POST tests
77 * @post_log_word is a bit mask defining which POST tests are recorded
78 * (see constants POST_*).
80 unsigned long post_log_word;
82 * @post_log_res: POST results
84 * @post_log_res is a bit mask with the POST results. A bit with value 1
85 * indicates successful execution.
87 unsigned long post_log_res;
89 * @post_init_f_time: time in ms when post_init_f() started
91 unsigned long post_init_f_time;
93 #ifdef CONFIG_BOARD_TYPES
95 * @board_type: board type
97 * If a U-Boot configuration supports multiple board types, the actual
98 * board type may be stored in this field.
100 unsigned long board_type;
103 * @have_console: console is available
105 * A value of 1 indicates that serial_init() was called and a console
107 * A value of 0 indicates that console input and output drivers shall
110 unsigned long have_console;
111 #if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
113 * @precon_buf_idx: pre-console buffer index
115 * @precon_buf_idx indicates the current position of the buffer used to
116 * collect output before the console becomes available
118 unsigned long precon_buf_idx;
121 * @env_addr: address of environment structure
123 * @env_addr contains the address of the structure holding the
124 * environment variables.
126 unsigned long env_addr;
128 * @env_valid: environment is valid
130 * See &enum env_valid
132 unsigned long env_valid;
134 * @env_has_init: bit mask indicating environment locations
136 * &enum env_location defines which bit relates to which location
138 unsigned long env_has_init;
140 * @env_load_prio: priority of the loaded environment
144 * @ram_base: base address of RAM used by U-Boot
146 unsigned long ram_base;
148 * @ram_top: top address of RAM used by U-Boot
150 unsigned long ram_top;
152 * @relocaddr: start address of U-Boot in RAM
154 * After relocation this field indicates the address to which U-Boot
155 * has been relocated. It can be displayed using the bdinfo command.
156 * Its value is needed to display the source code when debugging with
157 * GDB using the 'add-symbol-file u-boot <relocaddr>' command.
159 unsigned long relocaddr;
161 * @ram_size: RAM size in bytes
163 phys_size_t ram_size;
165 * @mon_len: monitor length in bytes
167 unsigned long mon_len;
169 * @irq_sp: IRQ stack pointer
171 unsigned long irq_sp;
173 * @start_addr_sp: initial stack pointer address
175 unsigned long start_addr_sp;
177 * @reloc_off: relocation offset
179 unsigned long reloc_off;
181 * @new_gd: pointer to relocated global data
183 struct global_data *new_gd;
187 * @dm_root: root instance for Driver Model
189 struct udevice *dm_root;
191 * @dm_root_f: pre-relocation root instance
193 struct udevice *dm_root_f;
195 * @uclass_root: head of core tree
197 struct list_head uclass_root;
198 # if CONFIG_IS_ENABLED(OF_PLATDATA)
199 /** Dynamic info about the driver */
200 struct driver_rt *dm_driver_rt;
205 * @timer: timer instance for Driver Model
207 struct udevice *timer;
210 * @fdt_blob: U-Boot's own device tree, NULL if none
212 const void *fdt_blob;
214 * @new_fdt: relocated device tree
218 * @fdt_size: space reserved for relocated device space
220 unsigned long fdt_size;
221 #if CONFIG_IS_ENABLED(OF_LIVE)
223 * @of_root: root node of the live tree
225 struct device_node *of_root;
228 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
230 * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
232 const void *multi_dtb_fit;
237 * The jump table contains pointers to exported functions. A pointer to
238 * the jump table is passed to standalone applications.
242 * @env_buf: buffer for env_get() before reloc
247 * @trace_buff: trace buffer
249 * When tracing function in U-Boot this field points to the buffer
250 * recording the function calls.
254 #if defined(CONFIG_SYS_I2C)
256 * @cur_i2c_bus: currently used I2C bus
261 * @timebase_h: high 32 bits of timer
263 unsigned int timebase_h;
265 * @timebase_l: low 32 bits of timer
267 unsigned int timebase_l;
268 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
270 * @malloc_base: base address of early malloc()
272 unsigned long malloc_base;
274 * @malloc_limit: limit address of early malloc()
276 unsigned long malloc_limit;
278 * @malloc_ptr: current address of early malloc()
280 unsigned long malloc_ptr;
284 * @hose: PCI hose for early use
286 struct pci_controller *hose;
288 * @pci_ram_top: top of region accessible to PCI
290 phys_addr_t pci_ram_top;
292 #ifdef CONFIG_PCI_BOOTDELAY
294 * @pcidelay_done: delay time before scanning of PIC hose expired
296 * If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of
297 * milliseconds defined by environment variable pcidelay before
298 * scanning. Once this delay has expired the flag @pcidelay_done
304 * @cur_serial_dev: current serial device
306 struct udevice *cur_serial_dev;
308 * @arch: architecture-specific data
310 struct arch_global_data arch;
311 #ifdef CONFIG_CONSOLE_RECORD
313 * @console_out: output buffer for console recording
315 * This buffer is used to collect output during console recording.
317 struct membuff console_out;
319 * @console_in: input buffer for console recording
321 * If console recording is activated, this buffer can be used to
324 struct membuff console_in;
326 #ifdef CONFIG_DM_VIDEO
328 * @video_top: top of video frame buffer area
332 * @video_bottom: bottom of video frame buffer area
336 #ifdef CONFIG_BOOTSTAGE
338 * @bootstage: boot stage information
340 struct bootstage_data *bootstage;
342 * @new_bootstage: relocated boot stage information
344 struct bootstage_data *new_bootstage;
348 * @log_drop_count: number of dropped log messages
350 * This counter is incremented for each log message which can not
351 * be processed because logging is not yet available as signaled by
352 * flag %GD_FLG_LOG_READY in @flags.
356 * @default_log_level: default logging level
358 * For logging devices without filters @default_log_level defines the
359 * logging level, cf. &enum log_level_t.
361 int default_log_level;
363 * @log_head: list of logging devices
365 struct list_head log_head;
367 * @log_fmt: bit mask for logging format
369 * The @log_fmt bit mask selects the fields to be shown in log messages.
370 * &enum log_fmt defines the bits of the bit mask.
375 * @processing_msg: a log message is being processed
377 * This flag is used to suppress the creation of additional messages
378 * while another message is being processed.
382 * @logc_prev: logging category of previous message
384 * This value is used as logging category for continuation messages.
388 * @logl_prev: logging level of the previous message
390 * This value is used as logging level for continuation messages.
394 #if CONFIG_IS_ENABLED(BLOBLIST)
396 * @bloblist: blob list information
398 struct bloblist_hdr *bloblist;
400 * @new_bloblist: relocated blob list information
402 struct bloblist_hdr *new_bloblist;
405 * @spl_handoff: SPL hand-off information
407 struct spl_handoff *spl_handoff;
410 #if defined(CONFIG_TRANSLATION_OFFSET)
412 * @translation_offset: optional translation offset
414 * See CONFIG_TRANSLATION_OFFSET.
416 fdt_addr_t translation_offset;
418 #if CONFIG_IS_ENABLED(WDT)
420 * @watchdog_dev: watchdog device
422 struct udevice *watchdog_dev;
424 #ifdef CONFIG_GENERATE_ACPI_TABLE
426 * @acpi_ctx: ACPI context pointer
428 struct acpi_ctx *acpi_ctx;
433 * gd_board_type() - retrieve board type
435 * Return: global board type
437 #ifdef CONFIG_BOARD_TYPES
438 #define gd_board_type() gd->board_type
440 #define gd_board_type() 0
443 /* These macros help avoid #ifdefs in the code */
444 #if CONFIG_IS_ENABLED(OF_LIVE)
445 #define gd_of_root() gd->of_root
446 #define gd_of_root_ptr() &gd->of_root
447 #define gd_set_of_root(_root) gd->of_root = (_root)
449 #define gd_of_root() NULL
450 #define gd_of_root_ptr() NULL
451 #define gd_set_of_root(_root)
454 #if CONFIG_IS_ENABLED(OF_PLATDATA)
455 #define gd_set_dm_driver_rt(dyn) gd->dm_driver_rt = dyn
456 #define gd_dm_driver_rt() gd->dm_driver_rt
458 #define gd_set_dm_driver_rt(dyn)
459 #define gd_dm_driver_rt() NULL
462 #ifdef CONFIG_GENERATE_ACPI_TABLE
463 #define gd_acpi_ctx() gd->acpi_ctx
465 #define gd_acpi_ctx() NULL
469 * enum gd_flags - global data flags
471 * See field flags of &struct global_data.
475 * @GD_FLG_RELOC: code was relocated to RAM
477 GD_FLG_RELOC = 0x00001,
479 * @GD_FLG_DEVINIT: devices have been initialized
481 GD_FLG_DEVINIT = 0x00002,
483 * @GD_FLG_SILENT: silent mode
485 GD_FLG_SILENT = 0x00004,
487 * @GD_FLG_POSTFAIL: critical POST test failed
489 GD_FLG_POSTFAIL = 0x00008,
491 * @GD_FLG_POSTSTOP: POST sequence aborted
493 GD_FLG_POSTSTOP = 0x00010,
495 * @GD_FLG_LOGINIT: log Buffer has been initialized
497 GD_FLG_LOGINIT = 0x00020,
499 * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
501 GD_FLG_DISABLE_CONSOLE = 0x00040,
503 * @GD_FLG_ENV_READY: environment imported into hash table
505 GD_FLG_ENV_READY = 0x00080,
507 * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
509 GD_FLG_SERIAL_READY = 0x00100,
511 * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
513 GD_FLG_FULL_MALLOC_INIT = 0x00200,
515 * @GD_FLG_SPL_INIT: spl_init() has been called
517 GD_FLG_SPL_INIT = 0x00400,
519 * @GD_FLG_SKIP_RELOC: don't relocate
521 GD_FLG_SKIP_RELOC = 0x00800,
523 * @GD_FLG_RECORD: record console
525 GD_FLG_RECORD = 0x01000,
527 * @GD_FLG_ENV_DEFAULT: default variable flag
529 GD_FLG_ENV_DEFAULT = 0x02000,
531 * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
533 GD_FLG_SPL_EARLY_INIT = 0x04000,
535 * @GD_FLG_LOG_READY: log system is ready for use
537 GD_FLG_LOG_READY = 0x08000,
539 * @GD_FLG_WDT_READY: watchdog is ready for use
541 GD_FLG_WDT_READY = 0x10000,
543 * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
545 GD_FLG_SKIP_LL_INIT = 0x20000,
547 * @GD_FLG_SMP_READY: SMP initialization is complete
549 GD_FLG_SMP_READY = 0x40000,
552 #endif /* __ASSEMBLY__ */
554 #endif /* __ASM_GENERIC_GBL_DATA_H */