2 * This file is part of the coreboot project.
4 * Copyright (C) 2007-2009 coresystems GmbH
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <device/device.h>
22 #include <console/console.h>
23 #include <boot/tables.h>
24 #if CONFIG_PCI_OPTION_ROM_RUN_YABEL
25 #include <x86emu/x86emu.h>
27 #include <pc80/mc146818rtc.h>
29 #include <arch/coreboot_tables.h>
32 int add_mainboard_resources(struct lb_memory *mem)
34 return add_northbridge_resources(mem);
37 #if CONFIG_PCI_OPTION_ROM_RUN_YABEL
38 static int int15_handler(void)
40 #define BOOT_DISPLAY_DEFAULT 0
41 #define BOOT_DISPLAY_CRT (1 << 0)
42 #define BOOT_DISPLAY_TV (1 << 1)
43 #define BOOT_DISPLAY_EFP (1 << 2)
44 #define BOOT_DISPLAY_LCD (1 << 3)
45 #define BOOT_DISPLAY_CRT2 (1 << 4)
46 #define BOOT_DISPLAY_TV2 (1 << 5)
47 #define BOOT_DISPLAY_EFP2 (1 << 6)
48 #define BOOT_DISPLAY_LCD2 (1 << 7)
50 printk_debug("%s: AX=%04x BX=%04x CX=%04x DX=%04x\n",
51 __func__, M.x86.R_AX, M.x86.R_BX, M.x86.R_CX, M.x86.R_DX);
54 case 0x5f35: /* Boot Display */
55 M.x86.R_AX = 0x005f; // Success
56 M.x86.R_CL = BOOT_DISPLAY_DEFAULT;
58 case 0x5f40: /* Boot Panel Type */
59 // M.x86.R_AX = 0x015f; // Supported but failed
60 M.x86.R_AX = 0x005f; // Success
61 M.x86.R_CL = 3; // Display ID
64 /* Interrupt was not handled */
68 /* Interrupt handled */
72 static void int15_install(void)
74 typedef int (* yabel_handleIntFunc)(void);
75 extern yabel_handleIntFunc yabel_intFuncArray[256];
76 yabel_intFuncArray[0x15] = int15_handler;
80 /* Hardware Monitor */
82 static u16 hwm_base = 0xa00;
84 static void hwm_write(u8 reg, u8 value)
86 outb(reg, hwm_base + 0x05);
87 outb(value, hwm_base + 0x06);
90 static void hwm_bank(u8 bank)
92 hwm_write(0x4e, bank);
95 #define FAN_CRUISE_CONTROL_DISABLED 0
96 #define FAN_CRUISE_CONTROL_SPEED 1
97 #define FAN_CRUISE_CONTROL_THERMAL 2
99 #define FAN_SPEED_5625 0
100 //#define FAN_TEMPERATURE_30DEGC 0
107 // FANIN Target Speed Register
108 // FANIN = 337500 / RPM
109 struct fan_speed fan_speeds[] = {
110 { 0x3c, 5625 }, { 0x41, 5192 }, { 0x47, 4753 }, { 0x4e, 4326 },
111 { 0x56, 3924 }, { 0x5f, 3552 }, { 0x69, 3214 }, { 0x74, 2909 },
112 { 0x80, 2636 }, { 0x8d, 2393 }, { 0x9b, 2177 }, { 0xaa, 1985 },
113 { 0xba, 1814 }, { 0xcb, 1662 }, { 0xdd, 1527 }, { 0xf0, 1406 }
121 struct temperature temperatures[] = {
122 { 30, 86 }, { 33, 91 }, { 36, 96 }, { 39, 102 },
123 { 42, 107 }, { 45, 113 }, { 48, 118 }, { 51, 123 },
124 { 54, 129 }, { 57, 134 }, { 60, 140 }, { 63, 145 },
125 { 66, 150 }, { 69, 156 }, { 72, 161 }, { 75, 167 }
128 static void hwm_setup(void)
130 int cpufan_control = 0, sysfan_control = 0;
131 int cpufan_speed = 0, sysfan_speed = 0;
132 int cpufan_temperature = 0, sysfan_temperature = 0;
134 if (get_option(&cpufan_control, "cpufan_cruise_control") < 0)
135 cpufan_control = FAN_CRUISE_CONTROL_DISABLED;
136 if (get_option(&cpufan_speed, "cpufan_speed") < 0)
137 cpufan_speed = FAN_SPEED_5625;
138 //if (get_option(&cpufan_temperature, "cpufan_temperature") < 0)
139 // cpufan_temperature = FAN_TEMPERATURE_30DEGC;
141 if (get_option(&sysfan_control, "sysfan_cruise_control") < 0)
142 sysfan_control = FAN_CRUISE_CONTROL_DISABLED;
143 if (get_option(&sysfan_speed, "sysfan_speed") < 0)
144 sysfan_speed = FAN_SPEED_5625;
145 //if (get_option(&sysfan_temperature, "sysfan_temperature") < 0)
146 // sysfan_temperature = FAN_TEMPERATURE_30DEGC;
148 // hwm_write(0x31, 0x20); // AVCC high limit
149 // hwm_write(0x34, 0x06); // VIN2 low limit
152 hwm_write(0x59, 0x20); // Diode Selection
153 hwm_write(0x5d, 0x0f); // All Sensors Diode, not Thermistor
156 hwm_write(0x54, 0xf1); // SYSTIN temperature offset
157 hwm_write(0x55, 0x19); // CPUTIN temperature offset
158 hwm_write(0x56, 0xfc); // AUXTIN temperature offset
160 hwm_bank(0x80); // Default
163 // 00 FANOUT is Manual Mode
164 // 01 FANOUT is Thermal Cruise Mode
165 // 10 FANOUT is Fan Speed Cruise Mode
166 switch (cpufan_control) {
167 case FAN_CRUISE_CONTROL_SPEED: fan_config |= (2 << 4); break;
168 case FAN_CRUISE_CONTROL_THERMAL: fan_config |= (1 << 4); break;
170 switch (sysfan_control) {
171 case FAN_CRUISE_CONTROL_SPEED: fan_config |= (2 << 2); break;
172 case FAN_CRUISE_CONTROL_THERMAL: fan_config |= (1 << 2); break;
174 // This register must be written first
175 hwm_write(0x04, fan_config);
177 switch (cpufan_control) {
178 case FAN_CRUISE_CONTROL_SPEED:
179 printk_debug("Fan Cruise Control setting CPU fan to %d RPM\n",
180 fan_speeds[cpufan_speed].fan_speed);
181 hwm_write(0x06, fan_speeds[cpufan_speed].fan_in); // CPUFANIN target speed
183 case FAN_CRUISE_CONTROL_THERMAL:
184 printk_debug("Fan Cruise Control setting CPU fan to activation at %d deg C/%d deg F\n",
185 temperatures[cpufan_temperature].deg_celsius,
186 temperatures[cpufan_temperature].deg_fahrenheit);
187 hwm_write(0x06, temperatures[cpufan_temperature].deg_celsius); // CPUFANIN target temperature
191 switch (sysfan_control) {
192 case FAN_CRUISE_CONTROL_SPEED:
193 printk_debug("Fan Cruise Control setting system fan to %d RPM\n",
194 fan_speeds[sysfan_speed].fan_speed);
195 hwm_write(0x05, fan_speeds[sysfan_speed].fan_in); // SYSFANIN target speed
197 case FAN_CRUISE_CONTROL_THERMAL:
198 printk_debug("Fan Cruise Control setting system fan to activation at %d deg C/%d deg F\n",
199 temperatures[sysfan_temperature].deg_celsius,
200 temperatures[sysfan_temperature].deg_fahrenheit);
201 hwm_write(0x05, temperatures[sysfan_temperature].deg_celsius); // SYSFANIN target temperature
205 hwm_write(0x0e, 0x02); // Fan Output Step Down Time
206 hwm_write(0x0f, 0x02); // Fan Output Step Up Time
208 hwm_write(0x47, 0xaf); // FAN divisor register
209 hwm_write(0x4b, 0x84); // AUXFANIN speed divisor
211 hwm_write(0x40, 0x01); // Init, but no SMI#
216 extern u32 * cim_verb_data;
217 extern u32 cim_verb_data_size;
219 static void verb_setup(void)
221 // Default VERB is fine on this mainboard.
222 cim_verb_data = NULL;
223 cim_verb_data_size = 0;
226 // mainboard_enable is executed as first thing after
227 // enumerate_buses().
229 static void mainboard_enable(device_t dev)
231 #if CONFIG_PCI_OPTION_ROM_RUN_YABEL
232 /* Install custom int15 handler for VGA OPROM */
239 struct chip_operations mainboard_ops = {
240 CHIP_NAME("Kontron 986LCD-M Mainboard")
241 .enable_dev = mainboard_enable,