1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <console/console.h>
5 #include <cpu/x86/smm.h>
6 #include <southbridge/intel/i82801gx/i82801gx.h>
8 #include <southbridge/intel/common/gpio.h>
9 #include <ec/acpi/ec.h>
12 #define MAX_LCD_BRIGHTNESS 0xd8
14 int mainboard_io_trap_handler(int smif
)
21 printk(BIOS_DEBUG
, "CPU power state switch\n");
22 // TODO, move to CPU handler?
25 printk(BIOS_DEBUG
, "Enable C-State SMM coordination\n");
26 // TODO, move to CPU handler?
29 printk(BIOS_DEBUG
, "S3 DTS SMI (completely re-enable DTS)\n");
30 // TODO, move to CPU handler?
33 printk(BIOS_DEBUG
, "S4 DTS SMI (Update NVS DTS temperature)\n");
34 // TODO, move to CPU handler?
37 printk(BIOS_DEBUG
, "Disable RF\n");
41 printk(BIOS_DEBUG
, "ACBS LAN Power on\n");
45 printk(BIOS_DEBUG
, "ACBS LAN Power off\n");
49 printk(BIOS_DEBUG
, "Check AC status\n");
53 printk(BIOS_DEBUG
, "Enable Bluetooth\n");
57 printk(BIOS_DEBUG
, "Disable Bluetooth\n");
61 printk(BIOS_DEBUG
, "Set Brightness\n");
63 printk(BIOS_DEBUG
, "brtl: %x\n", reg8
);
67 printk(BIOS_DEBUG
, "Get Brightness\n");
69 printk(BIOS_DEBUG
, "brtl: %x\n", reg8
);
73 printk(BIOS_DEBUG
, "Get ECO mode status\n");
77 printk(BIOS_DEBUG
, "Get sunlight readable status\n");
81 printk(BIOS_DEBUG
, "Get docking connection\n");
85 printk(BIOS_DEBUG
, "Power off docking\n");
89 printk(BIOS_DEBUG
, "EC: Turn on LED on ECO enable\n");
93 printk(BIOS_DEBUG
, "EC: Turn off LED on ECO disable\n");
97 printk(BIOS_DEBUG
, "LAN power off\n");
98 reg32
= inl(DEFAULT_GPIOBASE
+ GP_LVL
);
99 reg32
|= (1 << 24); // Disable LAN Power
100 outl(reg32
, DEFAULT_GPIOBASE
+ GP_LVL
);
103 printk(BIOS_DEBUG
, "RF enable\n");
107 printk(BIOS_DEBUG
, "Get RTC wake flag\n");
111 printk(BIOS_DEBUG
, "Hotkey function\n");
115 printk(BIOS_DEBUG
, "ECO disable\n");
123 * On success, the IO Trap Handler returns 0
124 * On failure, the IO Trap Handler returns a value != 0
130 static void mainboard_smi_hotkey(u8 hotkey
)
135 case 0x3b: break; // Fn+F1
136 case 0x3c: break; // Fn+F2
137 case 0x3d: break; // Fn+F3
138 case 0x3e: break; // Fn+F4
139 case 0x3f: break; // Fn+F5
140 case 0x40: // Fn+F6 (Decrease Display Brightness)
141 reg8
= ec_read(0x17);
142 reg8
= (reg8
> 8) ? (reg8
- 8) : 0;
143 ec_write(0x17, reg8
);
145 case 0x41: // Fn+F7 (Increase Display Brightness)
146 reg8
= ec_read(0x17);
148 reg8
= (reg8
>= MAX_LCD_BRIGHTNESS
) ? MAX_LCD_BRIGHTNESS
: reg8
;
149 ec_write(0x17, reg8
);
151 case 0x42: break; // Fn+F8
152 case 0x43: break; // Fn+F9
153 case 0x44: break; // Fn+F10
154 case 0x57: break; // Fn+F11
155 case 0x58: break; // Fn+F12
157 printk(BIOS_DEBUG
, "EC hotkey: %02x\n", hotkey
);
160 void mainboard_smi_gpi(u32 gpi_sts
)
163 send_ec_oem_command(0x5c);
164 source
= recv_ec_oem_data();
171 send_ec_oem_command(0x59);
172 hotkey
= recv_ec_oem_data();
173 mainboard_smi_hotkey(hotkey
);
176 printk(BIOS_DEBUG
, "EC SMI source: %02x\n", source
);