1 /*
2  * Copyright (c) 2012 The Chromium OS Authors.
3  * (C) Copyright 2002-2010
4  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5  *
6  * SPDX-License-Identifier:	GPL-2.0+
7  */
8 
9 #ifndef __ASM_GENERIC_GBL_DATA_H
10 #define __ASM_GENERIC_GBL_DATA_H
11 /*
12  * The following data structure is placed in some memory which is
13  * available very early after boot (like DPRAM on MPC8xx/MPC82xx, or
14  * some locked parts of the data cache) to allow for a minimum set of
15  * global variables during system initialization (until we have set
16  * up the memory controller so that we can use RAM).
17  *
18  * Keep it *SMALL* and remember to set GENERATED_GBL_DATA_SIZE > sizeof(gd_t)
19  *
20  * Each architecture has its own private fields. For now all are private
21  */
22 
23 #ifndef __ASSEMBLY__
24 #include <membuff.h>
25 #include <linux/list.h>
26 
27 typedef struct global_data {
28 	bd_t *bd;
29 	unsigned long flags;
30 	unsigned int baudrate;
31 	unsigned long cpu_clk;		/* CPU clock in Hz!		*/
32 	unsigned long bus_clk;
33 	/* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
34 	unsigned long pci_clk;
35 	unsigned long mem_clk;
36 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
37 	unsigned long fb_base;		/* Base address of framebuffer mem */
38 #endif
39 #if defined(CONFIG_POST)
40 	unsigned long post_log_word;	/* Record POST activities */
41 	unsigned long post_log_res;	/* success of POST test */
42 	unsigned long post_init_f_time;	/* When post_init_f started */
43 #endif
44 #ifdef CONFIG_BOARD_TYPES
45 	unsigned long board_type;
46 #endif
47 	unsigned long have_console;	/* serial_init() was called */
48 #if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
49 	unsigned long precon_buf_idx;	/* Pre-Console buffer index */
50 #endif
51 	unsigned long env_addr;		/* Address  of Environment struct */
52 	unsigned long env_valid;	/* Environment valid? enum env_valid */
53 	unsigned long env_has_init;	/* Bitmask of boolean of struct env_location offsets */
54 
55 	unsigned long ram_top;		/* Top address of RAM used by U-Boot */
56 	unsigned long relocaddr;	/* Start address of U-Boot in RAM */
57 	phys_size_t ram_size;		/* RAM size */
58 	unsigned long mon_len;		/* monitor len */
59 	unsigned long irq_sp;		/* irq stack pointer */
60 	unsigned long start_addr_sp;	/* start_addr_stackpointer */
61 	unsigned long reloc_off;
62 	struct global_data *new_gd;	/* relocated global data */
63 
64 #ifdef CONFIG_DM
65 	struct udevice	*dm_root;	/* Root instance for Driver Model */
66 	struct udevice	*dm_root_f;	/* Pre-relocation root instance */
67 	struct list_head uclass_root;	/* Head of core tree */
68 #endif
69 #ifdef CONFIG_TIMER
70 	struct udevice	*timer;		/* Timer instance for Driver Model */
71 #endif
72 
73 	const void *fdt_blob;		/* Our device tree, NULL if none */
74 	void *new_fdt;			/* Relocated FDT */
75 	unsigned long fdt_size;		/* Space reserved for relocated FDT */
76 #ifdef CONFIG_OF_LIVE
77 	struct device_node *of_root;
78 #endif
79 	struct jt_funcs *jt;		/* jump table */
80 	char env_buf[32];		/* buffer for env_get() before reloc. */
81 #ifdef CONFIG_TRACE
82 	void		*trace_buff;	/* The trace buffer */
83 #endif
84 #if defined(CONFIG_SYS_I2C)
85 	int		cur_i2c_bus;	/* current used i2c bus */
86 #endif
87 #ifdef CONFIG_SYS_I2C_MXC
88 	void *srdata[10];
89 #endif
90 	unsigned int timebase_h;
91 	unsigned int timebase_l;
92 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
93 	unsigned long malloc_base;	/* base address of early malloc() */
94 	unsigned long malloc_limit;	/* limit address */
95 	unsigned long malloc_ptr;	/* current address */
96 #endif
97 #ifdef CONFIG_PCI
98 	struct pci_controller *hose;	/* PCI hose for early use */
99 	phys_addr_t pci_ram_top;	/* top of region accessible to PCI */
100 #endif
101 #ifdef CONFIG_PCI_BOOTDELAY
102 	int pcidelay_done;
103 #endif
104 	struct udevice *cur_serial_dev;	/* current serial device */
105 	struct arch_global_data arch;	/* architecture-specific data */
106 #ifdef CONFIG_CONSOLE_RECORD
107 	struct membuff console_out;	/* console output */
108 	struct membuff console_in;	/* console input */
109 #endif
110 #ifdef CONFIG_DM_VIDEO
111 	ulong video_top;		/* Top of video frame buffer area */
112 	ulong video_bottom;		/* Bottom of video frame buffer area */
113 #endif
114 #ifdef CONFIG_BOOTSTAGE
115 	struct bootstage_data *bootstage;	/* Bootstage information */
116 	struct bootstage_data *new_bootstage;	/* Relocated bootstage info */
117 #endif
118 #ifdef CONFIG_LOG
119 	int log_drop_count;		/* Number of dropped log messages */
120 	int default_log_level;		/* For devices with no filters */
121 	struct list_head log_head;	/* List of struct log_device */
122 #endif
123 } gd_t;
124 #endif
125 
126 #ifdef CONFIG_BOARD_TYPES
127 #define gd_board_type()		gd->board_type
128 #else
129 #define gd_board_type()		0
130 #endif
131 
132 /*
133  * Global Data Flags - the top 16 bits are reserved for arch-specific flags
134  */
135 #define GD_FLG_RELOC		0x00001	/* Code was relocated to RAM	   */
136 #define GD_FLG_DEVINIT		0x00002	/* Devices have been initialized   */
137 #define GD_FLG_SILENT		0x00004	/* Silent mode			   */
138 #define GD_FLG_POSTFAIL		0x00008	/* Critical POST test failed	   */
139 #define GD_FLG_POSTSTOP		0x00010	/* POST seqeunce aborted	   */
140 #define GD_FLG_LOGINIT		0x00020	/* Log Buffer has been initialized */
141 #define GD_FLG_DISABLE_CONSOLE	0x00040	/* Disable console (in & out)	   */
142 #define GD_FLG_ENV_READY	0x00080	/* Env. imported into hash table   */
143 #define GD_FLG_SERIAL_READY	0x00100	/* Pre-reloc serial console ready  */
144 #define GD_FLG_FULL_MALLOC_INIT	0x00200	/* Full malloc() is ready	   */
145 #define GD_FLG_SPL_INIT		0x00400	/* spl_init() has been called	   */
146 #define GD_FLG_SKIP_RELOC	0x00800	/* Don't relocate		   */
147 #define GD_FLG_RECORD		0x01000	/* Record console		   */
148 #define GD_FLG_ENV_DEFAULT	0x02000 /* Default variable flag	   */
149 #define GD_FLG_SPL_EARLY_INIT	0x04000 /* Early SPL init is done	   */
150 #define GD_FLG_LOG_READY	0x08000 /* Log system is ready for use	   */
151 
152 #endif /* __ASM_GENERIC_GBL_DATA_H */
153