tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / mainboard / kontron / 986lcd-m / mainboard.c
blob2a0c1470e298de2eaf327577ed68801e817108bf
1 /*
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.
16 #include <types.h>
17 #include <device/device.h>
18 #include <console/console.h>
19 #include <drivers/intel/gma/int15.h>
20 #include <pc80/mc146818rtc.h>
21 #include <arch/io.h>
22 #include <arch/interrupt.h>
24 /* Hardware Monitor */
26 static u16 hwm_base = 0xa00;
28 static void hwm_write(u8 reg, u8 value)
30 outb(reg, hwm_base + 0x05);
31 outb(value, hwm_base + 0x06);
34 static void hwm_bank(u8 bank)
36 hwm_write(0x4e, bank);
39 #define FAN_CRUISE_CONTROL_DISABLED 0
40 #define FAN_CRUISE_CONTROL_SPEED 1
41 #define FAN_CRUISE_CONTROL_THERMAL 2
43 #define FAN_SPEED_5625 0
44 //#define FAN_TEMPERATURE_30DEGC 0
46 struct fan_speed {
47 u8 fan_in;
48 u16 fan_speed;
51 // FANIN Target Speed Register
52 // FANIN = 337500 / RPM
53 struct fan_speed fan_speeds[] = {
54 { 0x3c, 5625 }, { 0x41, 5192 }, { 0x47, 4753 }, { 0x4e, 4326 },
55 { 0x56, 3924 }, { 0x5f, 3552 }, { 0x69, 3214 }, { 0x74, 2909 },
56 { 0x80, 2636 }, { 0x8d, 2393 }, { 0x9b, 2177 }, { 0xaa, 1985 },
57 { 0xba, 1814 }, { 0xcb, 1662 }, { 0xdd, 1527 }, { 0xf0, 1406 }
60 struct temperature {
61 u8 deg_celsius;
62 u8 deg_fahrenheit;
65 struct temperature temperatures[] = {
66 { 30, 86 }, { 33, 91 }, { 36, 96 }, { 39, 102 },
67 { 42, 107 }, { 45, 113 }, { 48, 118 }, { 51, 123 },
68 { 54, 129 }, { 57, 134 }, { 60, 140 }, { 63, 145 },
69 { 66, 150 }, { 69, 156 }, { 72, 161 }, { 75, 167 }
72 static void hwm_setup(void)
74 int cpufan_control = 0, sysfan_control = 0;
75 int cpufan_speed = 0, sysfan_speed = 0;
76 int cpufan_temperature = 0, sysfan_temperature = 0;
78 cpufan_control = FAN_CRUISE_CONTROL_DISABLED;
79 get_option(&cpufan_control, "cpufan_cruise_control");
80 cpufan_speed = FAN_SPEED_5625;
81 get_option(&cpufan_speed, "cpufan_speed");
82 //cpufan_temperature = FAN_TEMPERATURE_30DEGC;
83 //get_option(&cpufan_temperature, "cpufan_temperature");
85 sysfan_control = FAN_CRUISE_CONTROL_DISABLED;
86 get_option(&sysfan_control, "sysfan_cruise_control");
87 sysfan_speed = FAN_SPEED_5625;
88 get_option(&sysfan_speed, "sysfan_speed");
89 //sysfan_temperature = FAN_TEMPERATURE_30DEGC;
90 //get_option(&sysfan_temperature, "sysfan_temperature");
92 // hwm_write(0x31, 0x20); // AVCC high limit
93 // hwm_write(0x34, 0x06); // VIN2 low limit
95 hwm_bank(0);
96 hwm_write(0x59, 0x20); // Diode Selection
97 hwm_write(0x5d, 0x0f); // All Sensors Diode, not Thermistor
99 hwm_bank(4);
100 hwm_write(0x54, 0xf1); // SYSTIN temperature offset
101 hwm_write(0x55, 0x19); // CPUTIN temperature offset
102 hwm_write(0x56, 0xfc); // AUXTIN temperature offset
104 hwm_bank(0x80); // Default
106 u8 fan_config = 0;
107 // 00 FANOUT is Manual Mode
108 // 01 FANOUT is Thermal Cruise Mode
109 // 10 FANOUT is Fan Speed Cruise Mode
110 switch (cpufan_control) {
111 case FAN_CRUISE_CONTROL_SPEED: fan_config |= (2 << 4); break;
112 case FAN_CRUISE_CONTROL_THERMAL: fan_config |= (1 << 4); break;
114 switch (sysfan_control) {
115 case FAN_CRUISE_CONTROL_SPEED: fan_config |= (2 << 2); break;
116 case FAN_CRUISE_CONTROL_THERMAL: fan_config |= (1 << 2); break;
118 // This register must be written first
119 hwm_write(0x04, fan_config);
121 switch (cpufan_control) {
122 case FAN_CRUISE_CONTROL_SPEED:
123 printk(BIOS_DEBUG, "Fan Cruise Control setting CPU fan to %d RPM\n",
124 fan_speeds[cpufan_speed].fan_speed);
125 hwm_write(0x06, fan_speeds[cpufan_speed].fan_in); // CPUFANIN target speed
126 break;
127 case FAN_CRUISE_CONTROL_THERMAL:
128 printk(BIOS_DEBUG, "Fan Cruise Control setting CPU fan to activation at %d deg C/%d deg F\n",
129 temperatures[cpufan_temperature].deg_celsius,
130 temperatures[cpufan_temperature].deg_fahrenheit);
131 hwm_write(0x06, temperatures[cpufan_temperature].deg_celsius); // CPUFANIN target temperature
132 break;
135 switch (sysfan_control) {
136 case FAN_CRUISE_CONTROL_SPEED:
137 printk(BIOS_DEBUG, "Fan Cruise Control setting system fan to %d RPM\n",
138 fan_speeds[sysfan_speed].fan_speed);
139 hwm_write(0x05, fan_speeds[sysfan_speed].fan_in); // SYSFANIN target speed
140 break;
141 case FAN_CRUISE_CONTROL_THERMAL:
142 printk(BIOS_DEBUG, "Fan Cruise Control setting system fan to activation at %d deg C/%d deg F\n",
143 temperatures[sysfan_temperature].deg_celsius,
144 temperatures[sysfan_temperature].deg_fahrenheit);
145 hwm_write(0x05, temperatures[sysfan_temperature].deg_celsius); // SYSFANIN target temperature
146 break;
149 hwm_write(0x0e, 0x02); // Fan Output Step Down Time
150 hwm_write(0x0f, 0x02); // Fan Output Step Up Time
152 hwm_write(0x47, 0xaf); // FAN divisor register
153 hwm_write(0x4b, 0x84); // AUXFANIN speed divisor
155 hwm_write(0x40, 0x01); // Init, but no SMI#
160 // mainboard_enable is executed as first thing after
161 // enumerate_buses().
163 static void mainboard_enable(device_t dev)
165 install_intel_vga_int15_handler(GMA_INT15_ACTIVE_LFP_INT_LVDS, GMA_INT15_PANEL_FIT_DEFAULT, GMA_INT15_BOOT_DISPLAY_DEFAULT, 3);
166 hwm_setup();
169 struct chip_operations mainboard_ops = {
170 .enable_dev = mainboard_enable,