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
24 #include <event_internal.h>
27 #include <linux/list.h>
28 #include <linux/build_bug.h>
29 #include <asm-offsets.h>
34 typedef struct global_data gd_t;
37 * struct global_data - global data structure
41 * @bd: board information
45 * @flags: global data flags
51 * @baudrate: baud rate of the serial interface
53 unsigned int baudrate;
55 * @cpu_clk: CPU clock rate in Hz
57 unsigned long cpu_clk;
59 * @bus_clk: platform clock rate in Hz
61 unsigned long bus_clk;
63 * @pci_clk: PCI clock rate in Hz
65 /* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
66 unsigned long pci_clk;
68 * @mem_clk: memory clock rate in Hz
70 unsigned long mem_clk;
71 #if CONFIG_IS_ENABLED(VIDEO)
73 * @fb_base: base address of frame buffer memory
75 unsigned long fb_base;
77 #if defined(CONFIG_POST)
79 * @post_log_word: active POST tests
81 * @post_log_word is a bit mask defining which POST tests are recorded
82 * (see constants POST_*).
84 unsigned long post_log_word;
86 * @post_log_res: POST results
88 * @post_log_res is a bit mask with the POST results. A bit with value 1
89 * indicates successful execution.
91 unsigned long post_log_res;
93 * @post_init_f_time: time in ms when post_init_f() started
95 unsigned long post_init_f_time;
97 #ifdef CONFIG_BOARD_TYPES
99 * @board_type: board type
101 * If a U-Boot configuration supports multiple board types, the actual
102 * board type may be stored in this field.
104 unsigned long board_type;
107 * @have_console: console is available
109 * A value of 1 indicates that serial_init() was called and a console
111 * A value of 0 indicates that console input and output drivers shall
114 unsigned long have_console;
115 #if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
117 * @precon_buf_idx: pre-console buffer index
119 * @precon_buf_idx indicates the current position of the
120 * buffer used to collect output before the console becomes
121 * available. When negative, the pre-console buffer is
122 * temporarily disabled (used when the pre-console buffer is
123 * being written out, to prevent adding its contents to
129 * @env_addr: address of environment structure
131 * @env_addr contains the address of the structure holding the
132 * environment variables.
134 unsigned long env_addr;
136 * @env_valid: environment is valid
138 * See &enum env_valid
140 unsigned long env_valid;
142 * @env_has_init: bit mask indicating environment locations
144 * &enum env_location defines which bit relates to which location
146 unsigned long env_has_init;
148 * @env_load_prio: priority of the loaded environment
152 * @ram_base: base address of RAM used by U-Boot
154 unsigned long ram_base;
156 * @ram_top: top address of RAM used by U-Boot
160 * @relocaddr: start address of U-Boot in RAM
162 * After relocation this field indicates the address to which U-Boot
163 * has been relocated. It can be displayed using the bdinfo command.
164 * Its value is needed to display the source code when debugging with
165 * GDB using the 'add-symbol-file u-boot <relocaddr>' command.
167 unsigned long relocaddr;
169 * @ram_size: RAM size in bytes
171 phys_size_t ram_size;
173 * @mon_len: monitor length in bytes
175 unsigned long mon_len;
177 * @irq_sp: IRQ stack pointer
179 unsigned long irq_sp;
181 * @start_addr_sp: initial stack pointer address
183 unsigned long start_addr_sp;
185 * @reloc_off: relocation offset
187 unsigned long reloc_off;
189 * @new_gd: pointer to relocated global data
191 struct global_data *new_gd;
195 * @dm_root: root instance for Driver Model
197 struct udevice *dm_root;
199 * @dm_root_f: pre-relocation root instance
201 struct udevice *dm_root_f;
204 * head of core tree when uclasses are not in read-only memory.
206 * When uclasses are in read-only memory, @uclass_root_s is not used and
207 * @uclass_root points to the root node generated by dtoc.
209 struct list_head uclass_root_s;
212 * pointer to head of core tree, if uclasses are in read-only memory and
213 * cannot be adjusted to use @uclass_root as a list head.
215 * When not in read-only memory, @uclass_root_s is used to hold the
216 * uclass root, and @uclass_root points to the address of
219 struct list_head *uclass_root;
220 # if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
221 /** @dm_driver_rt: Dynamic info about the driver */
222 struct driver_rt *dm_driver_rt;
224 #if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
225 /** @dm_udevice_rt: Dynamic info about the udevice */
226 struct udevice_rt *dm_udevice_rt;
228 * @dm_priv_base: Base address of the priv/plat region used when
229 * udevices and uclasses are in read-only memory. This is NULL if not
237 * @timer: timer instance for Driver Model
239 struct udevice *timer;
242 * @fdt_blob: U-Boot's own device tree, NULL if none
244 const void *fdt_blob;
246 * @new_fdt: relocated device tree
250 * @fdt_size: space reserved for relocated device space
252 unsigned long fdt_size;
254 * @fdt_src: Source of FDT
256 enum fdt_source_t fdt_src;
257 #if CONFIG_IS_ENABLED(OF_LIVE)
259 * @of_root: root node of the live tree
261 struct device_node *of_root;
264 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
266 * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
268 const void *multi_dtb_fit;
273 * The jump table contains pointers to exported functions. A pointer to
274 * the jump table is passed to standalone applications.
278 * @env_buf: buffer for env_get() before reloc
283 * @trace_buff: trace buffer
285 * When tracing function in U-Boot this field points to the buffer
286 * recording the function calls.
290 #if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
292 * @cur_i2c_bus: currently used I2C bus
297 * @timebase_h: high 32 bits of timer
299 unsigned int timebase_h;
301 * @timebase_l: low 32 bits of timer
303 unsigned int timebase_l;
305 * @malloc_start: start of malloc() region
307 #if CONFIG_IS_ENABLED(CMD_BDINFO_EXTRA)
308 unsigned long malloc_start;
310 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
312 * @malloc_base: base address of early malloc()
314 unsigned long malloc_base;
316 * @malloc_limit: limit address of early malloc()
318 unsigned long malloc_limit;
320 * @malloc_ptr: current address of early malloc()
322 unsigned long malloc_ptr;
326 * @hose: PCI hose for early use
328 struct pci_controller *hose;
330 * @pci_ram_top: top of region accessible to PCI
332 phys_addr_t pci_ram_top;
334 #ifdef CONFIG_PCI_BOOTDELAY
336 * @pcidelay_done: delay time before scanning of PIC hose expired
338 * If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of
339 * milliseconds defined by environment variable pcidelay before
340 * scanning. Once this delay has expired the flag @pcidelay_done
346 * @cur_serial_dev: current serial device
348 struct udevice *cur_serial_dev;
350 * @arch: architecture-specific data
352 struct arch_global_data arch;
353 #ifdef CONFIG_CONSOLE_RECORD
355 * @console_out: output buffer for console recording
357 * This buffer is used to collect output during console recording.
359 struct membuff console_out;
361 * @console_in: input buffer for console recording
363 * If console recording is activated, this buffer can be used to
366 struct membuff console_in;
368 #if CONFIG_IS_ENABLED(VIDEO)
370 * @video_top: top of video frame buffer area
374 * @video_bottom: bottom of video frame buffer area
378 #ifdef CONFIG_BOOTSTAGE
380 * @bootstage: boot stage information
382 struct bootstage_data *bootstage;
384 * @new_bootstage: relocated boot stage information
386 struct bootstage_data *new_bootstage;
390 * @log_drop_count: number of dropped log messages
392 * This counter is incremented for each log message which can not
393 * be processed because logging is not yet available as signaled by
394 * flag %GD_FLG_LOG_READY in @flags.
398 * @default_log_level: default logging level
400 * For logging devices without filters @default_log_level defines the
401 * logging level, cf. &enum log_level_t.
403 int default_log_level;
405 * @log_head: list of logging devices
407 struct list_head log_head;
409 * @log_fmt: bit mask for logging format
411 * The @log_fmt bit mask selects the fields to be shown in log messages.
412 * &enum log_fmt defines the bits of the bit mask.
417 * @processing_msg: a log message is being processed
419 * This flag is used to suppress the creation of additional messages
420 * while another message is being processed.
424 * @logc_prev: logging category of previous message
426 * This value is used as logging category for continuation messages.
430 * @logl_prev: logging level of the previous message
432 * This value is used as logging level for continuation messages.
436 * @log_cont: Previous log line did not finished wtih \n
438 * This allows for chained log messages on the same line
442 #if CONFIG_IS_ENABLED(BLOBLIST)
444 * @bloblist: blob list information
446 struct bloblist_hdr *bloblist;
448 * @new_bloblist: relocated blob list information
450 struct bloblist_hdr *new_bloblist;
452 #if CONFIG_IS_ENABLED(HANDOFF)
454 * @spl_handoff: SPL hand-off information
456 struct spl_handoff *spl_handoff;
458 #if defined(CONFIG_TRANSLATION_OFFSET)
460 * @translation_offset: optional translation offset
462 * See CONFIG_TRANSLATION_OFFSET.
464 fdt_addr_t translation_offset;
468 * @acpi_ctx: ACPI context pointer
470 struct acpi_ctx *acpi_ctx;
472 * @acpi_start: Start address of ACPI tables
476 #if CONFIG_IS_ENABLED(GENERATE_SMBIOS_TABLE)
478 * @smbios_version: Points to SMBIOS type 0 version
480 char *smbios_version;
482 #if CONFIG_IS_ENABLED(EVENT)
484 * @event_state: Points to the current state of events
486 struct event_state event_state;
490 * @cyclic_list: list of registered cyclic functions
492 struct hlist_head cyclic_list;
495 * @dmtag_list: List of DM tags
497 struct list_head dmtag_list;
500 static_assert(sizeof(struct global_data) == GD_SIZE);
504 * gd_board_type() - retrieve board type
506 * Return: global board type
508 #ifdef CONFIG_BOARD_TYPES
509 #define gd_board_type() gd->board_type
511 #define gd_board_type() 0
514 /* These macros help avoid #ifdefs in the code */
515 #if CONFIG_IS_ENABLED(OF_LIVE)
516 #define gd_of_root() gd->of_root
517 #define gd_of_root_ptr() &gd->of_root
518 #define gd_set_of_root(_root) gd->of_root = (_root)
520 #define gd_of_root() NULL
521 #define gd_of_root_ptr() NULL
522 #define gd_set_of_root(_root)
525 #if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
526 #define gd_set_dm_driver_rt(dyn) gd->dm_driver_rt = dyn
527 #define gd_dm_driver_rt() gd->dm_driver_rt
529 #define gd_set_dm_driver_rt(dyn)
530 #define gd_dm_driver_rt() NULL
533 #if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
534 #define gd_set_dm_udevice_rt(dyn) gd->dm_udevice_rt = dyn
535 #define gd_dm_udevice_rt() gd->dm_udevice_rt
536 #define gd_set_dm_priv_base(dyn) gd->dm_priv_base = dyn
537 #define gd_dm_priv_base() gd->dm_priv_base
539 #define gd_set_dm_udevice_rt(dyn)
540 #define gd_dm_udevice_rt() NULL
541 #define gd_set_dm_priv_base(dyn)
542 #define gd_dm_priv_base() NULL
546 #define gd_acpi_ctx() gd->acpi_ctx
547 #define gd_acpi_start() gd->acpi_start
548 #define gd_set_acpi_start(addr) gd->acpi_start = addr
550 #define gd_acpi_ctx() NULL
551 #define gd_acpi_start() 0UL
552 #define gd_set_acpi_start(addr)
555 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
556 #define gd_multi_dtb_fit() gd->multi_dtb_fit
557 #define gd_set_multi_dtb_fit(_dtb) gd->multi_dtb_fit = _dtb
559 #define gd_multi_dtb_fit() NULL
560 #define gd_set_multi_dtb_fit(_dtb)
563 #if CONFIG_IS_ENABLED(EVENT_DYNAMIC)
564 #define gd_event_state() ((struct event_state *)&gd->event_state)
566 #define gd_event_state() NULL
569 #if CONFIG_IS_ENABLED(CMD_BDINFO_EXTRA)
570 #define gd_malloc_start() gd->malloc_start
571 #define gd_set_malloc_start(_val) gd->malloc_start = (_val)
573 #define gd_malloc_start() 0
574 #define gd_set_malloc_start(val)
577 * enum gd_flags - global data flags
579 * See field flags of &struct global_data.
583 * @GD_FLG_RELOC: code was relocated to RAM
585 GD_FLG_RELOC = 0x00001,
587 * @GD_FLG_DEVINIT: devices have been initialized
589 GD_FLG_DEVINIT = 0x00002,
591 * @GD_FLG_SILENT: silent mode
593 GD_FLG_SILENT = 0x00004,
595 * @GD_FLG_POSTFAIL: critical POST test failed
597 GD_FLG_POSTFAIL = 0x00008,
599 * @GD_FLG_POSTSTOP: POST sequence aborted
601 GD_FLG_POSTSTOP = 0x00010,
603 * @GD_FLG_LOGINIT: log Buffer has been initialized
605 GD_FLG_LOGINIT = 0x00020,
607 * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
609 GD_FLG_DISABLE_CONSOLE = 0x00040,
611 * @GD_FLG_ENV_READY: environment imported into hash table
613 GD_FLG_ENV_READY = 0x00080,
615 * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
617 GD_FLG_SERIAL_READY = 0x00100,
619 * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
621 GD_FLG_FULL_MALLOC_INIT = 0x00200,
623 * @GD_FLG_SPL_INIT: spl_init() has been called
625 GD_FLG_SPL_INIT = 0x00400,
627 * @GD_FLG_SKIP_RELOC: don't relocate
629 GD_FLG_SKIP_RELOC = 0x00800,
631 * @GD_FLG_RECORD: record console
633 GD_FLG_RECORD = 0x01000,
635 * @GD_FLG_RECORD_OVF: record console overflow
637 GD_FLG_RECORD_OVF = 0x02000,
639 * @GD_FLG_ENV_DEFAULT: default variable flag
641 GD_FLG_ENV_DEFAULT = 0x04000,
643 * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
645 GD_FLG_SPL_EARLY_INIT = 0x08000,
647 * @GD_FLG_LOG_READY: log system is ready for use
649 GD_FLG_LOG_READY = 0x10000,
651 * @GD_FLG_CYCLIC_RUNNING: cyclic_run is in progress
653 GD_FLG_CYCLIC_RUNNING = 0x20000,
655 * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
657 GD_FLG_SKIP_LL_INIT = 0x40000,
659 * @GD_FLG_SMP_READY: SMP initialization is complete
661 GD_FLG_SMP_READY = 0x80000,
663 * @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests
665 GD_FLG_FDT_CHANGED = 0x100000,
667 * @GD_FLG_OF_TAG_MIGRATE: Device tree has old u-boot,dm- tags
669 GD_FLG_OF_TAG_MIGRATE = 0x200000,
672 #endif /* __ASSEMBLY__ */
674 #endif /* __ASM_GENERIC_GBL_DATA_H */