2 * This file is part of the LinuxBIOS project.
4 * Copyright (C) 2005 Tyan
5 * Written by Yinghai Lu <yhlu@tyan.com> for Tyan.
6 * Copyright (C) 2007 Ward Vandewege <ward@gnu.org>
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.
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.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <device/device.h>
25 #include <console/console.h>
26 #include <device/smbus.h>
29 * Do some s2881-specific HWM initialization for the ADT7463 chip
30 * See Analog Devices ADT7463 datasheet, Rev C (2004):
31 * http://www.analog.com/en/prod/0,,766_825_ADT7463,00.html
33 static void dummy_init(device_t dev)
37 struct device_path path;
41 /* Find the smbus controller (amd-8111) */
42 smbus_dev = dev_find_device(0x1022, 0x746b, 0);
44 die("SMBUS controller not found\n");
46 printk_debug("smbus controller found\n");
48 /* Find the adt7463 device */
49 path.type = DEVICE_PATH_I2C;
50 path.u.i2c.device = 0x2d;
51 adt7463 = find_dev_path(smbus_dev->link, &path);
53 die("adt7463 not found\n");
55 printk_debug("adt7463 found\n");
57 /* Set all fans to 'Fastest Speed Calculated by All 3 Temperature Channels Controls PWMx.' */
58 result = smbus_write_byte(adt7463, 0x5c, 0xc2);
59 result = smbus_write_byte(adt7463, 0x5d, 0xc2);
60 result = smbus_write_byte(adt7463, 0x5e, 0xc2);
62 /* Make sure that our fans never stop when temp falls below Tmin,
63 but rather keep going at minimum duty cycle (applies to automatic
64 fan control mode only) */
65 result = smbus_write_byte(adt7463, 0x62, 0xc0);
67 /* Set minimum PWM duty cycle to 25%, rather than the default 50% */
68 result = smbus_write_byte(adt7463, 0x64, 0x40);
69 result = smbus_write_byte(adt7463, 0x65, 0x40);
70 result = smbus_write_byte(adt7463, 0x66, 0x40);
72 /* Set Tmin to 55C, rather than the default 90C. Above this temperature
73 the fans will start blowing harder as temperature increases
74 (automatic mode only) */
75 result = smbus_write_byte(adt7463, 0x67, 0x37);
76 result = smbus_write_byte(adt7463, 0x68, 0x37);
77 result = smbus_write_byte(adt7463, 0x69, 0x37);
79 /* Set THERM limit to 70C, rather than the default 100C
80 The fans will kick in at 100% if the sensors reach this temperature,
81 (only in automatic mode, but supposedly even when hardware is locked up)
82 This is a failsafe measure. */
83 result = smbus_write_byte(adt7463, 0x6a, 0x46);
84 result = smbus_write_byte(adt7463, 0x6b, 0x46);
85 result = smbus_write_byte(adt7463, 0x6c, 0x46);
87 /* Remote temperature 1 offset (LSB == 0.25C) */
88 result = smbus_write_byte(adt7463, 0x70, 0x02);
89 /* Remote temperature 2 offset (LSB == 0.25C) */
90 result = smbus_write_byte(adt7463, 0x72, 0x01);
92 /* set TACH measurements to normal (1/second) */
93 result = smbus_write_byte(adt7463, 0x78, 0xf0);
95 printk_debug("adt7463 properly initilized");
98 static void dummy_noop(device_t dummy)
102 static struct device_operations dummy_operations = {
103 .read_resources = dummy_noop,
104 .set_resources = dummy_noop,
105 .enable_resources = dummy_noop,
109 static unsigned int scan_root_bus(device_t root, unsigned int max)
111 struct device_path path;
115 max = root_dev_scan_bus(root, max);
117 printk_debug("scan_root_bus ok\n");
119 /* The following is a little silly. We need a hook into the boot process *after*
120 * the ADT7643 device has been initialized. So we create this dummy device, and we
121 * put the ADT7643 s2881 specific settings in its init function, which gets called
122 * as the last device to be initialized.
125 link_i = root->links;
126 if (link_i >= MAX_LINKS) {
127 printk_debug("reached MAX_LINKS, not configuring adt7463");
130 root->link[link_i].link = link_i;
131 root->link[link_i].dev = root;
132 root->link[link_i].children = 0;
135 path.type = DEVICE_PATH_PNP;
137 path.u.pnp.device = 0;
138 dummy = alloc_dev(&root->link[link_i], &path);
139 dummy->ops = &dummy_operations;
144 static struct device_operations mainboard_operations = {
145 .read_resources = root_dev_read_resources,
146 .set_resources = root_dev_set_resources,
147 .enable_resources = root_dev_enable_resources,
148 .init = root_dev_init,
149 .scan_bus = scan_root_bus,
152 static void enable_dev(struct device *dev)
154 dev->ops = &mainboard_operations;
157 #if CONFIG_CHIP_NAME == 1
158 struct chip_operations mainboard_tyan_s2881_ops = {
159 CHIP_NAME("Tyan S2881 Mainboard")
160 .enable_dev = enable_dev,