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.
18 #include <console/console.h>
19 #include <cpu/x86/smm.h>
20 #include "southbridge/intel/i82801gx/i82801gx.h"
21 #include "southbridge/intel/i82801gx/nvs.h"
22 #include <ec/acpi/ec.h>
25 #define MAX_LCD_BRIGHTNESS 0xd8
27 /* The southbridge SMI handler checks whether gnvs has a
28 * valid pointer before calling the trap handler
30 extern global_nvs_t
*gnvs
;
32 int mainboard_io_trap_handler(int smif
)
39 printk(BIOS_DEBUG
, "CPU power state switch\n");
40 // TODO, move to CPU handler?
43 printk(BIOS_DEBUG
, "Enable C-State SMM coordination\n");
44 // TODO, move to CPU handler?
47 printk(BIOS_DEBUG
, "S3 DTS SMI (completely re-enable DTS)\n");
48 // TODO, move to CPU handler?
51 printk(BIOS_DEBUG
, "S4 DTS SMI (Update NVS DTS temperature)\n");
52 // TODO, move to CPU handler?
55 printk(BIOS_DEBUG
, "Disable RF\n");
59 printk(BIOS_DEBUG
, "ACBS LAN Power on\n");
63 printk(BIOS_DEBUG
, "ACBS LAN Power off\n");
67 printk(BIOS_DEBUG
, "Check AC status\n");
71 printk(BIOS_DEBUG
, "Enable Bluetooth\n");
75 printk(BIOS_DEBUG
, "Disable Bluetooth\n");
79 printk(BIOS_DEBUG
, "Set Brightness\n");
81 printk(BIOS_DEBUG
, "brtl: %x\n", reg8
);
85 printk(BIOS_DEBUG
, "Get Brightness\n");
87 printk(BIOS_DEBUG
, "brtl: %x\n", reg8
);
91 printk(BIOS_DEBUG
, "Get ECO mode status\n");
95 printk(BIOS_DEBUG
, "Get sunlight readable status\n");
99 printk(BIOS_DEBUG
, "Get docking connection\n");
103 printk(BIOS_DEBUG
, "Power off docking\n");
107 printk(BIOS_DEBUG
, "EC: Turn on LED on ECO enable\n");
111 printk(BIOS_DEBUG
, "EC: Turn off LED on ECO disable\n");
115 printk(BIOS_DEBUG
, "LAN power off\n");
116 reg32
= inl(DEFAULT_GPIOBASE
+ GP_LVL
);
117 reg32
|= (1 << 24); // Disable LAN Power
118 outl(reg32
, DEFAULT_GPIOBASE
+ GP_LVL
);
121 printk(BIOS_DEBUG
, "RF enable\n");
125 printk(BIOS_DEBUG
, "Get RTC wake flag\n");
129 printk(BIOS_DEBUG
, "Hotkey function\n");
133 printk(BIOS_DEBUG
, "ECO disable\n");
141 * On success, the IO Trap Handler returns 0
142 * On failure, the IO Trap Handler returns a value != 0
148 static void mainboard_smi_hotkey(u8 hotkey
)
153 case 0x3b: break; // Fn+F1
154 case 0x3c: break; // Fn+F2
155 case 0x3d: break; // Fn+F3
156 case 0x3e: break; // Fn+F4
157 case 0x3f: break; // Fn+F5
158 case 0x40: // Fn+F6 (Decrease Display Brightness)
159 reg8
= ec_read(0x17);
160 reg8
= (reg8
> 8) ? (reg8
- 8) : 0;
161 ec_write(0x17, reg8
);
163 case 0x41: // Fn+F7 (Increase Display Brightness)
164 reg8
= ec_read(0x17);
166 reg8
= (reg8
>= MAX_LCD_BRIGHTNESS
) ? MAX_LCD_BRIGHTNESS
: reg8
;
167 ec_write(0x17, reg8
);
169 case 0x42: break; // Fn+F8
170 case 0x43: break; // Fn+F9
171 case 0x44: break; // Fn+F10
172 case 0x57: break; // Fn+F11
173 case 0x58: break; // Fn+F12
175 printk(BIOS_DEBUG
, "EC hotkey: %02x\n", hotkey
);
178 void mainboard_smi_gpi(u32 gpi_sts
)
181 send_ec_oem_command(0x5c);
182 source
= recv_ec_oem_data();
189 send_ec_oem_command(0x59);
190 hotkey
= recv_ec_oem_data();
191 mainboard_smi_hotkey(hotkey
);
194 printk(BIOS_DEBUG
, "EC SMI source: %02x\n", source
);