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