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
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;
196 * head of core tree when uclasses are not in read-only memory.
198 * When uclasses are in read-only memory, @uclass_root_s is not used and
199 * @uclass_root points to the root node generated by dtoc.
201 struct list_head uclass_root_s;
204 * pointer to head of core tree, if uclasses are in read-only memory and
205 * cannot be adjusted to use @uclass_root as a list head.
207 * When not in read-only memory, @uclass_root_s is used to hold the
208 * uclass root, and @uclass_root points to the address of
211 struct list_head *uclass_root;
212 # if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
213 /** @dm_driver_rt: Dynamic info about the driver */
214 struct driver_rt *dm_driver_rt;
216 #if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
217 /** @dm_udevice_rt: Dynamic info about the udevice */
218 struct udevice_rt *dm_udevice_rt;
220 * @dm_priv_base: Base address of the priv/plat region used when
221 * udevices and uclasses are in read-only memory. This is NULL if not
229 * @timer: timer instance for Driver Model
231 struct udevice *timer;
234 * @fdt_blob: U-Boot's own device tree, NULL if none
236 const void *fdt_blob;
238 * @new_fdt: relocated device tree
242 * @fdt_size: space reserved for relocated device space
244 unsigned long fdt_size;
245 #if CONFIG_IS_ENABLED(OF_LIVE)
247 * @of_root: root node of the live tree
249 struct device_node *of_root;
252 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
254 * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
256 const void *multi_dtb_fit;
261 * The jump table contains pointers to exported functions. A pointer to
262 * the jump table is passed to standalone applications.
266 * @env_buf: buffer for env_get() before reloc
271 * @trace_buff: trace buffer
273 * When tracing function in U-Boot this field points to the buffer
274 * recording the function calls.
278 #if defined(CONFIG_SYS_I2C)
280 * @cur_i2c_bus: currently used I2C bus
285 * @timebase_h: high 32 bits of timer
287 unsigned int timebase_h;
289 * @timebase_l: low 32 bits of timer
291 unsigned int timebase_l;
292 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
294 * @malloc_base: base address of early malloc()
296 unsigned long malloc_base;
298 * @malloc_limit: limit address of early malloc()
300 unsigned long malloc_limit;
302 * @malloc_ptr: current address of early malloc()
304 unsigned long malloc_ptr;
308 * @hose: PCI hose for early use
310 struct pci_controller *hose;
312 * @pci_ram_top: top of region accessible to PCI
314 phys_addr_t pci_ram_top;
316 #ifdef CONFIG_PCI_BOOTDELAY
318 * @pcidelay_done: delay time before scanning of PIC hose expired
320 * If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of
321 * milliseconds defined by environment variable pcidelay before
322 * scanning. Once this delay has expired the flag @pcidelay_done
328 * @cur_serial_dev: current serial device
330 struct udevice *cur_serial_dev;
332 * @arch: architecture-specific data
334 struct arch_global_data arch;
335 #ifdef CONFIG_CONSOLE_RECORD
337 * @console_out: output buffer for console recording
339 * This buffer is used to collect output during console recording.
341 struct membuff console_out;
343 * @console_in: input buffer for console recording
345 * If console recording is activated, this buffer can be used to
348 struct membuff console_in;
350 #ifdef CONFIG_DM_VIDEO
352 * @video_top: top of video frame buffer area
356 * @video_bottom: bottom of video frame buffer area
360 #ifdef CONFIG_BOOTSTAGE
362 * @bootstage: boot stage information
364 struct bootstage_data *bootstage;
366 * @new_bootstage: relocated boot stage information
368 struct bootstage_data *new_bootstage;
372 * @log_drop_count: number of dropped log messages
374 * This counter is incremented for each log message which can not
375 * be processed because logging is not yet available as signaled by
376 * flag %GD_FLG_LOG_READY in @flags.
380 * @default_log_level: default logging level
382 * For logging devices without filters @default_log_level defines the
383 * logging level, cf. &enum log_level_t.
385 int default_log_level;
387 * @log_head: list of logging devices
389 struct list_head log_head;
391 * @log_fmt: bit mask for logging format
393 * The @log_fmt bit mask selects the fields to be shown in log messages.
394 * &enum log_fmt defines the bits of the bit mask.
399 * @processing_msg: a log message is being processed
401 * This flag is used to suppress the creation of additional messages
402 * while another message is being processed.
406 * @logc_prev: logging category of previous message
408 * This value is used as logging category for continuation messages.
412 * @logl_prev: logging level of the previous message
414 * This value is used as logging level for continuation messages.
418 * @log_cont: Previous log line did not finished wtih \n
420 * This allows for chained log messages on the same line
424 #if CONFIG_IS_ENABLED(BLOBLIST)
426 * @bloblist: blob list information
428 struct bloblist_hdr *bloblist;
430 * @new_bloblist: relocated blob list information
432 struct bloblist_hdr *new_bloblist;
434 #if CONFIG_IS_ENABLED(HANDOFF)
436 * @spl_handoff: SPL hand-off information
438 struct spl_handoff *spl_handoff;
440 #if defined(CONFIG_TRANSLATION_OFFSET)
442 * @translation_offset: optional translation offset
444 * See CONFIG_TRANSLATION_OFFSET.
446 fdt_addr_t translation_offset;
448 #if CONFIG_IS_ENABLED(WDT)
450 * @watchdog_dev: watchdog device
452 struct udevice *watchdog_dev;
454 #ifdef CONFIG_GENERATE_ACPI_TABLE
456 * @acpi_ctx: ACPI context pointer
458 struct acpi_ctx *acpi_ctx;
460 #if CONFIG_IS_ENABLED(GENERATE_SMBIOS_TABLE)
462 * @smbios_version: Points to SMBIOS type 0 version
464 char *smbios_version;
469 * gd_board_type() - retrieve board type
471 * Return: global board type
473 #ifdef CONFIG_BOARD_TYPES
474 #define gd_board_type() gd->board_type
476 #define gd_board_type() 0
479 /* These macros help avoid #ifdefs in the code */
480 #if CONFIG_IS_ENABLED(OF_LIVE)
481 #define gd_of_root() gd->of_root
482 #define gd_of_root_ptr() &gd->of_root
483 #define gd_set_of_root(_root) gd->of_root = (_root)
485 #define gd_of_root() NULL
486 #define gd_of_root_ptr() NULL
487 #define gd_set_of_root(_root)
490 #if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
491 #define gd_set_dm_driver_rt(dyn) gd->dm_driver_rt = dyn
492 #define gd_dm_driver_rt() gd->dm_driver_rt
494 #define gd_set_dm_driver_rt(dyn)
495 #define gd_dm_driver_rt() NULL
498 #if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
499 #define gd_set_dm_udevice_rt(dyn) gd->dm_udevice_rt = dyn
500 #define gd_dm_udevice_rt() gd->dm_udevice_rt
501 #define gd_set_dm_priv_base(dyn) gd->dm_priv_base = dyn
502 #define gd_dm_priv_base() gd->dm_priv_base
504 #define gd_set_dm_udevice_rt(dyn)
505 #define gd_dm_udevice_rt() NULL
506 #define gd_set_dm_priv_base(dyn)
507 #define gd_dm_priv_base() NULL
510 #ifdef CONFIG_GENERATE_ACPI_TABLE
511 #define gd_acpi_ctx() gd->acpi_ctx
513 #define gd_acpi_ctx() NULL
517 * enum gd_flags - global data flags
519 * See field flags of &struct global_data.
523 * @GD_FLG_RELOC: code was relocated to RAM
525 GD_FLG_RELOC = 0x00001,
527 * @GD_FLG_DEVINIT: devices have been initialized
529 GD_FLG_DEVINIT = 0x00002,
531 * @GD_FLG_SILENT: silent mode
533 GD_FLG_SILENT = 0x00004,
535 * @GD_FLG_POSTFAIL: critical POST test failed
537 GD_FLG_POSTFAIL = 0x00008,
539 * @GD_FLG_POSTSTOP: POST sequence aborted
541 GD_FLG_POSTSTOP = 0x00010,
543 * @GD_FLG_LOGINIT: log Buffer has been initialized
545 GD_FLG_LOGINIT = 0x00020,
547 * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
549 GD_FLG_DISABLE_CONSOLE = 0x00040,
551 * @GD_FLG_ENV_READY: environment imported into hash table
553 GD_FLG_ENV_READY = 0x00080,
555 * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
557 GD_FLG_SERIAL_READY = 0x00100,
559 * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
561 GD_FLG_FULL_MALLOC_INIT = 0x00200,
563 * @GD_FLG_SPL_INIT: spl_init() has been called
565 GD_FLG_SPL_INIT = 0x00400,
567 * @GD_FLG_SKIP_RELOC: don't relocate
569 GD_FLG_SKIP_RELOC = 0x00800,
571 * @GD_FLG_RECORD: record console
573 GD_FLG_RECORD = 0x01000,
575 * @GD_FLG_RECORD_OVF: record console overflow
577 GD_FLG_RECORD_OVF = 0x02000,
579 * @GD_FLG_ENV_DEFAULT: default variable flag
581 GD_FLG_ENV_DEFAULT = 0x04000,
583 * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
585 GD_FLG_SPL_EARLY_INIT = 0x08000,
587 * @GD_FLG_LOG_READY: log system is ready for use
589 GD_FLG_LOG_READY = 0x10000,
591 * @GD_FLG_WDT_READY: watchdog is ready for use
593 GD_FLG_WDT_READY = 0x20000,
595 * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
597 GD_FLG_SKIP_LL_INIT = 0x40000,
599 * @GD_FLG_SMP_READY: SMP initialization is complete
601 GD_FLG_SMP_READY = 0x80000,
604 #endif /* __ASSEMBLY__ */
606 #endif /* __ASM_GENERIC_GBL_DATA_H */