1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <device/mmio.h>
5 #include <console/console.h>
6 #include <cpu/x86/smm.h>
7 #include <cpu/intel/smm_reloc.h>
8 #include <device/device.h>
9 #include <device/pci.h>
10 #include <soc/iomap.h>
14 /* Save settings which will be committed in SMI functions. */
15 static uint32_t smm_save_params
[SMM_SAVE_PARAM_COUNT
];
17 void smm_southcluster_save_param(int param
, uint32_t data
)
19 smm_save_params
[param
] = data
;
22 void smm_southbridge_clear_state(void)
26 /* Log events from chipset before clearing */
28 southcluster_log_state();
30 smi_en
= inl(get_pmbase() + SMI_EN
);
31 if (smi_en
& APMC_EN
) {
32 printk(BIOS_INFO
, "SMI# handler already enabled?\n");
36 /* Dump and clear status registers */
45 static void smm_southcluster_route_gpios(void)
47 void *gpio_rout
= (void *)(PMC_BASE_ADDRESS
+ GPIO_ROUT
);
48 const unsigned short alt_gpio_smi
= ACPI_BASE_ADDRESS
+ ALT_GPIO_SMI
;
49 uint32_t alt_gpio_reg
= 0;
50 uint32_t route_reg
= smm_save_params
[SMM_SAVE_PARAM_GPIO_ROUTE
];
53 printk(BIOS_DEBUG
, "GPIO_ROUT = %08x\n", route_reg
);
55 /* Start the routing for the specific gpios. */
56 write32(gpio_rout
, route_reg
);
58 /* Enable SMIs for the gpios that are set to trigger the SMI. */
59 for (i
= 0; i
< 16; i
++) {
60 if ((route_reg
& ROUTE_MASK
) == ROUTE_SMI
)
61 alt_gpio_reg
|= (1 << i
);
65 printk(BIOS_DEBUG
, "ALT_GPIO_SMI = %08x\n", alt_gpio_reg
);
67 outl(alt_gpio_reg
, alt_gpio_smi
);
70 static void smm_southbridge_enable(uint16_t pm1_events
)
73 printk(BIOS_DEBUG
, "Enabling SMIs.\n");
74 if (!smm_save_params
[SMM_SAVE_PARAM_PCIE_WAKE_ENABLE
])
75 pm1_events
|= PCIEXPWAK_DIS
;
77 enable_pm1(pm1_events
);
78 disable_gpe(PME_B0_EN
);
80 /* Set up the GPIO route. */
81 smm_southcluster_route_gpios();
84 * Enable SMI generation:
85 * - on APMC writes (io 0xb2)
86 * - on writes to SLP_EN (sleep states)
87 * - on writes to GBL_RLS (bios commands)
90 * - on microcontroller writes (io 0x62/0x66)
92 enable_smi(APMC_EN
| SLP_SMI_EN
| GBL_SMI_EN
| EOS
);
95 void global_smi_enable(void)
97 smm_southbridge_enable(PWRBTN_EN
| GBL_EN
);