2 * This file is part of the coreboot project.
4 * Copyright (C) 2008-2009 coresystems GmbH
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
23 #include <arch/romcc_io.h>
24 #include <console/console.h>
25 #include <cpu/x86/smm.h>
26 #include "southbridge/intel/i82801gx/i82801gx.h"
27 #include "southbridge/intel/i82801gx/nvs.h"
30 #define MAX_LCD_BRIGHTNESS 0xd8
32 /* The southbridge SMI handler checks whether gnvs has a
33 * valid pointer before calling the trap handler
35 extern global_nvs_t *gnvs;
37 int mainboard_io_trap_handler(int smif)
44 printk(BIOS_DEBUG, "CPU power state switch\n");
45 // TODO, move to CPU handler?
48 printk(BIOS_DEBUG, "Enable C-State SMM coordination\n");
49 // TODO, move to CPU handler?
52 printk(BIOS_DEBUG, "S3 DTS SMI (completely re-enable DTS)\n");
53 // TODO, move to CPU handler?
56 printk(BIOS_DEBUG, "S4 DTS SMI (Update NVS DTS temperature)\n");
57 // TODO, move to CPU handler?
60 printk(BIOS_DEBUG, "Disable RF\n");
64 printk(BIOS_DEBUG, "ACBS LAN Power on\n");
68 printk(BIOS_DEBUG, "ACBS LAN Power off\n");
72 printk(BIOS_DEBUG, "Check AC status\n");
76 printk(BIOS_DEBUG, "Enable Bluetooth\n");
80 printk(BIOS_DEBUG, "Disable Bluetooth\n");
84 printk(BIOS_DEBUG, "Set Brightness\n");
86 printk(BIOS_DEBUG, "brtl: %x\n", reg8);
90 printk(BIOS_DEBUG, "Get Brightness\n");
92 printk(BIOS_DEBUG, "brtl: %x\n", reg8);
96 printk(BIOS_DEBUG, "Get ECO mode status\n");
100 printk(BIOS_DEBUG, "Get sunlight readable status\n");
104 printk(BIOS_DEBUG, "Get docking connection\n");
108 printk(BIOS_DEBUG, "Power off docking\n");
112 printk(BIOS_DEBUG, "EC: Turn on LED on ECO enable\n");
116 printk(BIOS_DEBUG, "EC: Turn off LED on ECO disable\n");
120 printk(BIOS_DEBUG, "LAN power off\n");
121 reg32 = inl(DEFAULT_GPIOBASE + GP_LVL);
122 reg32 |= (1 << 24); // Disable LAN Power
123 outl(reg32, DEFAULT_GPIOBASE + GP_LVL);
126 printk(BIOS_DEBUG, "RF enable\n");
130 printk(BIOS_DEBUG, "Get RTC wake flag\n");
134 printk(BIOS_DEBUG, "Hotkey function\n");
138 printk(BIOS_DEBUG, "ECO disable\n");
146 * On success, the IO Trap Handler returns 0
147 * On failure, the IO Trap Handler returns a value != 0
153 static void mainboard_smi_hotkey(u8 hotkey)
158 case 0x3b: break; // Fn+F1
159 case 0x3c: break; // Fn+F2
160 case 0x3d: break; // Fn+F3
161 case 0x3e: break; // Fn+F4
162 case 0x3f: break; // Fn+F5
163 case 0x40: // Fn+F6 (Decrease Display Brightness)
164 reg8 = ec_read(0x17);
165 reg8 = (reg8 > 8) ? (reg8 - 8) : 0;
166 ec_write(0x17, reg8);
168 case 0x41: // Fn+F7 (Increase Display Brightness)
169 reg8 = ec_read(0x17);
171 reg8 = (reg8 >= MAX_LCD_BRIGHTNESS) ? MAX_LCD_BRIGHTNESS : reg8;
172 ec_write(0x17, reg8);
174 case 0x42: break; // Fn+F8
175 case 0x43: break; // Fn+F9
176 case 0x44: break; // Fn+F10
177 case 0x57: break; // Fn+F11
178 case 0x58: break; // Fn+F12
180 printk(BIOS_DEBUG, "EC hotkey: %02x\n", hotkey);
183 void mainboard_smi_gpi(u16 gpi_sts)
186 send_ec_oem_command(0x5c);
187 source = recv_ec_oem_data();
194 send_ec_oem_command(0x59);
195 hotkey = recv_ec_oem_data();
196 mainboard_smi_hotkey(hotkey);
199 printk(BIOS_DEBUG, "EC SMI source: %02x\n", source);