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>
26 #include <linux/build_bug.h>
27 #include <asm-offsets.h>
32 typedef struct global_data gd_t;
35 * struct global_data - global data structure
39 * @bd: board information
43 * @flags: global data flags
49 * @baudrate: baud rate of the serial interface
51 unsigned int baudrate;
53 * @cpu_clk: CPU clock rate in Hz
55 unsigned long cpu_clk;
57 * @bus_clk: platform clock rate in Hz
59 unsigned long bus_clk;
61 * @pci_clk: PCI clock rate in Hz
63 /* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
64 unsigned long pci_clk;
66 * @mem_clk: memory clock rate in Hz
68 unsigned long mem_clk;
69 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
71 * @fb_base: base address of frame buffer memory
73 unsigned long fb_base;
75 #if defined(CONFIG_POST)
77 * @post_log_word: active POST tests
79 * @post_log_word is a bit mask defining which POST tests are recorded
80 * (see constants POST_*).
82 unsigned long post_log_word;
84 * @post_log_res: POST results
86 * @post_log_res is a bit mask with the POST results. A bit with value 1
87 * indicates successful execution.
89 unsigned long post_log_res;
91 * @post_init_f_time: time in ms when post_init_f() started
93 unsigned long post_init_f_time;
95 #ifdef CONFIG_BOARD_TYPES
97 * @board_type: board type
99 * If a U-Boot configuration supports multiple board types, the actual
100 * board type may be stored in this field.
102 unsigned long board_type;
105 * @have_console: console is available
107 * A value of 1 indicates that serial_init() was called and a console
109 * A value of 0 indicates that console input and output drivers shall
112 unsigned long have_console;
113 #if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
115 * @precon_buf_idx: pre-console buffer index
117 * @precon_buf_idx indicates the current position of the buffer used to
118 * collect output before the console becomes available
120 unsigned long precon_buf_idx;
123 * @env_addr: address of environment structure
125 * @env_addr contains the address of the structure holding the
126 * environment variables.
128 unsigned long env_addr;
130 * @env_valid: environment is valid
132 * See &enum env_valid
134 unsigned long env_valid;
136 * @env_has_init: bit mask indicating environment locations
138 * &enum env_location defines which bit relates to which location
140 unsigned long env_has_init;
142 * @env_load_prio: priority of the loaded environment
146 * @ram_base: base address of RAM used by U-Boot
148 unsigned long ram_base;
150 * @ram_top: top address of RAM used by U-Boot
154 * @relocaddr: start address of U-Boot in RAM
156 * After relocation this field indicates the address to which U-Boot
157 * has been relocated. It can be displayed using the bdinfo command.
158 * Its value is needed to display the source code when debugging with
159 * GDB using the 'add-symbol-file u-boot <relocaddr>' command.
161 unsigned long relocaddr;
163 * @ram_size: RAM size in bytes
165 phys_size_t ram_size;
167 * @mon_len: monitor length in bytes
169 unsigned long mon_len;
171 * @irq_sp: IRQ stack pointer
173 unsigned long irq_sp;
175 * @start_addr_sp: initial stack pointer address
177 unsigned long start_addr_sp;
179 * @reloc_off: relocation offset
181 unsigned long reloc_off;
183 * @new_gd: pointer to relocated global data
185 struct global_data *new_gd;
189 * @dm_root: root instance for Driver Model
191 struct udevice *dm_root;
193 * @dm_root_f: pre-relocation root instance
195 struct udevice *dm_root_f;
198 * head of core tree when uclasses are not in read-only memory.
200 * When uclasses are in read-only memory, @uclass_root_s is not used and
201 * @uclass_root points to the root node generated by dtoc.
203 struct list_head uclass_root_s;
206 * pointer to head of core tree, if uclasses are in read-only memory and
207 * cannot be adjusted to use @uclass_root as a list head.
209 * When not in read-only memory, @uclass_root_s is used to hold the
210 * uclass root, and @uclass_root points to the address of
213 struct list_head *uclass_root;
214 # if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
215 /** @dm_driver_rt: Dynamic info about the driver */
216 struct driver_rt *dm_driver_rt;
218 #if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
219 /** @dm_udevice_rt: Dynamic info about the udevice */
220 struct udevice_rt *dm_udevice_rt;
222 * @dm_priv_base: Base address of the priv/plat region used when
223 * udevices and uclasses are in read-only memory. This is NULL if not
231 * @timer: timer instance for Driver Model
233 struct udevice *timer;
236 * @fdt_blob: U-Boot's own device tree, NULL if none
238 const void *fdt_blob;
240 * @new_fdt: relocated device tree
244 * @fdt_size: space reserved for relocated device space
246 unsigned long fdt_size;
248 * @fdt_src: Source of FDT
250 enum fdt_source_t fdt_src;
251 #if CONFIG_IS_ENABLED(OF_LIVE)
253 * @of_root: root node of the live tree
255 struct device_node *of_root;
258 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
260 * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
262 const void *multi_dtb_fit;
267 * The jump table contains pointers to exported functions. A pointer to
268 * the jump table is passed to standalone applications.
272 * @env_buf: buffer for env_get() before reloc
277 * @trace_buff: trace buffer
279 * When tracing function in U-Boot this field points to the buffer
280 * recording the function calls.
284 #if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
286 * @cur_i2c_bus: currently used I2C bus
291 * @timebase_h: high 32 bits of timer
293 unsigned int timebase_h;
295 * @timebase_l: low 32 bits of timer
297 unsigned int timebase_l;
298 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
300 * @malloc_base: base address of early malloc()
302 unsigned long malloc_base;
304 * @malloc_limit: limit address of early malloc()
306 unsigned long malloc_limit;
308 * @malloc_ptr: current address of early malloc()
310 unsigned long malloc_ptr;
314 * @hose: PCI hose for early use
316 struct pci_controller *hose;
318 * @pci_ram_top: top of region accessible to PCI
320 phys_addr_t pci_ram_top;
322 #ifdef CONFIG_PCI_BOOTDELAY
324 * @pcidelay_done: delay time before scanning of PIC hose expired
326 * If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of
327 * milliseconds defined by environment variable pcidelay before
328 * scanning. Once this delay has expired the flag @pcidelay_done
334 * @cur_serial_dev: current serial device
336 struct udevice *cur_serial_dev;
338 * @arch: architecture-specific data
340 struct arch_global_data arch;
341 #ifdef CONFIG_CONSOLE_RECORD
343 * @console_out: output buffer for console recording
345 * This buffer is used to collect output during console recording.
347 struct membuff console_out;
349 * @console_in: input buffer for console recording
351 * If console recording is activated, this buffer can be used to
354 struct membuff console_in;
356 #ifdef CONFIG_DM_VIDEO
358 * @video_top: top of video frame buffer area
362 * @video_bottom: bottom of video frame buffer area
366 #ifdef CONFIG_BOOTSTAGE
368 * @bootstage: boot stage information
370 struct bootstage_data *bootstage;
372 * @new_bootstage: relocated boot stage information
374 struct bootstage_data *new_bootstage;
378 * @log_drop_count: number of dropped log messages
380 * This counter is incremented for each log message which can not
381 * be processed because logging is not yet available as signaled by
382 * flag %GD_FLG_LOG_READY in @flags.
386 * @default_log_level: default logging level
388 * For logging devices without filters @default_log_level defines the
389 * logging level, cf. &enum log_level_t.
391 int default_log_level;
393 * @log_head: list of logging devices
395 struct list_head log_head;
397 * @log_fmt: bit mask for logging format
399 * The @log_fmt bit mask selects the fields to be shown in log messages.
400 * &enum log_fmt defines the bits of the bit mask.
405 * @processing_msg: a log message is being processed
407 * This flag is used to suppress the creation of additional messages
408 * while another message is being processed.
412 * @logc_prev: logging category of previous message
414 * This value is used as logging category for continuation messages.
418 * @logl_prev: logging level of the previous message
420 * This value is used as logging level for continuation messages.
424 * @log_cont: Previous log line did not finished wtih \n
426 * This allows for chained log messages on the same line
430 #if CONFIG_IS_ENABLED(BLOBLIST)
432 * @bloblist: blob list information
434 struct bloblist_hdr *bloblist;
436 * @new_bloblist: relocated blob list information
438 struct bloblist_hdr *new_bloblist;
440 #if CONFIG_IS_ENABLED(HANDOFF)
442 * @spl_handoff: SPL hand-off information
444 struct spl_handoff *spl_handoff;
446 #if defined(CONFIG_TRANSLATION_OFFSET)
448 * @translation_offset: optional translation offset
450 * See CONFIG_TRANSLATION_OFFSET.
452 fdt_addr_t translation_offset;
454 #ifdef CONFIG_GENERATE_ACPI_TABLE
456 * @acpi_ctx: ACPI context pointer
458 struct acpi_ctx *acpi_ctx;
460 * @acpi_start: Start address of ACPI tables
464 #if CONFIG_IS_ENABLED(GENERATE_SMBIOS_TABLE)
466 * @smbios_version: Points to SMBIOS type 0 version
468 char *smbios_version;
472 static_assert(sizeof(struct global_data) == GD_SIZE);
476 * gd_board_type() - retrieve board type
478 * Return: global board type
480 #ifdef CONFIG_BOARD_TYPES
481 #define gd_board_type() gd->board_type
483 #define gd_board_type() 0
486 /* These macros help avoid #ifdefs in the code */
487 #if CONFIG_IS_ENABLED(OF_LIVE)
488 #define gd_of_root() gd->of_root
489 #define gd_of_root_ptr() &gd->of_root
490 #define gd_set_of_root(_root) gd->of_root = (_root)
492 #define gd_of_root() NULL
493 #define gd_of_root_ptr() NULL
494 #define gd_set_of_root(_root)
497 #if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
498 #define gd_set_dm_driver_rt(dyn) gd->dm_driver_rt = dyn
499 #define gd_dm_driver_rt() gd->dm_driver_rt
501 #define gd_set_dm_driver_rt(dyn)
502 #define gd_dm_driver_rt() NULL
505 #if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
506 #define gd_set_dm_udevice_rt(dyn) gd->dm_udevice_rt = dyn
507 #define gd_dm_udevice_rt() gd->dm_udevice_rt
508 #define gd_set_dm_priv_base(dyn) gd->dm_priv_base = dyn
509 #define gd_dm_priv_base() gd->dm_priv_base
511 #define gd_set_dm_udevice_rt(dyn)
512 #define gd_dm_udevice_rt() NULL
513 #define gd_set_dm_priv_base(dyn)
514 #define gd_dm_priv_base() NULL
517 #ifdef CONFIG_GENERATE_ACPI_TABLE
518 #define gd_acpi_ctx() gd->acpi_ctx
519 #define gd_acpi_start() gd->acpi_start
520 #define gd_set_acpi_start(addr) gd->acpi_start = addr
522 #define gd_acpi_ctx() NULL
523 #define gd_acpi_start() 0UL
524 #define gd_set_acpi_start(addr)
527 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
528 #define gd_multi_dtb_fit() gd->multi_dtb_fit
529 #define gd_set_multi_dtb_fit(_dtb) gd->multi_dtb_fit = _dtb
531 #define gd_multi_dtb_fit() NULL
532 #define gd_set_multi_dtb_fit(_dtb)
536 * enum gd_flags - global data flags
538 * See field flags of &struct global_data.
542 * @GD_FLG_RELOC: code was relocated to RAM
544 GD_FLG_RELOC = 0x00001,
546 * @GD_FLG_DEVINIT: devices have been initialized
548 GD_FLG_DEVINIT = 0x00002,
550 * @GD_FLG_SILENT: silent mode
552 GD_FLG_SILENT = 0x00004,
554 * @GD_FLG_POSTFAIL: critical POST test failed
556 GD_FLG_POSTFAIL = 0x00008,
558 * @GD_FLG_POSTSTOP: POST sequence aborted
560 GD_FLG_POSTSTOP = 0x00010,
562 * @GD_FLG_LOGINIT: log Buffer has been initialized
564 GD_FLG_LOGINIT = 0x00020,
566 * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
568 GD_FLG_DISABLE_CONSOLE = 0x00040,
570 * @GD_FLG_ENV_READY: environment imported into hash table
572 GD_FLG_ENV_READY = 0x00080,
574 * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
576 GD_FLG_SERIAL_READY = 0x00100,
578 * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
580 GD_FLG_FULL_MALLOC_INIT = 0x00200,
582 * @GD_FLG_SPL_INIT: spl_init() has been called
584 GD_FLG_SPL_INIT = 0x00400,
586 * @GD_FLG_SKIP_RELOC: don't relocate
588 GD_FLG_SKIP_RELOC = 0x00800,
590 * @GD_FLG_RECORD: record console
592 GD_FLG_RECORD = 0x01000,
594 * @GD_FLG_RECORD_OVF: record console overflow
596 GD_FLG_RECORD_OVF = 0x02000,
598 * @GD_FLG_ENV_DEFAULT: default variable flag
600 GD_FLG_ENV_DEFAULT = 0x04000,
602 * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
604 GD_FLG_SPL_EARLY_INIT = 0x08000,
606 * @GD_FLG_LOG_READY: log system is ready for use
608 GD_FLG_LOG_READY = 0x10000,
610 * @GD_FLG_WDT_READY: watchdog is ready for use
612 GD_FLG_WDT_READY = 0x20000,
614 * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
616 GD_FLG_SKIP_LL_INIT = 0x40000,
618 * @GD_FLG_SMP_READY: SMP initialization is complete
620 GD_FLG_SMP_READY = 0x80000,
623 #endif /* __ASSEMBLY__ */
625 #endif /* __ASM_GENERIC_GBL_DATA_H */