Alexandru Gagniuc | 2dbd08f | 2014-04-10 14:35:59 -0500 | [diff] [blame] | 1 | /* |
Martin Roth | ebace9f | 2018-05-26 18:56:17 -0600 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Alexandru Gagniuc | 2dbd08f | 2014-04-10 14:35:59 -0500 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2014 Alexandru Gagniuc <mr.nuke.me@gmail.com> |
Martin Roth | ebace9f | 2018-05-26 18:56:17 -0600 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License, or (at your |
| 9 | * option) any later version. |
| 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. |
| 15 | */ |
| 16 | |
| 17 | /* |
| 18 | * Utilities for SMI handlers and SMM setup |
Alexandru Gagniuc | 2dbd08f | 2014-04-10 14:35:59 -0500 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #ifndef _SOUTHBRIDGE_AMD_AGESA_HUDSON_SMI_H |
| 22 | #define _SOUTHBRIDGE_AMD_AGESA_HUDSON_SMI_H |
| 23 | |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame^] | 24 | #include <device/mmio.h> |
Alexandru Gagniuc | 2dbd08f | 2014-04-10 14:35:59 -0500 | [diff] [blame] | 25 | |
| 26 | /* ACPI_MMIO_BASE + 0x200 -- leave this string here so grep catches it. |
| 27 | * This is defined by AGESA, but we dpn't include AGESA headers to avoid |
| 28 | * polluting the namesace. |
| 29 | */ |
| 30 | #define SMI_BASE 0xfed80200 |
| 31 | |
| 32 | #define SMI_REG_SMITRIG0 0x98 |
| 33 | #define SMITRG0_EOS (1 << 28) |
| 34 | #define SMITRG0_SMIENB (1 << 31) |
| 35 | |
| 36 | #define SMI_REG_CONTROL0 0xa0 |
| 37 | |
Alexandru Gagniuc | 599d668 | 2014-04-17 23:33:50 -0500 | [diff] [blame] | 38 | enum smi_mode { |
| 39 | SMI_MODE_DISABLE = 0, |
| 40 | SMI_MODE_SMI = 1, |
| 41 | SMI_MODE_NMI = 2, |
| 42 | SMI_MODE_IRQ13 = 3, |
| 43 | }; |
| 44 | |
| 45 | enum smi_lvl { |
| 46 | SMI_LVL_LOW = 0, |
| 47 | SMI_LVL_HIGH = 1, |
Alexandru Gagniuc | 2dbd08f | 2014-04-10 14:35:59 -0500 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | static inline uint32_t smi_read32(uint8_t offset) |
| 51 | { |
Stefan Reinauer | 772029f | 2015-07-30 16:23:50 -0700 | [diff] [blame] | 52 | return read32((void *)((uintptr_t)SMI_BASE + offset)); |
Alexandru Gagniuc | 2dbd08f | 2014-04-10 14:35:59 -0500 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | static inline void smi_write32(uint8_t offset, uint32_t value) |
| 56 | { |
Stefan Reinauer | 772029f | 2015-07-30 16:23:50 -0700 | [diff] [blame] | 57 | write32((void *)((uintptr_t)SMI_BASE + offset), value); |
Alexandru Gagniuc | 2dbd08f | 2014-04-10 14:35:59 -0500 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | static inline uint16_t smi_read16(uint8_t offset) |
| 61 | { |
Stefan Reinauer | 772029f | 2015-07-30 16:23:50 -0700 | [diff] [blame] | 62 | return read16((void *)((uintptr_t)SMI_BASE + offset)); |
Alexandru Gagniuc | 2dbd08f | 2014-04-10 14:35:59 -0500 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | static inline void smi_write16(uint8_t offset, uint16_t value) |
| 66 | { |
Stefan Reinauer | 772029f | 2015-07-30 16:23:50 -0700 | [diff] [blame] | 67 | write16((void *)((uintptr_t)SMI_BASE + offset), value); |
Alexandru Gagniuc | 2dbd08f | 2014-04-10 14:35:59 -0500 | [diff] [blame] | 68 | } |
| 69 | |
Alexandru Gagniuc | 599d668 | 2014-04-17 23:33:50 -0500 | [diff] [blame] | 70 | void hudson_configure_gevent_smi(uint8_t gevent, uint8_t mode, uint8_t level); |
| 71 | void hudson_disable_gevent_smi(uint8_t gevent); |
| 72 | void hudson_enable_acpi_cmd_smi(void); |
| 73 | |
Alexandru Gagniuc | 2dbd08f | 2014-04-10 14:35:59 -0500 | [diff] [blame] | 74 | #ifndef __SMM__ |
| 75 | void hudson_enable_smi_generation(void); |
Alexandru Gagniuc | 2dbd08f | 2014-04-10 14:35:59 -0500 | [diff] [blame] | 76 | #endif |
| 77 | |
| 78 | #endif /* _SOUTHBRIDGE_AMD_AGESA_HUDSON_SMI_H */ |