Vladimir Serbinenko | b1ccccc | 2014-02-19 22:20:14 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 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. |
Vladimir Serbinenko | b1ccccc | 2014-02-19 22:20:14 +0100 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <arch/io.h> |
| 18 | #include <console/console.h> |
| 19 | #include <cpu/x86/smm.h> |
| 20 | #include "southbridge/intel/ibexpeak/nvs.h" |
| 21 | #include "southbridge/intel/ibexpeak/pch.h" |
| 22 | #include "southbridge/intel/ibexpeak/me.h" |
Alexander Couzens | 60d44dd0 | 2015-01-27 11:57:43 +0100 | [diff] [blame] | 23 | #include <northbridge/intel/nehalem/nehalem.h> |
Vladimir Serbinenko | b1ccccc | 2014-02-19 22:20:14 +0100 | [diff] [blame] | 24 | #include <cpu/intel/model_2065x/model_2065x.h> |
| 25 | #include <ec/acpi/ec.h> |
| 26 | #include <pc80/mc146818rtc.h> |
| 27 | #include <delay.h> |
| 28 | |
Vladimir Serbinenko | b1ccccc | 2014-02-19 22:20:14 +0100 | [diff] [blame] | 29 | static void mainboard_smm_init(void) |
| 30 | { |
| 31 | printk(BIOS_DEBUG, "initializing SMI\n"); |
| 32 | } |
| 33 | |
| 34 | int mainboard_io_trap_handler(int smif) |
| 35 | { |
| 36 | static int smm_initialized; |
| 37 | |
| 38 | if (!smm_initialized) { |
| 39 | mainboard_smm_init(); |
| 40 | smm_initialized = 1; |
| 41 | } |
| 42 | |
| 43 | switch (smif) { |
| 44 | |
| 45 | default: |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | /* On success, the IO Trap Handler returns 1 |
| 50 | * On failure, the IO Trap Handler returns a value != 1 */ |
| 51 | return 1; |
| 52 | } |
| 53 | |
| 54 | void mainboard_smi_gpi(u32 gpi_sts) |
| 55 | { |
| 56 | } |
| 57 | |
| 58 | static int mainboard_finalized = 0; |
| 59 | |
| 60 | int mainboard_smi_apmc(u8 data) |
| 61 | { |
Vladimir Serbinenko | b1ccccc | 2014-02-19 22:20:14 +0100 | [diff] [blame] | 62 | u8 tmp; |
Vladimir Serbinenko | b1ccccc | 2014-02-19 22:20:14 +0100 | [diff] [blame] | 63 | switch (data) { |
| 64 | case APM_CNT_FINALIZE: |
| 65 | printk(BIOS_DEBUG, "APMC: FINALIZE\n"); |
| 66 | if (mainboard_finalized) { |
| 67 | printk(BIOS_DEBUG, "APMC#: Already finalized\n"); |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | intel_me_finalize_smm(); |
| 72 | intel_pch_finalize_smm(); |
Alexander Couzens | 60d44dd0 | 2015-01-27 11:57:43 +0100 | [diff] [blame] | 73 | intel_nehalem_finalize_smm(); |
Vladimir Serbinenko | b1ccccc | 2014-02-19 22:20:14 +0100 | [diff] [blame] | 74 | intel_model_2065x_finalize_smm(); |
| 75 | |
| 76 | mainboard_finalized = 1; |
| 77 | break; |
| 78 | case APM_CNT_ACPI_ENABLE: |
| 79 | tmp = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xbb); |
| 80 | tmp &= ~0x03; |
| 81 | tmp |= 0x02; |
| 82 | pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xbb, tmp); |
| 83 | break; |
| 84 | case APM_CNT_ACPI_DISABLE: |
| 85 | tmp = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xbb); |
| 86 | tmp &= ~0x03; |
| 87 | tmp |= 0x01; |
| 88 | pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xbb, tmp); |
| 89 | break; |
| 90 | default: |
| 91 | break; |
| 92 | } |
| 93 | return 0; |
| 94 | } |