Myles Watson | 7eac445 | 2010-06-17 16:16:56 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2005 Tyan |
| 5 | * (Written by Yinghai Lu <yhlu@tyan.com> for Tyan) |
| 6 | * Copyright (C) 2007 Ward Vandewege <ward@gnu.org> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
Myles Watson | 7eac445 | 2010-06-17 16:16:56 +0000 | [diff] [blame] | 17 | */ |
| 18 | |
| 19 | #include <device/device.h> |
| 20 | #include <console/console.h> |
| 21 | #include <device/smbus.h> |
Myles Watson | 7eac445 | 2010-06-17 16:16:56 +0000 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Do some S2881-specific HWM initialization for the ADT7463 chip. |
| 25 | * |
| 26 | * Should be factored out so that it can be more general. |
| 27 | * |
| 28 | * See Analog Devices ADT7463 datasheet, Rev C (2004): |
| 29 | * http://www.analog.com/en/prod/0,,766_825_ADT7463,00.html |
| 30 | */ |
Edward O'Callaghan | 2c9d2cf | 2014-10-27 23:29:29 +1100 | [diff] [blame] | 31 | static void adt7463_init(struct device *adt7463) |
Myles Watson | 7eac445 | 2010-06-17 16:16:56 +0000 | [diff] [blame] | 32 | { |
Myles Watson | 7eac445 | 2010-06-17 16:16:56 +0000 | [diff] [blame] | 33 | int result; |
| 34 | |
Myles Watson | ad5107e | 2010-06-22 20:36:52 +0000 | [diff] [blame] | 35 | printk(BIOS_DEBUG, "ADT7463 is %s\n", dev_path(adt7463)); |
Myles Watson | 7eac445 | 2010-06-17 16:16:56 +0000 | [diff] [blame] | 36 | |
| 37 | /* Set all fans to 'Fastest Speed Calculated by All 3 Temperature |
| 38 | * Channels Controls PWMx'. |
| 39 | */ |
| 40 | result = smbus_write_byte(adt7463, 0x5c, 0xc2); |
| 41 | result = smbus_write_byte(adt7463, 0x5d, 0xc2); |
| 42 | result = smbus_write_byte(adt7463, 0x5e, 0xc2); |
| 43 | |
| 44 | /* Make sure that our fans never stop when temp. falls below Tmin, |
| 45 | * but rather keep going at minimum duty cycle (applies to automatic |
| 46 | * fan control mode only). |
| 47 | */ |
| 48 | result = smbus_write_byte(adt7463, 0x62, 0xc0); |
| 49 | |
| 50 | /* Set minimum PWM duty cycle to 25%, rather than the default 50%. */ |
| 51 | result = smbus_write_byte(adt7463, 0x64, 0x40); |
| 52 | result = smbus_write_byte(adt7463, 0x65, 0x40); |
| 53 | result = smbus_write_byte(adt7463, 0x66, 0x40); |
| 54 | |
| 55 | /* Set Tmin to 55C, rather than the default 90C. Above this temperature |
| 56 | * the fans will start blowing harder as temperature increases |
| 57 | * (automatic mode only). |
| 58 | */ |
| 59 | result = smbus_write_byte(adt7463, 0x67, 0x37); |
| 60 | result = smbus_write_byte(adt7463, 0x68, 0x37); |
| 61 | result = smbus_write_byte(adt7463, 0x69, 0x37); |
| 62 | |
| 63 | /* Set THERM limit to 70C, rather than the default 100C. |
| 64 | * The fans will kick in at 100% if the sensors reach this temperature, |
| 65 | * (only in automatic mode, but supposedly even when hardware is |
| 66 | * locked up). This is a failsafe measure. |
| 67 | */ |
| 68 | result = smbus_write_byte(adt7463, 0x6a, 0x46); |
| 69 | result = smbus_write_byte(adt7463, 0x6b, 0x46); |
| 70 | result = smbus_write_byte(adt7463, 0x6c, 0x46); |
| 71 | |
| 72 | /* Remote temperature 1 offset (LSB == 0.25C). */ |
| 73 | result = smbus_write_byte(adt7463, 0x70, 0x02); |
| 74 | |
| 75 | /* Remote temperature 2 offset (LSB == 0.25C). */ |
| 76 | result = smbus_write_byte(adt7463, 0x72, 0x01); |
| 77 | |
| 78 | /* Set TACH measurements to normal (1/second). */ |
| 79 | result = smbus_write_byte(adt7463, 0x78, 0xf0); |
| 80 | |
| 81 | printk(BIOS_DEBUG, "ADT7463 properly initialized\n"); |
| 82 | } |
| 83 | |
Myles Watson | 7eac445 | 2010-06-17 16:16:56 +0000 | [diff] [blame] | 84 | static struct device_operations adt7463_operations = { |
Edward O'Callaghan | 524625d | 2014-10-31 07:55:45 +1100 | [diff] [blame] | 85 | .read_resources = DEVICE_NOOP, |
| 86 | .set_resources = DEVICE_NOOP, |
| 87 | .enable_resources = DEVICE_NOOP, |
Vikram Narayanan | 0786bc6 | 2011-12-26 22:52:01 +0530 | [diff] [blame] | 88 | .init = adt7463_init, |
Myles Watson | 7eac445 | 2010-06-17 16:16:56 +0000 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | static void enable_dev(struct device *dev) |
| 92 | { |
| 93 | dev->ops = &adt7463_operations; |
| 94 | } |
| 95 | |
Myles Watson | ad5107e | 2010-06-22 20:36:52 +0000 | [diff] [blame] | 96 | struct chip_operations drivers_i2c_adt7463_ops = { |
Myles Watson | 7eac445 | 2010-06-17 16:16:56 +0000 | [diff] [blame] | 97 | CHIP_NAME("adt7463") |
| 98 | .enable_dev = enable_dev, |
| 99 | }; |