dtoc: Tidy up src_scan tests
[platform/kernel/u-boot.git] / include / asm-generic / global_data.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (c) 2012 The Chromium OS Authors.
4  * (C) Copyright 2002-2010
5  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6  */
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__
23 #include <fdtdec.h>
24 #include <membuff.h>
25 #include <linux/list.h>
26
27 struct acpi_ctx;
28 struct driver_rt;
29
30 typedef struct global_data gd_t;
31
32 /**
33  * struct global_data - global data structure
34  */
35 struct global_data {
36         /**
37          * @bd: board information
38          */
39         struct bd_info *bd;
40         /**
41          * @flags: global data flags
42          *
43          * See &enum gd_flags
44          */
45         unsigned long flags;
46         /**
47          * @baudrate: baud rate of the serial interface
48          */
49         unsigned int baudrate;
50         /**
51          * @cpu_clk: CPU clock rate in Hz
52          */
53         unsigned long cpu_clk;
54         /**
55          * @bus_clk: platform clock rate in Hz
56          */
57         unsigned long bus_clk;
58         /**
59          * @pci_clk: PCI clock rate in Hz
60          */
61         /* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
62         unsigned long pci_clk;
63         /**
64          * @mem_clk: memory clock rate in Hz
65          */
66         unsigned long mem_clk;
67 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
68         /**
69          * @fb_base: base address of frame buffer memory
70          */
71         unsigned long fb_base;
72 #endif
73 #if defined(CONFIG_POST)
74         /**
75          * @post_log_word: active POST tests
76          *
77          * @post_log_word is a bit mask defining which POST tests are recorded
78          * (see constants POST_*).
79          */
80         unsigned long post_log_word;
81         /**
82          * @post_log_res: POST results
83          *
84          * @post_log_res is a bit mask with the POST results. A bit with value 1
85          * indicates successful execution.
86          */
87         unsigned long post_log_res;
88         /**
89          * @post_init_f_time: time in ms when post_init_f() started
90          */
91         unsigned long post_init_f_time;
92 #endif
93 #ifdef CONFIG_BOARD_TYPES
94         /**
95          * @board_type: board type
96          *
97          * If a U-Boot configuration supports multiple board types, the actual
98          * board type may be stored in this field.
99          */
100         unsigned long board_type;
101 #endif
102         /**
103          * @have_console: console is available
104          *
105          * A value of 1 indicates that serial_init() was called and a console
106          * is available.
107          * A value of 0 indicates that console input and output drivers shall
108          * not be called.
109          */
110         unsigned long have_console;
111 #if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
112         /**
113          * @precon_buf_idx: pre-console buffer index
114          *
115          * @precon_buf_idx indicates the current position of the buffer used to
116          * collect output before the console becomes available
117          */
118         unsigned long precon_buf_idx;
119 #endif
120         /**
121          * @env_addr: address of environment structure
122          *
123          * @env_addr contains the address of the structure holding the
124          * environment variables.
125          */
126         unsigned long env_addr;
127         /**
128          * @env_valid: environment is valid
129          *
130          * See &enum env_valid
131          */
132         unsigned long env_valid;
133         /**
134          * @env_has_init: bit mask indicating environment locations
135          *
136          * &enum env_location defines which bit relates to which location
137          */
138         unsigned long env_has_init;
139         /**
140          * @env_load_prio: priority of the loaded environment
141          */
142         int env_load_prio;
143         /**
144          * @ram_base: base address of RAM used by U-Boot
145          */
146         unsigned long ram_base;
147         /**
148          * @ram_top: top address of RAM used by U-Boot
149          */
150         unsigned long ram_top;
151         /**
152          * @relocaddr: start address of U-Boot in RAM
153          *
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.
158          */
159         unsigned long relocaddr;
160         /**
161          * @ram_size: RAM size in bytes
162          */
163         phys_size_t ram_size;
164         /**
165          * @mon_len: monitor length in bytes
166          */
167         unsigned long mon_len;
168         /**
169          * @irq_sp: IRQ stack pointer
170          */
171         unsigned long irq_sp;
172         /**
173          * @start_addr_sp: initial stack pointer address
174          */
175         unsigned long start_addr_sp;
176         /**
177          * @reloc_off: relocation offset
178          */
179         unsigned long reloc_off;
180         /**
181          * @new_gd: pointer to relocated global data
182          */
183         struct global_data *new_gd;
184
185 #ifdef CONFIG_DM
186         /**
187          * @dm_root: root instance for Driver Model
188          */
189         struct udevice *dm_root;
190         /**
191          * @dm_root_f: pre-relocation root instance
192          */
193         struct udevice *dm_root_f;
194         /**
195          * @uclass_root: head of core tree
196          */
197         struct list_head uclass_root_s;
198         /**
199          * @uclass_root: pointer to head of core tree, if uclasses are in
200          * read-only memory and cannot be adjusted to use @uclass_root as a
201          * list head.
202          */
203         struct list_head *uclass_root;
204 # if CONFIG_IS_ENABLED(OF_PLATDATA)
205         /** Dynamic info about the driver */
206         struct driver_rt *dm_driver_rt;
207 # endif
208 #endif
209 #ifdef CONFIG_TIMER
210         /**
211          * @timer: timer instance for Driver Model
212          */
213         struct udevice *timer;
214 #endif
215         /**
216          * @fdt_blob: U-Boot's own device tree, NULL if none
217          */
218         const void *fdt_blob;
219         /**
220          * @new_fdt: relocated device tree
221          */
222         void *new_fdt;
223         /**
224          * @fdt_size: space reserved for relocated device space
225          */
226         unsigned long fdt_size;
227 #if CONFIG_IS_ENABLED(OF_LIVE)
228         /**
229          * @of_root: root node of the live tree
230          */
231         struct device_node *of_root;
232 #endif
233
234 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
235         /**
236          * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
237          */
238         const void *multi_dtb_fit;
239 #endif
240         /**
241          * @jt: jump table
242          *
243          * The jump table contains pointers to exported functions. A pointer to
244          * the jump table is passed to standalone applications.
245          */
246         struct jt_funcs *jt;
247         /**
248          * @env_buf: buffer for env_get() before reloc
249          */
250         char env_buf[32];
251 #ifdef CONFIG_TRACE
252         /**
253          * @trace_buff: trace buffer
254          *
255          * When tracing function in U-Boot this field points to the buffer
256          * recording the function calls.
257          */
258         void *trace_buff;
259 #endif
260 #if defined(CONFIG_SYS_I2C)
261         /**
262          * @cur_i2c_bus: currently used I2C bus
263          */
264         int cur_i2c_bus;
265 #endif
266         /**
267          * @timebase_h: high 32 bits of timer
268          */
269         unsigned int timebase_h;
270         /**
271          * @timebase_l: low 32 bits of timer
272          */
273         unsigned int timebase_l;
274 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
275         /**
276          * @malloc_base: base address of early malloc()
277          */
278         unsigned long malloc_base;
279         /**
280          * @malloc_limit: limit address of early malloc()
281          */
282         unsigned long malloc_limit;
283         /**
284          * @malloc_ptr: current address of early malloc()
285          */
286         unsigned long malloc_ptr;
287 #endif
288 #ifdef CONFIG_PCI
289         /**
290          * @hose: PCI hose for early use
291          */
292         struct pci_controller *hose;
293         /**
294          * @pci_ram_top: top of region accessible to PCI
295          */
296         phys_addr_t pci_ram_top;
297 #endif
298 #ifdef CONFIG_PCI_BOOTDELAY
299         /**
300          * @pcidelay_done: delay time before scanning of PIC hose expired
301          *
302          * If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of
303          * milliseconds defined by environment variable pcidelay before
304          * scanning. Once this delay has expired the flag @pcidelay_done
305          * is set to 1.
306          */
307         int pcidelay_done;
308 #endif
309         /**
310          * @cur_serial_dev: current serial device
311          */
312         struct udevice *cur_serial_dev;
313         /**
314          * @arch: architecture-specific data
315          */
316         struct arch_global_data arch;
317 #ifdef CONFIG_CONSOLE_RECORD
318         /**
319          * @console_out: output buffer for console recording
320          *
321          * This buffer is used to collect output during console recording.
322          */
323         struct membuff console_out;
324         /**
325          * @console_in: input buffer for console recording
326          *
327          * If console recording is activated, this buffer can be used to
328          * emulate input.
329          */
330         struct membuff console_in;
331 #endif
332 #ifdef CONFIG_DM_VIDEO
333         /**
334          * @video_top: top of video frame buffer area
335          */
336         ulong video_top;
337         /**
338          * @video_bottom: bottom of video frame buffer area
339          */
340         ulong video_bottom;
341 #endif
342 #ifdef CONFIG_BOOTSTAGE
343         /**
344          * @bootstage: boot stage information
345          */
346         struct bootstage_data *bootstage;
347         /**
348          * @new_bootstage: relocated boot stage information
349          */
350         struct bootstage_data *new_bootstage;
351 #endif
352 #ifdef CONFIG_LOG
353         /**
354          * @log_drop_count: number of dropped log messages
355          *
356          * This counter is incremented for each log message which can not
357          * be processed because logging is not yet available as signaled by
358          * flag %GD_FLG_LOG_READY in @flags.
359          */
360         int log_drop_count;
361         /**
362          * @default_log_level: default logging level
363          *
364          * For logging devices without filters @default_log_level defines the
365          * logging level, cf. &enum log_level_t.
366          */
367         int default_log_level;
368         /**
369          * @log_head: list of logging devices
370          */
371         struct list_head log_head;
372         /**
373          * @log_fmt: bit mask for logging format
374          *
375          * The @log_fmt bit mask selects the fields to be shown in log messages.
376          * &enum log_fmt defines the bits of the bit mask.
377          */
378         int log_fmt;
379
380         /**
381          * @processing_msg: a log message is being processed
382          *
383          * This flag is used to suppress the creation of additional messages
384          * while another message is being processed.
385          */
386         bool processing_msg;
387         /**
388          * @logc_prev: logging category of previous message
389          *
390          * This value is used as logging category for continuation messages.
391          */
392         int logc_prev;
393         /**
394          * @logl_prev: logging level of the previous message
395          *
396          * This value is used as logging level for continuation messages.
397          */
398         int logl_prev;
399 #endif
400 #if CONFIG_IS_ENABLED(BLOBLIST)
401         /**
402          * @bloblist: blob list information
403          */
404         struct bloblist_hdr *bloblist;
405         /**
406          * @new_bloblist: relocated blob list information
407          */
408         struct bloblist_hdr *new_bloblist;
409 # ifdef CONFIG_SPL
410         /**
411          * @spl_handoff: SPL hand-off information
412          */
413         struct spl_handoff *spl_handoff;
414 # endif
415 #endif
416 #if defined(CONFIG_TRANSLATION_OFFSET)
417         /**
418          * @translation_offset: optional translation offset
419          *
420          * See CONFIG_TRANSLATION_OFFSET.
421          */
422         fdt_addr_t translation_offset;
423 #endif
424 #if CONFIG_IS_ENABLED(WDT)
425         /**
426          * @watchdog_dev: watchdog device
427          */
428         struct udevice *watchdog_dev;
429 #endif
430 #ifdef CONFIG_GENERATE_ACPI_TABLE
431         /**
432          * @acpi_ctx: ACPI context pointer
433          */
434         struct acpi_ctx *acpi_ctx;
435 #endif
436 };
437
438 /**
439  * gd_board_type() - retrieve board type
440  *
441  * Return: global board type
442  */
443 #ifdef CONFIG_BOARD_TYPES
444 #define gd_board_type()         gd->board_type
445 #else
446 #define gd_board_type()         0
447 #endif
448
449 /* These macros help avoid #ifdefs in the code */
450 #if CONFIG_IS_ENABLED(OF_LIVE)
451 #define gd_of_root()            gd->of_root
452 #define gd_of_root_ptr()        &gd->of_root
453 #define gd_set_of_root(_root)   gd->of_root = (_root)
454 #else
455 #define gd_of_root()            NULL
456 #define gd_of_root_ptr()        NULL
457 #define gd_set_of_root(_root)
458 #endif
459
460 #if CONFIG_IS_ENABLED(OF_PLATDATA)
461 #define gd_set_dm_driver_rt(dyn)        gd->dm_driver_rt = dyn
462 #define gd_dm_driver_rt()               gd->dm_driver_rt
463 #else
464 #define gd_set_dm_driver_rt(dyn)
465 #define gd_dm_driver_rt()               NULL
466 #endif
467
468 #ifdef CONFIG_GENERATE_ACPI_TABLE
469 #define gd_acpi_ctx()           gd->acpi_ctx
470 #else
471 #define gd_acpi_ctx()           NULL
472 #endif
473
474 /**
475  * enum gd_flags - global data flags
476  *
477  * See field flags of &struct global_data.
478  */
479 enum gd_flags {
480         /**
481          * @GD_FLG_RELOC: code was relocated to RAM
482          */
483         GD_FLG_RELOC = 0x00001,
484         /**
485          * @GD_FLG_DEVINIT: devices have been initialized
486          */
487         GD_FLG_DEVINIT = 0x00002,
488         /**
489          * @GD_FLG_SILENT: silent mode
490          */
491         GD_FLG_SILENT = 0x00004,
492         /**
493          * @GD_FLG_POSTFAIL: critical POST test failed
494          */
495         GD_FLG_POSTFAIL = 0x00008,
496         /**
497          * @GD_FLG_POSTSTOP: POST sequence aborted
498          */
499         GD_FLG_POSTSTOP = 0x00010,
500         /**
501          * @GD_FLG_LOGINIT: log Buffer has been initialized
502          */
503         GD_FLG_LOGINIT = 0x00020,
504         /**
505          * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
506          */
507         GD_FLG_DISABLE_CONSOLE = 0x00040,
508         /**
509          * @GD_FLG_ENV_READY: environment imported into hash table
510          */
511         GD_FLG_ENV_READY = 0x00080,
512         /**
513          * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
514          */
515         GD_FLG_SERIAL_READY = 0x00100,
516         /**
517          * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
518          */
519         GD_FLG_FULL_MALLOC_INIT = 0x00200,
520         /**
521          * @GD_FLG_SPL_INIT: spl_init() has been called
522          */
523         GD_FLG_SPL_INIT = 0x00400,
524         /**
525          * @GD_FLG_SKIP_RELOC: don't relocate
526          */
527         GD_FLG_SKIP_RELOC = 0x00800,
528         /**
529          * @GD_FLG_RECORD: record console
530          */
531         GD_FLG_RECORD = 0x01000,
532         /**
533          * @GD_FLG_ENV_DEFAULT: default variable flag
534          */
535         GD_FLG_ENV_DEFAULT = 0x02000,
536         /**
537          * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
538          */
539         GD_FLG_SPL_EARLY_INIT = 0x04000,
540         /**
541          * @GD_FLG_LOG_READY: log system is ready for use
542          */
543         GD_FLG_LOG_READY = 0x08000,
544         /**
545          * @GD_FLG_WDT_READY: watchdog is ready for use
546          */
547         GD_FLG_WDT_READY = 0x10000,
548         /**
549          * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
550          */
551         GD_FLG_SKIP_LL_INIT = 0x20000,
552         /**
553          * @GD_FLG_SMP_READY: SMP initialization is complete
554          */
555         GD_FLG_SMP_READY = 0x40000,
556 };
557
558 #endif /* __ASSEMBLY__ */
559
560 #endif /* __ASM_GENERIC_GBL_DATA_H */