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
23 #include <event_internal.h>
26 #include <linux/list.h>
27 #include <linux/build_bug.h>
28 #include <asm-offsets.h>
33 typedef struct global_data gd_t;
36 * struct global_data - global data structure
40 * @bd: board information
44 * @flags: global data flags
50 * @baudrate: baud rate of the serial interface
52 unsigned int baudrate;
54 * @cpu_clk: CPU clock rate in Hz
56 unsigned long cpu_clk;
58 * @bus_clk: platform clock rate in Hz
60 unsigned long bus_clk;
62 * @pci_clk: PCI clock rate in Hz
64 /* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
65 unsigned long pci_clk;
67 * @mem_clk: memory clock rate in Hz
69 unsigned long mem_clk;
70 #if defined(CONFIG_LCD) || defined(CONFIG_DM_VIDEO)
72 * @fb_base: base address of frame buffer memory
74 unsigned long fb_base;
76 #if defined(CONFIG_POST)
78 * @post_log_word: active POST tests
80 * @post_log_word is a bit mask defining which POST tests are recorded
81 * (see constants POST_*).
83 unsigned long post_log_word;
85 * @post_log_res: POST results
87 * @post_log_res is a bit mask with the POST results. A bit with value 1
88 * indicates successful execution.
90 unsigned long post_log_res;
92 * @post_init_f_time: time in ms when post_init_f() started
94 unsigned long post_init_f_time;
96 #ifdef CONFIG_BOARD_TYPES
98 * @board_type: board type
100 * If a U-Boot configuration supports multiple board types, the actual
101 * board type may be stored in this field.
103 unsigned long board_type;
106 * @have_console: console is available
108 * A value of 1 indicates that serial_init() was called and a console
110 * A value of 0 indicates that console input and output drivers shall
113 unsigned long have_console;
114 #if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
116 * @precon_buf_idx: pre-console buffer index
118 * @precon_buf_idx indicates the current position of the buffer used to
119 * collect output before the console becomes available
121 unsigned long precon_buf_idx;
124 * @env_addr: address of environment structure
126 * @env_addr contains the address of the structure holding the
127 * environment variables.
129 unsigned long env_addr;
131 * @env_valid: environment is valid
133 * See &enum env_valid
135 unsigned long env_valid;
137 * @env_has_init: bit mask indicating environment locations
139 * &enum env_location defines which bit relates to which location
141 unsigned long env_has_init;
143 * @env_load_prio: priority of the loaded environment
147 * @ram_base: base address of RAM used by U-Boot
149 unsigned long ram_base;
151 * @ram_top: top address of RAM used by U-Boot
155 * @relocaddr: start address of U-Boot in RAM
157 * After relocation this field indicates the address to which U-Boot
158 * has been relocated. It can be displayed using the bdinfo command.
159 * Its value is needed to display the source code when debugging with
160 * GDB using the 'add-symbol-file u-boot <relocaddr>' command.
162 unsigned long relocaddr;
164 * @ram_size: RAM size in bytes
166 phys_size_t ram_size;
168 * @mon_len: monitor length in bytes
170 unsigned long mon_len;
172 * @irq_sp: IRQ stack pointer
174 unsigned long irq_sp;
176 * @start_addr_sp: initial stack pointer address
178 unsigned long start_addr_sp;
180 * @reloc_off: relocation offset
182 unsigned long reloc_off;
184 * @new_gd: pointer to relocated global data
186 struct global_data *new_gd;
190 * @dm_root: root instance for Driver Model
192 struct udevice *dm_root;
194 * @dm_root_f: pre-relocation root instance
196 struct udevice *dm_root_f;
199 * head of core tree when uclasses are not in read-only memory.
201 * When uclasses are in read-only memory, @uclass_root_s is not used and
202 * @uclass_root points to the root node generated by dtoc.
204 struct list_head uclass_root_s;
207 * pointer to head of core tree, if uclasses are in read-only memory and
208 * cannot be adjusted to use @uclass_root as a list head.
210 * When not in read-only memory, @uclass_root_s is used to hold the
211 * uclass root, and @uclass_root points to the address of
214 struct list_head *uclass_root;
215 # if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
216 /** @dm_driver_rt: Dynamic info about the driver */
217 struct driver_rt *dm_driver_rt;
219 #if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
220 /** @dm_udevice_rt: Dynamic info about the udevice */
221 struct udevice_rt *dm_udevice_rt;
223 * @dm_priv_base: Base address of the priv/plat region used when
224 * udevices and uclasses are in read-only memory. This is NULL if not
232 * @timer: timer instance for Driver Model
234 struct udevice *timer;
237 * @fdt_blob: U-Boot's own device tree, NULL if none
239 const void *fdt_blob;
241 * @new_fdt: relocated device tree
245 * @fdt_size: space reserved for relocated device space
247 unsigned long fdt_size;
249 * @fdt_src: Source of FDT
251 enum fdt_source_t fdt_src;
252 #if CONFIG_IS_ENABLED(OF_LIVE)
254 * @of_root: root node of the live tree
256 struct device_node *of_root;
259 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
261 * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
263 const void *multi_dtb_fit;
268 * The jump table contains pointers to exported functions. A pointer to
269 * the jump table is passed to standalone applications.
273 * @env_buf: buffer for env_get() before reloc
278 * @trace_buff: trace buffer
280 * When tracing function in U-Boot this field points to the buffer
281 * recording the function calls.
285 #if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
287 * @cur_i2c_bus: currently used I2C bus
292 * @timebase_h: high 32 bits of timer
294 unsigned int timebase_h;
296 * @timebase_l: low 32 bits of timer
298 unsigned int timebase_l;
299 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
301 * @malloc_base: base address of early malloc()
303 unsigned long malloc_base;
305 * @malloc_limit: limit address of early malloc()
307 unsigned long malloc_limit;
309 * @malloc_ptr: current address of early malloc()
311 unsigned long malloc_ptr;
315 * @hose: PCI hose for early use
317 struct pci_controller *hose;
319 * @pci_ram_top: top of region accessible to PCI
321 phys_addr_t pci_ram_top;
323 #ifdef CONFIG_PCI_BOOTDELAY
325 * @pcidelay_done: delay time before scanning of PIC hose expired
327 * If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of
328 * milliseconds defined by environment variable pcidelay before
329 * scanning. Once this delay has expired the flag @pcidelay_done
335 * @cur_serial_dev: current serial device
337 struct udevice *cur_serial_dev;
339 * @arch: architecture-specific data
341 struct arch_global_data arch;
342 #ifdef CONFIG_CONSOLE_RECORD
344 * @console_out: output buffer for console recording
346 * This buffer is used to collect output during console recording.
348 struct membuff console_out;
350 * @console_in: input buffer for console recording
352 * If console recording is activated, this buffer can be used to
355 struct membuff console_in;
357 #ifdef CONFIG_DM_VIDEO
359 * @video_top: top of video frame buffer area
363 * @video_bottom: bottom of video frame buffer area
367 #ifdef CONFIG_BOOTSTAGE
369 * @bootstage: boot stage information
371 struct bootstage_data *bootstage;
373 * @new_bootstage: relocated boot stage information
375 struct bootstage_data *new_bootstage;
379 * @log_drop_count: number of dropped log messages
381 * This counter is incremented for each log message which can not
382 * be processed because logging is not yet available as signaled by
383 * flag %GD_FLG_LOG_READY in @flags.
387 * @default_log_level: default logging level
389 * For logging devices without filters @default_log_level defines the
390 * logging level, cf. &enum log_level_t.
392 int default_log_level;
394 * @log_head: list of logging devices
396 struct list_head log_head;
398 * @log_fmt: bit mask for logging format
400 * The @log_fmt bit mask selects the fields to be shown in log messages.
401 * &enum log_fmt defines the bits of the bit mask.
406 * @processing_msg: a log message is being processed
408 * This flag is used to suppress the creation of additional messages
409 * while another message is being processed.
413 * @logc_prev: logging category of previous message
415 * This value is used as logging category for continuation messages.
419 * @logl_prev: logging level of the previous message
421 * This value is used as logging level for continuation messages.
425 * @log_cont: Previous log line did not finished wtih \n
427 * This allows for chained log messages on the same line
431 #if CONFIG_IS_ENABLED(BLOBLIST)
433 * @bloblist: blob list information
435 struct bloblist_hdr *bloblist;
437 * @new_bloblist: relocated blob list information
439 struct bloblist_hdr *new_bloblist;
441 #if CONFIG_IS_ENABLED(HANDOFF)
443 * @spl_handoff: SPL hand-off information
445 struct spl_handoff *spl_handoff;
447 #if defined(CONFIG_TRANSLATION_OFFSET)
449 * @translation_offset: optional translation offset
451 * See CONFIG_TRANSLATION_OFFSET.
453 fdt_addr_t translation_offset;
455 #ifdef CONFIG_GENERATE_ACPI_TABLE
457 * @acpi_ctx: ACPI context pointer
459 struct acpi_ctx *acpi_ctx;
461 * @acpi_start: Start address of ACPI tables
465 #if CONFIG_IS_ENABLED(GENERATE_SMBIOS_TABLE)
467 * @smbios_version: Points to SMBIOS type 0 version
469 char *smbios_version;
471 #if CONFIG_IS_ENABLED(EVENT)
473 * @event_state: Points to the current state of events
475 struct event_state event_state;
479 static_assert(sizeof(struct global_data) == GD_SIZE);
483 * gd_board_type() - retrieve board type
485 * Return: global board type
487 #ifdef CONFIG_BOARD_TYPES
488 #define gd_board_type() gd->board_type
490 #define gd_board_type() 0
493 /* These macros help avoid #ifdefs in the code */
494 #if CONFIG_IS_ENABLED(OF_LIVE)
495 #define gd_of_root() gd->of_root
496 #define gd_of_root_ptr() &gd->of_root
497 #define gd_set_of_root(_root) gd->of_root = (_root)
499 #define gd_of_root() NULL
500 #define gd_of_root_ptr() NULL
501 #define gd_set_of_root(_root)
504 #if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
505 #define gd_set_dm_driver_rt(dyn) gd->dm_driver_rt = dyn
506 #define gd_dm_driver_rt() gd->dm_driver_rt
508 #define gd_set_dm_driver_rt(dyn)
509 #define gd_dm_driver_rt() NULL
512 #if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
513 #define gd_set_dm_udevice_rt(dyn) gd->dm_udevice_rt = dyn
514 #define gd_dm_udevice_rt() gd->dm_udevice_rt
515 #define gd_set_dm_priv_base(dyn) gd->dm_priv_base = dyn
516 #define gd_dm_priv_base() gd->dm_priv_base
518 #define gd_set_dm_udevice_rt(dyn)
519 #define gd_dm_udevice_rt() NULL
520 #define gd_set_dm_priv_base(dyn)
521 #define gd_dm_priv_base() NULL
524 #ifdef CONFIG_GENERATE_ACPI_TABLE
525 #define gd_acpi_ctx() gd->acpi_ctx
526 #define gd_acpi_start() gd->acpi_start
527 #define gd_set_acpi_start(addr) gd->acpi_start = addr
529 #define gd_acpi_ctx() NULL
530 #define gd_acpi_start() 0UL
531 #define gd_set_acpi_start(addr)
534 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
535 #define gd_multi_dtb_fit() gd->multi_dtb_fit
536 #define gd_set_multi_dtb_fit(_dtb) gd->multi_dtb_fit = _dtb
538 #define gd_multi_dtb_fit() NULL
539 #define gd_set_multi_dtb_fit(_dtb)
542 #if CONFIG_IS_ENABLED(EVENT_DYNAMIC)
543 #define gd_event_state() ((struct event_state *)&gd->event_state)
545 #define gd_event_state() NULL
549 * enum gd_flags - global data flags
551 * See field flags of &struct global_data.
555 * @GD_FLG_RELOC: code was relocated to RAM
557 GD_FLG_RELOC = 0x00001,
559 * @GD_FLG_DEVINIT: devices have been initialized
561 GD_FLG_DEVINIT = 0x00002,
563 * @GD_FLG_SILENT: silent mode
565 GD_FLG_SILENT = 0x00004,
567 * @GD_FLG_POSTFAIL: critical POST test failed
569 GD_FLG_POSTFAIL = 0x00008,
571 * @GD_FLG_POSTSTOP: POST sequence aborted
573 GD_FLG_POSTSTOP = 0x00010,
575 * @GD_FLG_LOGINIT: log Buffer has been initialized
577 GD_FLG_LOGINIT = 0x00020,
579 * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
581 GD_FLG_DISABLE_CONSOLE = 0x00040,
583 * @GD_FLG_ENV_READY: environment imported into hash table
585 GD_FLG_ENV_READY = 0x00080,
587 * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
589 GD_FLG_SERIAL_READY = 0x00100,
591 * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
593 GD_FLG_FULL_MALLOC_INIT = 0x00200,
595 * @GD_FLG_SPL_INIT: spl_init() has been called
597 GD_FLG_SPL_INIT = 0x00400,
599 * @GD_FLG_SKIP_RELOC: don't relocate
601 GD_FLG_SKIP_RELOC = 0x00800,
603 * @GD_FLG_RECORD: record console
605 GD_FLG_RECORD = 0x01000,
607 * @GD_FLG_RECORD_OVF: record console overflow
609 GD_FLG_RECORD_OVF = 0x02000,
611 * @GD_FLG_ENV_DEFAULT: default variable flag
613 GD_FLG_ENV_DEFAULT = 0x04000,
615 * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
617 GD_FLG_SPL_EARLY_INIT = 0x08000,
619 * @GD_FLG_LOG_READY: log system is ready for use
621 GD_FLG_LOG_READY = 0x10000,
623 * @GD_FLG_WDT_READY: watchdog is ready for use
625 GD_FLG_WDT_READY = 0x20000,
627 * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
629 GD_FLG_SKIP_LL_INIT = 0x40000,
631 * @GD_FLG_SMP_READY: SMP initialization is complete
633 GD_FLG_SMP_READY = 0x80000,
636 #endif /* __ASSEMBLY__ */
638 #endif /* __ASM_GENERIC_GBL_DATA_H */