xref: /openbmc/linux/arch/mips/include/asm/bootinfo.h (revision c4f7ac64)
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file COPYING in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 1995, 1996, 2003 by Ralf Baechle
7  * Copyright (C) 1995, 1996 Andreas Busse
8  * Copyright (C) 1995, 1996 Stoned Elipot
9  * Copyright (C) 1995, 1996 Paul M. Antoine.
10  * Copyright (C) 2009       Zhang Le
11  */
12 #ifndef _ASM_BOOTINFO_H
13 #define _ASM_BOOTINFO_H
14 
15 #include <linux/types.h>
16 #include <asm/setup.h>
17 
18 /*
19  * The MACH_ IDs are sort of equivalent to PCI product IDs.  As such the
20  * numbers do not necessarily reflect technical relations or similarities
21  * between systems.
22  */
23 
24 /*
25  * Valid machtype values for group unknown
26  */
27 #define  MACH_UNKNOWN		0	/* whatever...			*/
28 
29 /*
30  * Valid machtype for group DEC
31  */
32 #define  MACH_DSUNKNOWN		0
33 #define  MACH_DS23100		1	/* DECstation 2100 or 3100	*/
34 #define  MACH_DS5100		2	/* DECsystem 5100		*/
35 #define  MACH_DS5000_200	3	/* DECstation 5000/200		*/
36 #define  MACH_DS5000_1XX	4	/* DECstation 5000/120, 125, 133, 150 */
37 #define  MACH_DS5000_XX		5	/* DECstation 5000/20, 25, 33, 50 */
38 #define  MACH_DS5000_2X0	6	/* DECstation 5000/240, 260	*/
39 #define  MACH_DS5400		7	/* DECsystem 5400		*/
40 #define  MACH_DS5500		8	/* DECsystem 5500		*/
41 #define  MACH_DS5800		9	/* DECsystem 5800		*/
42 #define  MACH_DS5900		10	/* DECsystem 5900		*/
43 
44 /*
45  * Valid machtype for group Mikrotik
46  */
47 #define MACH_MIKROTIK_RB532	0	/* Mikrotik RouterBoard 532	*/
48 #define MACH_MIKROTIK_RB532A	1	/* Mikrotik RouterBoard 532A	*/
49 
50 /*
51  * Valid machtype for Loongson family
52  */
53 enum loongson2ef_machine_type {
54 	MACH_LOONGSON_UNKNOWN,
55 	MACH_LEMOTE_FL2E,
56 	MACH_LEMOTE_FL2F,
57 	MACH_LEMOTE_ML2F7,
58 	MACH_LEMOTE_YL2F89,
59 	MACH_DEXXON_GDIUM2F10,
60 	MACH_LEMOTE_NAS,
61 	MACH_LEMOTE_LL2F,
62 	MACH_LOONGSON_END
63 };
64 
65 /*
66  * Valid machtype for group INGENIC
67  */
68 enum ingenic_machine_type {
69 	MACH_INGENIC_UNKNOWN,
70 	MACH_INGENIC_JZ4720,
71 	MACH_INGENIC_JZ4725,
72 	MACH_INGENIC_JZ4725B,
73 	MACH_INGENIC_JZ4730,
74 	MACH_INGENIC_JZ4740,
75 	MACH_INGENIC_JZ4750,
76 	MACH_INGENIC_JZ4755,
77 	MACH_INGENIC_JZ4760,
78 	MACH_INGENIC_JZ4770,
79 	MACH_INGENIC_JZ4775,
80 	MACH_INGENIC_JZ4780,
81 	MACH_INGENIC_X1000,
82 	MACH_INGENIC_X1000E,
83 	MACH_INGENIC_X1830,
84 	MACH_INGENIC_X2000,
85 	MACH_INGENIC_X2000E,
86 };
87 
88 extern char *system_type;
89 const char *get_system_type(void);
90 
91 extern unsigned long mips_machtype;
92 
93 extern void detect_memory_region(phys_addr_t start, phys_addr_t sz_min,  phys_addr_t sz_max);
94 
95 extern void prom_init(void);
96 extern void prom_free_prom_memory(void);
97 extern void prom_cleanup(void);
98 
99 extern void free_init_pages(const char *what,
100 			    unsigned long begin, unsigned long end);
101 
102 extern void (*free_init_pages_eva)(void *begin, void *end);
103 
104 /*
105  * Initial kernel command line, usually setup by prom_init()
106  */
107 extern char arcs_cmdline[COMMAND_LINE_SIZE];
108 
109 /*
110  * Registers a0, a1, a2 and a3 as passed to the kernel entry by firmware
111  */
112 extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;
113 
114 #ifdef CONFIG_USE_OF
115 #include <linux/libfdt.h>
116 #include <linux/of_fdt.h>
117 
118 extern char __appended_dtb[];
119 
120 static inline void *get_fdt(void)
121 {
122 	if (IS_ENABLED(CONFIG_MIPS_RAW_APPENDED_DTB) ||
123 	    IS_ENABLED(CONFIG_MIPS_ELF_APPENDED_DTB))
124 		if (fdt_magic(&__appended_dtb) == FDT_MAGIC)
125 			return &__appended_dtb;
126 
127 	if (fw_arg0 == -2) /* UHI interface */
128 		return (void *)fw_arg1;
129 
130 	if (IS_ENABLED(CONFIG_BUILTIN_DTB))
131 		if (&__dtb_start != &__dtb_end)
132 			return &__dtb_start;
133 
134 	return NULL;
135 }
136 #endif
137 
138 /*
139  * Platform memory detection hook called by arch_mem_init()
140  */
141 extern void plat_mem_setup(void);
142 
143 #ifdef CONFIG_SWIOTLB
144 /*
145  * Optional platform hook to call swiotlb_setup().
146  */
147 extern void plat_swiotlb_setup(void);
148 
149 #else
150 
151 static inline void plat_swiotlb_setup(void) {}
152 
153 #endif /* CONFIG_SWIOTLB */
154 
155 #ifdef CONFIG_USE_OF
156 /**
157  * plat_get_fdt() - Return a pointer to the platform's device tree blob
158  *
159  * This function provides a platform independent API to get a pointer to the
160  * flattened device tree blob. The interface between bootloader and kernel
161  * is not consistent across platforms so it is necessary to provide this
162  * API such that common startup code can locate the FDT.
163  *
164  * This is used by the KASLR code to get command line arguments and random
165  * seed from the device tree. Any platform wishing to use KASLR should
166  * provide this API and select SYS_SUPPORTS_RELOCATABLE.
167  *
168  * Return: Pointer to the flattened device tree blob.
169  */
170 extern void *plat_get_fdt(void);
171 
172 #ifdef CONFIG_RELOCATABLE
173 
174 /**
175  * plat_fdt_relocated() - Update platform's information about relocated dtb
176  *
177  * This function provides a platform-independent API to set platform's
178  * information about relocated DTB if it needs to be moved due to kernel
179  * relocation occurring at boot.
180  */
181 void plat_fdt_relocated(void *new_location);
182 
183 #endif /* CONFIG_RELOCATABLE */
184 #endif /* CONFIG_USE_OF */
185 
186 #endif /* _ASM_BOOTINFO_H */
187