blob: f31b4a0c9f4d05ece1a11fba88046219078c8d82 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass50b1fa32012-12-13 20:49:12 +00002/*
3 * Copyright (c) 2012 The Chromium OS Authors.
4 * (C) Copyright 2002-2010
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Simon Glass50b1fa32012-12-13 20:49:12 +00006 */
7
8#ifndef __ASM_GENERIC_GBL_DATA_H
9#define __ASM_GENERIC_GBL_DATA_H
10/*
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).
16 *
17 * Keep it *SMALL* and remember to set GENERATED_GBL_DATA_SIZE > sizeof(gd_t)
18 *
19 * Each architecture has its own private fields. For now all are private
20 */
21
22#ifndef __ASSEMBLY__
Stefan Roesec2c69712022-09-02 13:57:48 +020023#include <cyclic.h>
Simon Glass87a5d1b2022-03-04 08:43:00 -070024#include <event_internal.h>
Stefan Roesef2100f62019-04-12 16:42:28 +020025#include <fdtdec.h>
Simon Glass9854a872015-11-08 23:47:48 -070026#include <membuff.h>
Simon Glass6494d702014-02-26 15:59:18 -070027#include <linux/list.h>
Rasmus Villemoesee3a46a2021-05-18 11:19:47 +020028#include <linux/build_bug.h>
29#include <asm-offsets.h>
Simon Glass6494d702014-02-26 15:59:18 -070030
Bo Lv96a66d02023-05-12 19:18:22 +080031#ifdef CONFIG_AML_UASAN
32#include <amlogic/uasan.h>
33#endif
34
benlong.zhouf0969fb2023-10-26 16:42:01 +080035#ifdef CONFIG_AMLOGIC_MODIFY
36#ifdef CONFIG_AMLOGIC_TIME_PROFILE
37#define INITCALL_CNT 128
38struct init_call_time {
39 void *func;
40 unsigned int time;
41};
42#endif
43#endif
44
Simon Glass5019e202020-11-04 09:57:19 -070045struct acpi_ctx;
Simon Glassa294ead2020-10-03 11:31:33 -060046struct driver_rt;
47
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020048typedef struct global_data gd_t;
49
50/**
51 * struct global_data - global data structure
52 */
53struct global_data {
54 /**
55 * @bd: board information
56 */
Masahiro Yamadab36992f2020-02-25 02:22:27 +090057 struct bd_info *bd;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020058 /**
59 * @flags: global data flags
60 *
61 * See &enum gd_flags
62 */
Simon Glass50b1fa32012-12-13 20:49:12 +000063 unsigned long flags;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020064 /**
65 * @baudrate: baud rate of the serial interface
66 */
Simon Glassb5bec882013-03-05 14:40:05 +000067 unsigned int baudrate;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020068 /**
69 * @cpu_clk: CPU clock rate in Hz
70 */
71 unsigned long cpu_clk;
72 /**
73 * @bus_clk: platform clock rate in Hz
74 */
Simon Glass50b1fa32012-12-13 20:49:12 +000075 unsigned long bus_clk;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020076 /**
77 * @pci_clk: PCI clock rate in Hz
78 */
Simon Glass50b1fa32012-12-13 20:49:12 +000079 /* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
80 unsigned long pci_clk;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020081 /**
82 * @mem_clk: memory clock rate in Hz
83 */
Simon Glass50b1fa32012-12-13 20:49:12 +000084 unsigned long mem_clk;
Simon Glassb86986c2022-10-18 07:46:31 -060085#if defined(CONFIG_VIDEO)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020086 /**
87 * @fb_base: base address of frame buffer memory
88 */
89 unsigned long fb_base;
Simon Glass50b1fa32012-12-13 20:49:12 +000090#endif
Simon Glassc5404b62017-12-04 13:48:23 -070091#if defined(CONFIG_POST)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020092 /**
93 * @post_log_word: active POST tests
94 *
95 * @post_log_word is a bit mask defining which POST tests are recorded
96 * (see constants POST_*).
97 */
98 unsigned long post_log_word;
99 /**
100 * @post_log_res: POST results
101 *
102 * @post_log_res is a bit mask with the POST results. A bit with value 1
103 * indicates successful execution.
104 */
105 unsigned long post_log_res;
106 /**
107 * @post_init_f_time: time in ms when post_init_f() started
108 */
109 unsigned long post_init_f_time;
Simon Glass50b1fa32012-12-13 20:49:12 +0000110#endif
111#ifdef CONFIG_BOARD_TYPES
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200112 /**
113 * @board_type: board type
114 *
115 * If a U-Boot configuration supports multiple board types, the actual
116 * board type may be stored in this field.
117 */
Simon Glass50b1fa32012-12-13 20:49:12 +0000118 unsigned long board_type;
119#endif
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200120 /**
121 * @have_console: console is available
122 *
123 * A value of 1 indicates that serial_init() was called and a console
124 * is available.
125 * A value of 0 indicates that console input and output drivers shall
126 * not be called.
127 */
128 unsigned long have_console;
Simon Glass8f925582016-10-17 20:12:36 -0600129#if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200130 /**
131 * @precon_buf_idx: pre-console buffer index
132 *
Rasmus Villemoes04a20ca2022-05-03 15:13:27 +0200133 * @precon_buf_idx indicates the current position of the
134 * buffer used to collect output before the console becomes
135 * available. When negative, the pre-console buffer is
136 * temporarily disabled (used when the pre-console buffer is
137 * being written out, to prevent adding its contents to
138 * itself).
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200139 */
Rasmus Villemoes04a20ca2022-05-03 15:13:27 +0200140 long precon_buf_idx;
Simon Glass50b1fa32012-12-13 20:49:12 +0000141#endif
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200142 /**
143 * @env_addr: address of environment structure
144 *
145 * @env_addr contains the address of the structure holding the
146 * environment variables.
147 */
148 unsigned long env_addr;
149 /**
150 * @env_valid: environment is valid
151 *
152 * See &enum env_valid
153 */
154 unsigned long env_valid;
155 /**
156 * @env_has_init: bit mask indicating environment locations
157 *
158 * &enum env_location defines which bit relates to which location
159 */
160 unsigned long env_has_init;
161 /**
162 * @env_load_prio: priority of the loaded environment
163 */
164 int env_load_prio;
165 /**
166 * @ram_base: base address of RAM used by U-Boot
167 */
168 unsigned long ram_base;
169 /**
170 * @ram_top: top address of RAM used by U-Boot
171 */
Bin Meng37dc9582021-01-31 20:35:59 +0800172 phys_addr_t ram_top;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200173 /**
174 * @relocaddr: start address of U-Boot in RAM
175 *
176 * After relocation this field indicates the address to which U-Boot
177 * has been relocated. It can be displayed using the bdinfo command.
178 * Its value is needed to display the source code when debugging with
179 * GDB using the 'add-symbol-file u-boot <relocaddr>' command.
180 */
181 unsigned long relocaddr;
182 /**
183 * @ram_size: RAM size in bytes
184 */
185 phys_size_t ram_size;
186 /**
187 * @mon_len: monitor length in bytes
188 */
189 unsigned long mon_len;
190 /**
191 * @irq_sp: IRQ stack pointer
192 */
193 unsigned long irq_sp;
194 /**
195 * @start_addr_sp: initial stack pointer address
196 */
197 unsigned long start_addr_sp;
198 /**
199 * @reloc_off: relocation offset
200 */
Simon Glass50b1fa32012-12-13 20:49:12 +0000201 unsigned long reloc_off;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200202 /**
203 * @new_gd: pointer to relocated global data
204 */
205 struct global_data *new_gd;
Simon Glass6494d702014-02-26 15:59:18 -0700206
207#ifdef CONFIG_DM
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200208 /**
209 * @dm_root: root instance for Driver Model
210 */
211 struct udevice *dm_root;
212 /**
213 * @dm_root_f: pre-relocation root instance
214 */
215 struct udevice *dm_root_f;
216 /**
Heinrich Schuchardta03185a2021-01-24 21:48:00 +0100217 * @uclass_root_s:
218 * head of core tree when uclasses are not in read-only memory.
219 *
220 * When uclasses are in read-only memory, @uclass_root_s is not used and
221 * @uclass_root points to the root node generated by dtoc.
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200222 */
Simon Glass8a715532020-12-19 10:40:17 -0700223 struct list_head uclass_root_s;
224 /**
Heinrich Schuchardta03185a2021-01-24 21:48:00 +0100225 * @uclass_root:
226 * pointer to head of core tree, if uclasses are in read-only memory and
227 * cannot be adjusted to use @uclass_root as a list head.
228 *
229 * When not in read-only memory, @uclass_root_s is used to hold the
230 * uclass root, and @uclass_root points to the address of
231 * @uclass_root_s.
Simon Glass8a715532020-12-19 10:40:17 -0700232 */
233 struct list_head *uclass_root;
Simon Glassab933d82021-03-15 17:25:36 +1300234# if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
Simon Glassd211e042020-11-29 17:07:05 -0700235 /** @dm_driver_rt: Dynamic info about the driver */
Simon Glassa294ead2020-10-03 11:31:33 -0600236 struct driver_rt *dm_driver_rt;
237# endif
Simon Glassab933d82021-03-15 17:25:36 +1300238#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
239 /** @dm_udevice_rt: Dynamic info about the udevice */
240 struct udevice_rt *dm_udevice_rt;
Simon Glassbaf03712021-03-15 17:25:38 +1300241 /**
242 * @dm_priv_base: Base address of the priv/plat region used when
243 * udevices and uclasses are in read-only memory. This is NULL if not
244 * used
245 */
246 void *dm_priv_base;
Simon Glassab933d82021-03-15 17:25:36 +1300247# endif
Simon Glass6494d702014-02-26 15:59:18 -0700248#endif
Thomas Chouc8a7ba92015-10-09 13:46:34 +0800249#ifdef CONFIG_TIMER
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200250 /**
251 * @timer: timer instance for Driver Model
252 */
253 struct udevice *timer;
Thomas Chouc8a7ba92015-10-09 13:46:34 +0800254#endif
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200255 /**
256 * @fdt_blob: U-Boot's own device tree, NULL if none
257 */
258 const void *fdt_blob;
259 /**
260 * @new_fdt: relocated device tree
261 */
262 void *new_fdt;
263 /**
264 * @fdt_size: space reserved for relocated device space
265 */
266 unsigned long fdt_size;
Simon Glass39605c62021-12-16 20:59:33 -0700267 /**
268 * @fdt_src: Source of FDT
269 */
270 enum fdt_source_t fdt_src;
Simon Glassa652d9c2020-10-03 09:25:22 -0600271#if CONFIG_IS_ENABLED(OF_LIVE)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200272 /**
273 * @of_root: root node of the live tree
274 */
Simon Glass5e060d82017-05-18 20:08:53 -0600275 struct device_node *of_root;
276#endif
Jean-Jacques Hiblotf1d2bc92018-12-07 14:50:52 +0100277
278#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200279 /**
280 * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
281 */
282 const void *multi_dtb_fit;
Jean-Jacques Hiblotf1d2bc92018-12-07 14:50:52 +0100283#endif
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200284 /**
285 * @jt: jump table
286 *
287 * The jump table contains pointers to exported functions. A pointer to
288 * the jump table is passed to standalone applications.
289 */
290 struct jt_funcs *jt;
291 /**
292 * @env_buf: buffer for env_get() before reloc
293 */
294 char env_buf[32];
Simon Glass71c52db2013-06-11 11:14:42 -0700295#ifdef CONFIG_TRACE
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200296 /**
297 * @trace_buff: trace buffer
298 *
299 * When tracing function in U-Boot this field points to the buffer
300 * recording the function calls.
301 */
302 void *trace_buff;
Simon Glass71c52db2013-06-11 11:14:42 -0700303#endif
Tom Rini55dabcc2021-08-18 23:12:24 -0400304#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200305 /**
306 * @cur_i2c_bus: currently used I2C bus
307 */
308 int cur_i2c_bus;
Heiko Schocher385c9ef2012-01-16 21:12:23 +0000309#endif
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200310 /**
311 * @timebase_h: high 32 bits of timer
312 */
Peng Fan25112102017-05-09 10:32:03 +0800313 unsigned int timebase_h;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200314 /**
315 * @timebase_l: low 32 bits of timer
316 */
Peng Fan25112102017-05-09 10:32:03 +0800317 unsigned int timebase_l;
Andy Yanf1896c42017-07-24 17:43:34 +0800318#if CONFIG_VAL(SYS_MALLOC_F_LEN)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200319 /**
320 * @malloc_base: base address of early malloc()
321 */
322 unsigned long malloc_base;
323 /**
324 * @malloc_limit: limit address of early malloc()
325 */
326 unsigned long malloc_limit;
327 /**
328 * @malloc_ptr: current address of early malloc()
329 */
330 unsigned long malloc_ptr;
Simon Glassd59476b2014-07-10 22:23:28 -0600331#endif
Bin Meng8f9052f2014-12-30 22:53:21 +0800332#ifdef CONFIG_PCI
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200333 /**
334 * @hose: PCI hose for early use
335 */
336 struct pci_controller *hose;
337 /**
338 * @pci_ram_top: top of region accessible to PCI
339 */
340 phys_addr_t pci_ram_top;
Bin Meng8f9052f2014-12-30 22:53:21 +0800341#endif
342#ifdef CONFIG_PCI_BOOTDELAY
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200343 /**
344 * @pcidelay_done: delay time before scanning of PIC hose expired
345 *
346 * If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of
347 * milliseconds defined by environment variable pcidelay before
348 * scanning. Once this delay has expired the flag @pcidelay_done
349 * is set to 1.
350 */
Bin Meng8f9052f2014-12-30 22:53:21 +0800351 int pcidelay_done;
352#endif
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200353 /**
354 * @cur_serial_dev: current serial device
355 */
356 struct udevice *cur_serial_dev;
357 /**
358 * @arch: architecture-specific data
359 */
360 struct arch_global_data arch;
Simon Glass9854a872015-11-08 23:47:48 -0700361#ifdef CONFIG_CONSOLE_RECORD
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200362 /**
363 * @console_out: output buffer for console recording
364 *
365 * This buffer is used to collect output during console recording.
366 */
367 struct membuff console_out;
368 /**
369 * @console_in: input buffer for console recording
370 *
371 * If console recording is activated, this buffer can be used to
372 * emulate input.
373 */
374 struct membuff console_in;
Simon Glass9854a872015-11-08 23:47:48 -0700375#endif
Simon Glassb86986c2022-10-18 07:46:31 -0600376#ifdef CONFIG_VIDEO
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200377 /**
378 * @video_top: top of video frame buffer area
379 */
380 ulong video_top;
381 /**
382 * @video_bottom: bottom of video frame buffer area
383 */
384 ulong video_bottom;
Simon Glass5a541942016-01-18 19:52:21 -0700385#endif
Simon Glassb383d6c2017-05-22 05:05:25 -0600386#ifdef CONFIG_BOOTSTAGE
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200387 /**
388 * @bootstage: boot stage information
389 */
390 struct bootstage_data *bootstage;
391 /**
392 * @new_bootstage: relocated boot stage information
393 */
394 struct bootstage_data *new_bootstage;
Simon Glassb383d6c2017-05-22 05:05:25 -0600395#endif
Simon Glasse9c8d492017-12-04 13:48:24 -0700396#ifdef CONFIG_LOG
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200397 /**
398 * @log_drop_count: number of dropped log messages
399 *
400 * This counter is incremented for each log message which can not
401 * be processed because logging is not yet available as signaled by
402 * flag %GD_FLG_LOG_READY in @flags.
403 */
404 int log_drop_count;
405 /**
406 * @default_log_level: default logging level
407 *
408 * For logging devices without filters @default_log_level defines the
409 * logging level, cf. &enum log_level_t.
410 */
411 int default_log_level;
412 /**
413 * @log_head: list of logging devices
414 */
415 struct list_head log_head;
416 /**
417 * @log_fmt: bit mask for logging format
418 *
419 * The @log_fmt bit mask selects the fields to be shown in log messages.
420 * &enum log_fmt defines the bits of the bit mask.
421 */
422 int log_fmt;
Heinrich Schuchardt993a06b2020-10-17 14:31:57 +0200423
424 /**
425 * @processing_msg: a log message is being processed
426 *
427 * This flag is used to suppress the creation of additional messages
428 * while another message is being processed.
429 */
430 bool processing_msg;
Heinrich Schuchardtd094a072020-10-17 14:31:58 +0200431 /**
432 * @logc_prev: logging category of previous message
433 *
434 * This value is used as logging category for continuation messages.
435 */
436 int logc_prev;
437 /**
Heinrich Schuchardt096912b2020-10-30 18:50:31 +0100438 * @logl_prev: logging level of the previous message
Heinrich Schuchardtd094a072020-10-17 14:31:58 +0200439 *
440 * This value is used as logging level for continuation messages.
441 */
442 int logl_prev;
Simon Glass9ad7a6c2021-01-20 20:10:53 -0700443 /**
444 * @log_cont: Previous log line did not finished wtih \n
445 *
446 * This allows for chained log messages on the same line
447 */
448 bool log_cont;
Simon Glasse9c8d492017-12-04 13:48:24 -0700449#endif
Simon Glassf0293d32018-11-15 18:43:52 -0700450#if CONFIG_IS_ENABLED(BLOBLIST)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200451 /**
452 * @bloblist: blob list information
453 */
454 struct bloblist_hdr *bloblist;
455 /**
456 * @new_bloblist: relocated blob list information
457 */
458 struct bloblist_hdr *new_bloblist;
Ovidiu Panait13e0f022020-11-28 10:43:20 +0200459#endif
460#if CONFIG_IS_ENABLED(HANDOFF)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200461 /**
462 * @spl_handoff: SPL hand-off information
463 */
Simon Glassb0edea32018-11-15 18:44:09 -0700464 struct spl_handoff *spl_handoff;
Simon Glassf0293d32018-11-15 18:43:52 -0700465#endif
Stefan Roesef2100f62019-04-12 16:42:28 +0200466#if defined(CONFIG_TRANSLATION_OFFSET)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200467 /**
468 * @translation_offset: optional translation offset
469 *
470 * See CONFIG_TRANSLATION_OFFSET.
471 */
472 fdt_addr_t translation_offset;
Stefan Roesef2100f62019-04-12 16:42:28 +0200473#endif
Simon Glass5019e202020-11-04 09:57:19 -0700474#ifdef CONFIG_GENERATE_ACPI_TABLE
475 /**
476 * @acpi_ctx: ACPI context pointer
477 */
478 struct acpi_ctx *acpi_ctx;
Simon Glass233f0e32021-12-01 09:02:37 -0700479 /**
480 * @acpi_start: Start address of ACPI tables
481 */
482 ulong acpi_start;
Simon Glass5019e202020-11-04 09:57:19 -0700483#endif
Simon Glasse9adaa72021-02-04 21:17:20 -0700484#if CONFIG_IS_ENABLED(GENERATE_SMBIOS_TABLE)
485 /**
486 * @smbios_version: Points to SMBIOS type 0 version
487 */
488 char *smbios_version;
489#endif
Simon Glass87a5d1b2022-03-04 08:43:00 -0700490#if CONFIG_IS_ENABLED(EVENT)
491 /**
492 * @event_state: Points to the current state of events
493 */
494 struct event_state event_state;
495#endif
Stefan Roesec2c69712022-09-02 13:57:48 +0200496#ifdef CONFIG_CYCLIC
497 /**
Rasmus Villemoes50128ae2022-10-28 13:50:54 +0200498 * @cyclic_list: list of registered cyclic functions
Stefan Roesec2c69712022-09-02 13:57:48 +0200499 */
Rasmus Villemoes50128ae2022-10-28 13:50:54 +0200500 struct hlist_head cyclic_list;
Stefan Roesec2c69712022-09-02 13:57:48 +0200501#endif
AKASHI Takahiro6b7a6212022-03-08 20:36:46 +0900502 /**
503 * @dmtag_list: List of DM tags
504 */
505 struct list_head dmtag_list;
Bo Lv96a66d02023-05-12 19:18:22 +0800506#ifdef CONFIG_AML_UASAN
507 int uasan_enabled;
508 int in_asan_report;
509 unsigned long use_mem_end;
510 unsigned long use_mem_size;
511 unsigned long phy_mem_low;
512 unsigned long phy_mem_high;
513 unsigned long shadow_addr;
514 unsigned long shadow_size;
515 unsigned long section_red_zones[SECTION_RED_ZONE_NUM];
516#endif
benlong.zhouf0969fb2023-10-26 16:42:01 +0800517#ifdef CONFIG_AMLOGIC_MODIFY
518#ifdef CONFIG_AMLOGIC_TIME_PROFILE
519 struct init_call_time ict[INITCALL_CNT];
520 unsigned int time_print_flag;
521#endif
522#endif
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200523};
Rasmus Villemoesee3a46a2021-05-18 11:19:47 +0200524#ifndef DO_DEPS_ONLY
525static_assert(sizeof(struct global_data) == GD_SIZE);
526#endif
Simon Glass50b1fa32012-12-13 20:49:12 +0000527
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200528/**
529 * gd_board_type() - retrieve board type
530 *
531 * Return: global board type
532 */
Simon Glass52c41182017-03-31 08:40:24 -0600533#ifdef CONFIG_BOARD_TYPES
534#define gd_board_type() gd->board_type
535#else
536#define gd_board_type() 0
537#endif
538
Simon Glassa652d9c2020-10-03 09:25:22 -0600539/* These macros help avoid #ifdefs in the code */
540#if CONFIG_IS_ENABLED(OF_LIVE)
541#define gd_of_root() gd->of_root
542#define gd_of_root_ptr() &gd->of_root
543#define gd_set_of_root(_root) gd->of_root = (_root)
544#else
545#define gd_of_root() NULL
546#define gd_of_root_ptr() NULL
547#define gd_set_of_root(_root)
548#endif
549
Simon Glassab933d82021-03-15 17:25:36 +1300550#if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
Simon Glassa294ead2020-10-03 11:31:33 -0600551#define gd_set_dm_driver_rt(dyn) gd->dm_driver_rt = dyn
552#define gd_dm_driver_rt() gd->dm_driver_rt
553#else
554#define gd_set_dm_driver_rt(dyn)
555#define gd_dm_driver_rt() NULL
556#endif
557
Simon Glassab933d82021-03-15 17:25:36 +1300558#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
559#define gd_set_dm_udevice_rt(dyn) gd->dm_udevice_rt = dyn
560#define gd_dm_udevice_rt() gd->dm_udevice_rt
Simon Glassbaf03712021-03-15 17:25:38 +1300561#define gd_set_dm_priv_base(dyn) gd->dm_priv_base = dyn
562#define gd_dm_priv_base() gd->dm_priv_base
Simon Glassab933d82021-03-15 17:25:36 +1300563#else
564#define gd_set_dm_udevice_rt(dyn)
565#define gd_dm_udevice_rt() NULL
Simon Glassbaf03712021-03-15 17:25:38 +1300566#define gd_set_dm_priv_base(dyn)
567#define gd_dm_priv_base() NULL
Simon Glassab933d82021-03-15 17:25:36 +1300568#endif
569
Simon Glass5019e202020-11-04 09:57:19 -0700570#ifdef CONFIG_GENERATE_ACPI_TABLE
571#define gd_acpi_ctx() gd->acpi_ctx
Simon Glass233f0e32021-12-01 09:02:37 -0700572#define gd_acpi_start() gd->acpi_start
573#define gd_set_acpi_start(addr) gd->acpi_start = addr
Simon Glass5019e202020-11-04 09:57:19 -0700574#else
575#define gd_acpi_ctx() NULL
Simon Glass233f0e32021-12-01 09:02:37 -0700576#define gd_acpi_start() 0UL
577#define gd_set_acpi_start(addr)
Simon Glass5019e202020-11-04 09:57:19 -0700578#endif
579
Simon Glassb4b6daf2021-12-16 20:59:25 -0700580#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
581#define gd_multi_dtb_fit() gd->multi_dtb_fit
582#define gd_set_multi_dtb_fit(_dtb) gd->multi_dtb_fit = _dtb
583#else
584#define gd_multi_dtb_fit() NULL
585#define gd_set_multi_dtb_fit(_dtb)
586#endif
587
Simon Glass87a5d1b2022-03-04 08:43:00 -0700588#if CONFIG_IS_ENABLED(EVENT_DYNAMIC)
589#define gd_event_state() ((struct event_state *)&gd->event_state)
590#else
591#define gd_event_state() NULL
592#endif
593
Heinrich Schuchardtc82a97b2020-10-05 08:30:08 +0200594/**
595 * enum gd_flags - global data flags
596 *
597 * See field flags of &struct global_data.
Simon Glass50b1fa32012-12-13 20:49:12 +0000598 */
Heinrich Schuchardtc82a97b2020-10-05 08:30:08 +0200599enum gd_flags {
600 /**
601 * @GD_FLG_RELOC: code was relocated to RAM
602 */
603 GD_FLG_RELOC = 0x00001,
604 /**
605 * @GD_FLG_DEVINIT: devices have been initialized
606 */
607 GD_FLG_DEVINIT = 0x00002,
608 /**
609 * @GD_FLG_SILENT: silent mode
610 */
611 GD_FLG_SILENT = 0x00004,
612 /**
613 * @GD_FLG_POSTFAIL: critical POST test failed
614 */
615 GD_FLG_POSTFAIL = 0x00008,
616 /**
617 * @GD_FLG_POSTSTOP: POST sequence aborted
618 */
619 GD_FLG_POSTSTOP = 0x00010,
620 /**
621 * @GD_FLG_LOGINIT: log Buffer has been initialized
622 */
623 GD_FLG_LOGINIT = 0x00020,
624 /**
625 * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
626 */
627 GD_FLG_DISABLE_CONSOLE = 0x00040,
628 /**
629 * @GD_FLG_ENV_READY: environment imported into hash table
630 */
631 GD_FLG_ENV_READY = 0x00080,
632 /**
633 * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
634 */
635 GD_FLG_SERIAL_READY = 0x00100,
636 /**
637 * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
638 */
639 GD_FLG_FULL_MALLOC_INIT = 0x00200,
640 /**
641 * @GD_FLG_SPL_INIT: spl_init() has been called
642 */
643 GD_FLG_SPL_INIT = 0x00400,
644 /**
645 * @GD_FLG_SKIP_RELOC: don't relocate
646 */
647 GD_FLG_SKIP_RELOC = 0x00800,
648 /**
649 * @GD_FLG_RECORD: record console
650 */
651 GD_FLG_RECORD = 0x01000,
652 /**
Simon Glassc1a2bb42021-05-08 06:59:56 -0600653 * @GD_FLG_RECORD_OVF: record console overflow
654 */
655 GD_FLG_RECORD_OVF = 0x02000,
656 /**
Heinrich Schuchardtc82a97b2020-10-05 08:30:08 +0200657 * @GD_FLG_ENV_DEFAULT: default variable flag
658 */
Simon Glassc1a2bb42021-05-08 06:59:56 -0600659 GD_FLG_ENV_DEFAULT = 0x04000,
Heinrich Schuchardtc82a97b2020-10-05 08:30:08 +0200660 /**
661 * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
662 */
Simon Glassc1a2bb42021-05-08 06:59:56 -0600663 GD_FLG_SPL_EARLY_INIT = 0x08000,
Heinrich Schuchardtc82a97b2020-10-05 08:30:08 +0200664 /**
665 * @GD_FLG_LOG_READY: log system is ready for use
666 */
Simon Glassc1a2bb42021-05-08 06:59:56 -0600667 GD_FLG_LOG_READY = 0x10000,
Heinrich Schuchardtc82a97b2020-10-05 08:30:08 +0200668 /**
Stefan Roese5cbd0292022-11-17 09:20:34 +0100669 * @GD_FLG_CYCLIC_RUNNING: cyclic_run is in progress
Heinrich Schuchardtc82a97b2020-10-05 08:30:08 +0200670 */
Stefan Roese5cbd0292022-11-17 09:20:34 +0100671 GD_FLG_CYCLIC_RUNNING = 0x20000,
Heinrich Schuchardtc82a97b2020-10-05 08:30:08 +0200672 /**
673 * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
674 */
Simon Glassc1a2bb42021-05-08 06:59:56 -0600675 GD_FLG_SKIP_LL_INIT = 0x40000,
Heinrich Schuchardtc82a97b2020-10-05 08:30:08 +0200676 /**
677 * @GD_FLG_SMP_READY: SMP initialization is complete
678 */
Simon Glassc1a2bb42021-05-08 06:59:56 -0600679 GD_FLG_SMP_READY = 0x80000,
Simon Glasseb6e9032022-09-06 20:27:06 -0600680 /**
681 * @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests
682 */
683 GD_FLG_FDT_CHANGED = 0x100000,
Zhongfu Luo76072e32023-03-08 11:24:18 +0800684
685#ifdef CONFIG_AMLOGIC_MODIFY
686 /* Cache enabled */
687 GD_FLG_CACHE_EN = 0x200000,
688#endif
xia.jin958d2932024-06-07 03:12:53 +0000689#ifdef CONFIG_ARMV8_MULTIENTRY
690 GD_FLG_SMP = 0x400000,
691#endif
Heinrich Schuchardtc82a97b2020-10-05 08:30:08 +0200692};
693
xia.jin958d2932024-06-07 03:12:53 +0000694#ifdef CONFIG_ARMV8_MULTIENTRY
695#define in_smp() (gd->flags & GD_FLG_SMP)
696#endif
697
Heinrich Schuchardtc82a97b2020-10-05 08:30:08 +0200698#endif /* __ASSEMBLY__ */
Simon Glass50b1fa32012-12-13 20:49:12 +0000699
700#endif /* __ASM_GENERIC_GBL_DATA_H */