blob: db83f59ceb40765112599b81818029efcca4731c [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 Roesef2100f62019-04-12 16:42:28 +020023#include <fdtdec.h>
Simon Glass9854a872015-11-08 23:47:48 -070024#include <membuff.h>
Simon Glass6494d702014-02-26 15:59:18 -070025#include <linux/list.h>
26
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020027typedef struct global_data gd_t;
28
29/**
30 * struct global_data - global data structure
31 */
32struct global_data {
33 /**
34 * @bd: board information
35 */
Masahiro Yamadab36992f2020-02-25 02:22:27 +090036 struct bd_info *bd;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020037 /**
38 * @flags: global data flags
39 *
40 * See &enum gd_flags
41 */
Simon Glass50b1fa32012-12-13 20:49:12 +000042 unsigned long flags;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020043 /**
44 * @baudrate: baud rate of the serial interface
45 */
Simon Glassb5bec882013-03-05 14:40:05 +000046 unsigned int baudrate;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020047 /**
48 * @cpu_clk: CPU clock rate in Hz
49 */
50 unsigned long cpu_clk;
51 /**
52 * @bus_clk: platform clock rate in Hz
53 */
Simon Glass50b1fa32012-12-13 20:49:12 +000054 unsigned long bus_clk;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020055 /**
56 * @pci_clk: PCI clock rate in Hz
57 */
Simon Glass50b1fa32012-12-13 20:49:12 +000058 /* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
59 unsigned long pci_clk;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020060 /**
61 * @mem_clk: memory clock rate in Hz
62 */
Simon Glass50b1fa32012-12-13 20:49:12 +000063 unsigned long mem_clk;
Heiko Schocher98a82792019-07-22 06:49:04 +020064#if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020065 /**
66 * @fb_base: base address of frame buffer memory
67 */
68 unsigned long fb_base;
Simon Glass50b1fa32012-12-13 20:49:12 +000069#endif
Simon Glassc5404b62017-12-04 13:48:23 -070070#if defined(CONFIG_POST)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020071 /**
72 * @post_log_word: active POST tests
73 *
74 * @post_log_word is a bit mask defining which POST tests are recorded
75 * (see constants POST_*).
76 */
77 unsigned long post_log_word;
78 /**
79 * @post_log_res: POST results
80 *
81 * @post_log_res is a bit mask with the POST results. A bit with value 1
82 * indicates successful execution.
83 */
84 unsigned long post_log_res;
85 /**
86 * @post_init_f_time: time in ms when post_init_f() started
87 */
88 unsigned long post_init_f_time;
Simon Glass50b1fa32012-12-13 20:49:12 +000089#endif
90#ifdef CONFIG_BOARD_TYPES
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020091 /**
92 * @board_type: board type
93 *
94 * If a U-Boot configuration supports multiple board types, the actual
95 * board type may be stored in this field.
96 */
Simon Glass50b1fa32012-12-13 20:49:12 +000097 unsigned long board_type;
98#endif
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +020099 /**
100 * @have_console: console is available
101 *
102 * A value of 1 indicates that serial_init() was called and a console
103 * is available.
104 * A value of 0 indicates that console input and output drivers shall
105 * not be called.
106 */
107 unsigned long have_console;
Simon Glass8f925582016-10-17 20:12:36 -0600108#if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200109 /**
110 * @precon_buf_idx: pre-console buffer index
111 *
112 * @precon_buf_idx indicates the current position of the buffer used to
113 * collect output before the console becomes available
114 */
115 unsigned long precon_buf_idx;
Simon Glass50b1fa32012-12-13 20:49:12 +0000116#endif
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200117 /**
118 * @env_addr: address of environment structure
119 *
120 * @env_addr contains the address of the structure holding the
121 * environment variables.
122 */
123 unsigned long env_addr;
124 /**
125 * @env_valid: environment is valid
126 *
127 * See &enum env_valid
128 */
129 unsigned long env_valid;
130 /**
131 * @env_has_init: bit mask indicating environment locations
132 *
133 * &enum env_location defines which bit relates to which location
134 */
135 unsigned long env_has_init;
136 /**
137 * @env_load_prio: priority of the loaded environment
138 */
139 int env_load_prio;
140 /**
141 * @ram_base: base address of RAM used by U-Boot
142 */
143 unsigned long ram_base;
144 /**
145 * @ram_top: top address of RAM used by U-Boot
146 */
147 unsigned long ram_top;
148 /**
149 * @relocaddr: start address of U-Boot in RAM
150 *
151 * After relocation this field indicates the address to which U-Boot
152 * has been relocated. It can be displayed using the bdinfo command.
153 * Its value is needed to display the source code when debugging with
154 * GDB using the 'add-symbol-file u-boot <relocaddr>' command.
155 */
156 unsigned long relocaddr;
157 /**
158 * @ram_size: RAM size in bytes
159 */
160 phys_size_t ram_size;
161 /**
162 * @mon_len: monitor length in bytes
163 */
164 unsigned long mon_len;
165 /**
166 * @irq_sp: IRQ stack pointer
167 */
168 unsigned long irq_sp;
169 /**
170 * @start_addr_sp: initial stack pointer address
171 */
172 unsigned long start_addr_sp;
173 /**
174 * @reloc_off: relocation offset
175 */
Simon Glass50b1fa32012-12-13 20:49:12 +0000176 unsigned long reloc_off;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200177 /**
178 * @new_gd: pointer to relocated global data
179 */
180 struct global_data *new_gd;
Simon Glass6494d702014-02-26 15:59:18 -0700181
182#ifdef CONFIG_DM
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200183 /**
184 * @dm_root: root instance for Driver Model
185 */
186 struct udevice *dm_root;
187 /**
188 * @dm_root_f: pre-relocation root instance
189 */
190 struct udevice *dm_root_f;
191 /**
192 * @uclass_root: head of core tree
193 */
194 struct list_head uclass_root;
Simon Glass6494d702014-02-26 15:59:18 -0700195#endif
Thomas Chouc8a7ba92015-10-09 13:46:34 +0800196#ifdef CONFIG_TIMER
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200197 /**
198 * @timer: timer instance for Driver Model
199 */
200 struct udevice *timer;
Thomas Chouc8a7ba92015-10-09 13:46:34 +0800201#endif
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200202 /**
203 * @fdt_blob: U-Boot's own device tree, NULL if none
204 */
205 const void *fdt_blob;
206 /**
207 * @new_fdt: relocated device tree
208 */
209 void *new_fdt;
210 /**
211 * @fdt_size: space reserved for relocated device space
212 */
213 unsigned long fdt_size;
Simon Glass5e060d82017-05-18 20:08:53 -0600214#ifdef CONFIG_OF_LIVE
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200215 /**
216 * @of_root: root node of the live tree
217 */
Simon Glass5e060d82017-05-18 20:08:53 -0600218 struct device_node *of_root;
219#endif
Jean-Jacques Hiblotf1d2bc92018-12-07 14:50:52 +0100220
221#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200222 /**
223 * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
224 */
225 const void *multi_dtb_fit;
Jean-Jacques Hiblotf1d2bc92018-12-07 14:50:52 +0100226#endif
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200227 /**
228 * @jt: jump table
229 *
230 * The jump table contains pointers to exported functions. A pointer to
231 * the jump table is passed to standalone applications.
232 */
233 struct jt_funcs *jt;
234 /**
235 * @env_buf: buffer for env_get() before reloc
236 */
237 char env_buf[32];
Simon Glass71c52db2013-06-11 11:14:42 -0700238#ifdef CONFIG_TRACE
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200239 /**
240 * @trace_buff: trace buffer
241 *
242 * When tracing function in U-Boot this field points to the buffer
243 * recording the function calls.
244 */
245 void *trace_buff;
Simon Glass71c52db2013-06-11 11:14:42 -0700246#endif
Heiko Schocher385c9ef2012-01-16 21:12:23 +0000247#if defined(CONFIG_SYS_I2C)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200248 /**
249 * @cur_i2c_bus: currently used I2C bus
250 */
251 int cur_i2c_bus;
Heiko Schocher385c9ef2012-01-16 21:12:23 +0000252#endif
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200253 /**
254 * @timebase_h: high 32 bits of timer
255 */
Peng Fan25112102017-05-09 10:32:03 +0800256 unsigned int timebase_h;
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200257 /**
258 * @timebase_l: low 32 bits of timer
259 */
Peng Fan25112102017-05-09 10:32:03 +0800260 unsigned int timebase_l;
Andy Yanf1896c42017-07-24 17:43:34 +0800261#if CONFIG_VAL(SYS_MALLOC_F_LEN)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200262 /**
263 * @malloc_base: base address of early malloc()
264 */
265 unsigned long malloc_base;
266 /**
267 * @malloc_limit: limit address of early malloc()
268 */
269 unsigned long malloc_limit;
270 /**
271 * @malloc_ptr: current address of early malloc()
272 */
273 unsigned long malloc_ptr;
Simon Glassd59476b2014-07-10 22:23:28 -0600274#endif
Bin Meng8f9052f2014-12-30 22:53:21 +0800275#ifdef CONFIG_PCI
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200276 /**
277 * @hose: PCI hose for early use
278 */
279 struct pci_controller *hose;
280 /**
281 * @pci_ram_top: top of region accessible to PCI
282 */
283 phys_addr_t pci_ram_top;
Bin Meng8f9052f2014-12-30 22:53:21 +0800284#endif
285#ifdef CONFIG_PCI_BOOTDELAY
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200286 /**
287 * @pcidelay_done: delay time before scanning of PIC hose expired
288 *
289 * If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of
290 * milliseconds defined by environment variable pcidelay before
291 * scanning. Once this delay has expired the flag @pcidelay_done
292 * is set to 1.
293 */
Bin Meng8f9052f2014-12-30 22:53:21 +0800294 int pcidelay_done;
295#endif
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200296 /**
297 * @cur_serial_dev: current serial device
298 */
299 struct udevice *cur_serial_dev;
300 /**
301 * @arch: architecture-specific data
302 */
303 struct arch_global_data arch;
Simon Glass9854a872015-11-08 23:47:48 -0700304#ifdef CONFIG_CONSOLE_RECORD
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200305 /**
306 * @console_out: output buffer for console recording
307 *
308 * This buffer is used to collect output during console recording.
309 */
310 struct membuff console_out;
311 /**
312 * @console_in: input buffer for console recording
313 *
314 * If console recording is activated, this buffer can be used to
315 * emulate input.
316 */
317 struct membuff console_in;
Simon Glass9854a872015-11-08 23:47:48 -0700318#endif
Simon Glass5a541942016-01-18 19:52:21 -0700319#ifdef CONFIG_DM_VIDEO
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200320 /**
321 * @video_top: top of video frame buffer area
322 */
323 ulong video_top;
324 /**
325 * @video_bottom: bottom of video frame buffer area
326 */
327 ulong video_bottom;
Simon Glass5a541942016-01-18 19:52:21 -0700328#endif
Simon Glassb383d6c2017-05-22 05:05:25 -0600329#ifdef CONFIG_BOOTSTAGE
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200330 /**
331 * @bootstage: boot stage information
332 */
333 struct bootstage_data *bootstage;
334 /**
335 * @new_bootstage: relocated boot stage information
336 */
337 struct bootstage_data *new_bootstage;
Simon Glassb383d6c2017-05-22 05:05:25 -0600338#endif
Simon Glasse9c8d492017-12-04 13:48:24 -0700339#ifdef CONFIG_LOG
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200340 /**
341 * @log_drop_count: number of dropped log messages
342 *
343 * This counter is incremented for each log message which can not
344 * be processed because logging is not yet available as signaled by
345 * flag %GD_FLG_LOG_READY in @flags.
346 */
347 int log_drop_count;
348 /**
349 * @default_log_level: default logging level
350 *
351 * For logging devices without filters @default_log_level defines the
352 * logging level, cf. &enum log_level_t.
353 */
354 int default_log_level;
355 /**
356 * @log_head: list of logging devices
357 */
358 struct list_head log_head;
359 /**
360 * @log_fmt: bit mask for logging format
361 *
362 * The @log_fmt bit mask selects the fields to be shown in log messages.
363 * &enum log_fmt defines the bits of the bit mask.
364 */
365 int log_fmt;
Heinrich Schuchardt993a06b2020-10-17 14:31:57 +0200366
367 /**
368 * @processing_msg: a log message is being processed
369 *
370 * This flag is used to suppress the creation of additional messages
371 * while another message is being processed.
372 */
373 bool processing_msg;
Simon Glasse9c8d492017-12-04 13:48:24 -0700374#endif
Simon Glassf0293d32018-11-15 18:43:52 -0700375#if CONFIG_IS_ENABLED(BLOBLIST)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200376 /**
377 * @bloblist: blob list information
378 */
379 struct bloblist_hdr *bloblist;
380 /**
381 * @new_bloblist: relocated blob list information
382 */
383 struct bloblist_hdr *new_bloblist;
Simon Glassb0edea32018-11-15 18:44:09 -0700384# ifdef CONFIG_SPL
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200385 /**
386 * @spl_handoff: SPL hand-off information
387 */
Simon Glassb0edea32018-11-15 18:44:09 -0700388 struct spl_handoff *spl_handoff;
389# endif
Simon Glassf0293d32018-11-15 18:43:52 -0700390#endif
Stefan Roesef2100f62019-04-12 16:42:28 +0200391#if defined(CONFIG_TRANSLATION_OFFSET)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200392 /**
393 * @translation_offset: optional translation offset
394 *
395 * See CONFIG_TRANSLATION_OFFSET.
396 */
397 fdt_addr_t translation_offset;
Stefan Roesef2100f62019-04-12 16:42:28 +0200398#endif
Marek Vasut6874cb72019-06-09 03:46:21 +0200399#if CONFIG_IS_ENABLED(WDT)
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200400 /**
401 * @watchdog_dev: watchdog device
402 */
Stefan Roese06985282019-04-11 15:58:44 +0200403 struct udevice *watchdog_dev;
404#endif
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200405};
Simon Glass50b1fa32012-12-13 20:49:12 +0000406
Heinrich Schuchardt0c7cd152020-10-05 08:30:09 +0200407/**
408 * gd_board_type() - retrieve board type
409 *
410 * Return: global board type
411 */
Simon Glass52c41182017-03-31 08:40:24 -0600412#ifdef CONFIG_BOARD_TYPES
413#define gd_board_type() gd->board_type
414#else
415#define gd_board_type() 0
416#endif
417
Heinrich Schuchardtc82a97b2020-10-05 08:30:08 +0200418/**
419 * enum gd_flags - global data flags
420 *
421 * See field flags of &struct global_data.
Simon Glass50b1fa32012-12-13 20:49:12 +0000422 */
Heinrich Schuchardtc82a97b2020-10-05 08:30:08 +0200423enum gd_flags {
424 /**
425 * @GD_FLG_RELOC: code was relocated to RAM
426 */
427 GD_FLG_RELOC = 0x00001,
428 /**
429 * @GD_FLG_DEVINIT: devices have been initialized
430 */
431 GD_FLG_DEVINIT = 0x00002,
432 /**
433 * @GD_FLG_SILENT: silent mode
434 */
435 GD_FLG_SILENT = 0x00004,
436 /**
437 * @GD_FLG_POSTFAIL: critical POST test failed
438 */
439 GD_FLG_POSTFAIL = 0x00008,
440 /**
441 * @GD_FLG_POSTSTOP: POST sequence aborted
442 */
443 GD_FLG_POSTSTOP = 0x00010,
444 /**
445 * @GD_FLG_LOGINIT: log Buffer has been initialized
446 */
447 GD_FLG_LOGINIT = 0x00020,
448 /**
449 * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
450 */
451 GD_FLG_DISABLE_CONSOLE = 0x00040,
452 /**
453 * @GD_FLG_ENV_READY: environment imported into hash table
454 */
455 GD_FLG_ENV_READY = 0x00080,
456 /**
457 * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
458 */
459 GD_FLG_SERIAL_READY = 0x00100,
460 /**
461 * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
462 */
463 GD_FLG_FULL_MALLOC_INIT = 0x00200,
464 /**
465 * @GD_FLG_SPL_INIT: spl_init() has been called
466 */
467 GD_FLG_SPL_INIT = 0x00400,
468 /**
469 * @GD_FLG_SKIP_RELOC: don't relocate
470 */
471 GD_FLG_SKIP_RELOC = 0x00800,
472 /**
473 * @GD_FLG_RECORD: record console
474 */
475 GD_FLG_RECORD = 0x01000,
476 /**
477 * @GD_FLG_ENV_DEFAULT: default variable flag
478 */
479 GD_FLG_ENV_DEFAULT = 0x02000,
480 /**
481 * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
482 */
483 GD_FLG_SPL_EARLY_INIT = 0x04000,
484 /**
485 * @GD_FLG_LOG_READY: log system is ready for use
486 */
487 GD_FLG_LOG_READY = 0x08000,
488 /**
489 * @GD_FLG_WDT_READY: watchdog is ready for use
490 */
491 GD_FLG_WDT_READY = 0x10000,
492 /**
493 * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
494 */
495 GD_FLG_SKIP_LL_INIT = 0x20000,
496 /**
497 * @GD_FLG_SMP_READY: SMP initialization is complete
498 */
499 GD_FLG_SMP_READY = 0x40000,
500};
501
502#endif /* __ASSEMBLY__ */
Simon Glass50b1fa32012-12-13 20:49:12 +0000503
504#endif /* __ASM_GENERIC_GBL_DATA_H */