blob: abfd8c21cf533767501d2867481d3f471ced6d30 [file] [log] [blame]
Ronald G. Minnich182615d2004-08-24 16:20:46 +00001#include <console/console.h>
2#include <device/device.h>
3#include <device/pci.h>
4#include <device/pci_ids.h>
Stefan Reinauer138be832010-02-27 01:50:21 +00005#include "i82801dx.h"
Ronald G. Minnich182615d2004-08-24 16:20:46 +00006
Stefan Reinauer138be832010-02-27 01:50:21 +00007void i82801dx_enable(device_t dev)
Ronald G. Minnich182615d2004-08-24 16:20:46 +00008{
Steven J. Magnani75573312005-09-21 13:49:44 +00009 unsigned int index = 0;
10 uint8_t bHasDisableBit = 0;
11 uint16_t cur_disable_mask, new_disable_mask;
Ronald G. Minnich182615d2004-08-24 16:20:46 +000012
Steven J. Magnani75573312005-09-21 13:49:44 +000013// all 82801dbm devices are in bus 0
14 unsigned int devfn = PCI_DEVFN(0x1f, 0); // lpc
15 device_t lpc_dev = dev_find_slot(0, devfn); // 0
16 if (!lpc_dev)
Ronald G. Minnich182615d2004-08-24 16:20:46 +000017 return;
Steven J. Magnani75573312005-09-21 13:49:44 +000018
19 // Calculate disable bit position for specified device:function
20 // NOTE: For ICH-4, only the following devices can be disabled:
21 // D31: F0, F1, F3, F5, F6,
22 // D29: F0, F1, F2, F7
23
Stefan Reinauer2b34db82009-02-28 20:10:20 +000024 if (PCI_SLOT(dev->path.pci.devfn) == 31) {
25 index = PCI_FUNC(dev->path.pci.devfn);
Steven J. Magnani75573312005-09-21 13:49:44 +000026
27 switch (index) {
28 case 0:
29 case 1:
30 case 3:
31 case 5:
32 case 6:
33 bHasDisableBit = 1;
34 break;
35
36 default:
37 break;
38 };
39
40 if (index == 0)
41 index = 14; // D31:F0 bit is an exception
42
Stefan Reinauer2b34db82009-02-28 20:10:20 +000043 } else if (PCI_SLOT(dev->path.pci.devfn) == 29) {
44 index = 8 + PCI_FUNC(dev->path.pci.devfn);
Steven J. Magnani75573312005-09-21 13:49:44 +000045
Stefan Reinauer2b34db82009-02-28 20:10:20 +000046 if ((PCI_FUNC(dev->path.pci.devfn) < 3) || (PCI_FUNC(dev->path.pci.devfn) == 7))
Steven J. Magnani75573312005-09-21 13:49:44 +000047 bHasDisableBit = 1;
48 }
49
50 if (bHasDisableBit) {
51 cur_disable_mask = pci_read_config16(lpc_dev, FUNC_DIS);
52 new_disable_mask = cur_disable_mask & ~(1<<index); // enable it
53 if (!dev->enabled) {
54 new_disable_mask |= (1<<index); // disable it
55 }
56 if (new_disable_mask != cur_disable_mask) {
57 pci_write_config16(lpc_dev, FUNC_DIS, new_disable_mask);
Ronald G. Minnich182615d2004-08-24 16:20:46 +000058 }
59 }
Ronald G. Minnich182615d2004-08-24 16:20:46 +000060}
61
Stefan Reinauer138be832010-02-27 01:50:21 +000062struct chip_operations southbridge_intel_i82801dx_ops = {
63 CHIP_NAME("Intel ICH4/ICH4-M (82801Dx) Series Southbridge")
64 .enable_dev = i82801dx_enable,
Ronald G. Minnich182615d2004-08-24 16:20:46 +000065};