Add support for the ASUS M2N-E board.
[coreboot.git] / src / mainboard / asus / m2n-e / fanctl.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
5  *
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; either version 2 of the License, or
9  * (at your option) any later version.
10  *
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.
15  *
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, MA  02110-1301 USA
19  */
20
21 /*
22  * The ASUS M2N-E has 6 different fans, connected to two different chips:
23  * - ITE IT8716F: fan1 = CPU_FAN, fan2 = CHA_FAN1, fan3 = PWR_FAN1
24  * - Analog Devices ADT7475: fan1 = CHA_FAN4, fan2 = CHA_FAN2, fan3 = CHA_FAN3
25  */
26
27 #include <arch/io.h>
28 #include <stdlib.h>
29 #include <superio/ite/it8716f/it8716f.h>
30
31 static void write_index(u16 port, u8 reg, u8 value)
32 {
33         outb(reg, port);
34         outb(value, port + 1);
35 }
36
37 static const struct {
38         u8 index;
39         u8 value;
40 } sequence[] = {
41         /* Enable startup of monitoring operations. */
42         { 0x00, 0x11},
43         /* Polarity active-high, PWM frequency 23.43KHz, activate fans 1-3. */
44         { 0x14, 0xd7},
45         /* Set the correct sensor types. TMPIN1: diode, TMPIN2/3: resistor. */
46         { 0x51, 0x31},
47         /* Fan1 (CPU_FAN) is software-controlled. */
48         { 0x15, 0x7f},
49         /* Fan2 (CHA_FAN1) is software-controlled. */
50         { 0x16, 0x7f},
51         /* Fan3 (PWR_FAN1) is software-controlled. */
52         { 0x17, 0x7f},
53         /* Enable fan1/2/3, select "on/off mode" for all of them. */
54         { 0x13, 0x70},
55 };
56
57 /* Called from src/ite/it8716f/superio.c. */
58 void init_ec(u16 base)
59 {
60         int i;
61
62         for (i = 0; i < ARRAY_SIZE(sequence); i++)
63                 write_index(base, sequence[i].index, sequence[i].value);
64 }