blob: cade43d3ea1d7c4b613d8df765de253805d6080e [file] [log] [blame]
Harald Gutmann62cfe162009-06-19 12:03:40 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2004 Nick Barker <nick.barker9@btinternet.com>
5 * Copyright (C) 2007 Rudolf Marek <r.marek@assembler.cz>
6 * Copyright (C) 2009 Harald Gutmann <harald.gutmann@gmx.net>
7 *
Uwe Hermannc70e9fc2010-02-15 23:10:19 +00008 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
Harald Gutmann62cfe162009-06-19 12:03:40 +000012 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
Harald Gutmann62cfe162009-06-19 12:03:40 +000017 */
18
19#include <console/console.h>
20#include <string.h>
21#include <arch/acpi.h>
22#include <arch/io.h>
23#include <device/device.h>
24#include <device/pci_ids.h>
25
26extern unsigned pm_base;
27
28/* Create the Fixed ACPI Description Tables (FADT) for this board. */
29void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt)
30{
31 acpi_header_t *header = &(fadt->header);
32 device_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000033 int is_mcp55 = 0;
Harald Gutmann62cfe162009-06-19 12:03:40 +000034 dev = dev_find_device(PCI_VENDOR_ID_NVIDIA,
35 PCI_DEVICE_ID_NVIDIA_MCP55_LPC, 0);
36 if (dev)
37 is_mcp55 = 1;
38
39 memset((void *) fadt, 0, sizeof(acpi_fadt_t));
40 memcpy(header->signature, "FACP", 4);
41 header->length = sizeof(acpi_fadt_t);
42 header->revision = 1;
Stefan Reinauer03f82bd2011-09-20 22:36:32 +020043 memcpy(header->oem_id, OEM_ID, 6);
44 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
45 memcpy(header->asl_compiler_id, ASLC, 4);
Harald Gutmann62cfe162009-06-19 12:03:40 +000046 header->asl_compiler_revision = 42;
47
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000048 printk(BIOS_INFO, "ACPI: pm_base: %u...\n", pm_base);
Harald Gutmann62cfe162009-06-19 12:03:40 +000049
Stefan Reinauer4154c662010-04-14 10:12:23 +000050 fadt->firmware_ctrl = (u32)facs;
51 fadt->dsdt = (u32)dsdt;
Harald Gutmann62cfe162009-06-19 12:03:40 +000052 fadt->preferred_pm_profile = 1; //check
53 fadt->sci_int = 9;
54 /* disable system management mode by setting to 0 */
Stefan Reinauer14e22772010-04-27 06:56:47 +000055 fadt->smi_cmd = 0x0; //pm_base+0x42e; (value from proprietary acpi fadt)
Harald Gutmann62cfe162009-06-19 12:03:40 +000056 fadt->acpi_enable = 0xa1;
57 fadt->acpi_disable = 0xa0;
58 fadt->s4bios_req = 0x0;
59 fadt->pstate_cnt = 0x0;
60
61 fadt->pm1a_evt_blk = pm_base;
62 fadt->pm1b_evt_blk = 0x0;
63 fadt->pm1a_cnt_blk = pm_base + 0x4;
64 fadt->pm1b_cnt_blk = 0x0;
65 fadt->pm2_cnt_blk = pm_base + 0x1c;
66 fadt->pm_tmr_blk = pm_base + 0x8;
67 fadt->gpe0_blk = pm_base + 0x20;
68
69 fadt->pm1_evt_len = 4;
70 fadt->pm1_cnt_len = 2;
71 fadt->pm2_cnt_len = 1;
72 fadt->pm_tmr_len = 4;
73 fadt->gpe0_blk_len = 8;
74 if (is_mcp55) {
75 fadt->gpe1_blk = pm_base + 0x4a0;
76 fadt->gpe1_base = 0x20;
77 fadt->gpe1_blk_len = 0x10;
78 }
79 else {
80 fadt->gpe1_blk = 0x0;
81 fadt->gpe1_base = 0x0;
82 fadt->gpe1_blk_len = 0x0;
83 }
84
85 fadt->cst_cnt = 0;
86 fadt->p_lvl2_lat = 0x65;
87 fadt->p_lvl3_lat = 0x3e9;
88 fadt->flush_size = 0;
89 fadt->flush_stride = 0;
90 fadt->duty_offset = 1;
Stefan Reinauer14e22772010-04-27 06:56:47 +000091 fadt->duty_width = 3;
Harald Gutmann62cfe162009-06-19 12:03:40 +000092 fadt->day_alrm = 0x7d;
93 fadt->mon_alrm = 0x7e;
94 fadt->century = 0x32;
95
96 fadt->iapc_boot_arch = 0x0;
97
98 fadt->flags = 0x4a5;
99 fadt->reset_reg.space_id = 0;
100 fadt->reset_reg.bit_width = 0;
101 fadt->reset_reg.bit_offset = 0;
102 fadt->reset_reg.resv = 0;
103 fadt->reset_reg.addrl = 0x0;
104 fadt->reset_reg.addrh = 0x0;
105
106 fadt->reset_value = 0;
Stefan Reinauer4154c662010-04-14 10:12:23 +0000107 fadt->x_firmware_ctl_l = (u32)facs;
Harald Gutmann62cfe162009-06-19 12:03:40 +0000108 fadt->x_firmware_ctl_h = 0;
Stefan Reinauer4154c662010-04-14 10:12:23 +0000109 fadt->x_dsdt_l = (u32)dsdt;
Harald Gutmann62cfe162009-06-19 12:03:40 +0000110 fadt->x_dsdt_h = 0;
111
112 fadt->x_pm1a_evt_blk.space_id = 1;
113 fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
114 fadt->x_pm1a_evt_blk.bit_offset = 0;
115 fadt->x_pm1a_evt_blk.resv = 0;
116 fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk;
117 fadt->x_pm1a_evt_blk.addrh = 0x0;
118
119 fadt->x_pm1b_evt_blk.space_id = 1;
120 fadt->x_pm1b_evt_blk.bit_width = fadt->pm1_evt_len * 8;
121 fadt->x_pm1b_evt_blk.bit_offset = 0;
122 fadt->x_pm1b_evt_blk.resv = 0;
123 fadt->x_pm1b_evt_blk.addrl = fadt->pm1b_evt_blk;
124 fadt->x_pm1b_evt_blk.addrh = 0x0;
125
126 fadt->x_pm1a_cnt_blk.space_id = 1;
127 fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
128 fadt->x_pm1a_cnt_blk.bit_offset = 0;
129 fadt->x_pm1a_cnt_blk.resv = 0;
130 fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk;
131 fadt->x_pm1a_cnt_blk.addrh = 0x0;
132
133 fadt->x_pm1b_cnt_blk.space_id = 1;
134 fadt->x_pm1b_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
135 fadt->x_pm1b_cnt_blk.bit_offset = 0;
136 fadt->x_pm1b_cnt_blk.resv = 0;
137 fadt->x_pm1b_cnt_blk.addrl = fadt->pm1b_cnt_blk;
138 fadt->x_pm1b_cnt_blk.addrh = 0x0;
139
140 fadt->x_pm2_cnt_blk.space_id = 1;
141 fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8;
142 fadt->x_pm2_cnt_blk.bit_offset = 0;
143 fadt->x_pm2_cnt_blk.resv = 0;
144 fadt->x_pm2_cnt_blk.addrl = fadt->pm2_cnt_blk;
145 fadt->x_pm2_cnt_blk.addrh = 0x0;
146
147 fadt->x_pm_tmr_blk.space_id = 1;
148 fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
149 fadt->x_pm_tmr_blk.bit_offset = 0;
150 fadt->x_pm_tmr_blk.resv = 0;
151 fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk;
152 fadt->x_pm_tmr_blk.addrh = 0x0;
153
154 fadt->x_gpe0_blk.space_id = 1;
155 fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8;
156 fadt->x_gpe0_blk.bit_offset = 0;
157 fadt->x_gpe0_blk.resv = 0;
158 fadt->x_gpe0_blk.addrl = fadt->gpe0_blk;
159 fadt->x_gpe0_blk.addrh = 0x0;
160
161 fadt->x_gpe1_blk.space_id = 1;
Idwer Volleringd26da9c2013-12-22 21:38:18 +0000162 fadt->x_gpe1_blk.bit_width = fadt->gpe1_blk_len * 8;
Harald Gutmann62cfe162009-06-19 12:03:40 +0000163 fadt->x_gpe1_blk.bit_offset = 0;
164 fadt->x_gpe1_blk.resv = 0;
165 fadt->x_gpe1_blk.addrl = fadt->gpe1_blk;
166 fadt->x_gpe1_blk.addrh = 0x0;
167
168 header->checksum = acpi_checksum((void *) fadt, header->length);
169}