Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * ACPI - create the Fixed ACPI Description Tables (FADT) |
| 3 | * |
| 4 | * Copyright (C) 2004 Nick Barker <nick.barker9@btinternet.com> |
| 5 | * Copyright (C) 2009 One Laptop per Child, Association, Inc. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <string.h> |
| 19 | #include <arch/acpi.h> |
Uwe Hermann | 5df4168 | 2010-09-25 16:17:20 +0000 | [diff] [blame] | 20 | #include "northbridge/via/vx800/vx800.h" |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 21 | |
Uwe Hermann | d64f403 | 2009-06-07 14:38:32 +0000 | [diff] [blame] | 22 | void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt) |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 23 | { |
| 24 | acpi_header_t *header = &(fadt->header); |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 25 | |
| 26 | memset((void *)fadt, 0, sizeof(acpi_fadt_t)); |
| 27 | memcpy(header->signature, "FACP", 4); |
| 28 | header->length = 244; |
Scott Duplichan | 7c1fb7b | 2010-10-24 16:22:11 +0000 | [diff] [blame] | 29 | header->revision = 3; |
Stefan Reinauer | 03f82bd | 2011-09-20 22:36:32 +0200 | [diff] [blame] | 30 | memcpy(header->oem_id, OEM_ID, 6); |
| 31 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 32 | memcpy(header->asl_compiler_id, ASLC, 4); |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 33 | header->asl_compiler_revision = 0; |
| 34 | |
Stefan Reinauer | 56a684a | 2010-04-07 15:40:26 +0000 | [diff] [blame] | 35 | fadt->firmware_ctrl = (u32)facs; |
| 36 | fadt->dsdt = (u32)dsdt; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 37 | fadt->preferred_pm_profile = 0; |
| 38 | fadt->sci_int = 0x9; |
| 39 | |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 40 | fadt->smi_cmd = VX800_ACPI_IO_BASE + 0x2F; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 41 | fadt->acpi_enable = 0xA1; |
| 42 | fadt->acpi_disable = 0xA0; |
| 43 | |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 44 | /* |
| 45 | * Value 42F,A1,A0, if we don't want SMI, then set them to zero. |
| 46 | * fadt->smi_cmd = 0x0; |
| 47 | * fadt->acpi_enable = 0x0; |
| 48 | * fadt->acpi_disable = 0x0; |
| 49 | */ |
| 50 | |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 51 | fadt->s4bios_req = 0x0; |
| 52 | fadt->pstate_cnt = 0x0; |
| 53 | |
| 54 | fadt->pm1a_evt_blk = VX800_ACPI_IO_BASE; |
| 55 | fadt->pm1b_evt_blk = 0x0; |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 56 | fadt->pm1a_cnt_blk = VX800_ACPI_IO_BASE + 0x4; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 57 | fadt->pm1b_cnt_blk = 0x0; |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 58 | fadt->pm2_cnt_blk = 0x22; /* To support cpu-c3. */ |
| 59 | /* fadt->pm2_cnt_blk = 0x0; */ |
| 60 | fadt->pm_tmr_blk = VX800_ACPI_IO_BASE + 0x8; |
| 61 | fadt->gpe0_blk = VX800_ACPI_IO_BASE + 0x20; |
| 62 | fadt->gpe1_blk = VX800_ACPI_IO_BASE + 0x50; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 63 | |
| 64 | fadt->pm1_evt_len = 4; |
| 65 | fadt->pm1_cnt_len = 2; |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 66 | fadt->pm2_cnt_len = 1; /* To support cpu-c3. */ |
| 67 | /* fadt->pm2_cnt_len = 0; */ |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 68 | |
| 69 | fadt->pm_tmr_len = 4; |
| 70 | fadt->gpe0_blk_len = 4; |
| 71 | fadt->gpe1_blk_len = 4; |
| 72 | fadt->gpe1_base = 0x10; |
| 73 | fadt->cst_cnt = 0; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 74 | |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 75 | fadt->p_lvl2_lat = 0x50; /* This is the coreboot source. */ |
| 76 | fadt->p_lvl3_lat = 0x320; |
| 77 | /* fadt->p_lvl2_lat = 0x80; */ |
| 78 | /* fadt->p_lvl3_lat = 0x800; */ |
| 79 | /* fadt->p_lvl2_lat = 0x1; */ |
| 80 | /* fadt->p_lvl3_lat = 0x23; */ |
| 81 | |
| 82 | /* fadt->p_lvl2_lat = 0x200; */ /* Disable. */ |
| 83 | /* fadt->p_lvl3_lat = 0x2000; */ |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 84 | |
| 85 | fadt->flush_size = 0; |
| 86 | fadt->flush_stride = 0; |
| 87 | fadt->duty_offset = 0; |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 88 | /* fadt->duty_width = 1; */ |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 89 | fadt->duty_width = 4; |
| 90 | fadt->day_alrm = 0x7d; |
| 91 | fadt->mon_alrm = 0x7e; |
| 92 | fadt->century = 0x32; |
| 93 | fadt->iapc_boot_arch = 0x0; |
| 94 | fadt->flags = 0xa5; |
| 95 | |
| 96 | fadt->reset_reg.space_id = 0; |
| 97 | fadt->reset_reg.bit_width = 0; |
| 98 | fadt->reset_reg.bit_offset = 0; |
| 99 | fadt->reset_reg.resv = 0; |
| 100 | fadt->reset_reg.addrl = 0x0; |
| 101 | fadt->reset_reg.addrh = 0x0; |
| 102 | |
| 103 | fadt->reset_value = 0; |
Stefan Reinauer | 56a684a | 2010-04-07 15:40:26 +0000 | [diff] [blame] | 104 | fadt->x_firmware_ctl_l = (u32)facs; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 105 | fadt->x_firmware_ctl_h = 0; |
Stefan Reinauer | 56a684a | 2010-04-07 15:40:26 +0000 | [diff] [blame] | 106 | fadt->x_dsdt_l = (u32)dsdt; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 107 | fadt->x_dsdt_h = 0; |
| 108 | |
| 109 | fadt->x_pm1a_evt_blk.space_id = 1; |
| 110 | fadt->x_pm1a_evt_blk.bit_width = 4; |
| 111 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
| 112 | fadt->x_pm1a_evt_blk.resv = 0; |
| 113 | fadt->x_pm1a_evt_blk.addrl = VX800_ACPI_IO_BASE; |
| 114 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 115 | |
| 116 | fadt->x_pm1b_evt_blk.space_id = 1; |
| 117 | fadt->x_pm1b_evt_blk.bit_width = 4; |
| 118 | fadt->x_pm1b_evt_blk.bit_offset = 0; |
| 119 | fadt->x_pm1b_evt_blk.resv = 0; |
| 120 | fadt->x_pm1b_evt_blk.addrl = 0x0; |
| 121 | fadt->x_pm1b_evt_blk.addrh = 0x0; |
| 122 | |
| 123 | fadt->x_pm1a_cnt_blk.space_id = 1; |
| 124 | fadt->x_pm1a_cnt_blk.bit_width = 2; |
| 125 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
| 126 | fadt->x_pm1a_cnt_blk.resv = 0; |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 127 | fadt->x_pm1a_cnt_blk.addrl = VX800_ACPI_IO_BASE + 0x4; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 128 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 129 | |
| 130 | fadt->x_pm1b_cnt_blk.space_id = 1; |
| 131 | fadt->x_pm1b_cnt_blk.bit_width = 2; |
| 132 | fadt->x_pm1b_cnt_blk.bit_offset = 0; |
| 133 | fadt->x_pm1b_cnt_blk.resv = 0; |
| 134 | fadt->x_pm1b_cnt_blk.addrl = 0x0; |
| 135 | fadt->x_pm1b_cnt_blk.addrh = 0x0; |
| 136 | |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 137 | /* fadt->x_pm2_cnt_blk.space_id = 1; */ |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 138 | fadt->x_pm2_cnt_blk.space_id = 0; |
| 139 | fadt->x_pm2_cnt_blk.bit_width = 0; |
| 140 | fadt->x_pm2_cnt_blk.bit_offset = 0; |
| 141 | fadt->x_pm2_cnt_blk.resv = 0; |
| 142 | fadt->x_pm2_cnt_blk.addrl = 0x0; |
| 143 | fadt->x_pm2_cnt_blk.addrh = 0x0; |
| 144 | |
| 145 | fadt->x_pm_tmr_blk.space_id = 1; |
| 146 | fadt->x_pm_tmr_blk.bit_width = 4; |
| 147 | fadt->x_pm_tmr_blk.bit_offset = 0; |
| 148 | fadt->x_pm_tmr_blk.resv = 0; |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 149 | fadt->x_pm_tmr_blk.addrl = VX800_ACPI_IO_BASE + 0x8; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 150 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 151 | |
| 152 | fadt->x_gpe0_blk.space_id = 1; |
| 153 | fadt->x_gpe0_blk.bit_width = 0; |
| 154 | fadt->x_gpe0_blk.bit_offset = 0; |
| 155 | fadt->x_gpe0_blk.resv = 0; |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 156 | fadt->x_gpe0_blk.addrl = VX800_ACPI_IO_BASE + 0x20; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 157 | fadt->x_gpe0_blk.addrh = 0x0; |
| 158 | |
| 159 | fadt->x_gpe1_blk.space_id = 1; |
| 160 | fadt->x_gpe1_blk.bit_width = 0; |
| 161 | fadt->x_gpe1_blk.bit_offset = 0; |
| 162 | fadt->x_gpe1_blk.resv = 0; |
| 163 | fadt->x_gpe1_blk.addrl = 0x0; |
| 164 | fadt->x_gpe1_blk.addrh = 0x0; |
| 165 | |
| 166 | header->checksum = acpi_checksum((void *)fadt, sizeof(acpi_fadt_t)); |
| 167 | } |