Ronald Hoogenboom | 56cf01f | 2008-02-25 19:36:20 +0000 | [diff] [blame] | 1 | #include <arch/io.h> |
Carl-Daniel Hailfinger | 2ee6779 | 2008-10-01 12:52:52 +0000 | [diff] [blame] | 2 | #include <stdlib.h> |
Stefan Reinauer | d55e26f | 2010-04-25 13:54:30 +0000 | [diff] [blame] | 3 | #include <superio/ite/it8716f/it8716f.h> |
Ronald Hoogenboom | 56cf01f | 2008-02-25 19:36:20 +0000 | [diff] [blame] | 4 | |
| 5 | static void write_index(uint16_t port_base, uint8_t reg, uint8_t value) |
| 6 | { |
| 7 | outb(reg, port_base); |
| 8 | outb(value, port_base + 1); |
| 9 | } |
| 10 | |
| 11 | static const struct { |
| 12 | uint8_t index, value; |
| 13 | } sequence[]= { |
Ronald Hoogenboom | fb73fa1 | 2008-06-22 14:33:17 +0000 | [diff] [blame] | 14 | /* Make sure we can monitor, and enable SMI# interrupt output */ |
| 15 | { 0x00, 0x13}, |
| 16 | /* Disable fan interrupt status bits for SMI# */ |
| 17 | { 0x04, 0x37}, |
| 18 | /* Disable VIN interrupt status bits for SMI# */ |
| 19 | { 0x05, 0xff}, |
| 20 | /* Disable fan interrupt status bits for IRQ */ |
| 21 | { 0x07, 0x37}, |
| 22 | /* Disable VIN interrupt status bits for IRQ */ |
| 23 | { 0x08, 0xff}, |
| 24 | /* Disable external sensor interrupt */ |
| 25 | { 0x09, 0x87}, |
| 26 | /* Enable 16 bit counter divisors */ |
| 27 | { 0x0c, 0x07}, |
Ronald Hoogenboom | 56cf01f | 2008-02-25 19:36:20 +0000 | [diff] [blame] | 28 | /* Set FAN_CTL control register (0x14) polarity to high, and |
| 29 | activate fans 1, 2 and 3. */ |
Ronald Hoogenboom | fb73fa1 | 2008-06-22 14:33:17 +0000 | [diff] [blame] | 30 | { 0x14, 0xd7}, |
Ronald Hoogenboom | 56cf01f | 2008-02-25 19:36:20 +0000 | [diff] [blame] | 31 | /* set the correct sensor types 1,2 thermistor; 3 diode */ |
| 32 | { 0x51, 0x1c}, |
Ronald Hoogenboom | fb73fa1 | 2008-06-22 14:33:17 +0000 | [diff] [blame] | 33 | /* set the 'zero' voltage for diode type sensor 3 */ |
Ronald Hoogenboom | 56cf01f | 2008-02-25 19:36:20 +0000 | [diff] [blame] | 34 | { 0x5c, 0x80}, |
| 35 | // { 0x56, 0xe5}, |
| 36 | // { 0x57, 0xe5}, |
Ronald Hoogenboom | fb73fa1 | 2008-06-22 14:33:17 +0000 | [diff] [blame] | 37 | { 0x59, 0xec}, |
Ronald Hoogenboom | 56cf01f | 2008-02-25 19:36:20 +0000 | [diff] [blame] | 38 | { 0x5c, 0x00}, |
| 39 | /* fan1 (controlled by temp3) control parameters */ |
| 40 | /* fan off limit */ |
| 41 | { 0x60, 0xff}, |
| 42 | /* fan start limit */ |
| 43 | { 0x61, 0x14}, |
| 44 | /* ???? */ |
| 45 | // { 0x62, 0x00}, |
| 46 | /* start PWM */ |
| 47 | { 0x63, 0x27}, |
| 48 | /* smooth and slope PWM */ |
| 49 | { 0x64, 0x90}, |
| 50 | /* direct-down and interval */ |
| 51 | { 0x65, 0x03}, |
Ronald Hoogenboom | fb73fa1 | 2008-06-22 14:33:17 +0000 | [diff] [blame] | 52 | /* temperature limit of fan stop for fan3 (automatic) */ |
| 53 | { 0x70, 0xff}, |
| 54 | /* temperature limit of fan start for fan3 (automatic) */ |
| 55 | { 0x71, 0x14}, |
| 56 | /* Set PWM start & slope for fan3 */ |
| 57 | { 0x73, 0x20}, |
| 58 | /* Initialize PWM automatic mode slope values for fan3 */ |
| 59 | { 0x74, 0x90}, |
| 60 | /* set smartguardian temperature interval for fan3 */ |
| 61 | { 0x75, 0x03}, |
Ronald Hoogenboom | 56cf01f | 2008-02-25 19:36:20 +0000 | [diff] [blame] | 62 | /* fan1 auto controlled by temp3 */ |
| 63 | { 0x15, 0x82}, |
Ronald Hoogenboom | fb73fa1 | 2008-06-22 14:33:17 +0000 | [diff] [blame] | 64 | /* fan2 auto controlled by temp3 */ |
| 65 | { 0x16, 0x82}, |
| 66 | /* fan3 auto controlled by temp3 */ |
| 67 | { 0x17, 0x82}, |
Ronald Hoogenboom | 56cf01f | 2008-02-25 19:36:20 +0000 | [diff] [blame] | 68 | /* all fans enable, fan1 ctl smart */ |
Ronald Hoogenboom | fb73fa1 | 2008-06-22 14:33:17 +0000 | [diff] [blame] | 69 | { 0x13, 0x77} |
Ronald Hoogenboom | 56cf01f | 2008-02-25 19:36:20 +0000 | [diff] [blame] | 70 | }; |
| 71 | |
Ronald Hoogenboom | 56cf01f | 2008-02-25 19:36:20 +0000 | [diff] [blame] | 72 | /* |
| 73 | * Called from superio.c |
| 74 | */ |
| 75 | void init_ec(uint16_t base) |
| 76 | { |
| 77 | int i; |
Carl-Daniel Hailfinger | 2ee6779 | 2008-10-01 12:52:52 +0000 | [diff] [blame] | 78 | for (i=0; i<ARRAY_SIZE(sequence); i++) { |
Ronald Hoogenboom | 56cf01f | 2008-02-25 19:36:20 +0000 | [diff] [blame] | 79 | write_index(base, sequence[i].index, sequence[i].value); |
| 80 | } |
| 81 | } |