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"
28 #include <ec/acpi/ec.h>
31 #define MAX_LCD_BRIGHTNESS 0xd8
33 /* The southbridge SMI handler checks whether gnvs has a
34 * valid pointer before calling the trap handler
36 extern global_nvs_t *gnvs;
38 int mainboard_io_trap_handler(int smif)
45 printk(BIOS_DEBUG, "CPU power state switch\n");
46 // TODO, move to CPU handler?
49 printk(BIOS_DEBUG, "Enable C-State SMM coordination\n");
50 // TODO, move to CPU handler?
53 printk(BIOS_DEBUG, "S3 DTS SMI (completely re-enable DTS)\n");
54 // TODO, move to CPU handler?
57 printk(BIOS_DEBUG, "S4 DTS SMI (Update NVS DTS temperature)\n");
58 // TODO, move to CPU handler?
61 printk(BIOS_DEBUG, "Disable RF\n");
65 printk(BIOS_DEBUG, "ACBS LAN Power on\n");
69 printk(BIOS_DEBUG, "ACBS LAN Power off\n");
73 printk(BIOS_DEBUG, "Check AC status\n");
77 printk(BIOS_DEBUG, "Enable Bluetooth\n");
81 printk(BIOS_DEBUG, "Disable Bluetooth\n");
85 printk(BIOS_DEBUG, "Set Brightness\n");
87 printk(BIOS_DEBUG, "brtl: %x\n", reg8);
91 printk(BIOS_DEBUG, "Get Brightness\n");
93 printk(BIOS_DEBUG, "brtl: %x\n", reg8);
97 printk(BIOS_DEBUG, "Get ECO mode status\n");
101 printk(BIOS_DEBUG, "Get sunlight readable status\n");
105 printk(BIOS_DEBUG, "Get docking connection\n");
109 printk(BIOS_DEBUG, "Power off docking\n");
113 printk(BIOS_DEBUG, "EC: Turn on LED on ECO enable\n");
117 printk(BIOS_DEBUG, "EC: Turn off LED on ECO disable\n");
121 printk(BIOS_DEBUG, "LAN power off\n");
122 reg32 = inl(DEFAULT_GPIOBASE + GP_LVL);
123 reg32 |= (1 << 24); // Disable LAN Power
124 outl(reg32, DEFAULT_GPIOBASE + GP_LVL);
127 printk(BIOS_DEBUG, "RF enable\n");
131 printk(BIOS_DEBUG, "Get RTC wake flag\n");
135 printk(BIOS_DEBUG, "Hotkey function\n");
139 printk(BIOS_DEBUG, "ECO disable\n");
147 * On success, the IO Trap Handler returns 0
148 * On failure, the IO Trap Handler returns a value != 0
154 static void mainboard_smi_hotkey(u8 hotkey)
159 case 0x3b: break; // Fn+F1
160 case 0x3c: break; // Fn+F2
161 case 0x3d: break; // Fn+F3
162 case 0x3e: break; // Fn+F4
163 case 0x3f: break; // Fn+F5
164 case 0x40: // Fn+F6 (Decrease Display Brightness)
165 reg8 = ec_read(0x17);
166 reg8 = (reg8 > 8) ? (reg8 - 8) : 0;
167 ec_write(0x17, reg8);
169 case 0x41: // Fn+F7 (Increase Display Brightness)
170 reg8 = ec_read(0x17);
172 reg8 = (reg8 >= MAX_LCD_BRIGHTNESS) ? MAX_LCD_BRIGHTNESS : reg8;
173 ec_write(0x17, reg8);
175 case 0x42: break; // Fn+F8
176 case 0x43: break; // Fn+F9
177 case 0x44: break; // Fn+F10
178 case 0x57: break; // Fn+F11
179 case 0x58: break; // Fn+F12
181 printk(BIOS_DEBUG, "EC hotkey: %02x\n", hotkey);
184 void mainboard_smi_gpi(u16 gpi_sts)
187 send_ec_oem_command(0x5c);
188 source = recv_ec_oem_data();
195 send_ec_oem_command(0x59);
196 hotkey = recv_ec_oem_data();
197 mainboard_smi_hotkey(hotkey);
200 printk(BIOS_DEBUG, "EC SMI source: %02x\n", source);