blob: 0157af1aa4aff02da886f344c0513b6c22c663d7 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass0e724032012-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 Glass0e724032012-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 Roese85bddff2019-04-12 16:42:28 +020023#include <fdtdec.h>
Simon Glass1bb49232015-11-08 23:47:48 -070024#include <membuff.h>
Simon Glassdd6ab882014-02-26 15:59:18 -070025#include <linux/list.h>
26
Heinrich Schuchardt50d92862020-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 Yamadad788bba2020-02-25 02:22:27 +090036 struct bd_info *bd;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020037 /**
38 * @flags: global data flags
39 *
40 * See &enum gd_flags
41 */
Simon Glass0e724032012-12-13 20:49:12 +000042 unsigned long flags;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020043 /**
44 * @baudrate: baud rate of the serial interface
45 */
Simon Glass059c54f2013-03-05 14:40:05 +000046 unsigned int baudrate;
Heinrich Schuchardt50d92862020-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 Glass0e724032012-12-13 20:49:12 +000054 unsigned long bus_clk;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020055 /**
56 * @pci_clk: PCI clock rate in Hz
57 */
Simon Glass0e724032012-12-13 20:49:12 +000058 /* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
59 unsigned long pci_clk;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020060 /**
61 * @mem_clk: memory clock rate in Hz
62 */
Simon Glass0e724032012-12-13 20:49:12 +000063 unsigned long mem_clk;
Heiko Schocher70bd8182019-07-22 06:49:04 +020064#if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020065 /**
66 * @fb_base: base address of frame buffer memory
67 */
68 unsigned long fb_base;
Simon Glass0e724032012-12-13 20:49:12 +000069#endif
Simon Glass49badb92017-12-04 13:48:23 -070070#if defined(CONFIG_POST)
Heinrich Schuchardt50d92862020-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 Glass0e724032012-12-13 20:49:12 +000089#endif
90#ifdef CONFIG_BOARD_TYPES
Heinrich Schuchardt50d92862020-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 Glass0e724032012-12-13 20:49:12 +000097 unsigned long board_type;
98#endif
Heinrich Schuchardt50d92862020-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 Glasse304a5e2016-10-17 20:12:36 -0600108#if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
Heinrich Schuchardt50d92862020-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 Glass0e724032012-12-13 20:49:12 +0000116#endif
Heinrich Schuchardt50d92862020-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 Glass0e724032012-12-13 20:49:12 +0000176 unsigned long reloc_off;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200177 /**
178 * @new_gd: pointer to relocated global data
179 */
180 struct global_data *new_gd;
Simon Glassdd6ab882014-02-26 15:59:18 -0700181
182#ifdef CONFIG_DM
Heinrich Schuchardt50d92862020-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 Glassdd6ab882014-02-26 15:59:18 -0700195#endif
Thomas Choufb798b12015-10-09 13:46:34 +0800196#ifdef CONFIG_TIMER
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200197 /**
198 * @timer: timer instance for Driver Model
199 */
200 struct udevice *timer;
Thomas Choufb798b12015-10-09 13:46:34 +0800201#endif
Heinrich Schuchardt50d92862020-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 Glassa6eedb82017-05-18 20:08:53 -0600214#ifdef CONFIG_OF_LIVE
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200215 /**
216 * @of_root: root node of the live tree
217 */
Simon Glassa6eedb82017-05-18 20:08:53 -0600218 struct device_node *of_root;
219#endif
Jean-Jacques Hiblot7c530e32018-12-07 14:50:52 +0100220
221#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
Heinrich Schuchardt50d92862020-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 Hiblot7c530e32018-12-07 14:50:52 +0100226#endif
Heinrich Schuchardt50d92862020-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 Glass209a1a62013-06-11 11:14:42 -0700238#ifdef CONFIG_TRACE
Heinrich Schuchardt50d92862020-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 Glass209a1a62013-06-11 11:14:42 -0700246#endif
Heiko Schochere7d9c4f2012-01-16 21:12:23 +0000247#if defined(CONFIG_SYS_I2C)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200248 /**
249 * @cur_i2c_bus: currently used I2C bus
250 */
251 int cur_i2c_bus;
Heiko Schochere7d9c4f2012-01-16 21:12:23 +0000252#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200253 /**
254 * @timebase_h: high 32 bits of timer
255 */
Peng Fan9a60a9e2017-05-09 10:32:03 +0800256 unsigned int timebase_h;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200257 /**
258 * @timebase_l: low 32 bits of timer
259 */
Peng Fan9a60a9e2017-05-09 10:32:03 +0800260 unsigned int timebase_l;
Andy Yan1fa20e4d2017-07-24 17:43:34 +0800261#if CONFIG_VAL(SYS_MALLOC_F_LEN)
Heinrich Schuchardt50d92862020-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 Glass863e4042014-07-10 22:23:28 -0600274#endif
Bin Mengf1b81fc2014-12-30 22:53:21 +0800275#ifdef CONFIG_PCI
Heinrich Schuchardt50d92862020-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 Mengf1b81fc2014-12-30 22:53:21 +0800284#endif
285#ifdef CONFIG_PCI_BOOTDELAY
Heinrich Schuchardt50d92862020-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 Mengf1b81fc2014-12-30 22:53:21 +0800294 int pcidelay_done;
295#endif
Heinrich Schuchardt50d92862020-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 Glass1bb49232015-11-08 23:47:48 -0700304#ifdef CONFIG_CONSOLE_RECORD
Heinrich Schuchardt50d92862020-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 Glass1bb49232015-11-08 23:47:48 -0700318#endif
Simon Glassfce58f52016-01-18 19:52:21 -0700319#ifdef CONFIG_DM_VIDEO
Heinrich Schuchardt50d92862020-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 Glassfce58f52016-01-18 19:52:21 -0700328#endif
Simon Glass88200332017-05-22 05:05:25 -0600329#ifdef CONFIG_BOOTSTAGE
Heinrich Schuchardt50d92862020-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 Glass88200332017-05-22 05:05:25 -0600338#endif
Simon Glassd95645d2017-12-04 13:48:24 -0700339#ifdef CONFIG_LOG
Heinrich Schuchardt50d92862020-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 Schuchardtfdf55992020-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;
Heinrich Schuchardt0fc9f4f2020-10-17 14:31:58 +0200374 /**
375 * @logc_prev: logging category of previous message
376 *
377 * This value is used as logging category for continuation messages.
378 */
379 int logc_prev;
380 /**
381 * @logl_pref: logging level of the previous message
382 *
383 * This value is used as logging level for continuation messages.
384 */
385 int logl_prev;
Simon Glassd95645d2017-12-04 13:48:24 -0700386#endif
Simon Glassa815dab2018-11-15 18:43:52 -0700387#if CONFIG_IS_ENABLED(BLOBLIST)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200388 /**
389 * @bloblist: blob list information
390 */
391 struct bloblist_hdr *bloblist;
392 /**
393 * @new_bloblist: relocated blob list information
394 */
395 struct bloblist_hdr *new_bloblist;
Simon Glasse14f1a22018-11-15 18:44:09 -0700396# ifdef CONFIG_SPL
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200397 /**
398 * @spl_handoff: SPL hand-off information
399 */
Simon Glasse14f1a22018-11-15 18:44:09 -0700400 struct spl_handoff *spl_handoff;
401# endif
Simon Glassa815dab2018-11-15 18:43:52 -0700402#endif
Stefan Roese85bddff2019-04-12 16:42:28 +0200403#if defined(CONFIG_TRANSLATION_OFFSET)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200404 /**
405 * @translation_offset: optional translation offset
406 *
407 * See CONFIG_TRANSLATION_OFFSET.
408 */
409 fdt_addr_t translation_offset;
Stefan Roese85bddff2019-04-12 16:42:28 +0200410#endif
Marek Vasut55ec91b2019-06-09 03:46:21 +0200411#if CONFIG_IS_ENABLED(WDT)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200412 /**
413 * @watchdog_dev: watchdog device
414 */
Stefan Roese502acb02019-04-11 15:58:44 +0200415 struct udevice *watchdog_dev;
416#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200417};
Simon Glass0e724032012-12-13 20:49:12 +0000418
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200419/**
420 * gd_board_type() - retrieve board type
421 *
422 * Return: global board type
423 */
Simon Glassb4de3f32017-03-31 08:40:24 -0600424#ifdef CONFIG_BOARD_TYPES
425#define gd_board_type() gd->board_type
426#else
427#define gd_board_type() 0
428#endif
429
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200430/**
431 * enum gd_flags - global data flags
432 *
433 * See field flags of &struct global_data.
Simon Glass0e724032012-12-13 20:49:12 +0000434 */
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200435enum gd_flags {
436 /**
437 * @GD_FLG_RELOC: code was relocated to RAM
438 */
439 GD_FLG_RELOC = 0x00001,
440 /**
441 * @GD_FLG_DEVINIT: devices have been initialized
442 */
443 GD_FLG_DEVINIT = 0x00002,
444 /**
445 * @GD_FLG_SILENT: silent mode
446 */
447 GD_FLG_SILENT = 0x00004,
448 /**
449 * @GD_FLG_POSTFAIL: critical POST test failed
450 */
451 GD_FLG_POSTFAIL = 0x00008,
452 /**
453 * @GD_FLG_POSTSTOP: POST sequence aborted
454 */
455 GD_FLG_POSTSTOP = 0x00010,
456 /**
457 * @GD_FLG_LOGINIT: log Buffer has been initialized
458 */
459 GD_FLG_LOGINIT = 0x00020,
460 /**
461 * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
462 */
463 GD_FLG_DISABLE_CONSOLE = 0x00040,
464 /**
465 * @GD_FLG_ENV_READY: environment imported into hash table
466 */
467 GD_FLG_ENV_READY = 0x00080,
468 /**
469 * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
470 */
471 GD_FLG_SERIAL_READY = 0x00100,
472 /**
473 * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
474 */
475 GD_FLG_FULL_MALLOC_INIT = 0x00200,
476 /**
477 * @GD_FLG_SPL_INIT: spl_init() has been called
478 */
479 GD_FLG_SPL_INIT = 0x00400,
480 /**
481 * @GD_FLG_SKIP_RELOC: don't relocate
482 */
483 GD_FLG_SKIP_RELOC = 0x00800,
484 /**
485 * @GD_FLG_RECORD: record console
486 */
487 GD_FLG_RECORD = 0x01000,
488 /**
489 * @GD_FLG_ENV_DEFAULT: default variable flag
490 */
491 GD_FLG_ENV_DEFAULT = 0x02000,
492 /**
493 * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
494 */
495 GD_FLG_SPL_EARLY_INIT = 0x04000,
496 /**
497 * @GD_FLG_LOG_READY: log system is ready for use
498 */
499 GD_FLG_LOG_READY = 0x08000,
500 /**
501 * @GD_FLG_WDT_READY: watchdog is ready for use
502 */
503 GD_FLG_WDT_READY = 0x10000,
504 /**
505 * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
506 */
507 GD_FLG_SKIP_LL_INIT = 0x20000,
508 /**
509 * @GD_FLG_SMP_READY: SMP initialization is complete
510 */
511 GD_FLG_SMP_READY = 0x40000,
512};
513
514#endif /* __ASSEMBLY__ */
Simon Glass0e724032012-12-13 20:49:12 +0000515
516#endif /* __ASM_GENERIC_GBL_DATA_H */