blob: 3ed0d1148349939758f126c6b2302211c855cc69 [file] [log] [blame]
Michał Żygowski72f06ca2020-04-13 21:42:24 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <stdint.h>
4#include <arch/io.h>
Michał Żygowski72f06ca2020-04-13 21:42:24 +02005#include <cpu/x86/smm.h>
6#include <superio/smsc/sch5545/sch5545.h>
7
Michał Żygowski72f06ca2020-04-13 21:42:24 +02008int mainboard_smi_apmc(u8 data)
9{
10 u8 val;
11 switch (data) {
12 case APM_CNT_ACPI_ENABLE:
Michał Żygowski72f06ca2020-04-13 21:42:24 +020013 /* Enable wake on PS2 */
14 val = inb(SCH5545_RUNTIME_REG_BASE + SCH5545_RR_PME_EN1);
15 val |= (SCH5545_KBD_PME_EN | SCH5545_MOUSE_PME_EN);
16 outb(val, SCH5545_RUNTIME_REG_BASE + SCH5545_RR_PME_EN1);
17 /* Clear pending and enable PMEs */
18 outb(SCH5545_GLOBAL_PME_STS, SCH5545_RUNTIME_REG_BASE + SCH5545_RR_PME_STS);
19 outb(SCH5545_GLOBAL_PME_EN, SCH5545_RUNTIME_REG_BASE + SCH5545_RR_PME_EN);
20 break;
21 case APM_CNT_ACPI_DISABLE:
Michał Żygowski72f06ca2020-04-13 21:42:24 +020022 /* Disable wake on PS2 */
23 val = inb(SCH5545_RUNTIME_REG_BASE + SCH5545_RR_PME_EN1);
24 val &= ~(SCH5545_KBD_PME_EN | SCH5545_MOUSE_PME_EN);
25 outb(val, SCH5545_RUNTIME_REG_BASE + SCH5545_RR_PME_EN1);
26 /* Clear pending and disable PMEs */
27 outb(SCH5545_GLOBAL_PME_STS, SCH5545_RUNTIME_REG_BASE + SCH5545_RR_PME_STS);
28 outb(0, SCH5545_RUNTIME_REG_BASE + SCH5545_RR_PME_EN);
29 break;
30 default:
31 break;
32 }
33 return 0;
34}