Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 1 | #include <console/console.h> |
| 2 | #include <device/device.h> |
| 3 | #include <device/pci.h> |
| 4 | #include <device/pci_ids.h> |
Stefan Reinauer | 138be83 | 2010-02-27 01:50:21 +0000 | [diff] [blame^] | 5 | #include "i82801dx.h" |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 6 | |
Stefan Reinauer | 138be83 | 2010-02-27 01:50:21 +0000 | [diff] [blame^] | 7 | void i82801dx_enable(device_t dev) |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 8 | { |
Steven J. Magnani | 7557331 | 2005-09-21 13:49:44 +0000 | [diff] [blame] | 9 | unsigned int index = 0; |
| 10 | uint8_t bHasDisableBit = 0; |
| 11 | uint16_t cur_disable_mask, new_disable_mask; |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 12 | |
Steven J. Magnani | 7557331 | 2005-09-21 13:49:44 +0000 | [diff] [blame] | 13 | // 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. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 17 | return; |
Steven J. Magnani | 7557331 | 2005-09-21 13:49:44 +0000 | [diff] [blame] | 18 | |
| 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 Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame] | 24 | if (PCI_SLOT(dev->path.pci.devfn) == 31) { |
| 25 | index = PCI_FUNC(dev->path.pci.devfn); |
Steven J. Magnani | 7557331 | 2005-09-21 13:49:44 +0000 | [diff] [blame] | 26 | |
| 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 Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame] | 43 | } else if (PCI_SLOT(dev->path.pci.devfn) == 29) { |
| 44 | index = 8 + PCI_FUNC(dev->path.pci.devfn); |
Steven J. Magnani | 7557331 | 2005-09-21 13:49:44 +0000 | [diff] [blame] | 45 | |
Stefan Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame] | 46 | if ((PCI_FUNC(dev->path.pci.devfn) < 3) || (PCI_FUNC(dev->path.pci.devfn) == 7)) |
Steven J. Magnani | 7557331 | 2005-09-21 13:49:44 +0000 | [diff] [blame] | 47 | 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. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 58 | } |
| 59 | } |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Stefan Reinauer | 138be83 | 2010-02-27 01:50:21 +0000 | [diff] [blame^] | 62 | struct chip_operations southbridge_intel_i82801dx_ops = { |
| 63 | CHIP_NAME("Intel ICH4/ICH4-M (82801Dx) Series Southbridge") |
| 64 | .enable_dev = i82801dx_enable, |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 65 | }; |