Merge https://gitlab.denx.de/u-boot/custodians/u-boot-marvell
[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 typedef struct global_data gd_t;
28
29 /**
30  * struct global_data - global data structure
31  */
32 struct global_data {
33         /**
34          * @bd: board information
35          */
36         struct bd_info *bd;
37         /**
38          * @flags: global data flags
39          *
40          * See &enum gd_flags
41          */
42         unsigned long flags;
43         /**
44          * @baudrate: baud rate of the serial interface
45          */
46         unsigned int baudrate;
47         /**
48          * @cpu_clk: CPU clock rate in Hz
49          */
50         unsigned long cpu_clk;
51         /**
52          * @bus_clk: platform clock rate in Hz
53          */
54         unsigned long bus_clk;
55         /**
56          * @pci_clk: PCI clock rate in Hz
57          */
58         /* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
59         unsigned long pci_clk;
60         /**
61          * @mem_clk: memory clock rate in Hz
62          */
63         unsigned long mem_clk;
64 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
65         /**
66          * @fb_base: base address of frame buffer memory
67          */
68         unsigned long fb_base;
69 #endif
70 #if defined(CONFIG_POST)
71         /**
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;
89 #endif
90 #ifdef CONFIG_BOARD_TYPES
91         /**
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          */
97         unsigned long board_type;
98 #endif
99         /**
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;
108 #if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
109         /**
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;
116 #endif
117         /**
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          */
176         unsigned long reloc_off;
177         /**
178          * @new_gd: pointer to relocated global data
179          */
180         struct global_data *new_gd;
181
182 #ifdef CONFIG_DM
183         /**
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;
195 #endif
196 #ifdef CONFIG_TIMER
197         /**
198          * @timer: timer instance for Driver Model
199          */
200         struct udevice *timer;
201 #endif
202         /**
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;
214 #ifdef CONFIG_OF_LIVE
215         /**
216          * @of_root: root node of the live tree
217          */
218         struct device_node *of_root;
219 #endif
220
221 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
222         /**
223          * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
224          */
225         const void *multi_dtb_fit;
226 #endif
227         /**
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];
238 #ifdef CONFIG_TRACE
239         /**
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;
246 #endif
247 #if defined(CONFIG_SYS_I2C)
248         /**
249          * @cur_i2c_bus: currently used I2C bus
250          */
251         int cur_i2c_bus;
252 #endif
253         /**
254          * @timebase_h: high 32 bits of timer
255          */
256         unsigned int timebase_h;
257         /**
258          * @timebase_l: low 32 bits of timer
259          */
260         unsigned int timebase_l;
261 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
262         /**
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;
274 #endif
275 #ifdef CONFIG_PCI
276         /**
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;
284 #endif
285 #ifdef CONFIG_PCI_BOOTDELAY
286         /**
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          */
294         int pcidelay_done;
295 #endif
296         /**
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;
304 #ifdef CONFIG_CONSOLE_RECORD
305         /**
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;
318 #endif
319 #ifdef CONFIG_DM_VIDEO
320         /**
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;
328 #endif
329 #ifdef CONFIG_BOOTSTAGE
330         /**
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;
338 #endif
339 #ifdef CONFIG_LOG
340         /**
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;
366 #endif
367 #if CONFIG_IS_ENABLED(BLOBLIST)
368         /**
369          * @bloblist: blob list information
370          */
371         struct bloblist_hdr *bloblist;
372         /**
373          * @new_bloblist: relocated blob list information
374          */
375         struct bloblist_hdr *new_bloblist;
376 # ifdef CONFIG_SPL
377         /**
378          * @spl_handoff: SPL hand-off information
379          */
380         struct spl_handoff *spl_handoff;
381 # endif
382 #endif
383 #if defined(CONFIG_TRANSLATION_OFFSET)
384         /**
385          * @translation_offset: optional translation offset
386          *
387          * See CONFIG_TRANSLATION_OFFSET.
388          */
389         fdt_addr_t translation_offset;
390 #endif
391 #if CONFIG_IS_ENABLED(WDT)
392         /**
393          * @watchdog_dev: watchdog device
394          */
395         struct udevice *watchdog_dev;
396 #endif
397 };
398
399 /**
400  * gd_board_type() - retrieve board type
401  *
402  * Return: global board type
403  */
404 #ifdef CONFIG_BOARD_TYPES
405 #define gd_board_type()         gd->board_type
406 #else
407 #define gd_board_type()         0
408 #endif
409
410 /**
411  * enum gd_flags - global data flags
412  *
413  * See field flags of &struct global_data.
414  */
415 enum gd_flags {
416         /**
417          * @GD_FLG_RELOC: code was relocated to RAM
418          */
419         GD_FLG_RELOC = 0x00001,
420         /**
421          * @GD_FLG_DEVINIT: devices have been initialized
422          */
423         GD_FLG_DEVINIT = 0x00002,
424         /**
425          * @GD_FLG_SILENT: silent mode
426          */
427         GD_FLG_SILENT = 0x00004,
428         /**
429          * @GD_FLG_POSTFAIL: critical POST test failed
430          */
431         GD_FLG_POSTFAIL = 0x00008,
432         /**
433          * @GD_FLG_POSTSTOP: POST sequence aborted
434          */
435         GD_FLG_POSTSTOP = 0x00010,
436         /**
437          * @GD_FLG_LOGINIT: log Buffer has been initialized
438          */
439         GD_FLG_LOGINIT = 0x00020,
440         /**
441          * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
442          */
443         GD_FLG_DISABLE_CONSOLE = 0x00040,
444         /**
445          * @GD_FLG_ENV_READY: environment imported into hash table
446          */
447         GD_FLG_ENV_READY = 0x00080,
448         /**
449          * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
450          */
451         GD_FLG_SERIAL_READY = 0x00100,
452         /**
453          * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
454          */
455         GD_FLG_FULL_MALLOC_INIT = 0x00200,
456         /**
457          * @GD_FLG_SPL_INIT: spl_init() has been called
458          */
459         GD_FLG_SPL_INIT = 0x00400,
460         /**
461          * @GD_FLG_SKIP_RELOC: don't relocate
462          */
463         GD_FLG_SKIP_RELOC = 0x00800,
464         /**
465          * @GD_FLG_RECORD: record console
466          */
467         GD_FLG_RECORD = 0x01000,
468         /**
469          * @GD_FLG_ENV_DEFAULT: default variable flag
470          */
471         GD_FLG_ENV_DEFAULT = 0x02000,
472         /**
473          * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
474          */
475         GD_FLG_SPL_EARLY_INIT = 0x04000,
476         /**
477          * @GD_FLG_LOG_READY: log system is ready for use
478          */
479         GD_FLG_LOG_READY = 0x08000,
480         /**
481          * @GD_FLG_WDT_READY: watchdog is ready for use
482          */
483         GD_FLG_WDT_READY = 0x10000,
484         /**
485          * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
486          */
487         GD_FLG_SKIP_LL_INIT = 0x20000,
488         /**
489          * @GD_FLG_SMP_READY: SMP initialization is complete
490          */
491         GD_FLG_SMP_READY = 0x40000,
492 };
493
494 #endif /* __ASSEMBLY__ */
495
496 #endif /* __ASM_GENERIC_GBL_DATA_H */