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 defined(CONFIG_LCD) || defined(CONFIG_DM_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 buffer used to
120 * collect output before the console becomes available
122 unsigned long precon_buf_idx;
125 * @env_addr: address of environment structure
127 * @env_addr contains the address of the structure holding the
128 * environment variables.
130 unsigned long env_addr;
132 * @env_valid: environment is valid
134 * See &enum env_valid
136 unsigned long env_valid;
138 * @env_has_init: bit mask indicating environment locations
140 * &enum env_location defines which bit relates to which location
142 unsigned long env_has_init;
144 * @env_load_prio: priority of the loaded environment
148 * @ram_base: base address of RAM used by U-Boot
150 unsigned long ram_base;
152 * @ram_top: top address of RAM used by U-Boot
156 * @relocaddr: start address of U-Boot in RAM
158 * After relocation this field indicates the address to which U-Boot
159 * has been relocated. It can be displayed using the bdinfo command.
160 * Its value is needed to display the source code when debugging with
161 * GDB using the 'add-symbol-file u-boot <relocaddr>' command.
163 unsigned long relocaddr;
165 * @ram_size: RAM size in bytes
167 phys_size_t ram_size;
169 * @mon_len: monitor length in bytes
171 unsigned long mon_len;
173 * @irq_sp: IRQ stack pointer
175 unsigned long irq_sp;
177 * @start_addr_sp: initial stack pointer address
179 unsigned long start_addr_sp;
181 * @reloc_off: relocation offset
183 unsigned long reloc_off;
185 * @new_gd: pointer to relocated global data
187 struct global_data *new_gd;
191 * @dm_root: root instance for Driver Model
193 struct udevice *dm_root;
195 * @dm_root_f: pre-relocation root instance
197 struct udevice *dm_root_f;
200 * head of core tree when uclasses are not in read-only memory.
202 * When uclasses are in read-only memory, @uclass_root_s is not used and
203 * @uclass_root points to the root node generated by dtoc.
205 struct list_head uclass_root_s;
208 * pointer to head of core tree, if uclasses are in read-only memory and
209 * cannot be adjusted to use @uclass_root as a list head.
211 * When not in read-only memory, @uclass_root_s is used to hold the
212 * uclass root, and @uclass_root points to the address of
215 struct list_head *uclass_root;
216 # if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
217 /** @dm_driver_rt: Dynamic info about the driver */
218 struct driver_rt *dm_driver_rt;
220 #if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
221 /** @dm_udevice_rt: Dynamic info about the udevice */
222 struct udevice_rt *dm_udevice_rt;
224 * @dm_priv_base: Base address of the priv/plat region used when
225 * udevices and uclasses are in read-only memory. This is NULL if not
233 * @timer: timer instance for Driver Model
235 struct udevice *timer;
238 * @fdt_blob: U-Boot's own device tree, NULL if none
240 const void *fdt_blob;
242 * @new_fdt: relocated device tree
246 * @fdt_size: space reserved for relocated device space
248 unsigned long fdt_size;
250 * @fdt_src: Source of FDT
252 enum fdt_source_t fdt_src;
253 #if CONFIG_IS_ENABLED(OF_LIVE)
255 * @of_root: root node of the live tree
257 struct device_node *of_root;
260 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
262 * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
264 const void *multi_dtb_fit;
269 * The jump table contains pointers to exported functions. A pointer to
270 * the jump table is passed to standalone applications.
274 * @env_buf: buffer for env_get() before reloc
279 * @trace_buff: trace buffer
281 * When tracing function in U-Boot this field points to the buffer
282 * recording the function calls.
286 #if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
288 * @cur_i2c_bus: currently used I2C bus
293 * @timebase_h: high 32 bits of timer
295 unsigned int timebase_h;
297 * @timebase_l: low 32 bits of timer
299 unsigned int timebase_l;
300 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
302 * @malloc_base: base address of early malloc()
304 unsigned long malloc_base;
306 * @malloc_limit: limit address of early malloc()
308 unsigned long malloc_limit;
310 * @malloc_ptr: current address of early malloc()
312 unsigned long malloc_ptr;
316 * @hose: PCI hose for early use
318 struct pci_controller *hose;
320 * @pci_ram_top: top of region accessible to PCI
322 phys_addr_t pci_ram_top;
324 #ifdef CONFIG_PCI_BOOTDELAY
326 * @pcidelay_done: delay time before scanning of PIC hose expired
328 * If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of
329 * milliseconds defined by environment variable pcidelay before
330 * scanning. Once this delay has expired the flag @pcidelay_done
336 * @cur_serial_dev: current serial device
338 struct udevice *cur_serial_dev;
340 * @arch: architecture-specific data
342 struct arch_global_data arch;
343 #ifdef CONFIG_CONSOLE_RECORD
345 * @console_out: output buffer for console recording
347 * This buffer is used to collect output during console recording.
349 struct membuff console_out;
351 * @console_in: input buffer for console recording
353 * If console recording is activated, this buffer can be used to
356 struct membuff console_in;
358 #ifdef CONFIG_DM_VIDEO
360 * @video_top: top of video frame buffer area
364 * @video_bottom: bottom of video frame buffer area
368 #ifdef CONFIG_BOOTSTAGE
370 * @bootstage: boot stage information
372 struct bootstage_data *bootstage;
374 * @new_bootstage: relocated boot stage information
376 struct bootstage_data *new_bootstage;
380 * @log_drop_count: number of dropped log messages
382 * This counter is incremented for each log message which can not
383 * be processed because logging is not yet available as signaled by
384 * flag %GD_FLG_LOG_READY in @flags.
388 * @default_log_level: default logging level
390 * For logging devices without filters @default_log_level defines the
391 * logging level, cf. &enum log_level_t.
393 int default_log_level;
395 * @log_head: list of logging devices
397 struct list_head log_head;
399 * @log_fmt: bit mask for logging format
401 * The @log_fmt bit mask selects the fields to be shown in log messages.
402 * &enum log_fmt defines the bits of the bit mask.
407 * @processing_msg: a log message is being processed
409 * This flag is used to suppress the creation of additional messages
410 * while another message is being processed.
414 * @logc_prev: logging category of previous message
416 * This value is used as logging category for continuation messages.
420 * @logl_prev: logging level of the previous message
422 * This value is used as logging level for continuation messages.
426 * @log_cont: Previous log line did not finished wtih \n
428 * This allows for chained log messages on the same line
432 #if CONFIG_IS_ENABLED(BLOBLIST)
434 * @bloblist: blob list information
436 struct bloblist_hdr *bloblist;
438 * @new_bloblist: relocated blob list information
440 struct bloblist_hdr *new_bloblist;
442 #if CONFIG_IS_ENABLED(HANDOFF)
444 * @spl_handoff: SPL hand-off information
446 struct spl_handoff *spl_handoff;
448 #if defined(CONFIG_TRANSLATION_OFFSET)
450 * @translation_offset: optional translation offset
452 * See CONFIG_TRANSLATION_OFFSET.
454 fdt_addr_t translation_offset;
456 #ifdef CONFIG_GENERATE_ACPI_TABLE
458 * @acpi_ctx: ACPI context pointer
460 struct acpi_ctx *acpi_ctx;
462 * @acpi_start: Start address of ACPI tables
466 #if CONFIG_IS_ENABLED(GENERATE_SMBIOS_TABLE)
468 * @smbios_version: Points to SMBIOS type 0 version
470 char *smbios_version;
472 #if CONFIG_IS_ENABLED(EVENT)
474 * @event_state: Points to the current state of events
476 struct event_state event_state;
480 * @cyclic: cyclic driver data
482 struct cyclic_drv *cyclic;
485 * @dmtag_list: List of DM tags
487 struct list_head dmtag_list;
490 static_assert(sizeof(struct global_data) == GD_SIZE);
494 * gd_board_type() - retrieve board type
496 * Return: global board type
498 #ifdef CONFIG_BOARD_TYPES
499 #define gd_board_type() gd->board_type
501 #define gd_board_type() 0
504 /* These macros help avoid #ifdefs in the code */
505 #if CONFIG_IS_ENABLED(OF_LIVE)
506 #define gd_of_root() gd->of_root
507 #define gd_of_root_ptr() &gd->of_root
508 #define gd_set_of_root(_root) gd->of_root = (_root)
510 #define gd_of_root() NULL
511 #define gd_of_root_ptr() NULL
512 #define gd_set_of_root(_root)
515 #if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
516 #define gd_set_dm_driver_rt(dyn) gd->dm_driver_rt = dyn
517 #define gd_dm_driver_rt() gd->dm_driver_rt
519 #define gd_set_dm_driver_rt(dyn)
520 #define gd_dm_driver_rt() NULL
523 #if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
524 #define gd_set_dm_udevice_rt(dyn) gd->dm_udevice_rt = dyn
525 #define gd_dm_udevice_rt() gd->dm_udevice_rt
526 #define gd_set_dm_priv_base(dyn) gd->dm_priv_base = dyn
527 #define gd_dm_priv_base() gd->dm_priv_base
529 #define gd_set_dm_udevice_rt(dyn)
530 #define gd_dm_udevice_rt() NULL
531 #define gd_set_dm_priv_base(dyn)
532 #define gd_dm_priv_base() NULL
535 #ifdef CONFIG_GENERATE_ACPI_TABLE
536 #define gd_acpi_ctx() gd->acpi_ctx
537 #define gd_acpi_start() gd->acpi_start
538 #define gd_set_acpi_start(addr) gd->acpi_start = addr
540 #define gd_acpi_ctx() NULL
541 #define gd_acpi_start() 0UL
542 #define gd_set_acpi_start(addr)
545 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
546 #define gd_multi_dtb_fit() gd->multi_dtb_fit
547 #define gd_set_multi_dtb_fit(_dtb) gd->multi_dtb_fit = _dtb
549 #define gd_multi_dtb_fit() NULL
550 #define gd_set_multi_dtb_fit(_dtb)
553 #if CONFIG_IS_ENABLED(EVENT_DYNAMIC)
554 #define gd_event_state() ((struct event_state *)&gd->event_state)
556 #define gd_event_state() NULL
560 * enum gd_flags - global data flags
562 * See field flags of &struct global_data.
566 * @GD_FLG_RELOC: code was relocated to RAM
568 GD_FLG_RELOC = 0x00001,
570 * @GD_FLG_DEVINIT: devices have been initialized
572 GD_FLG_DEVINIT = 0x00002,
574 * @GD_FLG_SILENT: silent mode
576 GD_FLG_SILENT = 0x00004,
578 * @GD_FLG_POSTFAIL: critical POST test failed
580 GD_FLG_POSTFAIL = 0x00008,
582 * @GD_FLG_POSTSTOP: POST sequence aborted
584 GD_FLG_POSTSTOP = 0x00010,
586 * @GD_FLG_LOGINIT: log Buffer has been initialized
588 GD_FLG_LOGINIT = 0x00020,
590 * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
592 GD_FLG_DISABLE_CONSOLE = 0x00040,
594 * @GD_FLG_ENV_READY: environment imported into hash table
596 GD_FLG_ENV_READY = 0x00080,
598 * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
600 GD_FLG_SERIAL_READY = 0x00100,
602 * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
604 GD_FLG_FULL_MALLOC_INIT = 0x00200,
606 * @GD_FLG_SPL_INIT: spl_init() has been called
608 GD_FLG_SPL_INIT = 0x00400,
610 * @GD_FLG_SKIP_RELOC: don't relocate
612 GD_FLG_SKIP_RELOC = 0x00800,
614 * @GD_FLG_RECORD: record console
616 GD_FLG_RECORD = 0x01000,
618 * @GD_FLG_RECORD_OVF: record console overflow
620 GD_FLG_RECORD_OVF = 0x02000,
622 * @GD_FLG_ENV_DEFAULT: default variable flag
624 GD_FLG_ENV_DEFAULT = 0x04000,
626 * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
628 GD_FLG_SPL_EARLY_INIT = 0x08000,
630 * @GD_FLG_LOG_READY: log system is ready for use
632 GD_FLG_LOG_READY = 0x10000,
634 * @GD_FLG_WDT_READY: watchdog is ready for use
636 GD_FLG_WDT_READY = 0x20000,
638 * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
640 GD_FLG_SKIP_LL_INIT = 0x40000,
642 * @GD_FLG_SMP_READY: SMP initialization is complete
644 GD_FLG_SMP_READY = 0x80000,
647 #endif /* __ASSEMBLY__ */
649 #endif /* __ASM_GENERIC_GBL_DATA_H */