38350d7ef2bbd9070554b1a3a967ae672103e8df
[coreboot.git] / src / southbridge / intel / i82801gx / i82801gx_watchdog.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008-2009 coresystems GmbH
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; version 2 of
9  * the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 #include <console/console.h>
22 #include <arch/io.h>
23 #include <device/device.h>
24 #include <device/pci.h>
25 #include <watchdog.h>
26
27 void watchdog_off(void)
28 {
29         device_t dev;
30         unsigned long value, base;
31
32         /* Turn off the ICH7 watchdog. */
33         dev = dev_find_slot(0, PCI_DEVFN(0x1f, 0));
34
35         /* Enable I/O space. */
36         value = pci_read_config16(dev, 0x04);
37         value |= (1 << 10);
38         pci_write_config16(dev, 0x04, value);
39
40         /* Get TCO base. */
41         base = (pci_read_config32(dev, 0x40) & 0x0fffe) + 0x60;
42
43         /* Disable the watchdog timer. */
44         value = inw(base + 0x08);
45         value |= 1 << 11;
46         outw(value, base + 0x08);
47
48         /* Clear TCO timeout status. */
49         outw(0x0008, base + 0x04);
50         outw(0x0002, base + 0x06);
51
52         printk_debug("ICH7 watchdog disabled\r\n");
53 }