e22ffeef80e829f855935616ec8b24c9db1824b1
[coreboot.git] / src / mainboard / dell / s1850 / 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_sio_watchdog(device_t dev)
9 {
10 #if 0
11         /* FIXME move me somewhere more appropriate */
12         pnp_set_logical_device(dev);
13         pnp_set_enable(dev, 1);
14         pnp_set_iobase(dev, PNP_IDX_IO0, NSC_WDBASE);
15         /* disable the sio watchdog */
16         outb(0, NSC_WDBASE + 0);
17         pnp_set_enable(dev, 0);
18 #endif
19 }
20
21 static void disable_ich5_watchdog(void)
22 {
23         /* FIXME move me somewhere more appropriate */
24         device_t dev;
25         unsigned long value, base;
26         dev = pci_locate_device(PCI_ID(0x8086, 0x24d0), 0);
27         if (dev == PCI_DEV_INVALID) {
28                 die("Missing ich5?");
29         }
30         /* Enable I/O space */
31         value = pci_read_config16(dev, 0x04);
32         value |= (1 << 10);
33         pci_write_config16(dev, 0x04, value);
34         
35         /* Set and enable acpibase */
36         pci_write_config32(dev, 0x40, ICH5_WDBASE | 1);
37         pci_write_config8(dev, 0x44, 0x10);
38         base = ICH5_WDBASE + 0x60;
39         
40         /* Set bit 11 in TCO1_CNT */
41         value = inw(base + 0x08);
42         value |= 1 << 11;
43         outw(value, base + 0x08);
44         
45         /* Clear TCO timeout status */
46         outw(0x0008, base + 0x04);
47         outw(0x0002, base + 0x06);
48 }
49
50
51 static void disable_watchdogs(void)
52 {
53 //      disable_sio_watchdog(NSC_WD_DEV);
54         disable_ich5_watchdog();
55         print_debug("Watchdogs disabled\r\n");
56 }
57