blob: 17a4d344913ffbb4532ff03c4939368e89baf6c3 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenk591dda52002-11-18 00:14:45 +00002/*
Wolfgang Denkf710efd2010-07-24 20:22:02 +02003 * (C) Copyright 2002-2010
wdenk591dda52002-11-18 00:14:45 +00004 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
wdenk591dda52002-11-18 00:14:45 +00005 */
6
7#ifndef __ASM_GBL_DATA_H
8#define __ASM_GBL_DATA_H
Simon Glass3ac47d72012-12-13 20:48:30 +00009
10#ifndef __ASSEMBLY__
11
Simon Glass9909bf32015-08-10 20:44:31 -060012#include <asm/processor.h>
13
Simon Glass30580fc2014-11-12 22:42:23 -070014enum pei_boot_mode_t {
15 PEI_BOOT_NONE = 0,
16 PEI_BOOT_SOFT_RESET,
17 PEI_BOOT_RESUME,
18
19};
20
Simon Glassd21f34e2016-03-11 22:07:26 -070021struct dimm_info {
22 uint32_t dimm_size;
23 uint16_t ddr_type;
24 uint16_t ddr_frequency;
25 uint8_t rank_per_dimm;
26 uint8_t channel_num;
27 uint8_t dimm_num;
28 uint8_t bank_locator;
29 /* The 5th byte is '\0' for the end of string */
30 uint8_t serial[5];
31 /* The 19th byte is '\0' for the end of string */
32 uint8_t module_part_number[19];
33 uint16_t mod_id;
34 uint8_t mod_type;
35 uint8_t bus_width;
36} __packed;
37
38struct pei_memory_info {
39 uint8_t dimm_cnt;
40 /* Maximum num of dimm is 8 */
41 struct dimm_info dimm[8];
42} __packed;
43
Simon Glass268eefd2014-11-12 22:42:28 -070044struct memory_area {
45 uint64_t start;
46 uint64_t size;
47};
48
49struct memory_info {
50 int num_areas;
51 uint64_t total_memory;
52 uint64_t total_32bit_memory;
53 struct memory_area area[CONFIG_NR_DRAM_BANKS];
54};
55
Simon Glass7bf5b9e2015-01-01 16:18:07 -070056#define MAX_MTRR_REQUESTS 8
57
58/**
59 * A request for a memory region to be set up in a particular way. These
60 * requests are processed before board_init_r() is called. They are generally
61 * optional and can be ignored with some performance impact.
62 */
63struct mtrr_request {
64 int type; /* MTRR_TYPE_... */
65 uint64_t start;
66 uint64_t size;
67};
68
Simon Glass3ac47d72012-12-13 20:48:30 +000069/* Architecture-specific global data */
70struct arch_global_data {
Simon Glass9909bf32015-08-10 20:44:31 -060071 u64 gdt[X86_GDT_NUM_ENTRIES] __aligned(16);
Bin Meng47eac042015-01-22 11:29:40 +080072 struct global_data *gd_addr; /* Location of Global Data */
73 uint8_t x86; /* CPU family */
74 uint8_t x86_vendor; /* CPU vendor */
75 uint8_t x86_model;
76 uint8_t x86_mask;
Bin Meng035c1d22014-11-09 22:18:56 +080077 uint32_t x86_device;
Simon Glass6fa6e4a2013-02-28 19:26:12 +000078 uint64_t tsc_base; /* Initial value returned by rdtsc() */
Simon Glass471919d2017-09-05 19:49:46 -060079 unsigned long clock_rate; /* Clock rate of timer in Hz */
Simon Glass347c05b2013-02-28 19:26:15 +000080 void *new_fdt; /* Relocated FDT */
Simon Glass1f4476c2014-11-06 13:20:10 -070081 uint32_t bist; /* Built-in self test value */
Simon Glass30580fc2014-11-12 22:42:23 -070082 enum pei_boot_mode_t pei_boot_mode;
Simon Glass60af0172014-11-12 22:42:24 -070083 const struct pch_gpio_map *gpio_map; /* board GPIO map */
Simon Glass268eefd2014-11-12 22:42:28 -070084 struct memory_info meminfo; /* Memory information */
Simon Glassd21f34e2016-03-11 22:07:26 -070085 struct pei_memory_info pei_meminfo; /* PEI memory information */
Park, Aiden6e3cc362019-08-03 08:30:12 +000086#ifdef CONFIG_USE_HOB
Bin Meng47eac042015-01-22 11:29:40 +080087 void *hob_list; /* FSP HOB list */
Bin Meng005f0af2014-12-12 21:05:31 +080088#endif
Simon Glass7bf5b9e2015-01-01 16:18:07 -070089 struct mtrr_request mtrr_req[MAX_MTRR_REQUESTS];
90 int mtrr_req_count;
Bin Meng47eac042015-01-22 11:29:40 +080091 int has_mtrr;
Simon Glass428dfa42015-01-19 22:16:14 -070092 /* MRC training data to save for the next boot */
93 char *mrc_output;
94 unsigned int mrc_output_len;
Simon Glassf95ad8c2015-08-04 12:33:57 -060095 ulong table; /* Table pointer from previous loader */
Simon Glass37e706d2017-01-16 07:04:17 -070096 int turbo_state; /* Current turbo state */
Simon Glassf64d6f72017-01-16 07:04:16 -070097 struct irq_routing_table *pirq_routing_table;
Bin Meng322ec3e2016-05-11 07:44:59 -070098#ifdef CONFIG_SEABIOS
99 u32 high_table_ptr;
100 u32 high_table_limit;
101#endif
Bin Mengef61f772017-04-21 07:24:32 -0700102#ifdef CONFIG_HAVE_ACPI_RESUME
Bin Meng2ee5b852017-04-21 07:24:33 -0700103 int prev_sleep_state; /* Previous sleep state ACPI_S0/1../5 */
Bin Meng353f5cb2017-04-21 07:24:47 -0700104 ulong backup_mem; /* Backup memory address for S3 */
Bin Mengef61f772017-04-21 07:24:32 -0700105#endif
Simon Glass3ac47d72012-12-13 20:48:30 +0000106};
107
Graeme Russ3c28f482011-09-01 00:48:27 +0000108#endif
wdenk591dda52002-11-18 00:14:45 +0000109
Simon Glassd3887632012-12-13 20:49:27 +0000110#include <asm-generic/global_data.h>
111
112#ifndef __ASSEMBLY__
Simon Glass590aef72017-01-16 07:03:59 -0700113# if defined(CONFIG_EFI_APP) || CONFIG_IS_ENABLED(X86_64)
Simon Glass7f65c092015-07-31 09:31:35 -0600114
Simon Glass590aef72017-01-16 07:03:59 -0700115/* TODO(sjg@chromium.org): Consider using a fixed register for gd on x86_64 */
Simon Glass7f65c092015-07-31 09:31:35 -0600116#define gd global_data_ptr
117
118#define DECLARE_GLOBAL_DATA_PTR extern struct global_data *global_data_ptr
119# else
Simon Glass42081ce2013-06-11 11:14:52 -0700120static inline __attribute__((no_instrument_function)) gd_t *get_fs_gd_ptr(void)
Graeme Russ35368962011-12-31 22:58:15 +1100121{
122 gd_t *gd_ptr;
123
Simon Glass590aef72017-01-16 07:03:59 -0700124#if CONFIG_IS_ENABLED(X86_64)
125 asm volatile("fs mov 0, %0\n" : "=r" (gd_ptr));
126#else
Graeme Russ35368962011-12-31 22:58:15 +1100127 asm volatile("fs movl 0, %0\n" : "=r" (gd_ptr));
Simon Glass590aef72017-01-16 07:03:59 -0700128#endif
Graeme Russ35368962011-12-31 22:58:15 +1100129
130 return gd_ptr;
131}
132
133#define gd get_fs_gd_ptr()
Graeme Russ5fb91cc2010-10-07 20:03:29 +1100134
Simon Glass5d18dc92015-07-31 09:31:28 -0600135#define DECLARE_GLOBAL_DATA_PTR
Simon Glass7f65c092015-07-31 09:31:35 -0600136# endif
Simon Glass5d18dc92015-07-31 09:31:28 -0600137
Graeme Russ5fb91cc2010-10-07 20:03:29 +1100138#endif
139
wdenk591dda52002-11-18 00:14:45 +0000140#endif /* __ASM_GBL_DATA_H */