xref: /linux/arch/mips/include/asm/mach-loongson64/boot_param.h (revision 164666fa66669d437bdcc8d5f1744a2aee73be41)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_MACH_LOONGSON64_BOOT_PARAM_H_
3 #define __ASM_MACH_LOONGSON64_BOOT_PARAM_H_
4 
5 #include <linux/types.h>
6 
7 #define SYSTEM_RAM_LOW		1
8 #define SYSTEM_RAM_HIGH		2
9 #define SYSTEM_RAM_RESERVED	3
10 #define PCI_IO			4
11 #define PCI_MEM			5
12 #define LOONGSON_CFG_REG	6
13 #define VIDEO_ROM		7
14 #define ADAPTER_ROM		8
15 #define ACPI_TABLE		9
16 #define SMBIOS_TABLE		10
17 #define MAX_MEMORY_TYPE		11
18 
19 #define LOONGSON3_BOOT_MEM_MAP_MAX 128
20 struct efi_memory_map_loongson {
21 	u16 vers;	/* version of efi_memory_map */
22 	u32 nr_map;	/* number of memory_maps */
23 	u32 mem_freq;	/* memory frequence */
24 	struct mem_map {
25 		u32 node_id;	/* node_id which memory attached to */
26 		u32 mem_type;	/* system memory, pci memory, pci io, etc. */
27 		u64 mem_start;	/* memory map start address */
28 		u32 mem_size;	/* each memory_map size, not the total size */
29 	} map[LOONGSON3_BOOT_MEM_MAP_MAX];
30 } __packed;
31 
32 enum loongson_cpu_type {
33 	Legacy_2E = 0x0,
34 	Legacy_2F = 0x1,
35 	Legacy_3A = 0x2,
36 	Legacy_3B = 0x3,
37 	Legacy_1A = 0x4,
38 	Legacy_1B = 0x5,
39 	Legacy_2G = 0x6,
40 	Legacy_2H = 0x7,
41 	Loongson_1A = 0x100,
42 	Loongson_1B = 0x101,
43 	Loongson_2E = 0x200,
44 	Loongson_2F = 0x201,
45 	Loongson_2G = 0x202,
46 	Loongson_2H = 0x203,
47 	Loongson_3A = 0x300,
48 	Loongson_3B = 0x301
49 };
50 
51 /*
52  * Capability and feature descriptor structure for MIPS CPU
53  */
54 struct efi_cpuinfo_loongson {
55 	u16 vers;     /* version of efi_cpuinfo_loongson */
56 	u32 processor_id; /* PRID, e.g. 6305, 6306 */
57 	u32 cputype;  /* Loongson_3A/3B, etc. */
58 	u32 total_node;   /* num of total numa nodes */
59 	u16 cpu_startup_core_id; /* Boot core id */
60 	u16 reserved_cores_mask;
61 	u32 cpu_clock_freq; /* cpu_clock */
62 	u32 nr_cpus;
63 } __packed;
64 
65 #define MAX_UARTS 64
66 struct uart_device {
67 	u32 iotype; /* see include/linux/serial_core.h */
68 	u32 uartclk;
69 	u32 int_offset;
70 	u64 uart_base;
71 } __packed;
72 
73 #define MAX_SENSORS 64
74 #define SENSOR_TEMPER  0x00000001
75 #define SENSOR_VOLTAGE 0x00000002
76 #define SENSOR_FAN     0x00000004
77 struct sensor_device {
78 	char name[32];  /* a formal name */
79 	char label[64]; /* a flexible description */
80 	u32 type;       /* SENSOR_* */
81 	u32 id;         /* instance id of a sensor-class */
82 	u32 fan_policy; /* see loongson_hwmon.h */
83 	u32 fan_percent;/* only for constant speed policy */
84 	u64 base_addr;  /* base address of device registers */
85 } __packed;
86 
87 struct system_loongson {
88 	u16 vers;     /* version of system_loongson */
89 	u32 ccnuma_smp; /* 0: no numa; 1: has numa */
90 	u32 sing_double_channel; /* 1:single; 2:double */
91 	u32 nr_uarts;
92 	struct uart_device uarts[MAX_UARTS];
93 	u32 nr_sensors;
94 	struct sensor_device sensors[MAX_SENSORS];
95 	char has_ec;
96 	char ec_name[32];
97 	u64 ec_base_addr;
98 	char has_tcm;
99 	char tcm_name[32];
100 	u64 tcm_base_addr;
101 	u64 workarounds; /* see workarounds.h */
102 } __packed;
103 
104 struct irq_source_routing_table {
105 	u16 vers;
106 	u16 size;
107 	u16 rtr_bus;
108 	u16 rtr_devfn;
109 	u32 vendor;
110 	u32 device;
111 	u32 PIC_type;   /* conform use HT or PCI to route to CPU-PIC */
112 	u64 ht_int_bit; /* 3A: 1<<24; 3B: 1<<16 */
113 	u64 ht_enable;  /* irqs used in this PIC */
114 	u32 node_id;    /* node id: 0x0-0; 0x1-1; 0x10-2; 0x11-3 */
115 	u64 pci_mem_start_addr;
116 	u64 pci_mem_end_addr;
117 	u64 pci_io_start_addr;
118 	u64 pci_io_end_addr;
119 	u64 pci_config_addr;
120 	u32 dma_mask_bits;
121 } __packed;
122 
123 struct interface_info {
124 	u16 vers; /* version of the specificition */
125 	u16 size;
126 	u8  flag;
127 	char description[64];
128 } __packed;
129 
130 #define MAX_RESOURCE_NUMBER 128
131 struct resource_loongson {
132 	u64 start; /* resource start address */
133 	u64 end;   /* resource end address */
134 	char name[64];
135 	u32 flags;
136 };
137 
138 struct archdev_data {};  /* arch specific additions */
139 
140 struct board_devices {
141 	char name[64];    /* hold the device name */
142 	u32 num_resources; /* number of device_resource */
143 	/* for each device's resource */
144 	struct resource_loongson resource[MAX_RESOURCE_NUMBER];
145 	/* arch specific additions */
146 	struct archdev_data archdata;
147 };
148 
149 struct loongson_special_attribute {
150 	u16 vers;     /* version of this special */
151 	char special_name[64]; /* special_atribute_name */
152 	u32 loongson_special_type; /* type of special device */
153 	/* for each device's resource */
154 	struct resource_loongson resource[MAX_RESOURCE_NUMBER];
155 };
156 
157 struct loongson_params {
158 	u64 memory_offset;	/* efi_memory_map_loongson struct offset */
159 	u64 cpu_offset;		/* efi_cpuinfo_loongson struct offset */
160 	u64 system_offset;	/* system_loongson struct offset */
161 	u64 irq_offset;		/* irq_source_routing_table struct offset */
162 	u64 interface_offset;	/* interface_info struct offset */
163 	u64 special_offset;	/* loongson_special_attribute struct offset */
164 	u64 boarddev_table_offset;  /* board_devices offset */
165 };
166 
167 struct smbios_tables {
168 	u16 vers;     /* version of smbios */
169 	u64 vga_bios; /* vga_bios address */
170 	struct loongson_params lp;
171 };
172 
173 struct efi_reset_system_t {
174 	u64 ResetCold;
175 	u64 ResetWarm;
176 	u64 ResetType;
177 	u64 Shutdown;
178 	u64 DoSuspend; /* NULL if not support */
179 };
180 
181 struct efi_loongson {
182 	u64 mps;	/* MPS table */
183 	u64 acpi;	/* ACPI table (IA64 ext 0.71) */
184 	u64 acpi20;	/* ACPI table (ACPI 2.0) */
185 	struct smbios_tables smbios;	/* SM BIOS table */
186 	u64 sal_systab;	/* SAL system table */
187 	u64 boot_info;	/* boot info table */
188 };
189 
190 struct boot_params {
191 	struct efi_loongson efi;
192 	struct efi_reset_system_t reset_system;
193 };
194 
195 enum loongson_bridge_type {
196 	LS7A = 1,
197 	RS780E = 2,
198 	VIRTUAL = 3
199 };
200 
201 extern struct efi_memory_map_loongson *loongson_memmap;
202 extern struct loongson_system_configuration loongson_sysconf;
203 
204 extern struct board_devices *eboard;
205 extern struct interface_info *einter;
206 extern struct loongson_special_attribute *especial;
207 
208 extern u32 node_id_offset;
209 extern void ls7a_early_config(void);
210 extern void rs780e_early_config(void);
211 extern void virtual_early_config(void);
212 
213 #endif
214