blob: 0aa1144184837305d5251ed0b9d2412ec36e0bff [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
Simon Glasscfd6a002020-10-03 11:31:33 -060027struct driver_rt;
28
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020029typedef struct global_data gd_t;
30
31/**
32 * struct global_data - global data structure
33 */
34struct global_data {
35 /**
36 * @bd: board information
37 */
Masahiro Yamadad788bba2020-02-25 02:22:27 +090038 struct bd_info *bd;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020039 /**
40 * @flags: global data flags
41 *
42 * See &enum gd_flags
43 */
Simon Glass0e724032012-12-13 20:49:12 +000044 unsigned long flags;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020045 /**
46 * @baudrate: baud rate of the serial interface
47 */
Simon Glass059c54f2013-03-05 14:40:05 +000048 unsigned int baudrate;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020049 /**
50 * @cpu_clk: CPU clock rate in Hz
51 */
52 unsigned long cpu_clk;
53 /**
54 * @bus_clk: platform clock rate in Hz
55 */
Simon Glass0e724032012-12-13 20:49:12 +000056 unsigned long bus_clk;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020057 /**
58 * @pci_clk: PCI clock rate in Hz
59 */
Simon Glass0e724032012-12-13 20:49:12 +000060 /* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
61 unsigned long pci_clk;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020062 /**
63 * @mem_clk: memory clock rate in Hz
64 */
Simon Glass0e724032012-12-13 20:49:12 +000065 unsigned long mem_clk;
Heiko Schocher70bd8182019-07-22 06:49:04 +020066#if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020067 /**
68 * @fb_base: base address of frame buffer memory
69 */
70 unsigned long fb_base;
Simon Glass0e724032012-12-13 20:49:12 +000071#endif
Simon Glass49badb92017-12-04 13:48:23 -070072#if defined(CONFIG_POST)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020073 /**
74 * @post_log_word: active POST tests
75 *
76 * @post_log_word is a bit mask defining which POST tests are recorded
77 * (see constants POST_*).
78 */
79 unsigned long post_log_word;
80 /**
81 * @post_log_res: POST results
82 *
83 * @post_log_res is a bit mask with the POST results. A bit with value 1
84 * indicates successful execution.
85 */
86 unsigned long post_log_res;
87 /**
88 * @post_init_f_time: time in ms when post_init_f() started
89 */
90 unsigned long post_init_f_time;
Simon Glass0e724032012-12-13 20:49:12 +000091#endif
92#ifdef CONFIG_BOARD_TYPES
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020093 /**
94 * @board_type: board type
95 *
96 * If a U-Boot configuration supports multiple board types, the actual
97 * board type may be stored in this field.
98 */
Simon Glass0e724032012-12-13 20:49:12 +000099 unsigned long board_type;
100#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200101 /**
102 * @have_console: console is available
103 *
104 * A value of 1 indicates that serial_init() was called and a console
105 * is available.
106 * A value of 0 indicates that console input and output drivers shall
107 * not be called.
108 */
109 unsigned long have_console;
Simon Glasse304a5e2016-10-17 20:12:36 -0600110#if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200111 /**
112 * @precon_buf_idx: pre-console buffer index
113 *
114 * @precon_buf_idx indicates the current position of the buffer used to
115 * collect output before the console becomes available
116 */
117 unsigned long precon_buf_idx;
Simon Glass0e724032012-12-13 20:49:12 +0000118#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200119 /**
120 * @env_addr: address of environment structure
121 *
122 * @env_addr contains the address of the structure holding the
123 * environment variables.
124 */
125 unsigned long env_addr;
126 /**
127 * @env_valid: environment is valid
128 *
129 * See &enum env_valid
130 */
131 unsigned long env_valid;
132 /**
133 * @env_has_init: bit mask indicating environment locations
134 *
135 * &enum env_location defines which bit relates to which location
136 */
137 unsigned long env_has_init;
138 /**
139 * @env_load_prio: priority of the loaded environment
140 */
141 int env_load_prio;
142 /**
143 * @ram_base: base address of RAM used by U-Boot
144 */
145 unsigned long ram_base;
146 /**
147 * @ram_top: top address of RAM used by U-Boot
148 */
149 unsigned long ram_top;
150 /**
151 * @relocaddr: start address of U-Boot in RAM
152 *
153 * After relocation this field indicates the address to which U-Boot
154 * has been relocated. It can be displayed using the bdinfo command.
155 * Its value is needed to display the source code when debugging with
156 * GDB using the 'add-symbol-file u-boot <relocaddr>' command.
157 */
158 unsigned long relocaddr;
159 /**
160 * @ram_size: RAM size in bytes
161 */
162 phys_size_t ram_size;
163 /**
164 * @mon_len: monitor length in bytes
165 */
166 unsigned long mon_len;
167 /**
168 * @irq_sp: IRQ stack pointer
169 */
170 unsigned long irq_sp;
171 /**
172 * @start_addr_sp: initial stack pointer address
173 */
174 unsigned long start_addr_sp;
175 /**
176 * @reloc_off: relocation offset
177 */
Simon Glass0e724032012-12-13 20:49:12 +0000178 unsigned long reloc_off;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200179 /**
180 * @new_gd: pointer to relocated global data
181 */
182 struct global_data *new_gd;
Simon Glassdd6ab882014-02-26 15:59:18 -0700183
184#ifdef CONFIG_DM
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200185 /**
186 * @dm_root: root instance for Driver Model
187 */
188 struct udevice *dm_root;
189 /**
190 * @dm_root_f: pre-relocation root instance
191 */
192 struct udevice *dm_root_f;
193 /**
194 * @uclass_root: head of core tree
195 */
196 struct list_head uclass_root;
Simon Glasscfd6a002020-10-03 11:31:33 -0600197# if CONFIG_IS_ENABLED(OF_PLATDATA)
198 /** Dynamic info about the driver */
199 struct driver_rt *dm_driver_rt;
200# endif
Simon Glassdd6ab882014-02-26 15:59:18 -0700201#endif
Thomas Choufb798b12015-10-09 13:46:34 +0800202#ifdef CONFIG_TIMER
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200203 /**
204 * @timer: timer instance for Driver Model
205 */
206 struct udevice *timer;
Thomas Choufb798b12015-10-09 13:46:34 +0800207#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200208 /**
209 * @fdt_blob: U-Boot's own device tree, NULL if none
210 */
211 const void *fdt_blob;
212 /**
213 * @new_fdt: relocated device tree
214 */
215 void *new_fdt;
216 /**
217 * @fdt_size: space reserved for relocated device space
218 */
219 unsigned long fdt_size;
Simon Glass40916e62020-10-03 09:25:22 -0600220#if CONFIG_IS_ENABLED(OF_LIVE)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200221 /**
222 * @of_root: root node of the live tree
223 */
Simon Glassa6eedb82017-05-18 20:08:53 -0600224 struct device_node *of_root;
225#endif
Jean-Jacques Hiblot7c530e32018-12-07 14:50:52 +0100226
227#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200228 /**
229 * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
230 */
231 const void *multi_dtb_fit;
Jean-Jacques Hiblot7c530e32018-12-07 14:50:52 +0100232#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200233 /**
234 * @jt: jump table
235 *
236 * The jump table contains pointers to exported functions. A pointer to
237 * the jump table is passed to standalone applications.
238 */
239 struct jt_funcs *jt;
240 /**
241 * @env_buf: buffer for env_get() before reloc
242 */
243 char env_buf[32];
Simon Glass209a1a62013-06-11 11:14:42 -0700244#ifdef CONFIG_TRACE
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200245 /**
246 * @trace_buff: trace buffer
247 *
248 * When tracing function in U-Boot this field points to the buffer
249 * recording the function calls.
250 */
251 void *trace_buff;
Simon Glass209a1a62013-06-11 11:14:42 -0700252#endif
Heiko Schochere7d9c4f2012-01-16 21:12:23 +0000253#if defined(CONFIG_SYS_I2C)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200254 /**
255 * @cur_i2c_bus: currently used I2C bus
256 */
257 int cur_i2c_bus;
Heiko Schochere7d9c4f2012-01-16 21:12:23 +0000258#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200259 /**
260 * @timebase_h: high 32 bits of timer
261 */
Peng Fan9a60a9e2017-05-09 10:32:03 +0800262 unsigned int timebase_h;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200263 /**
264 * @timebase_l: low 32 bits of timer
265 */
Peng Fan9a60a9e2017-05-09 10:32:03 +0800266 unsigned int timebase_l;
Andy Yan1fa20e4d2017-07-24 17:43:34 +0800267#if CONFIG_VAL(SYS_MALLOC_F_LEN)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200268 /**
269 * @malloc_base: base address of early malloc()
270 */
271 unsigned long malloc_base;
272 /**
273 * @malloc_limit: limit address of early malloc()
274 */
275 unsigned long malloc_limit;
276 /**
277 * @malloc_ptr: current address of early malloc()
278 */
279 unsigned long malloc_ptr;
Simon Glass863e4042014-07-10 22:23:28 -0600280#endif
Bin Mengf1b81fc2014-12-30 22:53:21 +0800281#ifdef CONFIG_PCI
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200282 /**
283 * @hose: PCI hose for early use
284 */
285 struct pci_controller *hose;
286 /**
287 * @pci_ram_top: top of region accessible to PCI
288 */
289 phys_addr_t pci_ram_top;
Bin Mengf1b81fc2014-12-30 22:53:21 +0800290#endif
291#ifdef CONFIG_PCI_BOOTDELAY
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200292 /**
293 * @pcidelay_done: delay time before scanning of PIC hose expired
294 *
295 * If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of
296 * milliseconds defined by environment variable pcidelay before
297 * scanning. Once this delay has expired the flag @pcidelay_done
298 * is set to 1.
299 */
Bin Mengf1b81fc2014-12-30 22:53:21 +0800300 int pcidelay_done;
301#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200302 /**
303 * @cur_serial_dev: current serial device
304 */
305 struct udevice *cur_serial_dev;
306 /**
307 * @arch: architecture-specific data
308 */
309 struct arch_global_data arch;
Simon Glass1bb49232015-11-08 23:47:48 -0700310#ifdef CONFIG_CONSOLE_RECORD
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200311 /**
312 * @console_out: output buffer for console recording
313 *
314 * This buffer is used to collect output during console recording.
315 */
316 struct membuff console_out;
317 /**
318 * @console_in: input buffer for console recording
319 *
320 * If console recording is activated, this buffer can be used to
321 * emulate input.
322 */
323 struct membuff console_in;
Simon Glass1bb49232015-11-08 23:47:48 -0700324#endif
Simon Glassfce58f52016-01-18 19:52:21 -0700325#ifdef CONFIG_DM_VIDEO
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200326 /**
327 * @video_top: top of video frame buffer area
328 */
329 ulong video_top;
330 /**
331 * @video_bottom: bottom of video frame buffer area
332 */
333 ulong video_bottom;
Simon Glassfce58f52016-01-18 19:52:21 -0700334#endif
Simon Glass88200332017-05-22 05:05:25 -0600335#ifdef CONFIG_BOOTSTAGE
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200336 /**
337 * @bootstage: boot stage information
338 */
339 struct bootstage_data *bootstage;
340 /**
341 * @new_bootstage: relocated boot stage information
342 */
343 struct bootstage_data *new_bootstage;
Simon Glass88200332017-05-22 05:05:25 -0600344#endif
Simon Glassd95645d2017-12-04 13:48:24 -0700345#ifdef CONFIG_LOG
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200346 /**
347 * @log_drop_count: number of dropped log messages
348 *
349 * This counter is incremented for each log message which can not
350 * be processed because logging is not yet available as signaled by
351 * flag %GD_FLG_LOG_READY in @flags.
352 */
353 int log_drop_count;
354 /**
355 * @default_log_level: default logging level
356 *
357 * For logging devices without filters @default_log_level defines the
358 * logging level, cf. &enum log_level_t.
359 */
360 int default_log_level;
361 /**
362 * @log_head: list of logging devices
363 */
364 struct list_head log_head;
365 /**
366 * @log_fmt: bit mask for logging format
367 *
368 * The @log_fmt bit mask selects the fields to be shown in log messages.
369 * &enum log_fmt defines the bits of the bit mask.
370 */
371 int log_fmt;
Heinrich Schuchardtfdf55992020-10-17 14:31:57 +0200372
373 /**
374 * @processing_msg: a log message is being processed
375 *
376 * This flag is used to suppress the creation of additional messages
377 * while another message is being processed.
378 */
379 bool processing_msg;
Heinrich Schuchardt0fc9f4f2020-10-17 14:31:58 +0200380 /**
381 * @logc_prev: logging category of previous message
382 *
383 * This value is used as logging category for continuation messages.
384 */
385 int logc_prev;
386 /**
387 * @logl_pref: logging level of the previous message
388 *
389 * This value is used as logging level for continuation messages.
390 */
391 int logl_prev;
Simon Glassd95645d2017-12-04 13:48:24 -0700392#endif
Simon Glassa815dab2018-11-15 18:43:52 -0700393#if CONFIG_IS_ENABLED(BLOBLIST)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200394 /**
395 * @bloblist: blob list information
396 */
397 struct bloblist_hdr *bloblist;
398 /**
399 * @new_bloblist: relocated blob list information
400 */
401 struct bloblist_hdr *new_bloblist;
Simon Glasse14f1a22018-11-15 18:44:09 -0700402# ifdef CONFIG_SPL
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200403 /**
404 * @spl_handoff: SPL hand-off information
405 */
Simon Glasse14f1a22018-11-15 18:44:09 -0700406 struct spl_handoff *spl_handoff;
407# endif
Simon Glassa815dab2018-11-15 18:43:52 -0700408#endif
Stefan Roese85bddff2019-04-12 16:42:28 +0200409#if defined(CONFIG_TRANSLATION_OFFSET)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200410 /**
411 * @translation_offset: optional translation offset
412 *
413 * See CONFIG_TRANSLATION_OFFSET.
414 */
415 fdt_addr_t translation_offset;
Stefan Roese85bddff2019-04-12 16:42:28 +0200416#endif
Marek Vasut55ec91b2019-06-09 03:46:21 +0200417#if CONFIG_IS_ENABLED(WDT)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200418 /**
419 * @watchdog_dev: watchdog device
420 */
Stefan Roese502acb02019-04-11 15:58:44 +0200421 struct udevice *watchdog_dev;
422#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200423};
Simon Glass0e724032012-12-13 20:49:12 +0000424
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200425/**
426 * gd_board_type() - retrieve board type
427 *
428 * Return: global board type
429 */
Simon Glassb4de3f32017-03-31 08:40:24 -0600430#ifdef CONFIG_BOARD_TYPES
431#define gd_board_type() gd->board_type
432#else
433#define gd_board_type() 0
434#endif
435
Simon Glass40916e62020-10-03 09:25:22 -0600436/* These macros help avoid #ifdefs in the code */
437#if CONFIG_IS_ENABLED(OF_LIVE)
438#define gd_of_root() gd->of_root
439#define gd_of_root_ptr() &gd->of_root
440#define gd_set_of_root(_root) gd->of_root = (_root)
441#else
442#define gd_of_root() NULL
443#define gd_of_root_ptr() NULL
444#define gd_set_of_root(_root)
445#endif
446
Simon Glasscfd6a002020-10-03 11:31:33 -0600447#if CONFIG_IS_ENABLED(OF_PLATDATA)
448#define gd_set_dm_driver_rt(dyn) gd->dm_driver_rt = dyn
449#define gd_dm_driver_rt() gd->dm_driver_rt
450#else
451#define gd_set_dm_driver_rt(dyn)
452#define gd_dm_driver_rt() NULL
453#endif
454
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200455/**
456 * enum gd_flags - global data flags
457 *
458 * See field flags of &struct global_data.
Simon Glass0e724032012-12-13 20:49:12 +0000459 */
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200460enum gd_flags {
461 /**
462 * @GD_FLG_RELOC: code was relocated to RAM
463 */
464 GD_FLG_RELOC = 0x00001,
465 /**
466 * @GD_FLG_DEVINIT: devices have been initialized
467 */
468 GD_FLG_DEVINIT = 0x00002,
469 /**
470 * @GD_FLG_SILENT: silent mode
471 */
472 GD_FLG_SILENT = 0x00004,
473 /**
474 * @GD_FLG_POSTFAIL: critical POST test failed
475 */
476 GD_FLG_POSTFAIL = 0x00008,
477 /**
478 * @GD_FLG_POSTSTOP: POST sequence aborted
479 */
480 GD_FLG_POSTSTOP = 0x00010,
481 /**
482 * @GD_FLG_LOGINIT: log Buffer has been initialized
483 */
484 GD_FLG_LOGINIT = 0x00020,
485 /**
486 * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
487 */
488 GD_FLG_DISABLE_CONSOLE = 0x00040,
489 /**
490 * @GD_FLG_ENV_READY: environment imported into hash table
491 */
492 GD_FLG_ENV_READY = 0x00080,
493 /**
494 * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
495 */
496 GD_FLG_SERIAL_READY = 0x00100,
497 /**
498 * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
499 */
500 GD_FLG_FULL_MALLOC_INIT = 0x00200,
501 /**
502 * @GD_FLG_SPL_INIT: spl_init() has been called
503 */
504 GD_FLG_SPL_INIT = 0x00400,
505 /**
506 * @GD_FLG_SKIP_RELOC: don't relocate
507 */
508 GD_FLG_SKIP_RELOC = 0x00800,
509 /**
510 * @GD_FLG_RECORD: record console
511 */
512 GD_FLG_RECORD = 0x01000,
513 /**
514 * @GD_FLG_ENV_DEFAULT: default variable flag
515 */
516 GD_FLG_ENV_DEFAULT = 0x02000,
517 /**
518 * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
519 */
520 GD_FLG_SPL_EARLY_INIT = 0x04000,
521 /**
522 * @GD_FLG_LOG_READY: log system is ready for use
523 */
524 GD_FLG_LOG_READY = 0x08000,
525 /**
526 * @GD_FLG_WDT_READY: watchdog is ready for use
527 */
528 GD_FLG_WDT_READY = 0x10000,
529 /**
530 * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
531 */
532 GD_FLG_SKIP_LL_INIT = 0x20000,
533 /**
534 * @GD_FLG_SMP_READY: SMP initialization is complete
535 */
536 GD_FLG_SMP_READY = 0x40000,
537};
538
539#endif /* __ASSEMBLY__ */
Simon Glass0e724032012-12-13 20:49:12 +0000540
541#endif /* __ASM_GENERIC_GBL_DATA_H */