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