xref: /openbmc/u-boot/arch/x86/cpu/quark/acpi.c (revision 87a62bce)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com>
4  */
5 
6 #include <common.h>
7 #include <asm/acpi_table.h>
8 #include <asm/tables.h>
9 #include <asm/arch/global_nvs.h>
10 #include <asm/arch/iomap.h>
11 
12 void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs,
13 		      void *dsdt)
14 {
15 	struct acpi_table_header *header = &(fadt->header);
16 	u16 pmbase = ACPI_PM1_BASE_ADDRESS;
17 
18 	memset((void *)fadt, 0, sizeof(struct acpi_fadt));
19 
20 	acpi_fill_header(header, "FACP");
21 	header->length = sizeof(struct acpi_fadt);
22 	header->revision = 4;
23 
24 	fadt->firmware_ctrl = (u32)facs;
25 	fadt->dsdt = (u32)dsdt;
26 	fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED;
27 	fadt->sci_int = 9;
28 	fadt->smi_cmd = 0;
29 	fadt->acpi_enable = 0;
30 	fadt->acpi_disable = 0;
31 	fadt->s4bios_req = 0;
32 	fadt->pstate_cnt = 0;
33 	fadt->pm1a_evt_blk = pmbase;
34 	fadt->pm1b_evt_blk = 0x0;
35 	fadt->pm1a_cnt_blk = pmbase + 0x4;
36 	fadt->pm1b_cnt_blk = 0x0;
37 	fadt->pm2_cnt_blk = 0x0;
38 	fadt->pm_tmr_blk = pmbase + 0x8;
39 	fadt->gpe0_blk = ACPI_GPE0_BASE_ADDRESS;
40 	fadt->gpe1_blk = 0;
41 	fadt->pm1_evt_len = 4;
42 	fadt->pm1_cnt_len = 2;
43 	fadt->pm2_cnt_len = 0;
44 	fadt->pm_tmr_len = 4;
45 	fadt->gpe0_blk_len = 8;
46 	fadt->gpe1_blk_len = 0;
47 	fadt->gpe1_base = 0;
48 	fadt->cst_cnt = 0;
49 	fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED;
50 	fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED;
51 	fadt->flush_size = 0;
52 	fadt->flush_stride = 0;
53 	fadt->duty_offset = 1;
54 	fadt->duty_width = 3;
55 	fadt->day_alrm = 0x00;
56 	fadt->mon_alrm = 0x00;
57 	fadt->century = 0x00;
58 	fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES;
59 	fadt->flags = ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED |
60 		ACPI_FADT_POWER_BUTTON | ACPI_FADT_SLEEP_BUTTON |
61 		ACPI_FADT_S4_RTC_WAKE | ACPI_FADT_RESET_REGISTER |
62 		ACPI_FADT_PLATFORM_CLOCK;
63 
64 	fadt->reset_reg.space_id = ACPI_ADDRESS_SPACE_IO;
65 	fadt->reset_reg.bit_width = 8;
66 	fadt->reset_reg.bit_offset = 0;
67 	fadt->reset_reg.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
68 	fadt->reset_reg.addrl = IO_PORT_RESET;
69 	fadt->reset_reg.addrh = 0;
70 	fadt->reset_value = SYS_RST | RST_CPU;
71 
72 	fadt->x_firmware_ctl_l = (u32)facs;
73 	fadt->x_firmware_ctl_h = 0;
74 	fadt->x_dsdt_l = (u32)dsdt;
75 	fadt->x_dsdt_h = 0;
76 
77 	fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
78 	fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
79 	fadt->x_pm1a_evt_blk.bit_offset = 0;
80 	fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
81 	fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk;
82 	fadt->x_pm1a_evt_blk.addrh = 0x0;
83 
84 	fadt->x_pm1b_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
85 	fadt->x_pm1b_evt_blk.bit_width = 0;
86 	fadt->x_pm1b_evt_blk.bit_offset = 0;
87 	fadt->x_pm1b_evt_blk.access_size = 0;
88 	fadt->x_pm1b_evt_blk.addrl = 0x0;
89 	fadt->x_pm1b_evt_blk.addrh = 0x0;
90 
91 	fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
92 	fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
93 	fadt->x_pm1a_cnt_blk.bit_offset = 0;
94 	fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
95 	fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk;
96 	fadt->x_pm1a_cnt_blk.addrh = 0x0;
97 
98 	fadt->x_pm1b_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
99 	fadt->x_pm1b_cnt_blk.bit_width = 0;
100 	fadt->x_pm1b_cnt_blk.bit_offset = 0;
101 	fadt->x_pm1b_cnt_blk.access_size = 0;
102 	fadt->x_pm1b_cnt_blk.addrl = 0x0;
103 	fadt->x_pm1b_cnt_blk.addrh = 0x0;
104 
105 	fadt->x_pm2_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
106 	fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8;
107 	fadt->x_pm2_cnt_blk.bit_offset = 0;
108 	fadt->x_pm2_cnt_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
109 	fadt->x_pm2_cnt_blk.addrl = fadt->pm2_cnt_blk;
110 	fadt->x_pm2_cnt_blk.addrh = 0x0;
111 
112 	fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO;
113 	fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
114 	fadt->x_pm_tmr_blk.bit_offset = 0;
115 	fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
116 	fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk;
117 	fadt->x_pm_tmr_blk.addrh = 0x0;
118 
119 	fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO;
120 	fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8;
121 	fadt->x_gpe0_blk.bit_offset = 0;
122 	fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
123 	fadt->x_gpe0_blk.addrl = fadt->gpe0_blk;
124 	fadt->x_gpe0_blk.addrh = 0x0;
125 
126 	fadt->x_gpe1_blk.space_id = ACPI_ADDRESS_SPACE_IO;
127 	fadt->x_gpe1_blk.bit_width = 0;
128 	fadt->x_gpe1_blk.bit_offset = 0;
129 	fadt->x_gpe1_blk.access_size = 0;
130 	fadt->x_gpe1_blk.addrl = 0x0;
131 	fadt->x_gpe1_blk.addrh = 0x0;
132 
133 	header->checksum = table_compute_checksum(fadt, header->length);
134 }
135 
136 void acpi_create_gnvs(struct acpi_global_nvs *gnvs)
137 {
138 	/* quark is a uni-processor */
139 	gnvs->pcnt = 1;
140 }
141