summaryrefslogtreecommitdiff
path: root/src/southbridge/amd/agesa/hudson/smi.c
diff options
context:
space:
mode:
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>2014-04-10 14:35:59 -0500
committerAlexandru Gagniuc <mr.nuke.me@gmail.com>2014-04-17 04:41:49 +0200
commit2dbd08faf4be1f2a156730f8857b4c6bb72909e3 (patch)
treead2c5834a0a3a97317eaf5ea0f5682f077d34fe7 /src/southbridge/amd/agesa/hudson/smi.c
parent065b7da298953feaec3563bf753f45cf00fba2c0 (diff)
downloadcoreboot-2dbd08faf4be1f2a156730f8857b4c6bb72909e3.tar.xz
southbridge/amd/agesa/hudson: Add initial support for SMM
This sets up the infrastructure to handle SMIs generated by the Hudson southbridge. An API for interfacing to mainboard handlers is not defined at this point. A few functions are defined to allow mainboard code to enable SMIs from GEVENT pins. These are the only functions which I expect to be needed anytime in the foreseeable future. SMIs are always acknowledged and cleared, as not clearing an SMI will cause us to re-enter the SMI, effectively bricking the machine if a southbridge-generated SMI without a handler occurs. Change-Id: Ibceb21ac5423eb134d3eb7d24800280b183f7619 Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-on: http://review.coreboot.org/5494 Reviewed-by: Aaron Durbin <adurbin@gmail.com> Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/southbridge/amd/agesa/hudson/smi.c')
-rw-r--r--src/southbridge/amd/agesa/hudson/smi.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/southbridge/amd/agesa/hudson/smi.c b/src/southbridge/amd/agesa/hudson/smi.c
new file mode 100644
index 0000000000..bb5e192f53
--- /dev/null
+++ b/src/southbridge/amd/agesa/hudson/smi.c
@@ -0,0 +1,60 @@
+/*
+ * Utilities for SMM setup
+ *
+ * Copyright (C) 2014 Alexandru Gagniuc <mr.nuke.me@gmail.com>
+ * Subject to the GNU GPL v2, or (at your option) any later version.
+ */
+
+#include "smi.h"
+
+#include <console/console.h>
+#include <cpu/cpu.h>
+
+void smm_setup_structures(void *gnvs, void *tcg, void *smi1)
+{
+ printk(BIOS_DEBUG, "smm_setup_structures STUB!!!\n");
+}
+
+/** Set the EOS bit and enable SMI generation from southbridge */
+void hudson_enable_smi_generation(void)
+{
+ uint32_t reg = smi_read32(SMI_REG_SMITRIG0);
+ reg &= ~SMITRG0_SMIENB; /* Enable SMI generation */
+ reg |= SMITRG0_EOS; /* Set EOS bit */
+ smi_write32(SMI_REG_SMITRIG0, reg);
+}
+
+static void enable_smi(uint8_t smi_num)
+{
+ uint8_t reg32_offset, bit_offset;
+ uint32_t reg32;
+
+ /* SMI sources range from [0:149] */
+ if (smi_num > 149) {
+ printk(BIOS_WARNING, "BUG: Invalid SMI: %u\n", smi_num);
+ return;
+ }
+
+ /* 16 sources per register, 2 bits per source; registers are 4 bytes */
+ reg32_offset = (smi_num / 16) * 4;
+ bit_offset = (smi_num % 16) * 2;
+
+ reg32 = smi_read32(SMI_REG_CONTROL0 + reg32_offset);
+ reg32 &= ~(3 << (bit_offset));
+ reg32 |= (SMI_SRC_MODE_SMI << (bit_offset));
+ smi_write32(SMI_REG_CONTROL0 + reg32_offset, reg32);
+
+}
+
+/** Enable generation of SMIs for given GPE */
+void hudson_enable_gevent_smi(uint8_t gevent)
+{
+ /* GEVENT pins range from [0:23] */
+ if (gevent > 23) {
+ printk(BIOS_WARNING, "BUG: Invalid GEVENT: %u\n", gevent);
+ return;
+ }
+
+ /* SMI0 source is GEVENT0 and so on */
+ enable_smi(gevent);
+}