2 * This file is part of the coreboot project.
4 * Copyright (C) 2004 Tyan Computer
5 * Written by Yinghai Lu <yhlu@tyan.com> for Tyan Computer.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
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.
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
21 #include <console/console.h>
23 #include <device/device.h>
24 #include <device/pci.h>
25 #include <device/pci_ids.h>
26 #include <device/pci_ops.h>
29 static uint32_t final_reg;
31 static device_t find_lpc_dev(device_t dev, unsigned devfn)
35 lpc_dev = dev_find_slot(dev->bus->secondary, devfn);
39 if ((lpc_dev->vendor != PCI_VENDOR_ID_NVIDIA)
40 || ((lpc_dev->device != PCI_DEVICE_ID_NVIDIA_CK804_LPC)
41 && (lpc_dev->device != PCI_DEVICE_ID_NVIDIA_CK804_PRO)
42 && (lpc_dev->device != PCI_DEVICE_ID_NVIDIA_CK804_SLAVE)))
45 id = pci_read_config32(lpc_dev, PCI_VENDOR_ID);
46 if ((id != (PCI_VENDOR_ID_NVIDIA |
47 (PCI_DEVICE_ID_NVIDIA_CK804_LPC << 16)))
48 && (id != (PCI_VENDOR_ID_NVIDIA |
49 (PCI_DEVICE_ID_NVIDIA_CK804_PRO << 16)))
50 && (id != (PCI_VENDOR_ID_NVIDIA |
51 (PCI_DEVICE_ID_NVIDIA_CK804_SLAVE << 16))))
60 void ck804_enable(device_t dev)
63 unsigned index = 0, index2 = 0, deviceid, vendorid, devfn;
64 uint32_t reg_old, reg;
67 struct southbridge_nvidia_ck804_config *conf;
68 conf = dev->chip_info;
70 if (dev->device == 0x0000) {
71 vendorid = pci_read_config32(dev, PCI_VENDOR_ID);
72 deviceid = (vendorid >> 16) & 0xffff;
73 /* vendorid &= 0xffff; */
75 /* vendorid = dev->vendor; */
76 deviceid = dev->device;
79 devfn = (dev->path.pci.devfn) & ~7;
81 case PCI_DEVICE_ID_NVIDIA_CK804_SM:
84 case PCI_DEVICE_ID_NVIDIA_CK804_USB:
88 case PCI_DEVICE_ID_NVIDIA_CK804_USB2:
92 case PCI_DEVICE_ID_NVIDIA_CK804_NIC:
96 case PCI_DEVICE_ID_NVIDIA_CK804_NIC_BRIDGE:
100 case PCI_DEVICE_ID_NVIDIA_CK804_ACI:
104 case PCI_DEVICE_ID_NVIDIA_CK804_MCI:
108 case PCI_DEVICE_ID_NVIDIA_CK804_IDE:
112 case PCI_DEVICE_ID_NVIDIA_CK804_SATA0:
116 case PCI_DEVICE_ID_NVIDIA_CK804_SATA1:
120 case PCI_DEVICE_ID_NVIDIA_CK804_PCI:
124 case PCI_DEVICE_ID_NVIDIA_CK804_PCI_E:
134 for (i = 0; i < 4; i++) {
135 lpc_dev = find_lpc_dev(dev, devfn - (i << 3));
143 reg_old = reg = pci_read_config32(lpc_dev, 0xe4);
145 reg |= (1 << index2);
147 pci_write_config32(lpc_dev, 0xe4, reg);
154 lpc_dev = find_lpc_dev(dev, devfn);
159 final_reg = pci_read_config32(lpc_dev, 0xe8);
160 final_reg &= ~((1 << 16) | (1 << 8) | (1 << 20) | (1 << 10)
161 | (1 << 12) | (1 << 13) | (1 << 14) | (1 << 22)
162 | (1 << 18) | (1 << 15));
163 pci_write_config32(lpc_dev, 0xe8, final_reg);
165 reg_old = reg = pci_read_config32(lpc_dev, 0xe4);
168 pci_write_config32(lpc_dev, 0xe4, reg);
170 byte = pci_read_config8(lpc_dev, 0x74);
172 pci_write_config8(dev, 0x74, byte);
174 byte = pci_read_config8(lpc_dev, 0xdd);
175 byte |= ((1 << 0) | (1 << 3));
176 pci_write_config8(dev, 0xdd, byte);
182 final_reg |= (1 << index);
185 reg_old = pci_read_config32(lpc_dev, 0xe8);
186 if (final_reg != reg_old)
187 pci_write_config32(lpc_dev, 0xe8, final_reg);
191 struct chip_operations southbridge_nvidia_ck804_ops = {
192 CHIP_NAME("NVIDIA CK804 Southbridge")
193 .enable_dev = ck804_enable,