Patrick Georgi | 021b703 | 2012-11-06 11:05:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007-2008 coresystems GmbH |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Patrick Georgi | 021b703 | 2012-11-06 11:05:38 +0100 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <string.h> |
| 18 | #include <device/pci.h> |
| 19 | #include <arch/acpi.h> |
| 20 | #include <cpu/x86/smm.h> |
| 21 | |
| 22 | void acpi_create_fadt(acpi_fadt_t * fadt, acpi_facs_t * facs, void *dsdt) |
| 23 | { |
| 24 | acpi_header_t *header = &(fadt->header); |
| 25 | u16 pmbase = pci_read_config16(dev_find_slot(0, PCI_DEVFN(0x1f,0)), 0x40) & 0xfffe; |
| 26 | |
| 27 | memset((void *) fadt, 0, sizeof(acpi_fadt_t)); |
| 28 | memcpy(header->signature, "FACP", 4); |
| 29 | header->length = sizeof(acpi_fadt_t); |
| 30 | header->revision = 3; |
| 31 | memcpy(header->oem_id, OEM_ID, 6); |
| 32 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 33 | memcpy(header->asl_compiler_id, ASLC, 4); |
| 34 | header->asl_compiler_revision = 0; |
| 35 | |
| 36 | fadt->firmware_ctrl = (unsigned long) facs; |
| 37 | fadt->dsdt = (unsigned long) dsdt; |
| 38 | fadt->model = 0x00; |
| 39 | fadt->preferred_pm_profile = PM_MOBILE; |
| 40 | fadt->sci_int = 0x9; |
| 41 | fadt->smi_cmd = APM_CNT; |
| 42 | fadt->acpi_enable = APM_CNT_ACPI_ENABLE; |
| 43 | fadt->acpi_disable = APM_CNT_ACPI_DISABLE; |
| 44 | fadt->s4bios_req = 0x0; |
| 45 | fadt->pstate_cnt = APM_CNT_PST_CONTROL; |
| 46 | |
| 47 | fadt->pm1a_evt_blk = pmbase; |
| 48 | fadt->pm1b_evt_blk = 0x0; |
| 49 | fadt->pm1a_cnt_blk = pmbase + 0x4; |
| 50 | fadt->pm1b_cnt_blk = 0x0; |
| 51 | fadt->pm2_cnt_blk = pmbase + 0x50; |
| 52 | fadt->pm_tmr_blk = pmbase + 0x8; |
| 53 | fadt->gpe0_blk = pmbase + 0x20; |
| 54 | fadt->gpe1_blk = 0; |
| 55 | |
| 56 | fadt->pm1_evt_len = 4; |
| 57 | fadt->pm1_cnt_len = 2; /* Upper word is reserved and |
| 58 | Linux complains about 32 bit. */ |
| 59 | fadt->pm2_cnt_len = 1; |
| 60 | fadt->pm_tmr_len = 4; |
| 61 | fadt->gpe0_blk_len = 16; |
| 62 | fadt->gpe1_blk_len = 0; |
| 63 | fadt->gpe1_base = 0; |
| 64 | fadt->cst_cnt = APM_CNT_CST_CONTROL; |
| 65 | fadt->p_lvl2_lat = 1; |
| 66 | fadt->p_lvl3_lat = 0x39; |
| 67 | fadt->flush_size = 0; |
| 68 | fadt->flush_stride = 0; |
| 69 | fadt->duty_offset = 1; |
| 70 | fadt->duty_width = 3; |
| 71 | fadt->day_alrm = 0xd; |
| 72 | fadt->mon_alrm = 0x00; |
| 73 | fadt->century = 0x32; |
| 74 | fadt->iapc_boot_arch = 0x00; |
| 75 | fadt->flags = ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED | |
| 76 | ACPI_FADT_SLEEP_BUTTON | ACPI_FADT_S4_RTC_WAKE | |
| 77 | ACPI_FADT_DOCKING_SUPPORTED | ACPI_FADT_RESET_REGISTER | |
| 78 | ACPI_FADT_PLATFORM_CLOCK; |
| 79 | |
| 80 | fadt->reset_reg.space_id = ACPI_ADDRESS_SPACE_IO; |
| 81 | fadt->reset_reg.bit_width = 8; |
| 82 | fadt->reset_reg.bit_offset = 0; |
| 83 | fadt->reset_reg.resv = 0; |
| 84 | fadt->reset_reg.addrl = 0xcf9; |
| 85 | fadt->reset_reg.addrh = 0; |
| 86 | fadt->reset_value = 0x06; |
| 87 | |
| 88 | fadt->x_firmware_ctl_l = 0; /* Set X_FIRMWARE_CTRL only if FACS is */ |
| 89 | fadt->x_firmware_ctl_h = 0; /* above 4GB. If X_FIRMWARE_CTRL is set, */ |
| 90 | /* then FIRMWARE_CTRL must be zero. */ |
| 91 | fadt->x_dsdt_l = (unsigned long)dsdt; |
| 92 | fadt->x_dsdt_h = 0; |
| 93 | |
| 94 | fadt->x_pm1a_evt_blk.space_id = 1; |
| 95 | fadt->x_pm1a_evt_blk.bit_width = 32; |
| 96 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
| 97 | fadt->x_pm1a_evt_blk.resv = 0; |
| 98 | fadt->x_pm1a_evt_blk.addrl = pmbase; |
| 99 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 100 | |
| 101 | fadt->x_pm1b_evt_blk.space_id = 0; |
| 102 | fadt->x_pm1b_evt_blk.bit_width = 0; |
| 103 | fadt->x_pm1b_evt_blk.bit_offset = 0; |
| 104 | fadt->x_pm1b_evt_blk.resv = 0; |
| 105 | fadt->x_pm1b_evt_blk.addrl = 0x0; |
| 106 | fadt->x_pm1b_evt_blk.addrh = 0x0; |
| 107 | |
| 108 | fadt->x_pm1a_cnt_blk.space_id = 1; |
| 109 | fadt->x_pm1a_cnt_blk.bit_width = 16; /* Upper word is reserved and |
| 110 | Linux complains about 32 bit. */ |
| 111 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
| 112 | fadt->x_pm1a_cnt_blk.resv = 0; |
| 113 | fadt->x_pm1a_cnt_blk.addrl = pmbase + 0x4; |
| 114 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 115 | |
| 116 | fadt->x_pm1b_cnt_blk.space_id = 0; |
| 117 | fadt->x_pm1b_cnt_blk.bit_width = 0; |
| 118 | fadt->x_pm1b_cnt_blk.bit_offset = 0; |
| 119 | fadt->x_pm1b_cnt_blk.resv = 0; |
| 120 | fadt->x_pm1b_cnt_blk.addrl = 0x0; |
| 121 | fadt->x_pm1b_cnt_blk.addrh = 0x0; |
| 122 | |
| 123 | fadt->x_pm2_cnt_blk.space_id = 1; |
| 124 | fadt->x_pm2_cnt_blk.bit_width = 8; |
| 125 | fadt->x_pm2_cnt_blk.bit_offset = 0; |
| 126 | fadt->x_pm2_cnt_blk.resv = 0; |
| 127 | fadt->x_pm2_cnt_blk.addrl = pmbase + 0x50; |
| 128 | fadt->x_pm2_cnt_blk.addrh = 0x0; |
| 129 | |
| 130 | fadt->x_pm_tmr_blk.space_id = 1; |
| 131 | fadt->x_pm_tmr_blk.bit_width = 32; |
| 132 | fadt->x_pm_tmr_blk.bit_offset = 0; |
| 133 | fadt->x_pm_tmr_blk.resv = 0; |
| 134 | fadt->x_pm_tmr_blk.addrl = pmbase + 0x8; |
| 135 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 136 | |
| 137 | fadt->x_gpe0_blk.space_id = 1; |
| 138 | fadt->x_gpe0_blk.bit_width = 128; |
| 139 | fadt->x_gpe0_blk.bit_offset = 0; |
| 140 | fadt->x_gpe0_blk.resv = 0; |
| 141 | fadt->x_gpe0_blk.addrl = pmbase + 0x20; |
| 142 | fadt->x_gpe0_blk.addrh = 0x0; |
| 143 | |
| 144 | fadt->x_gpe1_blk.space_id = 0; |
| 145 | fadt->x_gpe1_blk.bit_width = 0; |
| 146 | fadt->x_gpe1_blk.bit_offset = 0; |
| 147 | fadt->x_gpe1_blk.resv = 0; |
| 148 | fadt->x_gpe1_blk.addrl = 0x0; |
| 149 | fadt->x_gpe1_blk.addrh = 0x0; |
| 150 | |
| 151 | header->checksum = |
| 152 | acpi_checksum((void *) fadt, header->length); |
| 153 | } |