blob: 93c6f19b90da045bee5ff25ab027b0f27c8d09ff [file] [log] [blame]
Myles Watson7eac4452010-06-17 16:16:56 +00001/*
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 Watson7eac4452010-06-17 16:16:56 +000017 */
18
19#include <device/device.h>
20#include <console/console.h>
21#include <device/smbus.h>
Myles Watson7eac4452010-06-17 16:16:56 +000022
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'Callaghan2c9d2cf2014-10-27 23:29:29 +110031static void adt7463_init(struct device *adt7463)
Myles Watson7eac4452010-06-17 16:16:56 +000032{
Myles Watson7eac4452010-06-17 16:16:56 +000033 int result;
34
Myles Watsonad5107e2010-06-22 20:36:52 +000035 printk(BIOS_DEBUG, "ADT7463 is %s\n", dev_path(adt7463));
Myles Watson7eac4452010-06-17 16:16:56 +000036
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 Watson7eac4452010-06-17 16:16:56 +000084static struct device_operations adt7463_operations = {
Edward O'Callaghan524625d2014-10-31 07:55:45 +110085 .read_resources = DEVICE_NOOP,
86 .set_resources = DEVICE_NOOP,
87 .enable_resources = DEVICE_NOOP,
Vikram Narayanan0786bc62011-12-26 22:52:01 +053088 .init = adt7463_init,
Myles Watson7eac4452010-06-17 16:16:56 +000089};
90
91static void enable_dev(struct device *dev)
92{
93 dev->ops = &adt7463_operations;
94}
95
Myles Watsonad5107e2010-06-22 20:36:52 +000096struct chip_operations drivers_i2c_adt7463_ops = {
Myles Watson7eac4452010-06-17 16:16:56 +000097 CHIP_NAME("adt7463")
98 .enable_dev = enable_dev,
99};