aboutsummaryrefslogtreecommitdiff
path: root/src/mainboard/asus/m2n-e/fanctl.c
blob: bcee1d31f7439c1fed341f616d0d42bfda2ed4fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * This file is part of the coreboot project.
 *
 * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */

/*
 * The ASUS M2N-E has 6 different fans, connected to two different chips:
 * - ITE IT8716F: fan1 = CPU_FAN, fan2 = CHA_FAN1, fan3 = PWR_FAN1
 * - Analog Devices ADT7475: fan1 = CHA_FAN4, fan2 = CHA_FAN2, fan3 = CHA_FAN3
 */

#include <arch/io.h>
#include <stdlib.h>
#include <superio/ite/it8716f/it8716f.h>

static void write_index(u16 port, u8 reg, u8 value)
{
	outb(reg, port);
	outb(value, port + 1);
}

static const struct {
	u8 index;
	u8 value;
} sequence[] = {
	/* Enable startup of monitoring operations. */
	{ 0x00, 0x11},
	/* Polarity active-high, PWM frequency 23.43KHz, activate fans 1-3. */
	{ 0x14, 0xd7},
	/* Set the correct sensor types. TMPIN1: diode, TMPIN2/3: resistor. */
	{ 0x51, 0x31},
	/* Fan1 (CPU_FAN) is software-controlled. */
	{ 0x15, 0x7f},
	/* Fan2 (CHA_FAN1) is software-controlled. */
	{ 0x16, 0x7f},
	/* Fan3 (PWR_FAN1) is software-controlled. */
	{ 0x17, 0x7f},
	/* Enable fan1/2/3, select "on/off mode" for all of them. */
	{ 0x13, 0x70},
};

/* Called from src/ite/it8716f/superio.c. */
void init_ec(u16 base)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(sequence); i++)
		write_index(base, sequence[i].index, sequence[i].value);
}