2531bc29690e5138850bbc35ff780b76a9e09c56
[coreboot.git] / src / mainboard / supermicro / x6dai_g / watchdog.c
1 #include <device/pnp_def.h>
2
3 #define NSC_WD_DEV PNP_DEV(0x2e, 0xa)
4 #define NSC_WDBASE 0x600
5 #define ICH5_WDBASE 0x400
6 #define ICH5_GPIOBASE 0x500
7
8 static void disable_esb6300_watchdog(void)
9 {
10         /* FIXME move me somewhere more appropriate */
11         device_t dev;
12         unsigned long value, base;
13         dev = pci_locate_device(PCI_ID(0x8086, 0x25a1), 0);
14         if (dev == PCI_DEV_INVALID) {
15                 die("Missing 6300ESB?");
16         }
17         /* Enable I/O space */
18         value = pci_read_config16(dev, 0x04);
19         value |= (1 << 10);
20         pci_write_config16(dev, 0x04, value);
21         
22         /* Set and enable acpibase */
23         pci_write_config32(dev, 0x40, ICH5_WDBASE | 1);
24         pci_write_config8(dev, 0x44, 0x10);
25         base = ICH5_WDBASE + 0x60;
26         
27         /* Set bit 11 in TCO1_CNT */
28         value = inw(base + 0x08);
29         value |= 1 << 11;
30         outw(value, base + 0x08);
31         
32         /* Clear TCO timeout status */
33         outw(0x0008, base + 0x04);
34         outw(0x0002, base + 0x06);
35 }
36
37 static void disable_watchdogs(void)
38 {
39         disable_esb6300_watchdog();
40         print_debug("Watchdogs disabled\n");
41 }
42